Browse Source

Merge branch 'master' into dev_ml_423

maliang 1 week ago
parent
commit
35074df008

+ 11 - 5
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);
@@ -591,10 +596,10 @@ public class MaterialController extends BaseController {
             String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit();
             String[] mpArr = mpList.split(",");
             //支持序列号查询,先根据序列号查询条码,如果查不到就直接查条码
-            MaterialExtend materialExtend = materialService.getMaterialExtendBySerialNumber(barCode);
-            if(materialExtend!=null && StringUtil.isNotEmpty(materialExtend.getBarCode())) {
-                barCode = materialExtend.getBarCode();
-            }
+//            MaterialExtend materialExtend = materialService.getMaterialExtendBySerialNumber(barCode);
+//            if(materialExtend!=null && StringUtil.isNotEmpty(materialExtend.getBarCode())) {
+//                barCode = materialExtend.getBarCode();
+//            }
             List<MaterialVo4Unit> list = materialService.getMaterialByBarCode(barCode);
             if(list!=null && list.size()>0) {
                 for(MaterialVo4Unit mvo: list) {
@@ -644,6 +649,7 @@ public class MaterialController extends BaseController {
                         mvo.setDepotId(depotId);
                         getStockByMaterialInfo(mvo);
                     }
+                    mvo.setInventory(mvo.getStock());
                 }
             }
             res.code = 200;

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

@@ -21,6 +21,7 @@ import com.jsh.erp.datasource.vo.TaskStocktakingVO;
 import com.jsh.erp.datasource.vo.TreeNode;
 import com.jsh.erp.query.LambdaQueryWrapperX;
 import com.jsh.erp.service.*;
+import com.jsh.erp.utils.StringUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
@@ -278,7 +279,12 @@ public class PdaController extends BaseController {
 
     @PostMapping("/inventoryInquiry")
     @ApiOperation("存货查询-商品存货查询")
-    public TableDataInfo inventoryInquiry(@RequestBody PDAInventoryDTO pdaInventoryDTO) throws Exception {
+    public TableDataInfo inventoryInquiry(@RequestBody PDAInventoryDTO pdaInventoryDTO){
+        if (StringUtil.isNotEmpty(pdaInventoryDTO.getPosition())){
+            pdaInventoryDTO.setMaterialIds(materialService.selectMaterialIdByPosition(pdaInventoryDTO.getPosition()));
+        }
+        //查询类型id的子类型
+        pdaInventoryDTO.setCategoryIds(materialService.selectCategoryIds(pdaInventoryDTO.getCategoryId()));
         startPage();
         List<PDADepotItemVO> list = materialService.inventoryInquiry(pdaInventoryDTO);
         return getDataTable(list);

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

@@ -1,12 +1,15 @@
 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 com.jsh.erp.datasource.pda.dto.PDAInventoryDTO;
+import com.jsh.erp.datasource.pda.vo.PDADepotItemVO;
 import org.apache.ibatis.annotations.Param;
 
 public interface MaterialMapper extends BaseMapperX<Material>{
+
     long countByExample(MaterialExample example);
 
     int deleteByExample(MaterialExample example);
@@ -28,4 +31,6 @@ public interface MaterialMapper extends BaseMapperX<Material>{
     int updateByPrimaryKeySelective(Material record);
 
     int updateByPrimaryKey(Material record);
+
+    List<PDADepotItemVO> inventoryInquiryList(PDAInventoryDTO pdaInventoryDTO);
 }

+ 0 - 2
src/main/java/com/jsh/erp/datasource/mappers/MaterialMapperEx.java

@@ -170,8 +170,6 @@ public interface MaterialMapperEx {
 
     List<MaterialCurrentStock4SystemSku> getMaterialCurrentPriceByIdList(@Param("idList") List<Long> idList);
 
-    List<PDADepotItemVO> inventoryInquiry(PDAInventoryDTO pdaInventoryDTO);
-
     /**
      * 根据单据子表id查询打印信息
      * @param depotItemId 单据子表id

+ 3 - 0
src/main/java/com/jsh/erp/datasource/pda/dto/PDADepotMaterialDto.java

@@ -10,6 +10,9 @@ import java.util.Date;
 @Data
 public class PDADepotMaterialDto {
 
+    @ApiModelProperty("条码")
+    private String barCode;
+
     @ApiModelProperty("批次号")
     private String batchNumber;
 

+ 3 - 0
src/main/java/com/jsh/erp/datasource/vo/TaskStocktakingVO.java

@@ -18,6 +18,9 @@ public class TaskStocktakingVO extends TaskStocktaking {
     @ApiModelProperty("创建人名称")
     private String createByName;
 
+    @ApiModelProperty("盘点人名称")
+    private String operByName;
+
     @ApiModelProperty("仓库名称")
     private String depotName;
 

+ 15 - 1
src/main/java/com/jsh/erp/service/MaterialService.java

@@ -206,7 +206,21 @@ public interface MaterialService extends IService<Material> {
      * pdaInventoryDTO
      * @return
      */
-    List<PDADepotItemVO> inventoryInquiry(PDAInventoryDTO pdaInventoryDTO) throws Exception;
+    List<PDADepotItemVO> inventoryInquiry(PDAInventoryDTO pdaInventoryDTO);
+
+    /**
+     * 根据库位查询商品id集合
+     * @param position
+     * @return
+     */
+    List<Long> selectMaterialIdByPosition(String position);
+
+    /**
+     * 根据类型id查询子类型集合
+     * @param id 类型id
+     * @return
+     */
+    List<Long> selectCategoryIds(Long id);
 
     /**
      * 查询库位树

+ 8 - 12
src/main/java/com/jsh/erp/service/impl/DepotHeadServiceImpl.java

@@ -2,7 +2,6 @@ package com.jsh.erp.service.impl;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jsh.erp.constants.BusinessConstants;
@@ -20,7 +19,6 @@ import com.jsh.erp.exception.JshException;
 import com.jsh.erp.query.LambdaQueryWrapperX;
 import com.jsh.erp.query.QueryWrapperX;
 import com.jsh.erp.service.*;
-import com.jsh.erp.util.QRCodeGenerator;
 import com.jsh.erp.utils.ExcelUtils;
 import com.jsh.erp.utils.PageUtils;
 import com.jsh.erp.utils.StringUtil;
@@ -1214,10 +1212,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(),
@@ -1995,7 +1989,7 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
         Map<String,PDADepotMaterialDto> materialMap = new HashMap<>();
         for (int i = 0; i < list.size(); i++) {
             operNumber = operNumber + list.get(i).getMaterialNumber().intValue();
-            materialMap.put(list.get(i).getBatchNumber(),list.get(i));
+            materialMap.put(list.get(i).getBarCode(),list.get(i));
         }
         depotHead.setGoodsQuantity(operNumber);
         //商品总类
@@ -2013,15 +2007,17 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
         for (DepotItem depotItem : depotItems) {
             //获取子表单商品
             MaterialExtend materialExtend = materialExtendService.getMaterialExtend(depotItem.getMaterialExtendId());
-            //获取子表单批次号
-            String batchNumber = materialExtend.getBatchNumber();
+            //获取商品条码
+            String barCode = materialExtend.getBarCode();
             //修改原先采购订单实际入库数量
             //depotItemService.update(new UpdateWrapper<DepotItem>().set("actual_quantity_in_storage", materialMap.get(batchNumber).getMaterialNumber()).eq("id", depotItem.getId()));
             //设置单据主表id
             depotItem.setHeaderId(id);
+            //设置关联子表id
+            depotItem.setLinkId(depotItem.getId());
             depotItem.setId(null);
             //设置实际入库数量
-            depotItem.setOperNumber(materialMap.get(batchNumber).getMaterialNumber());
+            depotItem.setOperNumber(materialMap.get(barCode).getMaterialNumber());
             //以下进行单位换算
             Unit unitInfo = materialService.findUnit(depotItem.getMaterialId()); //查询多单位信息
             if (StringUtil.isExist(depotItem.getOperNumber())) {
@@ -2067,9 +2063,9 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
             //更新当前成本价
             depotItemService.updateCurrentUnitPrice(depotItem);
             //修改商品生产日期
-            materialExtendService.update(new UpdateWrapper<MaterialExtend>().set("production_date",materialMap.get(batchNumber).getProductionDate()).eq("id", materialExtend.getId()));
+            //materialExtendService.update(new UpdateWrapper<MaterialExtend>().set("production_date",materialMap.get(batchNumber).getProductionDate()).eq("id", materialExtend.getId()));
             //修改订单总额
-            updateTotalPriceById(depotHead);
+            //updateTotalPriceById(depotHead);
         }
         //修改采购订单状态、操作人、操作时间
         this.update(new UpdateWrapper<DepotHead>().set("status", "2").set("oper_id",userInfo.getId()).set("submit_time",new Date()).eq("id", pdaDepotHeadDTO.getId()));

+ 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;
     }

+ 30 - 22
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 -> {
@@ -1949,12 +1945,34 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
         return info;
     }
 
+    /**
+     * PDA库存查询
+     */
+    @Override
+    public List<PDADepotItemVO> inventoryInquiry(PDAInventoryDTO pdaInventoryDTO){
+        return materialMapper.inventoryInquiryList(pdaInventoryDTO);
+    }
+
+    /**
+     * 根据库位查询商品id集合
+     */
     @Override
-    public List<PDADepotItemVO> inventoryInquiry(PDAInventoryDTO pdaInventoryDTO) throws Exception {
-        pdaInventoryDTO.setMaterialIds(materialInitialStockMapper.selectMaterialIdByPosition(pdaInventoryDTO.getPosition()));
-        //查询类型id的子类型
-        pdaInventoryDTO.setCategoryIds(selectCategoryIds(pdaInventoryDTO.getCategoryId()));
-        return materialMapperEx.inventoryInquiry(pdaInventoryDTO);
+    public List<Long> selectMaterialIdByPosition(String position) {
+        return materialInitialStockMapper.selectMaterialIdByPosition(position);
+    }
+
+    /**
+     * 根据类型id查询子类型集合
+     */
+    @Override
+    public List<Long> selectCategoryIds(Long id) {
+        List<Long> longs = new ArrayList<>();
+        longs.add(id);
+        List<MaterialCategory> list = materialCategoryService.list(new LambdaQueryWrapperX<MaterialCategory>().eq(MaterialCategory::getParentId,id).eq(MaterialCategory::getDeleteFlag,"0"));
+        for (MaterialCategory materialCategory : list) {
+            longs.addAll(selectCategoryIds(materialCategory.getId()));
+        }
+        return longs;
     }
 
     /**
@@ -2094,14 +2112,4 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
         materialMap.values().forEach(v -> materials.add(v));
         return materials;
     }
-
-    public List<Long> selectCategoryIds(Long id) throws Exception {
-        List<Long> longs = new ArrayList<>();
-        longs.add(id);
-        List<MaterialCategory> list = materialCategoryService.list(new LambdaQueryWrapperX<MaterialCategory>().eq(MaterialCategory::getParentId,id).eq(MaterialCategory::getDeleteFlag,"0"));
-        for (MaterialCategory materialCategory : list) {
-            longs.addAll(selectCategoryIds(materialCategory.getId()));
-        }
-        return longs;
-    }
 }

+ 5 - 0
src/main/java/com/jsh/erp/service/impl/TaskStocktakingServiceImpl.java

@@ -137,6 +137,11 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
         if (user1 != null) {
             taskStocktakingVO.setCreateByName(user1.getUsername());
         }
+        //获取盘点人名称
+        User user2 = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getId, one.getOperBy()));
+        if (user2 != null) {
+            taskStocktakingVO.setOperByName(user2.getUsername());
+        }
         //获取仓库名称
         Depot depot = depotService.getDepot(one.getDepotId());
         taskStocktakingVO.setDepotName(depot.getName());

+ 2 - 2
src/main/resources/mapper_xml/DepotItemMapper.xml

@@ -600,8 +600,8 @@
       m.`name` AS material_name,
       m.standard AS material_standard,
       me.batch_number AS batch_number,
-      me.production_date AS production_date,
-      me.position AS position,
+      di.production_date AS production_date,
+      di.position AS position,
 	  me.inventory AS inventory,
 	  me.bar_code AS bar_code,
 	  di.oper_number AS oper_number,

+ 44 - 0
src/main/resources/mapper_xml/MaterialMapper.xml

@@ -488,4 +488,48 @@
     where id = #{id,jdbcType=BIGINT}
   </update>
 
+  <select id="inventoryInquiryList" parameterType="com.jsh.erp.datasource.pda.dto.PDAInventoryDTO" resultType="com.jsh.erp.datasource.pda.vo.PDADepotItemVO">
+    SELECT
+    m.id materialId,
+    me.id materialExtendId,
+    m.name materialName,
+    m.standard materialStandard,
+    me.position,
+    me.bar_code,
+    me.commodity_unit,
+    m.img_name,
+    CAST(IFNULL(mi.inventory,0) / me.ratio AS DECIMAL(10,0)) inventory
+    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 (SELECT material_id,SUM(current_number) AS 'inventory' FROM jsh_material_current_stock GROUP BY material_id) mi ON m.id = mi.material_id
+    <where>
+      m.enabled = 1 and me.id is not null
+      <if test="keyword != null and keyword !=''">
+        <bind name="bindKey" value="'%'+keyword+'%'"/>
+        and (m.name like #{bindKey} or me.bar_code like #{bindKey})
+      </if>
+      <if test="categoryId != null">
+        and m.category_id IN (
+        <foreach collection="categoryIds" item="item" separator=",">
+          #{item}
+        </foreach>
+        )
+      </if>
+      <if test="materialIds != null">
+        and m.id IN (
+        <foreach collection="materialIds" item="item" separator=",">
+          #{item}
+        </foreach>
+        )
+      </if>
+      <if test="type == 'have'">
+        and mi.inventory > 0
+      </if>
+      <if test="type == 'none'">
+        and ifnull(mi.inventory,0) &lt;= 0
+      </if>
+      and ifnull(me.delete_flag,'0') !='1'
+    </where>
+  </select>
+
 </mapper>

+ 1 - 45
src/main/resources/mapper_xml/MaterialMapperEx.xml

@@ -866,50 +866,6 @@
         ORDER BY m.id DESC, me.default_flag DESC, me.production_date,me.batch_number ASC
     </select>
 
-    <select id="inventoryInquiry" parameterType="com.jsh.erp.datasource.pda.dto.PDAInventoryDTO" resultType="com.jsh.erp.datasource.pda.vo.PDADepotItemVO">
-        SELECT
-            m.id materialId,
-            me.id materialExtendId,
-            m.name materialName,
-            m.standard materialStandard,
-            me.position,
-            me.bar_code,
-            me.commodity_unit,
-            m.img_name,
-            CAST(IFNULL(mi.inventory,0) / me.ratio AS DECIMAL(10,0)) inventory
-        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 (SELECT material_id,SUM(current_number) AS 'inventory' FROM jsh_material_current_stock GROUP BY material_id) mi ON m.id = mi.material_id
-        WHERE
-          m.enabled = 1
-          and me.id is not null
-          <if test="keyword != null and keyword !=''">
-              <bind name="bindKey" value="'%'+keyword+'%'"/>
-              and (m.name like #{bindKey} or me.bar_code like #{bindKey})
-          </if>
-          <if test="categoryId != null">
-              and m.category_id IN (
-              <foreach collection="categoryIds" item="item" separator=",">
-                  #{item}
-              </foreach>
-              )
-          </if>
-          <if test="materialIds != null">
-              and m.id IN (
-              <foreach collection="materialIds" item="item" separator=",">
-                  #{item}
-              </foreach>
-              )
-          </if>
-          <if test="type == 'have'">
-              and mi.inventory > 0
-          </if>
-          <if test="type == 'none'">
-              and ifnull(mi.inventory,0) &lt;= 0
-          </if>
-          and ifnull(me.delete_flag,'0') !='1'
-    </select>
-
     <select id="getMaterialCurrentPriceByIdList" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku">
         WITH RankedExtend AS (
             SELECT
@@ -944,7 +900,7 @@
         LEFT JOIN jsh_depot_head dh ON di.header_id = dh.id
         LEFT JOIN jsh_material m ON di.material_id = m.id
         LEFT JOIN jsh_supplier s ON dh.organ_id = s.id
-        LEFT JOIN material_batch mb ON di.id = mb.depot_item_id
+        LEFT JOIN material_batch mb ON (SELECT id FROM jsh_depot_item WHERE link_id = di.id LIMIT 1) = mb.depot_item_id
         WHERE di.id = #{depotItemId}
     </select>