|
@@ -58,6 +58,9 @@ public class MaterialController extends BaseController {
|
|
|
@Resource
|
|
|
private MaterialBatchService materialBatchService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private MaterialUnitService materialUnitService;
|
|
|
+
|
|
|
@Value(value="${file.uploadType}")
|
|
|
private Long fileUploadType;
|
|
|
|
|
@@ -75,6 +78,7 @@ public class MaterialController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //商品信息 - 列表
|
|
|
@GetMapping(value = "/list")
|
|
|
@ApiOperation(value = "获取信息列表")
|
|
|
public TableDataInfo getList(@RequestParam(value = Constants.SEARCH, required = false) String search) {
|
|
@@ -281,40 +285,159 @@ public class MaterialController extends BaseController {
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
+// @GetMapping(value = "/findBySelect")
|
|
|
+// @ApiOperation(value = "查找商品信息")
|
|
|
+// public JSONObject findBySelect(@RequestParam(value = "categoryId", required = false) Long categoryId,
|
|
|
+// @RequestParam(value = "q", required = false) String q,
|
|
|
+// @RequestParam(value = "standardOrModel", required = false) String standardOrModel,
|
|
|
+// @RequestParam(value = "mpList", required = false) String mpList,
|
|
|
+// @RequestParam(value = "depotId", required = false) Long depotId,
|
|
|
+// @RequestParam(value = "color", required = false) String color,
|
|
|
+// @RequestParam(value = "brand", required = false) String brand,
|
|
|
+// @RequestParam(value = "mfrs", required = false) String mfrs,
|
|
|
+// @RequestParam(value = "enableSerialNumber", required = false) String enableSerialNumber,
|
|
|
+// @RequestParam(value = "enableBatchNumber", required = false) String enableBatchNumber,
|
|
|
+// @RequestParam("page") Integer currentPage,
|
|
|
+// @RequestParam("rows") Integer pageSize,
|
|
|
+// HttpServletRequest request) throws Exception{
|
|
|
+// JSONObject object = new JSONObject();
|
|
|
+// try {
|
|
|
+// String[] mpArr = new String[]{};
|
|
|
+// if(StringUtil.isNotEmpty(mpList)){
|
|
|
+// mpArr= mpList.split(",");
|
|
|
+// }
|
|
|
+// List<MaterialVo4Unit> dataList = materialService.findBySelectWithBarCode(categoryId, q, StringUtil.toNull(standardOrModel),
|
|
|
+// StringUtil.toNull(color), StringUtil.toNull(brand), StringUtil.toNull(mfrs), enableSerialNumber, enableBatchNumber,
|
|
|
+// (currentPage-1)*pageSize, pageSize,depotId);
|
|
|
+// int total = materialService.findBySelectWithBarCodeCount(categoryId, q, StringUtil.toNull(standardOrModel),
|
|
|
+// StringUtil.toNull(color), StringUtil.toNull(brand), StringUtil.toNull(mfrs), enableSerialNumber, enableBatchNumber,depotId);
|
|
|
+// object.put("total", total);
|
|
|
+// JSONArray dataArray = new JSONArray();
|
|
|
+// //存放数据json数组
|
|
|
+// if (null != dataList) {
|
|
|
+// for (MaterialVo4Unit material : dataList) {
|
|
|
+// JSONObject item = new JSONObject();
|
|
|
+// item.put("id", material.getMeId()); //商品扩展表的id
|
|
|
+// item.put("mid", material.getId()); //商品扩展表的id
|
|
|
+// String ratioStr = ""; //比例
|
|
|
+// Unit unit = new Unit();
|
|
|
+// BigDecimal ratio = new BigDecimal("1");
|
|
|
+// if (material.getUnitId() == null) {
|
|
|
+// ratioStr = "";
|
|
|
+// } else {
|
|
|
+// unit = unitService.getUnit(material.getUnitId());
|
|
|
+// //拼接副单位的比例
|
|
|
+// String commodityUnit = material.getCommodityUnit();
|
|
|
+// if(commodityUnit.equals(unit.getBasicUnit())) {
|
|
|
+// ratioStr = "[基本]";
|
|
|
+// ratio = new BigDecimal("1");
|
|
|
+// }
|
|
|
+// if(commodityUnit.equals(unit.getOtherUnit()) && unit.getRatio()!=null) {
|
|
|
+// ratioStr = "[" + unit.getRatio().stripTrailingZeros().toPlainString() + unit.getBasicUnit() + "]";
|
|
|
+// ratio = unit.getRatio();
|
|
|
+// }
|
|
|
+// if(commodityUnit.equals(unit.getOtherUnitTwo()) && unit.getRatioTwo()!=null) {
|
|
|
+// ratioStr = "[" + unit.getRatioTwo().stripTrailingZeros().toPlainString() + unit.getBasicUnit() + "]";
|
|
|
+// ratio = unit.getRatioTwo();
|
|
|
+// }
|
|
|
+// if(commodityUnit.equals(unit.getOtherUnitThree()) && unit.getRatioThree()!=null) {
|
|
|
+// ratioStr = "[" + unit.getRatioThree().stripTrailingZeros().toPlainString() + unit.getBasicUnit() + "]";
|
|
|
+// ratio = unit.getRatioThree();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// item.put("barCode", material.getBarCode());
|
|
|
+// item.put("name", material.getName());
|
|
|
+// item.put("mnemonic", material.getMnemonic());
|
|
|
+// item.put("categoryName", material.getCategoryName());
|
|
|
+// item.put("standard", material.getStandard());
|
|
|
+// item.put("model", material.getModel());
|
|
|
+// item.put("color", material.getColor());
|
|
|
+// item.put("brand", material.getBrand());
|
|
|
+// //item.put("mfrs", material.getMfrs());
|
|
|
+// item.put("unit", material.getCommodityUnit() + ratioStr);
|
|
|
+// item.put("sku", material.getSku());
|
|
|
+// item.put("enableSerialNumber", material.getEnableSerialNumber());
|
|
|
+// item.put("enableBatchNumber", material.getEnableBatchNumber());
|
|
|
+// item.put("productionDate",material.getProductionDate());
|
|
|
+// item.put("expiryNum",material.getExpiryNum());
|
|
|
+// item.put("batchNumber",material.getBatchNumber());
|
|
|
+// item.put("position",material.getPosition());
|
|
|
+// item.put("supplierId",material.getSupplierId());
|
|
|
+// item.put("supplierName",material.getSupplierName());
|
|
|
+// item.put("depotId",material.getDepotId());
|
|
|
+// item.put("depotName",material.getDepotName());
|
|
|
+// item.put("unitId",material.getUnitId());
|
|
|
+// item.put("inventory",materialService.getMaterialStockByMid(material.getId()).divide(ratio,2,BigDecimal.ROUND_HALF_UP));
|
|
|
+// BigDecimal stock;
|
|
|
+// if(StringUtil.isNotEmpty(material.getSku())){
|
|
|
+// stock = depotItemService.getSkuStockByParam(depotId,material.getMeId(),null,null);
|
|
|
+// } else {
|
|
|
+// stock = depotItemService.getCurrentStockByParam(depotId, material.getId());
|
|
|
+// if (material.getUnitId()!=null){
|
|
|
+// String commodityUnit = material.getCommodityUnit();
|
|
|
+// stock = unitService.parseStockByUnit(stock, unit, commodityUnit);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// item.put("stock", stock);
|
|
|
+// item.put("expand", materialService.getMaterialOtherByParam(mpArr, material));
|
|
|
+// item.put("imgName", material.getImgName());
|
|
|
+// if(fileUploadType == 2) {
|
|
|
+// item.put("imgSmall", "small");
|
|
|
+// item.put("imgLarge", "large");
|
|
|
+// } else {
|
|
|
+// item.put("imgSmall", "");
|
|
|
+// item.put("imgLarge", "");
|
|
|
+// }
|
|
|
+// dataArray.add(item);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// object.put("rows", dataArray);
|
|
|
+// } catch (Exception e) {
|
|
|
+// logger.error(e.getMessage(), e);
|
|
|
+// }
|
|
|
+// return object;
|
|
|
+// }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查找商品信息-下拉框
|
|
|
+ * @param mpList
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@GetMapping(value = "/findBySelect")
|
|
|
@ApiOperation(value = "查找商品信息")
|
|
|
public JSONObject findBySelect(@RequestParam(value = "categoryId", required = false) Long categoryId,
|
|
|
- @RequestParam(value = "q", required = false) String q,
|
|
|
- @RequestParam(value = "standardOrModel", required = false) String standardOrModel,
|
|
|
- @RequestParam(value = "mpList", required = false) String mpList,
|
|
|
- @RequestParam(value = "depotId", required = false) Long depotId,
|
|
|
- @RequestParam(value = "color", required = false) String color,
|
|
|
- @RequestParam(value = "brand", required = false) String brand,
|
|
|
- @RequestParam(value = "mfrs", required = false) String mfrs,
|
|
|
- @RequestParam(value = "enableSerialNumber", required = false) String enableSerialNumber,
|
|
|
- @RequestParam(value = "enableBatchNumber", required = false) String enableBatchNumber,
|
|
|
- @RequestParam("page") Integer currentPage,
|
|
|
- @RequestParam("rows") Integer pageSize,
|
|
|
- HttpServletRequest request) throws Exception{
|
|
|
+ @RequestParam(value = "q", required = false) String q,
|
|
|
+ @RequestParam(value = "standardOrModel", required = false) String standardOrModel,
|
|
|
+ @RequestParam(value = "mpList", required = false) String mpList,
|
|
|
+ @RequestParam(value = "depotId", required = false) Long depotId,
|
|
|
+ @RequestParam(value = "color", required = false) String color,
|
|
|
+ @RequestParam(value = "brand", required = false) String brand,
|
|
|
+ @RequestParam(value = "mfrs", required = false) String mfrs,
|
|
|
+ @RequestParam(value = "enableSerialNumber", required = false) String enableSerialNumber,
|
|
|
+ @RequestParam(value = "enableBatchNumber", required = false) String enableBatchNumber,
|
|
|
+ @RequestParam("page") Integer currentPage,
|
|
|
+ @RequestParam("rows") Integer pageSize,
|
|
|
+ HttpServletRequest request) throws Exception{
|
|
|
JSONObject object = new JSONObject();
|
|
|
try {
|
|
|
String[] mpArr = new String[]{};
|
|
|
if(StringUtil.isNotEmpty(mpList)){
|
|
|
mpArr= mpList.split(",");
|
|
|
}
|
|
|
- List<MaterialVo4Unit> dataList = materialService.findBySelectWithBarCode(categoryId, q, StringUtil.toNull(standardOrModel),
|
|
|
+ List<MaterialVo4Unit> dataList = materialService.findBySelectWithSku(categoryId, q, StringUtil.toNull(standardOrModel),
|
|
|
StringUtil.toNull(color), StringUtil.toNull(brand), StringUtil.toNull(mfrs), enableSerialNumber, enableBatchNumber,
|
|
|
(currentPage-1)*pageSize, pageSize,depotId);
|
|
|
- int total = materialService.findBySelectWithBarCodeCount(categoryId, q, StringUtil.toNull(standardOrModel),
|
|
|
+ int total = materialService.findBySelectWithSkuCount(categoryId, q, StringUtil.toNull(standardOrModel),
|
|
|
StringUtil.toNull(color), StringUtil.toNull(brand), StringUtil.toNull(mfrs), enableSerialNumber, enableBatchNumber,depotId);
|
|
|
object.put("total", total);
|
|
|
JSONArray dataArray = new JSONArray();
|
|
|
//存放数据json数组
|
|
|
if (null != dataList) {
|
|
|
for (MaterialVo4Unit material : dataList) {
|
|
|
- JSONObject item = new JSONObject();
|
|
|
- item.put("id", material.getMeId()); //商品扩展表的id
|
|
|
- item.put("mid", material.getId()); //商品扩展表的id
|
|
|
+// JSONObject item = new JSONObject();
|
|
|
+// item.put("id", material.getMeId()); //商品扩展表的id
|
|
|
+// item.put("mid", material.getId()); //商品扩展表的id
|
|
|
String ratioStr = ""; //比例
|
|
|
Unit unit = new Unit();
|
|
|
BigDecimal ratio = new BigDecimal("1");
|
|
@@ -341,29 +464,30 @@ public class MaterialController extends BaseController {
|
|
|
ratio = unit.getRatioThree();
|
|
|
}
|
|
|
}
|
|
|
- item.put("barCode", material.getBarCode());
|
|
|
- item.put("name", material.getName());
|
|
|
- item.put("mnemonic", material.getMnemonic());
|
|
|
- item.put("categoryName", material.getCategoryName());
|
|
|
- item.put("standard", material.getStandard());
|
|
|
- item.put("model", material.getModel());
|
|
|
- item.put("color", material.getColor());
|
|
|
- item.put("brand", material.getBrand());
|
|
|
- //item.put("mfrs", material.getMfrs());
|
|
|
- item.put("unit", material.getCommodityUnit() + ratioStr);
|
|
|
- item.put("sku", material.getSku());
|
|
|
- item.put("enableSerialNumber", material.getEnableSerialNumber());
|
|
|
- item.put("enableBatchNumber", material.getEnableBatchNumber());
|
|
|
- item.put("productionDate",material.getProductionDate());
|
|
|
- item.put("expiryNum",material.getExpiryNum());
|
|
|
- item.put("batchNumber",material.getBatchNumber());
|
|
|
- item.put("position",material.getPosition());
|
|
|
- item.put("supplierId",material.getSupplierId());
|
|
|
- item.put("supplierName",material.getSupplierName());
|
|
|
- item.put("depotId",material.getDepotId());
|
|
|
- item.put("depotName",material.getDepotName());
|
|
|
- item.put("unitId",material.getUnitId());
|
|
|
- item.put("inventory",materialService.getMaterialStockByMid(material.getId()).divide(ratio,2,BigDecimal.ROUND_HALF_UP));
|
|
|
+// item.put("barCode", material.getBarCode());
|
|
|
+// item.put("name", material.getName());
|
|
|
+// item.put("mnemonic", material.getMnemonic());
|
|
|
+// item.put("categoryName", material.getCategoryName());
|
|
|
+// item.put("standard", material.getStandard());
|
|
|
+// item.put("model", material.getModel());
|
|
|
+// item.put("color", material.getColor());
|
|
|
+// item.put("brand", material.getBrand());
|
|
|
+// item.put("mfrs", material.getMfrs());
|
|
|
+// item.put("unit", material.getCommodityUnit() + ratioStr);
|
|
|
+ material.setUnit(material.getCommodityUnit());
|
|
|
+// item.put("sku", material.getSku());
|
|
|
+// item.put("enableSerialNumber", material.getEnableSerialNumber());
|
|
|
+// item.put("enableBatchNumber", material.getEnableBatchNumber());
|
|
|
+// item.put("productionDate",material.getProductionDate());
|
|
|
+// item.put("expiryNum",material.getExpiryNum());
|
|
|
+// item.put("batchNumber",material.getBatchNumber());
|
|
|
+// item.put("position",material.getPosition());
|
|
|
+// item.put("supplierId",material.getSupplierId());
|
|
|
+// item.put("supplierName",material.getSupplierName());
|
|
|
+// item.put("depotId",material.getDepotId());
|
|
|
+// item.put("depotName",material.getDepotName());
|
|
|
+// item.put("unitId",material.getUnitId());
|
|
|
+// item.put("inventory",materialService.getMaterialStockByMid(material.getId()).divide(ratio,2,BigDecimal.ROUND_HALF_UP));
|
|
|
BigDecimal stock;
|
|
|
if(StringUtil.isNotEmpty(material.getSku())){
|
|
|
stock = depotItemService.getSkuStockByParam(depotId,material.getMeId(),null,null);
|
|
@@ -374,20 +498,10 @@ public class MaterialController extends BaseController {
|
|
|
stock = unitService.parseStockByUnit(stock, unit, commodityUnit);
|
|
|
}
|
|
|
}
|
|
|
- item.put("stock", stock);
|
|
|
- item.put("expand", materialService.getMaterialOtherByParam(mpArr, material));
|
|
|
- item.put("imgName", material.getImgName());
|
|
|
- if(fileUploadType == 2) {
|
|
|
- item.put("imgSmall", "small");
|
|
|
- item.put("imgLarge", "large");
|
|
|
- } else {
|
|
|
- item.put("imgSmall", "");
|
|
|
- item.put("imgLarge", "");
|
|
|
- }
|
|
|
- dataArray.add(item);
|
|
|
+ material.setStock(materialService.getMaterialStockByMid(material.getId()));
|
|
|
}
|
|
|
}
|
|
|
- object.put("rows", dataArray);
|
|
|
+ object.put("rows", dataList);
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(), e);
|
|
|
}
|
|
@@ -665,16 +779,15 @@ public class MaterialController extends BaseController {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@GetMapping(value = "/getMaterialBySku")
|
|
|
- @ApiOperation(value = "根据条码查询商品信息")
|
|
|
- public BaseResponseInfo getMaterialBySku(@RequestParam("sku") String barCode,
|
|
|
- @RequestParam(value = "depotId", required = false) Long depotId,
|
|
|
- @RequestParam(required = false, value = "prefixNo") String prefixNo,
|
|
|
- HttpServletRequest request) throws Exception {
|
|
|
- BaseResponseInfo res = new BaseResponseInfo();
|
|
|
- try {
|
|
|
- List<MaterialVo4Unit> list = materialService.getMaterialByBarCode(barCode);
|
|
|
- if(list!=null && list.size()>0) {
|
|
|
+ @ApiOperation(value = "根据sku查询商品信息")
|
|
|
+ public AjaxResult getMaterialBySku(@RequestParam("sku") String sku,
|
|
|
+ @RequestParam(value = "depotId", required = false) Long depotId,
|
|
|
+ @RequestParam(required = false, value = "prefixNo") String prefixNo) {
|
|
|
+ List<MaterialVo4Unit> list = materialService.getMaterialBySku(sku);
|
|
|
+ if(list != null && list.size() > 0) {
|
|
|
for(MaterialVo4Unit mvo: list) {
|
|
|
+ //包装规格
|
|
|
+ mvo.setUnitName(materialUnitService.getStandardByMeId(mvo.getMeId()));
|
|
|
if ("LSCK".equals(prefixNo) || "LSTH".equals(prefixNo)) {
|
|
|
//零售价
|
|
|
mvo.setBillPrice(mvo.getCommodityDecimal());
|
|
@@ -689,37 +802,28 @@ public class MaterialController extends BaseController {
|
|
|
mvo.setBillPrice(mvo.getDefaultWholesaleDecimal());
|
|
|
}
|
|
|
//仓库id
|
|
|
- if (depotId == null) {
|
|
|
- JSONArray depotArr = depotService.findDepotByCurrentUser();
|
|
|
- for (Object obj : depotArr) {
|
|
|
- JSONObject depotObj = JSONObject.parseObject(obj.toString());
|
|
|
- if (depotObj.get("isDefault") != null) {
|
|
|
- Boolean isDefault = depotObj.getBoolean("isDefault");
|
|
|
- if (isDefault) {
|
|
|
- Long id = depotObj.getLong("id");
|
|
|
- if (!"CGDD".equals(prefixNo) && !"XSDD".equals(prefixNo)) {
|
|
|
- //除订单之外的单据才有仓库
|
|
|
- mvo.setDepotId(id);
|
|
|
- }
|
|
|
- getStockByMaterialInfo(mvo);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- mvo.setDepotId(depotId);
|
|
|
- getStockByMaterialInfo(mvo);
|
|
|
- }
|
|
|
- mvo.setInventory(mvo.getStock());
|
|
|
+// if (depotId == null) {
|
|
|
+// JSONArray depotArr = depotService.findDepotByCurrentUser();
|
|
|
+// for (Object obj : depotArr) {
|
|
|
+// JSONObject depotObj = JSONObject.parseObject(obj.toString());
|
|
|
+// if (depotObj.get("isDefault") != null) {
|
|
|
+// Boolean isDefault = depotObj.getBoolean("isDefault");
|
|
|
+// if (isDefault) {
|
|
|
+// Long id = depotObj.getLong("id");
|
|
|
+// if (!"CGDD".equals(prefixNo) && !"XSDD".equals(prefixNo)) {
|
|
|
+// //除订单之外的单据才有仓库
|
|
|
+// mvo.setDepotId(id);
|
|
|
+// }
|
|
|
+// //getStockByMaterialInfo(mvo);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// mvo.setDepotId(depotId);
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
- res.code = 200;
|
|
|
- res.data = list;
|
|
|
- } catch(Exception e){
|
|
|
- logger.error(e.getMessage(), e);
|
|
|
- res.code = 500;
|
|
|
- res.data = "获取数据失败";
|
|
|
- }
|
|
|
- return res;
|
|
|
+ return AjaxResult.success(list);
|
|
|
}
|
|
|
|
|
|
/**
|