优化单据中商品条码的搜索方式
This commit is contained in:
@@ -176,12 +176,17 @@ public class DepotItemController {
|
||||
ratio = ratio.substring(ratio.indexOf("("));
|
||||
}
|
||||
//名称/型号/扩展信息/包装
|
||||
String MaterialName = diEx.getBarCode() + "_" + ((diEx.getMName() == null || diEx.getMName().equals("")) ? "" : diEx.getMName())
|
||||
String MaterialName = ((diEx.getMName() == null || diEx.getMName().equals("")) ? "" : diEx.getMName())
|
||||
+ ((diEx.getMStandard() == null || diEx.getMStandard().equals("")) ? "" : "(" + diEx.getMStandard() + ")")
|
||||
+ ((diEx.getMModel() == null || diEx.getMModel().equals("")) ? "" : "(" + diEx.getMModel() + ")");
|
||||
String materialOther = getOtherInfo(mpArr, diEx);
|
||||
MaterialName = MaterialName + materialOther + ((diEx.getUnitName() == null || diEx.getUnitName().equals("")) ? "" : "(" + diEx.getUnitName() + ")") + ratio;
|
||||
item.put("MaterialName", MaterialName == null ? "" : MaterialName);
|
||||
item.put("barCode", diEx.getBarCode());
|
||||
item.put("name", diEx.getMName());
|
||||
item.put("standard", diEx.getMStandard());
|
||||
item.put("model", diEx.getMModel());
|
||||
item.put("materialOther", materialOther);
|
||||
BigDecimal stock = depotItemService.getStockByParam(diEx.getDepotId(),diEx.getMaterialId(),null,null,tenantId);
|
||||
item.put("Stock", stock);
|
||||
item.put("Unit", diEx.getMaterialUnit());
|
||||
@@ -200,11 +205,6 @@ public class DepotItemController {
|
||||
item.put("TaxRate", diEx.getTaxRate());
|
||||
item.put("TaxMoney", diEx.getTaxMoney());
|
||||
item.put("TaxLastMoney", diEx.getTaxLastMoney());
|
||||
item.put("OtherField1", diEx.getOtherField1());
|
||||
item.put("OtherField2", diEx.getOtherField2());
|
||||
item.put("OtherField3", diEx.getOtherField3());
|
||||
item.put("OtherField4", diEx.getOtherField4());
|
||||
item.put("OtherField5", diEx.getOtherField5());
|
||||
item.put("MType", diEx.getMaterialType());
|
||||
item.put("op", 1);
|
||||
dataArray.add(item);
|
||||
|
||||
@@ -108,13 +108,32 @@ public class MaterialController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findByIdWithBarCode")
|
||||
public BaseResponseInfo findByIdWithBarCode(@RequestParam("meId") Long meId, HttpServletRequest request) throws Exception{
|
||||
public BaseResponseInfo findByIdWithBarCode(@RequestParam("meId") Long meId,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request) throws Exception{
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
String[] mpArr = mpList.split(",");
|
||||
MaterialVo4Unit mu = new MaterialVo4Unit();
|
||||
List<MaterialVo4Unit> list = materialService.findByIdWithBarCode(meId);
|
||||
if(list!=null && list.size()>0) {
|
||||
mu = list.get(0);
|
||||
String expand = ""; //扩展信息
|
||||
for (int i = 0; i < mpArr.length; i++) {
|
||||
if (mpArr[i].equals("制造商")) {
|
||||
expand = expand + ((mu.getMfrs() == null || mu.getMfrs().equals("")) ? "" : "(" + mu.getMfrs() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义1")) {
|
||||
expand = expand + ((mu.getOtherField1() == null || mu.getOtherField1().equals("")) ? "" : "(" + mu.getOtherField1() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义2")) {
|
||||
expand = expand + ((mu.getOtherField2() == null || mu.getOtherField2().equals("")) ? "" : "(" + mu.getOtherField2() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义3")) {
|
||||
expand = expand + ((mu.getOtherField3() == null || mu.getOtherField3().equals("")) ? "" : "(" + mu.getOtherField3() + ")");
|
||||
}
|
||||
}
|
||||
mu.setMaterialOther(expand);
|
||||
}
|
||||
res.code = 200;
|
||||
res.data = mu;
|
||||
@@ -194,7 +213,7 @@ public class MaterialController {
|
||||
item.put("model", material.getModel());
|
||||
item.put("standard", material.getStandard());
|
||||
item.put("unit", material.getCommodityUnit() + ratio);
|
||||
if(depotId!=null&& StringUtil.isNotEmpty(q)) {
|
||||
if(depotId!=null) {
|
||||
BigDecimal stock = depotItemService.getStockByParam(depotId,material.getId(),null,null,tenantId);
|
||||
item.put("stock", stock);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.jsh.erp.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.MaterialExtend;
|
||||
import com.jsh.erp.datasource.vo.MaterialExtendVo4List;
|
||||
import com.jsh.erp.service.materialExtend.MaterialExtendService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
@@ -63,4 +64,21 @@ public class MaterialExtendController {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getInfoByBarCode")
|
||||
public BaseResponseInfo getInfoByBarCode(@RequestParam("barCode") String barCode,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
MaterialExtend materialExtend = materialExtendService.getInfoByBarCode(barCode);
|
||||
res.code = 200;
|
||||
res.data = materialExtend;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,10 +322,10 @@ public class DepotItemService {
|
||||
DepotItem depotItem = new DepotItem();
|
||||
JSONObject rowObj = JSONObject.parseObject(rowArr.getString(i));
|
||||
depotItem.setHeaderId(headerId);
|
||||
Long materialExtendId = rowObj.getLong("MaterialExtendId");
|
||||
Long materialId = materialExtendService.getMaterialExtend(materialExtendId).getMaterialId();
|
||||
depotItem.setMaterialId(materialId);
|
||||
depotItem.setMaterialExtendId(rowObj.getLong("MaterialExtendId"));
|
||||
String barCode = rowObj.getString("barCode");
|
||||
MaterialExtend materialExtend = materialExtendService.getInfoByBarCode(barCode);
|
||||
depotItem.setMaterialId(materialExtend.getMaterialId());
|
||||
depotItem.setMaterialExtendId(materialExtend.getId());
|
||||
depotItem.setMaterialUnit(rowObj.getString("Unit"));
|
||||
if (StringUtil.isExist(rowObj.get("OperNumber"))) {
|
||||
depotItem.setOperNumber(rowObj.getBigDecimal("OperNumber"));
|
||||
@@ -333,7 +333,7 @@ public class DepotItemService {
|
||||
String Unit = rowObj.get("Unit").toString();
|
||||
BigDecimal oNumber = rowObj.getBigDecimal("OperNumber");
|
||||
//以下进行单位换算
|
||||
String unitName = materialService.findUnitName(materialId); //查询计量单位名称
|
||||
String unitName = materialService.findUnitName(materialExtend.getMaterialId()); //查询计量单位名称
|
||||
if (!StringUtil.isEmpty(unitName)) {
|
||||
String unitList = unitName.substring(0, unitName.indexOf("("));
|
||||
String ratioList = unitName.substring(unitName.indexOf("("));
|
||||
|
||||
@@ -308,4 +308,16 @@ public class MaterialExtendService {
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public MaterialExtend getInfoByBarCode(String barCode)throws Exception {
|
||||
MaterialExtend materialExtend = new MaterialExtend();
|
||||
MaterialExtendExample example = new MaterialExtendExample();
|
||||
example.createCriteria().andBarCodeEqualTo(barCode)
|
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
List<MaterialExtend> list = materialExtendMapper.selectByExample(example);
|
||||
if(list!=null && list.size()>0) {
|
||||
materialExtend = list.get(0);
|
||||
}
|
||||
return materialExtend;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@
|
||||
</select>
|
||||
|
||||
<select id="getMaterialByMeId" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultMapList">
|
||||
select m.*,me.bar_code m_bar_code,u.name unitName, mc.name categoryName
|
||||
select m.*,me.bar_code,u.name unitName, mc.name categoryName
|
||||
FROM jsh_material m
|
||||
left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
|
||||
left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_flag,'0') !='1'
|
||||
|
||||
Reference in New Issue
Block a user