Forráskód Böngészése

修改商品提醒bug,处理商品库存单位换算

huang 2 hete
szülő
commit
6b337f2925

+ 7 - 1
src/main/java/com/jsh/erp/controller/MaterialController.java

@@ -324,6 +324,7 @@ public class MaterialController extends BaseController {
                     item.put("mid", material.getId()); //商品扩展表的id
                     String ratioStr = ""; //比例
                     Unit unit = new Unit();
+                    BigDecimal ratio = new BigDecimal("1");
                     if (material.getUnitId() == null) {
                         ratioStr = "";
                     } else {
@@ -332,15 +333,19 @@ public class MaterialController extends BaseController {
                         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());
@@ -365,7 +370,7 @@ public class MaterialController extends BaseController {
                     item.put("depotId",material.getDepotId());
                     item.put("depotName",material.getDepotName());
                     item.put("unitId",material.getUnitId());
-                    item.put("inventory",materialService.getMaterialStockByMid(material.getId()));
+                    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);
@@ -644,6 +649,7 @@ public class MaterialController extends BaseController {
                         mvo.setDepotId(depotId);
                         getStockByMaterialInfo(mvo);
                     }
+                    mvo.setInventory(mvo.getStock());
                 }
             }
             res.code = 200;

+ 1 - 1
src/main/java/com/jsh/erp/datasource/mappers/MaterialMapper.java

@@ -1,12 +1,12 @@
 package com.jsh.erp.datasource.mappers;
 
-import com.jsh.erp.datasource.entities.DepotItem;
 import com.jsh.erp.datasource.entities.Material;
 import com.jsh.erp.datasource.entities.MaterialExample;
 import java.util.List;
 import org.apache.ibatis.annotations.Param;
 
 public interface MaterialMapper extends BaseMapperX<Material>{
+
     long countByExample(MaterialExample example);
 
     int deleteByExample(MaterialExample example);

+ 0 - 4
src/main/java/com/jsh/erp/service/impl/DepotHeadServiceImpl.java

@@ -1214,10 +1214,6 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
             Long headId = list.get(0).getId();
             /**入库和出库处理单据子表信息*/
             depotItemService.saveDetials(rows,headId, "add",request);
-            //处理实际入库数量价格总额
-//            if (list.get(0).getSubType().equals("采购") || !list.get(0).getSubType().equals("销售")){
-//                updateTotalPriceById(list.get(0));
-//            }
         }
         logService.insertLog("单据",
                 new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(depotHead.getNumber()).toString(),

+ 7 - 1
src/main/java/com/jsh/erp/service/impl/DepotItemServiceImpl.java

@@ -97,7 +97,13 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
         for (PDADepotItemVO pdaDepotItemVO : list) {
             Unit unitInfo = materialService.findUnit(pdaDepotItemVO.getMaterialId()); //查询多单位信息
             pdaDepotItemVO.setActualQuantityInStorage(depotItemService.getFinishNumber(pdaDepotItemVO.getMaterialExtendId(), pdaDepotItemVO.getId(), pdaDepotItemVO.getHeaderId(), unitInfo, pdaDepotItemVO.getMaterialUnit(), "basic").toString());
-            pdaDepotItemVO.setInventory(materialService.getMaterialStockByMid(pdaDepotItemVO.getMaterialId()).toString());
+            BigDecimal stock;
+            if (unitInfo != null && unitInfo.getId() != null){
+                stock = unitService.parseStockByUnit(materialService.getMaterialStockByMid(pdaDepotItemVO.getMaterialId()),unitInfo,pdaDepotItemVO.getCommodityUnit());
+            }else {
+                stock = materialService.getMaterialStockByMid(pdaDepotItemVO.getMaterialId());
+            }
+            pdaDepotItemVO.setInventory(stock.toString());
         }
         return list;
     }

+ 3 - 7
src/main/java/com/jsh/erp/service/impl/MaterialServiceImpl.java

@@ -88,9 +88,8 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
     private SupplierService supplierService;
     @Resource
     private DepotMapperEx depotMapperEx;
-
     @Resource
-    private MaterialBatchService materialBarCodeService;
+    private MaterialBatchService materialBatchService;
 
     @Value(value="${file.uploadType}")
     private Long fileUploadType;
@@ -1464,7 +1463,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
         List<MaterialVo4Unit> list = materialMapperEx.getMaterialByBarCode(barCodeArray);
         list.forEach(v -> {
             v.setUnitList(v.getUnitId() == null ? null : unitService.getUnitListByID(v.getUnitId()));
-            v.setInventory(getMaterialStockByMid(v.getId()));
         });
         return list;
     }
@@ -1665,10 +1663,8 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
         MaterialExample materialExample = new MaterialExample();
         materialExample.createCriteria().andDeleteFlagEqualTo("0");
         List<Material> materials = materialMapper.selectByExample(materialExample);
-        //获取商品子表信息
-        MaterialExtendExample materialExtendExample = new MaterialExtendExample();
-        materialExtendExample.createCriteria().andDeleteFlagEqualTo("0");
-        List<MaterialExtend> extendList = materialExtendMapper.selectByExample(materialExtendExample);
+        //获取商品批次信息
+        List<MaterialBatch> extendList = materialBatchService.list(new LambdaQueryWrapperX<MaterialBatch>().eq(MaterialBatch::getDeleteFlag,"0"));
         //无动销提醒
         materials.stream().filter( v -> v.getMovingPinReminderCycle() != null && !"".equals(v.getMovingPinReminderCycle()))
                         .forEach(v -> {