优化商品条码查询接口,支持选择多商品
This commit is contained in:
@@ -7,6 +7,7 @@ import com.jsh.erp.constants.BusinessConstants;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.*;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.depot.DepotService;
|
||||
import com.jsh.erp.service.depotItem.DepotItemService;
|
||||
import com.jsh.erp.service.material.MaterialService;
|
||||
import com.jsh.erp.service.redis.RedisService;
|
||||
@@ -45,6 +46,9 @@ public class MaterialController {
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
|
||||
@Resource
|
||||
private DepotService depotService;
|
||||
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
@@ -445,40 +449,63 @@ public class MaterialController {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
String[] mpArr = mpList.split(",");
|
||||
MaterialVo4Unit mu = new MaterialVo4Unit();
|
||||
List<MaterialVo4Unit> list = materialService.getMaterialByBarCode(barCode);
|
||||
if(list!=null && list.size()>0) {
|
||||
mu = list.get(0);
|
||||
for(MaterialVo4Unit mvo: list) {
|
||||
String expand = ""; //扩展信息
|
||||
for (int i = 0; i < mpArr.length; i++) {
|
||||
if (mpArr[i].equals("制造商")) {
|
||||
expand = expand + ((mu.getMfrs() == null || mu.getMfrs().equals("")) ? "" : "(" + mu.getMfrs() + ")");
|
||||
expand = expand + ((mvo.getMfrs() == null || mvo.getMfrs().equals("")) ? "" : "(" + mvo.getMfrs() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义1")) {
|
||||
expand = expand + ((mu.getOtherField1() == null || mu.getOtherField1().equals("")) ? "" : "(" + mu.getOtherField1() + ")");
|
||||
expand = expand + ((mvo.getOtherField1() == null || mvo.getOtherField1().equals("")) ? "" : "(" + mvo.getOtherField1() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义2")) {
|
||||
expand = expand + ((mu.getOtherField2() == null || mu.getOtherField2().equals("")) ? "" : "(" + mu.getOtherField2() + ")");
|
||||
expand = expand + ((mvo.getOtherField2() == null || mvo.getOtherField2().equals("")) ? "" : "(" + mvo.getOtherField2() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义3")) {
|
||||
expand = expand + ((mu.getOtherField3() == null || mu.getOtherField3().equals("")) ? "" : "(" + mu.getOtherField3() + ")");
|
||||
expand = expand + ((mvo.getOtherField3() == null || mvo.getOtherField3().equals("")) ? "" : "(" + mvo.getOtherField3() + ")");
|
||||
}
|
||||
}
|
||||
mu.setMaterialOther(expand);
|
||||
mvo.setMaterialOther(expand);
|
||||
if("LSCK".equals(prefixNo) || "LSTH".equals(prefixNo)) {
|
||||
//零售价
|
||||
mu.setBillPrice(mu.getCommodityDecimal());
|
||||
mvo.setBillPrice(mvo.getCommodityDecimal());
|
||||
} else if("CGDD".equals(prefixNo) || "CGRK".equals(prefixNo) || "CGTH".equals(prefixNo)
|
||||
|| "QTRK".equals(prefixNo) || "DBCK".equals(prefixNo) || "ZZD".equals(prefixNo) || "CXD".equals(prefixNo) ) {
|
||||
//采购价
|
||||
mu.setBillPrice(mu.getPurchaseDecimal());
|
||||
mvo.setBillPrice(mvo.getPurchaseDecimal());
|
||||
} else if("XSDD".equals(prefixNo) || "XSCK".equals(prefixNo) || "XSTH".equals(prefixNo) || "QTCK".equals(prefixNo)) {
|
||||
//销售价
|
||||
mu.setBillPrice(mu.getWholesaleDecimal());
|
||||
mvo.setBillPrice(mvo.getWholesaleDecimal());
|
||||
}
|
||||
//仓库id
|
||||
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 depotId = depotObj.getLong("id");
|
||||
mvo.setDepotId(depotId);
|
||||
//库存
|
||||
BigDecimal stock = depotItemService.getStockByParam(depotId,mvo.getId(),null,null);
|
||||
if (mvo.getUnitId()!=null){
|
||||
Unit unit = unitService.getUnit(mvo.getUnitId());
|
||||
if(mvo.getCommodityUnit().equals(unit.getOtherUnit())) {
|
||||
if(unit.getRatio()!=0) {
|
||||
stock = stock.divide(BigDecimal.valueOf(unit.getRatio()),2,BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
}
|
||||
}
|
||||
mvo.setStock(stock);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res.code = 200;
|
||||
res.data = mu;
|
||||
res.data = list;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
|
||||
@@ -36,6 +36,8 @@ public class MaterialVo4Unit extends Material{
|
||||
|
||||
private String sku;
|
||||
|
||||
private Long depotId;
|
||||
|
||||
public String getUnitName() {
|
||||
return unitName;
|
||||
}
|
||||
@@ -163,4 +165,12 @@ public class MaterialVo4Unit extends Material{
|
||||
public void setSku(String sku) {
|
||||
this.sku = sku;
|
||||
}
|
||||
|
||||
public Long getDepotId() {
|
||||
return depotId;
|
||||
}
|
||||
|
||||
public void setDepotId(Long depotId) {
|
||||
this.depotId = depotId;
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public interface MaterialMapperEx {
|
||||
|
||||
int setUnitIdToNull(@Param("id") Long id);
|
||||
|
||||
List<MaterialVo4Unit> getMaterialByBarCode(@Param("barCode") String barCode);
|
||||
List<MaterialVo4Unit> getMaterialByBarCode(@Param("barCodeArray") String [] barCodeArray);
|
||||
|
||||
List<MaterialVo4Unit> getListWithStock(
|
||||
@Param("depotId") Long depotId,
|
||||
|
||||
@@ -803,7 +803,8 @@ public class MaterialService {
|
||||
}
|
||||
|
||||
public List<MaterialVo4Unit> getMaterialByBarCode(String barCode) {
|
||||
return materialMapperEx.getMaterialByBarCode(barCode);
|
||||
String [] barCodeArray=barCode.split(",");
|
||||
return materialMapperEx.getMaterialByBarCode(barCodeArray);
|
||||
}
|
||||
|
||||
public List<MaterialVo4Unit> getListWithStock(Long depotId, List<Long> idList, String materialParam, Integer offset, Integer rows) {
|
||||
|
||||
@@ -307,8 +307,14 @@
|
||||
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'
|
||||
where me.bar_code = #{barCode}
|
||||
where
|
||||
me.bar_code in (
|
||||
<foreach collection="barCodeArray" item="barCode" separator=",">
|
||||
#{barCode}
|
||||
</foreach>
|
||||
)
|
||||
and ifnull(m.delete_flag,'0') !='1'
|
||||
order by me.id desc
|
||||
</select>
|
||||
|
||||
<update id="setUnitIdToNull">
|
||||
|
||||
Reference in New Issue
Block a user