Prechádzať zdrojové kódy

景聚庭-代码恢复

huangguoce 6 dní pred
rodič
commit
1c5e0281c3
21 zmenil súbory, kde vykonal 306 pridanie a 559 odobranie
  1. 0 10
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/collect/domain/PsiCollectDetailed.java
  2. 1 2
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/collect/mapper/xml/PsiCollectBasicMapper.xml
  3. 10 10
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/collect/mapper/xml/PsiCollectDetailedMapper.xml
  4. 14 16
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/collect/service/PsiCollectService.java
  5. 0 16
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/loss/domain/PsiLossDetailed.java
  6. 2 6
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/loss/mapper/xml/PsiLossBasicMapper.xml
  7. 0 8
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/loss/mapper/xml/PsiLossDetailedMapper.xml
  8. 94 87
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/loss/service/PsiLossService.java
  9. 10 13
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/loss/service/dto/PsiLossExportDto.java
  10. 0 32
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/materialType/domain/PsiMaterialTypeInfo.java
  11. 8 0
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/materialType/mapper/PsiMaterialTypeMapper.java
  12. 11 19
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/materialType/mapper/xml/PsiMaterialTypeMapper.xml
  13. 6 34
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/materialType/service/PsiMaterialTypeService.java
  14. 0 10
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/domain/PsiWareHouseDetailed.java
  15. 114 131
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/mapper/xml/PsiWareHouseBasicMapper.xml
  16. 10 6
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/mapper/xml/PsiWareHouseSummaryMapper.xml
  17. 25 103
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/service/PsiWareHouseBasicService.java
  18. 0 10
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/service/dto/PsiWareHouseDto.java
  19. 0 10
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/purchase/domain/PsiMaterialDetailed.java
  20. 0 35
      jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/purchase/service/PsiMaterialService.java
  21. 1 1
      jeeplus-modules/jeeplus-xxl-job-executor-sample/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java

+ 0 - 10
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/collect/domain/PsiCollectDetailed.java

@@ -78,16 +78,6 @@ public class PsiCollectDetailed extends BaseEntity {
     private String company;
 
     /**
-     * 品牌
-     */
-    private String brand;
-
-    /**
-     * 规格
-     */
-    private String specification;
-
-    /**
      * 备注
      */
     private String remarks;

+ 1 - 2
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/collect/mapper/xml/PsiCollectBasicMapper.xml

@@ -34,7 +34,7 @@
 			a.handled_by,
 			a.handled_by_office,
 			a.collect_date,
-			c.name as goods_name,
+			b.goods_name,
 			b.id as detail_id,
 			so.name as handledByOfficeName,
 			su.name as handledByName,
@@ -49,7 +49,6 @@
 			left join sys_user su on a.handled_by = su.id
 			left join sys_office so on a.handled_by_office = so.id
 			left join psi_management_collect_detailed b on a.id = b.basic_id and b.del_flag = '0'
-			left join psi_management_type c on b.collect_type = c.id
 			left join act_ru_task art ON a.proc_ins_id = art.PROC_INST_ID_
 			left join psi_management_collect_basics_return returna on returna.basic_id = a.id and returna.del_flag = '0'
 			left join act_ru_task art_r ON returna.proc_ins_id = art_r.PROC_INST_ID_

+ 10 - 10
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/collect/mapper/xml/PsiCollectDetailedMapper.xml

@@ -15,8 +15,6 @@
         a.goods_name,
         a.collect_number,
         a.company,
-        a.brand,
-        a.specification,
         a.current_inventory,
                c.spec,
         su.name AS recipientAgent, su.id AS recipientAgentId, so.name AS recipientOffice,
@@ -32,7 +30,8 @@
              LEFT JOIN (
                 SELECT
                     sum( collect_number ) AS collect_number,
-                    collect_type
+                    goods_name,
+                STATUS
                 FROM
                     psi_management_collect_detailed e
                     LEFT JOIN psi_management_collect_basics f ON e.basic_id = f.id
@@ -41,25 +40,26 @@
                     f.`status` = 5
                     AND e.del_flag = 0
                 GROUP BY
-                    e.collect_type
-                ) b ON a.collect_type =  b.collect_type
+                    e.goods_name
+                ) b ON a.goods_name = b.goods_name
 
              LEFT JOIN (
                  SELECT
                      sum( current_inventory ) AS current_inventory,
-                     ware_house_type
+                     trade_name
                  FROM
                      psi_management_warehouse_detailed e
                  WHERE  e.del_flag = 0
-                 GROUP BY e.ware_house_type
-             ) wd ON a.collect_type = wd.ware_house_type
+                 GROUP BY
+                     e.trade_name
+             ) wd ON a.goods_name = wd.trade_name
 
-             LEFT JOIN psi_management_warehouse_detailed c on a.collect_type = c.ware_house_type
+             LEFT JOIN psi_management_warehouse_detailed c on a.goods_name = c.trade_name and a.collect_type = c.ware_house_type
              LEFT JOIN psi_management_warehouse_basics bas ON c.basic_id = bas.id
 
              LEFT JOIN psi_management_type d ON a.collect_type = d.id
              WHERE a.basic_id = #{id} AND a.del_flag = '0' and c.del_flag = '0' AND ( bas.`status` = '0' OR bas.`status` = '5')
-             group by a.id;
+             group by a.goods_name;
     </select>
     <select id="getRecordsByBasicId" resultType="com.jeeplus.psimanage.collect.domain.PsiCollectDetailedRecord">
         select

+ 14 - 16
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/collect/service/PsiCollectService.java

@@ -414,7 +414,7 @@ public class PsiCollectService {
                         List<PsiWareHouseDetailed> infoByProduceDateDesc = new ArrayList<>();
                         for (PsiCollectDetailedRecord psiCollectDetailedRecord : recordList) {
                             //如果领用详情的分类和物品名  跟  领用分配的相同
-                            if(detailInfo.getCollectTypeId().equals(psiCollectDetailedRecord.getCollectTypeId())){
+                            if(detailInfo.getCollectTypeId().equals(psiCollectDetailedRecord.getCollectTypeId()) && detailInfo.getGoodsName().equals(psiCollectDetailedRecord.getGoodsName())){
                                 String recordId = UUID.randomUUID().toString().replace("-", "");
                                 psiCollectDetailedRecord.setSurplusStock("0");//退回数量
                                 psiCollectDetailedRecord.setReturnedNum("0");//已退回数量
@@ -497,20 +497,18 @@ public class PsiCollectService {
                         //向用户发起通知
                         if (null != notifiedPartyUsers) {
                             for (UserDTO userDTO1 : notifiedPartyUsers) {
-                                if(userDTO1 != null){
-                                    //发送通知
-                                    Map<String ,String > map = new HashMap<>();
-                                    map.put("taskId",dto.getProcInsId());
-                                    map.put("title",title);
-                                    map.put("defId",info.getProcessDefinitionId());
-                                    map.put("taskName","领用申请审批通过");
-                                    map.put("createUser","管理员");
-                                    map.put("createTime",day);
-                                    map.put("noticeName",userDTO1.getLoginName());
-                                    map.put("noticeId",userDTO1.getId());
-                                    map.put("createById",userDTO.getId());
-                                    flowTaskService.add(map);
-                                }
+                                //发送通知
+                                Map<String ,String > map = new HashMap<>();
+                                map.put("taskId",dto.getProcInsId());
+                                map.put("title",title);
+                                map.put("defId",info.getProcessDefinitionId());
+                                map.put("taskName","领用申请审批通过");
+                                map.put("createUser","管理员");
+                                map.put("createTime",day);
+                                map.put("noticeName",userDTO1.getLoginName());
+                                map.put("noticeId",userDTO1.getId());
+                                map.put("createById",userDTO.getId());
+                                flowTaskService.add(map);
                         }
                     }
                 }
@@ -864,7 +862,7 @@ public class PsiCollectService {
             queryWrapper.like("a.collect_no", dto.getCollectNo());
         }
         if (StringUtils.isNotEmpty(dto.getGoodsName())) {
-            queryWrapper.like("c.name", dto.getGoodsName());
+            queryWrapper.like("b.goods_name", dto.getGoodsName());
         }
         if (StringUtils.isNotEmpty(dto.getHandledBy())) {
             queryWrapper.eq("su.id", dto.getHandledBy());

+ 0 - 16
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/loss/domain/PsiLossDetailed.java

@@ -32,20 +32,11 @@ public class PsiLossDetailed extends BaseEntity {
 
     private String goodsName;
 
-    private String inventoryId;
-
     @TableField("loss_number")
     private String lossNumber;
 
-    @TableField("loss_reason")
-    private String lossReason;
-
     private String company;
 
-    private String brand;
-
-    private String specification;
-
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private Date produceDate;
 
@@ -59,13 +50,6 @@ public class PsiLossDetailed extends BaseEntity {
     private String surplusNumber;
 
     @TableField(exist = false)
-    private String wareHouseNumber;
-
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @TableField(exist = false)
-    private Date wareHouseDate;
-
-    @TableField(exist = false)
     private List<WorkAttachmentDto> fileInfoLost;
 
     @TableField(exist = false)

+ 2 - 6
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/loss/mapper/xml/PsiLossBasicMapper.xml

@@ -26,7 +26,7 @@
             a.handled_by,
             a.handled_by_office,
             a.collect_date AS lossDate,
-            t.name as goodsName,
+            b.goods_name,
             b.id AS detail_id,
             so.name AS handledByOfficeName,
             su.name AS handledByName,
@@ -35,7 +35,6 @@
         LEFT JOIN sys_user su ON a.handled_by = su.id
         LEFT JOIN sys_office so ON su.office_id = so.id
         LEFT JOIN psi_management_loss_detailed b ON a.id = b.basic_id AND b.del_flag = '0'
-        LEFT JOIN psi_management_type t ON b.collect_type = t.id
         LEFT JOIN act_ru_task art ON a.proc_ins_id = art.PROC_INST_ID_
         ${ew.customSqlSegment}
         ORDER BY a.update_time DESC
@@ -43,12 +42,11 @@
 
     <select id="getLossByTradeName" resultType="com.jeeplus.psimanage.loss.domain.PsiLossDetailed">
         SELECT
-            t.name as goodsName,
+            a.goods_name,
             b.id,
             so.name AS handledByOfficeName,
             su.name AS handledByName,
             a.loss_number,
-            a.loss_reason,
             a.produce_date,
             b.collect_no as lossNo,
             b.collect_date as createTime
@@ -56,8 +54,6 @@
             left join psi_management_loss_basics b on a.basic_id = b.id
                  LEFT JOIN sys_user su ON b.handled_by = su.id
                  LEFT JOIN sys_office so ON su.office_id = so.id
-            LEFT JOIN psi_management_type t ON a.collect_type = t.id
-
             ${ew.customSqlSegment}
         ORDER BY a.update_time DESC
     </select>

+ 0 - 8
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/loss/mapper/xml/PsiLossDetailedMapper.xml

@@ -15,18 +15,12 @@
             a.recipient_agent,
             a.collect_type,
             a.goods_name,
-            a.inventory_id,
             a.loss_number,
-            a.loss_reason,
             a.company,
-            a.brand,
-            a.specification,
             a.produce_date,
             a.shelf_life,
             a.spec,
             a.shelf_life_unit,
-            bas.ware_house_number,
-            bas.ware_house_date,
             su.name AS recipientAgent,
             su.id AS recipientAgentId,
             so.name AS recipientOffice,
@@ -36,8 +30,6 @@
         FROM psi_management_loss_detailed a
         LEFT JOIN sys_user su ON a.recipient_agent = su.id
         LEFT JOIN sys_office so ON su.office_id = so.id
-        LEFT JOIN psi_management_warehouse_detailed wd ON a.inventory_id = wd.id
-        LEFT JOIN psi_management_warehouse_basics bas ON wd.basic_id = bas.id
 
         LEFT JOIN psi_management_type d ON a.collect_type = d.id
         WHERE a.basic_id = #{id}

+ 94 - 87
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/loss/service/PsiLossService.java

@@ -1,5 +1,6 @@
 package com.jeeplus.psimanage.loss.service;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -20,6 +21,7 @@ import com.jeeplus.psimanage.loss.service.dto.PsiLossExportDto;
 import com.jeeplus.psimanage.oss.service.dto.WorkAttachmentDto;
 import com.jeeplus.psimanage.psiWareHouse.domain.PsiWareHouseDetailed;
 import com.jeeplus.psimanage.psiWareHouse.mapper.PsiWareHouseDetailedMapper;
+import com.jeeplus.psimanage.psiWareHouse.mapper.PsiWareHouseSummaryMapper;
 import com.jeeplus.psimanage.purchase.service.PsiMaterialService;
 import com.jeeplus.psimanage.serialNumTpl.service.PsiSerialnumTplService;
 import com.jeeplus.sys.feign.IRoleApi;
@@ -56,6 +58,9 @@ public class PsiLossService {
     private PsiMaterialService psiMaterialService;
 
     @Resource
+    private PsiWareHouseSummaryMapper summaryMapper;
+
+    @Resource
     private PsiWareHouseDetailedMapper psiWareHouseDetailedMapper;
 
     @Resource
@@ -90,6 +95,9 @@ public class PsiLossService {
 
     public String add(PsiLossDto dto, UserDTO userDTO) throws Exception {
         validateDetailInfos(dto.getDetailInfos());
+        PsiLossDetailed detail = dto.getDetailInfos().get(0);
+        prepareDetail(detail, userDTO);
+        fillStockInfo(detail);
 
         String id = UUID.randomUUID().toString().replace("-", "");
         PsiLossBasic info = new PsiLossBasic();
@@ -104,23 +112,17 @@ public class PsiLossService {
         info.setDelFlag(0);
         basicMapper.insert(info);
 
-        for (PsiLossDetailed detail : dto.getDetailInfos()) {
-            prepareDetail(detail, userDTO);
-            fillStockInfo(detail);
-            detail.setId(UUID.randomUUID().toString().replace("-", ""));
-            detail.setBasicId(id);
-            detailedMapper.insert(detail);
-            saveDetailFiles(detail, userDTO);
-        }
+        detail.setId(UUID.randomUUID().toString().replace("-", ""));
+        detail.setBasicId(id);
+        detailedMapper.insert(detail);
+        saveDetailFiles(detail, userDTO);
 
         if (CollectionUtils.isNotEmpty(dto.getFiles())) {
             psiMaterialService.saveFiles(dto.getFiles(), userDTO, id);
         }
 
         if (isApproved(info.getStatus())) {
-            for (PsiLossDetailed detail : dto.getDetailInfos()) {
-                deductInventory(detail);
-            }
+            deductInventory(detail);
         }
         return id;
     }
@@ -142,10 +144,13 @@ public class PsiLossService {
 
         List<String> dbIds = detailedMapper.getIdByBasicId(dto.getId());
         List<String> liveIds = new ArrayList<>();
-        for (PsiLossDetailed detail : dto.getDetailInfos()) {
-            if (StringUtils.isNotBlank(detail.getId())) {
-                liveIds.add(detail.getId());
-            }
+        PsiLossDetailed detail = dto.getDetailInfos().get(0);
+        prepareDetail(detail, userDTO);
+        fillStockInfo(detail);
+        detail.setBasicId(dto.getId());
+
+        if (StringUtils.isNotBlank(detail.getId())) {
+            liveIds.add(detail.getId());
         }
         if (CollectionUtils.isNotEmpty(dbIds)) {
             dbIds.stream()
@@ -156,29 +161,22 @@ public class PsiLossService {
                     });
         }
 
-        for (PsiLossDetailed detail : dto.getDetailInfos()) {
-            prepareDetail(detail, userDTO);
-            fillStockInfo(detail);
-            detail.setBasicId(dto.getId());
-            if (StringUtils.isBlank(detail.getId()) || detailedMapper.selectById(detail.getId()) == null) {
-                detail.setId(UUID.randomUUID().toString().replace("-", ""));
-                detail.setCreateById(userDTO.getId());
-                detail.setCreateTime(new Date());
-                detail.setDelFlag(0);
-                detailedMapper.insert(detail);
-                saveDetailFiles(detail, userDTO);
-            } else {
-                detailedMapper.updateById(detail);
-                psiMaterialService.updateFiles(detail.getFileInfoLost(), userDTO, detail.getId());
-            }
+        if (StringUtils.isBlank(detail.getId()) || detailedMapper.selectById(detail.getId()) == null) {
+            detail.setId(UUID.randomUUID().toString().replace("-", ""));
+            detail.setCreateById(userDTO.getId());
+            detail.setCreateTime(new Date());
+            detail.setDelFlag(0);
+            detailedMapper.insert(detail);
+            saveDetailFiles(detail, userDTO);
+        } else {
+            detailedMapper.updateById(detail);
+            psiMaterialService.updateFiles(detail.getFileInfoLost(), userDTO, detail.getId());
         }
 
         psiMaterialService.updateFiles(dto.getFiles(), userDTO, dto.getId());
 
         if (!isApproved(oldInfo.getStatus()) && isApproved(info.getStatus())) {
-            for (PsiLossDetailed detail : dto.getDetailInfos()) {
-                deductInventory(detail);
-            }
+            deductInventory(detail);
             //通知发起人
             List<UserDTO> notifiedPartyUsers = new ArrayList<>();
             SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
@@ -219,7 +217,7 @@ public class PsiLossService {
         List<PsiLossDetailed> detailList = detailedMapper.getByBasicId(id);
         if (CollectionUtils.isNotEmpty(detailList)) {
             detailList.forEach(detail -> {
-                detail.setSurplusNumber(formatNumber(getAvailableBottleCount(detail)));
+                detail.setSurplusNumber(formatNumber(getAvailableBottleCount(detail.getGoodsName(), getCollectTypeId(detail))));
                 List<WorkAttachmentDto> fileList = detailedMapper.getByAttachmentId(detail.getId());
                 if (CollectionUtils.isNotEmpty(fileList)) {
                     fileList.forEach(file -> file.setCreateBy(SpringUtil.getBean(IUserApi.class).getById(file.getBy())));
@@ -247,7 +245,7 @@ public class PsiLossService {
             queryWrapper.like("a.collect_no", dto.getLossNo());
         }
         if (StringUtils.isNotBlank(dto.getGoodsName())) {
-            queryWrapper.like("t.name", dto.getGoodsName());
+            queryWrapper.like("b.goods_name", dto.getGoodsName());
         }
         if (StringUtils.isNotBlank(dto.getHandledBy())) {
             queryWrapper.eq("su.id", dto.getHandledBy());
@@ -287,11 +285,8 @@ public class PsiLossService {
         if (StringUtils.isNotBlank(dto.getLossNo())) {
             queryWrapper.like("b.collect_no", dto.getLossNo());
         }
-        //if (StringUtils.isNotBlank(dto.getGoodsName())) {
-        //    queryWrapper.eq("t.name", dto.getGoodsName());
-        //}
-        if(StringUtils.isNotBlank(dto.getCollectType())){
-            queryWrapper.eq("t.id", dto.getCollectType());
+        if (StringUtils.isNotBlank(dto.getGoodsName())) {
+            queryWrapper.eq("a.goods_name", dto.getGoodsName());
         }
         if (dto.getLossDates() != null && dto.getLossDates().length == 2) {
             queryWrapper.between("b.collect_date", dto.getLossDates()[0], dto.getLossDates()[1]);
@@ -305,27 +300,21 @@ public class PsiLossService {
         if (CollectionUtils.isEmpty(detailInfos)) {
             throw new RuntimeException("报损明细不能为空");
         }
-        for (int i = 0; i < detailInfos.size(); i++) {
-            PsiLossDetailed detail = detailInfos.get(i);
-            String lineNo = String.valueOf(i + 1);
-            if (StringUtils.isBlank(detail.getRecipientAgentId())) {
-                throw new RuntimeException("报损明细第" + lineNo + "行报损人不能为空");
-            }
-            if (StringUtils.isBlank(getCollectTypeId(detail))) {
-                throw new RuntimeException("报损明细第" + lineNo + "行报损类型不能为空");
-            }
-            if (StringUtils.isBlank(detail.getGoodsName())) {
-                throw new RuntimeException("报损明细第" + lineNo + "行物品名称不能为空");
-            }
-            if (StringUtils.isBlank(detail.getInventoryId())) {
-                throw new RuntimeException("报损明细第" + lineNo + "行请选择报损库存批次");
-            }
-            if (StringUtils.isBlank(detail.getLossNumber())) {
-                throw new RuntimeException("报损明细第" + lineNo + "行报损数量不能为空");
-            }
-            if (StringUtils.isBlank(detail.getLossReason())) {
-                throw new RuntimeException("报损明细第" + lineNo + "行报损原因不能为空");
-            }
+        if (detailInfos.size() != 1) {
+            throw new RuntimeException("报损单只能保存一条明细");
+        }
+        PsiLossDetailed detail = detailInfos.get(0);
+        if (StringUtils.isBlank(detail.getRecipientAgentId())) {
+            throw new RuntimeException("报损人不能为空");
+        }
+        if (StringUtils.isBlank(getCollectTypeId(detail))) {
+            throw new RuntimeException("报损类型不能为空");
+        }
+        if (StringUtils.isBlank(detail.getGoodsName())) {
+            throw new RuntimeException("物品名称不能为空");
+        }
+        if (StringUtils.isBlank(detail.getLossNumber())) {
+            throw new RuntimeException("报损数量不能为空");
         }
     }
 
@@ -348,40 +337,59 @@ public class PsiLossService {
     }
 
     private void fillStockInfo(PsiLossDetailed detail) {
-        detail.setSurplusNumber(formatNumber(getAvailableBottleCount(detail)));
+        detail.setSurplusNumber(formatNumber(getAvailableBottleCount(detail.getGoodsName(), getCollectTypeId(detail))));
     }
 
     private void deductInventory(PsiLossDetailed detail) {
         double lossNumber = parseDouble(detail.getLossNumber());
-        PsiWareHouseDetailed inventory = getInventory(detail.getInventoryId());
-        double spec = parseSpec(inventory.getSpec());
-        double available = round(parseDouble(inventory.getCurrentInventory()) * spec);
+        double available = getAvailableBottleCount(detail.getGoodsName(), getCollectTypeId(detail));
         if (lossNumber - available > 0.001D) {
-            throw new RuntimeException("报损数量不能大于当前批次库存数量");
+            throw new RuntimeException("报损数量不能大于当前库存数量");
+        }
+        List<PsiWareHouseDetailed> updateList = batchCalculation(detail);
+        if (CollUtil.isNotEmpty(updateList)) {
+            psiWareHouseDetailedMapper.updateBatchById(updateList);
         }
-        PsiWareHouseDetailed update = new PsiWareHouseDetailed();
-        update.setId(inventory.getId());
-        update.setCurrentInventory(formatNumber(round((available - lossNumber) / spec)));
-        psiWareHouseDetailedMapper.updateBatchById(Collections.singletonList(update));
     }
 
-    private double getAvailableBottleCount(PsiLossDetailed detail) {
-        if (detail == null || StringUtils.isBlank(detail.getInventoryId())) {
-            return 0D;
+    private List<PsiWareHouseDetailed> batchCalculation(PsiLossDetailed detail) {
+        List<PsiWareHouseDetailed> inventoryList = summaryMapper.getInfoByProduceDateDesc(detail.getGoodsName(), getCollectTypeId(detail));
+        List<PsiWareHouseDetailed> updateList = new ArrayList<>();
+        double pending = parseDouble(detail.getLossNumber());
+        for (PsiWareHouseDetailed inventory : inventoryList) {
+            if (pending <= 0.001D) {
+                break;
+            }
+            double currentBox = parseDouble(inventory.getCurrentInventory());
+            double spec = parseSpec(inventory.getSpec());
+            double totalUnit = round(currentBox * spec);
+            if (totalUnit <= 0.001D) {
+                continue;
+            }
+            PsiWareHouseDetailed update = new PsiWareHouseDetailed();
+            update.setId(inventory.getId());
+            if (totalUnit >= pending) {
+                update.setCurrentInventory(formatNumber(round((totalUnit - pending) / spec)));
+                pending = 0D;
+            } else {
+                update.setCurrentInventory("0");
+                pending = round(pending - totalUnit);
+            }
+            updateList.add(update);
         }
-        PsiWareHouseDetailed inventory = getInventory(detail.getInventoryId());
-        return round(parseDouble(inventory.getCurrentInventory()) * parseSpec(inventory.getSpec()));
+        return updateList;
     }
 
-    private PsiWareHouseDetailed getInventory(String inventoryId) {
-        if (StringUtils.isBlank(inventoryId)) {
-            throw new RuntimeException("请选择报损库存批次");
+    private double getAvailableBottleCount(String goodsName, String collectTypeId) {
+        if (StringUtils.isBlank(goodsName) || StringUtils.isBlank(collectTypeId)) {
+            return 0D;
         }
-        PsiWareHouseDetailed inventory = psiWareHouseDetailedMapper.selectById(inventoryId);
-        if (inventory == null || !"0".equals(String.valueOf(inventory.getDelFlag()))) {
-            throw new RuntimeException("报损库存批次不存在");
+        List<PsiWareHouseDetailed> inventoryList = summaryMapper.getInfoByProduceDateDesc(goodsName, collectTypeId);
+        double total = 0D;
+        for (PsiWareHouseDetailed inventory : inventoryList) {
+            total += parseDouble(inventory.getCurrentInventory()) * parseSpec(inventory.getSpec());
         }
-        return inventory;
+        return round(total);
     }
 
     private String getCollectTypeId(PsiLossDetailed detail) {
@@ -436,13 +444,12 @@ public class PsiLossService {
             recordList.forEach(record -> {
                 PsiLossExportDto exportDto = new PsiLossExportDto();
                 exportDto.setLossNo(item.getLossNo());
-                //exportDto.setRecipientAgent(record.getRecipientAgent());
-                //exportDto.setRecipientOffice(record.getRecipientOffice());
+                exportDto.setRecipientAgent(record.getRecipientAgent());
+                exportDto.setRecipientOffice(record.getRecipientOffice());
                 exportDto.setCollectType(record.getCollectType());
-                //exportDto.setGoodsName(record.getGoodsName());
-                //exportDto.setProduceDate(record.getProduceDate() == null ? "暂无生产日期" : dateFormat.format(record.getProduceDate()));
+                exportDto.setGoodsName(record.getGoodsName());
+                exportDto.setProduceDate(record.getProduceDate() == null ? "暂无生产日期" : dateFormat.format(record.getProduceDate()));
                 exportDto.setLossNumber(record.getLossNumber());
-                exportDto.setLossReason(record.getLossReason());
                 result.add(exportDto);
             });
         });

+ 10 - 13
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/loss/service/dto/PsiLossExportDto.java

@@ -17,25 +17,22 @@ public class PsiLossExportDto {
     @ExcelProperty("报损编号")
     private String lossNo;
 
-    //@ExcelProperty("报损人")
-    //private String recipientAgent;
-    //
-    //@ExcelProperty("报损部门")
-    //private String recipientOffice;
+    @ExcelProperty("报损人")
+    private String recipientAgent;
 
-    @ExcelProperty("物品名称")
+    @ExcelProperty("报损部门")
+    private String recipientOffice;
+
+    @ExcelProperty("物品类型")
     private String collectType;
 
-    //@ExcelProperty("物品名称")
-    //private String goodsName;
+    @ExcelProperty("物品名称")
+    private String goodsName;
 
-    //@ExcelProperty("生产日期")
-    //private String produceDate;
+    @ExcelProperty("生产日期")
+    private String produceDate;
 
     @ExcelProperty("报损数量")
     private String lossNumber;
 
-    @ExcelProperty("报损原因")
-    private String lossReason;
-
 }

+ 0 - 32
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/materialType/domain/PsiMaterialTypeInfo.java

@@ -80,39 +80,7 @@ public class PsiMaterialTypeInfo extends TreeEntity<PsiMaterialTypeInfo> {
 
     private String parentIds;
 
-    /**
-     * 信息类别:0分类,1商品
-     */
-    private String infoType;
-
-    /**
-     * 品牌
-     */
-    private String brand;
-
-    /**
-     * 规格
-     */
-    private String specification;
-
-    /**
-     * 单位
-     */
-    private String company;
-
     @TableField(exist = false)
     private Boolean disabled = false;
 
-    /**
-     * 当前剩余库存数量
-     */
-    @TableField(exist = false)
-    private String currentInventory;
-
-    /**
-     * 剩余库存数量,兼容领用页面原有字段
-     */
-    @TableField(exist = false)
-    private String surplusNumber;
-
 }

+ 8 - 0
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/materialType/mapper/PsiMaterialTypeMapper.java

@@ -29,6 +29,14 @@ public interface PsiMaterialTypeMapper extends BaseMapper<PsiMaterialTypeInfo>,
      * @return
      */
     PsiMaterialTypeInfo getById(String id);
+    /**
+     * 根据name和parentId查询名称是否重复
+     * @param name
+     * @param parentId
+     * @return
+     */
+    Integer checkNameIsExist(@Param("name") String name, @Param("parentId") String parentId);
+
     Integer getNo(@Param("parentId") String parentId);
 
     Integer getLevel(@Param("parentId") String parentId);

+ 11 - 19
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/materialType/mapper/xml/PsiMaterialTypeMapper.xml

@@ -14,12 +14,6 @@
 		<result property="sort" column="sort" jdbcType="VARCHAR"/>
 		<result property="parentId" column="parent_id" jdbcType="VARCHAR"/>
 		<result property="parentIds" column="parent_ids" jdbcType="VARCHAR"/>
-		<result property="infoType" column="info_type" jdbcType="VARCHAR"/>
-		<result property="brand" column="brand" jdbcType="VARCHAR"/>
-		<result property="specification" column="specification" jdbcType="VARCHAR"/>
-		<result property="company" column="company" jdbcType="VARCHAR"/>
-		<result property="currentInventory" column="current_inventory" jdbcType="VARCHAR"/>
-		<result property="surplusNumber" column="current_inventory" jdbcType="VARCHAR"/>
 
 	</resultMap>
 
@@ -35,19 +29,7 @@
 		a.name,
 		a.sort,
 		a.parent_id,
-		a.parent_ids,
-		a.info_type,
-		a.brand,
-		a.specification,
-		a.company,
-		IFNULL((
-			SELECT SUM(CAST(IFNULL(NULLIF(wd.current_inventory, ''), '0') AS DECIMAL(18,4)))
-			FROM psi_management_warehouse_detailed wd
-			LEFT JOIN psi_management_warehouse_basics wb ON wd.basic_id = wb.id AND wb.del_flag = 0
-			WHERE wd.del_flag = 0
-			  AND wd.ware_house_type = a.id
-			  AND (wb.id IS NULL OR wb.status IN ('0', '5'))
-		), 0) AS current_inventory
+		a.parent_ids
     </sql>
 
 
@@ -68,6 +50,16 @@
 		</where>
 	</select>
 
+	<select id="checkNameIsExist" resultType="java.lang.Integer">
+        SELECT
+			COUNT( 0 )
+		FROM
+			psi_management_type
+		WHERE
+			del_flag = 0
+			AND `name` = #{name}
+			AND parent_id = #{parentId}
+    </select>
     <select id="getNo" resultType="java.lang.Integer">
         SELECT
 			(MAX(`sort`) + 1) AS `sort`

+ 6 - 34
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/materialType/service/PsiMaterialTypeService.java

@@ -39,9 +39,6 @@ public class PsiMaterialTypeService extends ServiceImpl<PsiMaterialTypeMapper, P
             List<PsiMaterialTypeInfo> materialTypeInfoList = this.list(new QueryWrapper<PsiMaterialTypeInfo>().lambda()
                     .like(StringUtils.isNotBlank(info.getName()), PsiMaterialTypeInfo::getName, info.getName())
             );
-            if (CollectionUtil.isEmpty(materialTypeInfoList)) {
-                return new ArrayList<>();
-            }
             List<String> collect = materialTypeInfoList.stream().map(PsiMaterialTypeInfo::getId).collect(Collectors.toList());
             //materialTypeInfoList的父级id全部获取
             List<String> cupIdList = materialTypeInfoList.stream().map(PsiMaterialTypeInfo::getParentId).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
@@ -130,9 +127,6 @@ public class PsiMaterialTypeService extends ServiceImpl<PsiMaterialTypeMapper, P
             List<PsiMaterialTypeInfo> materialTypeInfoList = this.list(new QueryWrapper<PsiMaterialTypeInfo>().lambda()
                     .like(StringUtils.isNotBlank(info.getName()), PsiMaterialTypeInfo::getName, info.getName())
             );
-            if (CollectionUtil.isEmpty(materialTypeInfoList)) {
-                return new ArrayList<>();
-            }
             List<String> collect = materialTypeInfoList.stream().map(PsiMaterialTypeInfo::getId).collect(Collectors.toList());
             //materialTypeInfoList的父级id全部获取
             List<String> cupIdList = materialTypeInfoList.stream().map(PsiMaterialTypeInfo::getParentId).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
@@ -182,7 +176,7 @@ public class PsiMaterialTypeService extends ServiceImpl<PsiMaterialTypeMapper, P
 
         wrapper.eq(BaseEntity::getDelFlag, 0);
         wrapper.orderByAsc(PsiMaterialTypeInfo::getSort);
-        return mapper.findList(wrapper);
+        return mapper.selectList(wrapper);
     }
 
     public String saveM(PsiMaterialTypeInfo info) {
@@ -203,8 +197,11 @@ public class PsiMaterialTypeService extends ServiceImpl<PsiMaterialTypeMapper, P
      * @return
      */
     public String add(PsiMaterialTypeInfo info) {
-        if (!prepareMaterialTypeInfo(info)) {
-            return "商品节点下不能新增下级";
+
+        // 判断名称是否已存在
+        Integer isExist = mapper.checkNameIsExist(info.getName(), info.getParentId());
+        if (isExist > 0) {
+            return "false";
         }
         // 获取当前登录人信息
         UserDTO userDto = SpringUtil.getBean ( IUserApi.class ).getByToken(TokenProvider.getCurrentToken ( ));
@@ -232,37 +229,12 @@ public class PsiMaterialTypeService extends ServiceImpl<PsiMaterialTypeMapper, P
         UserDTO userDto = SpringUtil.getBean ( IUserApi.class ).getByToken(TokenProvider.getCurrentToken ( ));
         // 获取当前登录人信息
 //        UserDTO userDto = UserUtils.getCurrentUserDTO();
-        if (!prepareMaterialTypeInfo(info)) {
-            return "商品节点下不能新增下级";
-        }
         info.setUpdateBy(userDto.getId());
         info.setUpdateDate(new Date());
         mapper.updateById(info);
         return "操作完成";
     }
 
-    private boolean prepareMaterialTypeInfo(PsiMaterialTypeInfo info) {
-        if (info == null) {
-            return true;
-        }
-        if (StringUtils.isBlank(info.getInfoType())) {
-            info.setInfoType("0");
-        }
-        if (StringUtils.isNotBlank(info.getParentId()) && !"0".equals(info.getParentId())) {
-            PsiMaterialTypeInfo parentInfo = mapper.selectById(info.getParentId());
-            if (parentInfo != null && "1".equals(parentInfo.getInfoType())) {
-                return false;
-            }
-        }
-        if (!"1".equals(info.getInfoType())) {
-            info.setInfoType("0");
-            info.setBrand(null);
-            info.setSpecification(null);
-            info.setCompany(null);
-        }
-        return true;
-    }
-
     /**
      * 生成序号/层级
      * @param info

+ 0 - 10
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/domain/PsiWareHouseDetailed.java

@@ -78,11 +78,6 @@ public class PsiWareHouseDetailed extends BaseEntity {
     private String company;
 
     /**
-     * 品牌
-     */
-    private String brand;
-
-    /**
      * 商品总价
      */
     private String tradeTotalPrice;
@@ -143,11 +138,6 @@ public class PsiWareHouseDetailed extends BaseEntity {
     private String spec;
 
     /**
-     * 规格
-     */
-    private String specification;
-
-    /**
      * 生产日期
      */
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")

+ 114 - 131
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/mapper/xml/PsiWareHouseBasicMapper.xml

@@ -37,10 +37,8 @@
 				a.create_by_id as createBy,
 				a.create_time as createDate,
 				a.ware_house_type,
-				c.name as trade_name,
-				c.brand,
-				c.specification,
-				c.company,
+				a.trade_name,
+				a.company,
 				b.NAME AS wareHouseTypeName,
 				sum( trade_number ) AS allNumber,
 				b.collect_number AS borrowNumber,
@@ -50,32 +48,25 @@
 				psi_management_warehouse_detailed a
 				LEFT JOIN (
 				SELECT
-					sum(
-						CASE
-							WHEN r.status = '5' AND d.id IS NULL THEN IFNULL(e.not_surplus_stock, 0)
-							WHEN r.status = '5' AND d.is_return = '2' THEN IFNULL(e.not_surplus_stock, e.collect_number)
-							WHEN r.status = '5' AND d.is_return = '1' THEN 0
-							ELSE IFNULL(e.not_surplus_stock, e.collect_number)
-						END
-					) AS collect_number,
-					e.collect_type,
+					sum( g.collect_number ) AS collect_number,
+					e.goods_name,
 					c.NAME as name,
-					min(e.basic_id) as mmcId
+					e.basic_id as mmcId,
+				STATUS
 				FROM
-					psi_management_collect_detailed_record e
+					psi_management_collect_detailed e
 					LEFT JOIN psi_management_collect_basics f ON e.basic_id = f.id
 					AND f.del_flag = 0
-					LEFT JOIN psi_management_collect_detailed d ON e.detail_id = d.id
-					LEFT JOIN psi_management_collect_basics_return r ON r.basic_id = e.basic_id AND r.del_flag = 0
 					LEFT JOIN psi_management_type c ON e.collect_type = c.id
+					left join psi_management_collect_detailed g on e.goods_name = g.goods_name and g.del_flag = 0
 				WHERE
 					f.`status` = 5 AND e.del_flag = 0
 				GROUP BY
-					e.collect_type, c.NAME
-				) b ON a.ware_house_type = b.collect_type
+					e.id
+				) b ON a.trade_name = b.goods_name
 				LEFT JOIN psi_management_type c ON a.ware_house_type = c.id
 				${ew.customSqlSegment}
-				GROUP BY a.ware_house_type
+				GROUP BY a.trade_name,a.ware_house_type
 				HAVING sum( trade_number ) - IFNULL(collect_number,0) &lt;= 5
 				ORDER BY a.update_time DESC
 	</select>
@@ -86,10 +77,8 @@
 			a.create_by_id as createBy,
 			a.create_time as createDate,
 			a.ware_house_type,
-			c.name as trade_name,
-			c.brand,
-			c.specification,
-			c.company,
+			a.trade_name,
+			a.company,
 			c.name as wareHouseTypeName,
 			sum( trade_number ) AS allNumber,
 			b.collect_number AS borrowNumber,
@@ -108,51 +97,45 @@
 			left join
 			(
 			select
-			    sum(
-					CASE
-						WHEN r.status = '5' AND d.id IS NULL THEN IFNULL(e.not_surplus_stock, 0)
-						WHEN r.status = '5' AND d.is_return = '2' THEN IFNULL(e.not_surplus_stock, e.collect_number)
-						WHEN r.status = '5' AND d.is_return = '1' THEN 0
-						ELSE IFNULL(e.not_surplus_stock, e.collect_number)
-					END
-				) as collect_number,
-			    e.collect_type
-			 from psi_management_collect_detailed_record e
+			    sum(collect_number) as collect_number,
+			    goods_name,
+			    status
+			 from psi_management_collect_detailed e
 			left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
-			left join psi_management_collect_detailed d on e.detail_id = d.id
-			left join psi_management_collect_basics_return r on r.basic_id = e.basic_id and r.del_flag = 0
-			WHERE f.`status` = 5 and e.del_flag = 0
-			GROUP BY e.collect_type
+			WHERE f.`status` = 5 and e.del_flag = 0 and e.is_return = '0'
+			GROUP BY e.goods_name
 			) b
-			on a.ware_house_type = b.collect_type
+			on a.trade_name = b.goods_name
 			left join
 			(
 				select
 					sum(loss_number) as loss_number,
-					collect_type
+					goods_name,
+					status
 				from psi_management_loss_detailed e
 						 left join psi_management_loss_basics f on e.basic_id = f.id and f.del_flag = 0
 				WHERE f.`status` = 5 and e.del_flag = 0
-				GROUP BY e.collect_type
+				GROUP BY e.goods_name
 			) loss
-			on a.ware_house_type = loss.collect_type
+			on a.trade_name = loss.goods_name
 			left join
 			(
 				select
 					sum(returned_num) AS returned_num,
 					sum(not_surplus_stock) AS not_surplus_stock,
-					collect_type
+					inventory_id,
+					goods_name,
+					status
 				from psi_management_collect_detailed_record e
 						 left join psi_management_collect_basics pmcba on e.basic_id = pmcba.id and pmcba.del_flag = 0
 				WHERE pmcba.`status` = 5 and e.del_flag = 0
-				group BY e.collect_type
+				group BY e.goods_name
 			) pmcdra
-			on a.ware_house_type = pmcdra.collect_type
+			on a.trade_name = pmcdra.goods_name
 			LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
 			left join psi_management_type c on a.ware_house_type = c.id
 			${ew.customSqlSegment}
-			GROUP BY a.ware_house_type
-			HAVING SUM(CAST(IFNULL(NULLIF(a.current_inventory, ''), '0') AS DECIMAL(18,4))) > 0
+			GROUP BY a.trade_name,a.ware_house_type
 			ORDER BY a.ware_house_type DESC,a.trade_name
 	</select>
 
@@ -163,12 +146,12 @@
 			a.create_by_id as createBy,
 			a.create_time as createDate,
 			a.ware_house_type,
-			c.name as trade_name,
-			c.company,
+			a.trade_name,
+			a.company,
 			c.name as wareHouseTypeName,
 			IFNULL(his_detail.trade_number,0)  AS allNumber,
-			IFNULL(b.collect_number,0) AS borrowNumber,
-			IFNULL(loss.loss_number,0) AS lossNumber,
+			b.collect_number AS borrowNumber,
+			loss.loss_number AS lossNumber,
 			IFNULL(loss_after.loss_number, 0) AS afterLossNumber,
 			IFNULL(after_pmwd.trade_number, 0) AS afterTradeNumber,
 			IFNULL(after_pmcdra.not_surplus_stock, 0) AS afterNotSurplusStock,
@@ -187,32 +170,28 @@
 				left join
 			(
 				select
-					sum(
-						CASE
-							WHEN r.status = '5' AND d.id IS NULL THEN IFNULL(e.not_surplus_stock, 0)
-							WHEN r.status = '5' AND d.is_return = '2' THEN IFNULL(e.not_surplus_stock, e.collect_number)
-							WHEN r.status = '5' AND d.is_return = '1' THEN 0
-							ELSE IFNULL(e.not_surplus_stock, e.collect_number)
-						END
-					) as collect_number,
-					e.collect_type
-				from psi_management_collect_detailed_record e
+					sum(collect_number) as collect_number,
+					goods_name,
+					collect_type,
+					status
+				from psi_management_collect_detailed e
 						 left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
-						 left join psi_management_collect_detailed d on e.detail_id = d.id
-						 left join psi_management_collect_basics_return r on r.basic_id = e.basic_id and r.del_flag = 0
 				WHERE f.`status` = 5
 				  and e.del_flag = 0
+				  and e.is_return = '0'
 				<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
 					and f.collect_date &gt;= #{dto.dateRange[0]} AND f.collect_date &lt;= #{dto.dateRange[1]}
 				</if>
-				GROUP BY e.collect_type
+				GROUP BY e.goods_name, e.collect_type
 			) b
-			on a.ware_house_type = b.collect_type
+			on a.trade_name = b.goods_name AND a.ware_house_type = b.collect_type
 				left join
 			(
 				select
 					sum(loss_number) as loss_number,
-					collect_type
+					goods_name,
+					collect_type,
+					status
 				from psi_management_loss_detailed e
 						 left join psi_management_loss_basics f on e.basic_id = f.id and f.del_flag = 0
 				WHERE f.`status` = 5
@@ -220,13 +199,15 @@
 				<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
 					and f.collect_date &gt;= #{dto.dateRange[0]} AND f.collect_date &lt;= #{dto.dateRange[1]}
 				</if>
-				GROUP BY e.collect_type
+				GROUP BY e.goods_name, e.collect_type
 			) loss
-			on a.ware_house_type = loss.collect_type
+			on a.trade_name = loss.goods_name AND a.ware_house_type = loss.collect_type
 			left join(
 				select
 				sum(loss_number) as loss_number,
-				collect_type
+				goods_name,
+				collect_type,
+				status
 				from psi_management_loss_detailed e
 				left join psi_management_loss_basics f on e.basic_id = f.id and f.del_flag = 0
 				WHERE f.`status` = 5
@@ -234,14 +215,15 @@
 				<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
 				and f.collect_date  &gt;= #{dto.dateRange[1]}
 				</if>
-				GROUP BY e.collect_type
+				GROUP BY e.goods_name, e.collect_type
 			) loss_after
-			on a.ware_house_type = loss_after.collect_type
+			on a.trade_name = loss_after.goods_name AND a.ware_house_type = loss_after.collect_type
 				left join
 			(
 				select
 					sum(returned_num) AS returned_num,
 					sum(not_surplus_stock) AS not_surplus_stock,
+					goods_name,
 					collect_type
 				from psi_management_collect_detailed_record e
 						 left join psi_management_collect_basics pmcba on e.basic_id = pmcba.id and pmcba.del_flag = 0
@@ -250,13 +232,14 @@
 				<if test=" dto != null and dto.dateRange != null and dto.dateRange.length == 2">
 					and pmcba.collect_date &gt;= #{dto.dateRange[0]} AND pmcba.collect_date &lt;= #{dto.dateRange[1]}
 				</if>
-				group BY e.collect_type
+				group BY e.goods_name, e.collect_type
 			) pmcdra
-			on a.ware_house_type = pmcdra.collect_type
+			on a.trade_name = pmcdra.goods_name AND a.ware_house_type = pmcdra.collect_type
 		LEFT JOIN (
 				select
 					sum(returned_num) AS returned_num,
 					sum(not_surplus_stock) AS not_surplus_stock,
+					goods_name,
 					collect_type
 				from psi_management_collect_detailed_record e
 					left join psi_management_collect_basics pmcba on e.basic_id = pmcba.id and pmcba.del_flag = 0
@@ -265,19 +248,21 @@
 				<if test=" dto != null and dto.dateRange != null and dto.dateRange.length == 2">
 					and pmcba.collect_date &gt;= #{dto.dateRange[1]}
 				</if>
-				group BY e.collect_type
+				group BY e.goods_name, e.collect_type
 			) after_pmcdra
-		on a.ware_house_type = after_pmcdra.collect_type
+		on a.trade_name = after_pmcdra.goods_name AND a.ware_house_type = after_pmcdra.collect_type
 			LEFT JOIN (
 				SELECT
+				trade_name,
 				ware_house_type,
 				SUM(current_inventory) AS allCurrentInventory
 				FROM psi_management_warehouse_detailed
 				WHERE del_flag = 0
-				GROUP BY ware_house_type
-			) all_stock ON a.ware_house_type = all_stock.ware_house_type
+				GROUP BY trade_name, ware_house_type
+			) all_stock ON a.trade_name = all_stock.trade_name AND a.ware_house_type = all_stock.ware_house_type
 			LEFT JOIN (
 				SELECT
+					pwd.trade_name,
 					pwd.ware_house_type,
 					SUM(pwd.trade_number) AS trade_number
 				FROM psi_management_warehouse_detailed pwd
@@ -286,10 +271,11 @@
 					<if test=" dto != null and dto.dateRange != null and dto.dateRange.length == 2">
 						and pmcba.ware_house_date &gt;= #{dto.dateRange[0]} AND pmcba.ware_house_date &lt;= #{dto.dateRange[1]}
 					</if>
-					GROUP BY pwd.ware_house_type
-			) his_detail ON a.ware_house_type = his_detail.ware_house_type
+					GROUP BY pwd.trade_name, pwd.ware_house_type
+			) his_detail ON a.trade_name = his_detail.trade_name AND a.ware_house_type = his_detail.ware_house_type
 			LEFT JOIN (
 				SELECT
+					ab.trade_name,
 					ab.ware_house_type,
 					SUM(ab.trade_number) AS trade_number
 				FROM psi_management_warehouse_detailed ab
@@ -298,13 +284,12 @@
 				<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
 					and pmcba.ware_house_date  &gt;= #{dto.dateRange[1]}
 				</if>
-				GROUP BY ab.ware_house_type
-			) after_pmwd ON a.ware_house_type = after_pmwd.ware_house_type
+				GROUP BY ab.trade_name, ab.ware_house_type
+			) after_pmwd ON a.trade_name = after_pmwd.trade_name AND a.ware_house_type = after_pmwd.ware_house_type
 				LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
 				left join psi_management_type c on a.ware_house_type = c.id
 			${ew.customSqlSegment}
-		GROUP BY a.ware_house_type
-		HAVING SUM(CAST(IFNULL(NULLIF(all_stock.allCurrentInventory, ''), '0') AS DECIMAL(18,4))) > 0
+		GROUP BY a.trade_name,a.ware_house_type
 		ORDER BY a.ware_house_type DESC,a.trade_name
 	</select>
 
@@ -316,7 +301,7 @@
 			a.create_by_id as createBy,
 			a.create_time as createDate,
 			a.ware_house_type,
-			c.name as trade_name,
+			a.trade_name,
 			a.company,
 			c.name as wareHouseTypeName,
 			sum( trade_number ) AS allNumber,
@@ -334,17 +319,18 @@
 			(
 				select
 					sum(collect_number) as collect_number,
-					collect_type
+					goods_name,
+					status
 				from psi_management_collect_detailed e
 						 left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
 				WHERE f.`status` = 5 and e.del_flag = 0
-				GROUP BY e.collect_type
+				GROUP BY e.goods_name
 			) b
-			on a.ware_house_type = b.collect_type
+			on a.trade_name = b.goods_name
 				LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
 				left join psi_management_type c on a.ware_house_type = c.id
 			${ew.customSqlSegment}
-		GROUP BY a.ware_house_type
+		GROUP BY a.trade_name,a.ware_house_type
 		ORDER BY a.ware_house_type DESC,a.trade_name
 	</select>
 
@@ -353,32 +339,28 @@
 		SELECT
 			a.id,
 			a.produce_date as produce_date,
-			a.ware_house_type,
-			c.name as trade_name,
+			a.trade_name,
 			a.spec,
-			a.specification,
 			a.company,
-			a.brand,
 			a.current_inventory,
-			a.warn_num,
-			a.warn_flag,
-			bas.ware_house_number,
-			bas.ware_house_date
+			pmwd.warn_num,
+			pmwd.warn_flag
 		FROM
 			psi_management_warehouse_detailed a
 				LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
+				LEFT JOIN psi_management_warehouse_detailed pmwd on bas.id = pmwd.basic_id
 				left join psi_management_type c on a.ware_house_type = c.id
 			${ew.customSqlSegment}
 
-		GROUP BY a.id
-		ORDER BY a.create_time asc
+		GROUP BY a.trade_name,a.ware_house_type,a.produce_date
+		ORDER BY a.produce_date asc
 	</select>
 	<select id="getAllData"
 			resultType="com.jeeplus.psimanage.psiWareHouse.service.dto.PsiWareHouseDto">
 		SELECT
 			a.id,
 			a.produce_date as produce_date,
-			c.name as trade_name,
+			a.trade_name,
 			a.spec,
 			a.company,
 			a.current_inventory,
@@ -393,7 +375,7 @@
 				left join psi_management_type c on a.ware_house_type = c.id
 			${ew.customSqlSegment}
 
-		GROUP BY a.ware_house_type,a.produce_date
+		GROUP BY a.trade_name,a.ware_house_type,a.produce_date
 		ORDER BY a.produce_date asc
 	</select>
 
@@ -424,7 +406,7 @@
 			a.ware_house_date,
 			sy.name as wareHouseHandledBy,
 			so.name as wareHouseHandledByOff,
-			t.name as tradeName,
+			b.trade_name,
 			b.trade_number,
 			b.current_inventory,
 			b.ware_house_type,
@@ -436,7 +418,6 @@
 			psi_management_warehouse_basics a
 			LEFT JOIN
 			psi_management_warehouse_detailed b on a.id = b.basic_id and b.del_flag = 0
-			LEFT JOIN psi_management_type t ON b.ware_house_type = t.id
 
 			left join sys_user sy on sy.id = a.handled_by
 			left join sys_office so on sy.office_id = so.id
@@ -453,9 +434,9 @@
 			sy.name as collectHandleBy,
 			so.name as collectHandleByOff,
 			a.collect_date,
+			b.goods_name,
 			b.collect_number,
-			b.current_inventory as currentInventory,
-			c.name AS goodsName,
+			b.current_inventory,
 			pmwd.spec,
 			pmcdr.not_surplus_stock as notSurplusStock,
 			b.collect_type as collectType
@@ -465,7 +446,6 @@
 			psi_management_collect_detailed b on a.id = b.basic_id and b.del_flag = 0
 			LEFT JOIN psi_management_collect_detailed_record pmcdr ON b.id = pmcdr.detail_id
 			LEFT JOIN psi_management_warehouse_detailed pmwd ON pmcdr.inventory_id = pmwd.id
-			LEFT JOIN psi_management_type c ON b.collect_type = c.id
 			left join sys_user sy on sy.id = a.handled_by
 			left join sys_office so on sy.office_id = so.id
 
@@ -484,22 +464,23 @@
 			c.name as wareHouseTypeName,
 			sum(trade_number) as allNumber,
 			b.collect_number as borrowNumber,
-			sum(a.current_inventory) as tradeNumber,
+			a.current_inventory as tradeNumber,
 			a.warn_num,
 			a.warn_flag
 		FROM
 			psi_management_warehouse_detailed a
 			left join
-			(select sum(collect_number) as collect_number,collect_type from psi_management_collect_detailed e
+			(select sum(collect_number) as collect_number,goods_name,status from psi_management_collect_detailed e
 			left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
 			WHERE f.`status` = 5 and e.collect_type = #{collectTypeId}
-			GROUP BY e.collect_type) b
-			on a.ware_house_type = b.collect_type
+			GROUP BY e.goods_name) b
+			on a.trade_name = b.goods_name
 			LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
 			left join psi_management_type c on a.ware_house_type = c.id
-			where a.ware_house_type = #{collectTypeId}
+			where a.trade_name = #{goodsName}
+			  and a.ware_house_type = #{collectTypeId}
 			  and a.del_flag = 0
-			GROUP BY a.ware_house_type
+			GROUP BY a.trade_name
 			ORDER BY a.update_time DESC
 	</select>
 	<select id="getByTypeAndGoodsNameByProduceDate"
@@ -518,18 +499,19 @@
 		FROM
 			psi_management_warehouse_detailed a
 				left join
-			(select sum(collect_number) as collect_number,collect_type from psi_management_collect_detailed e
+			(select sum(collect_number) as collect_number,goods_name,status from psi_management_collect_detailed e
 																					 left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
 			 WHERE f.`status` = 5 and e.collect_type = #{collectTypeId}
-			 GROUP BY e.collect_type) b
-			on a.ware_house_type = b.collect_type
+			 GROUP BY e.goods_name) b
+			on a.trade_name = b.goods_name
 
 				LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
 				left join psi_management_type c on a.ware_house_type = c.id
-		where a.ware_house_type = #{collectTypeId}
+		where a.trade_name = #{goodsName}
+		  and a.ware_house_type = #{collectTypeId}
 		  and a.produce_date = #{produceDate}
 		  and a.del_flag = 0
-		GROUP BY a.ware_house_type,a.produce_date
+		GROUP BY a.trade_name
 		ORDER BY a.produce_date asc
 	</select>
 
@@ -548,14 +530,15 @@
 		FROM
 			psi_management_warehouse_detailed a
 				left join
-			(select sum(collect_number) as collect_number,collect_type from psi_management_collect_detailed e
+			(select sum(collect_number) as collect_number,goods_name,status from psi_management_collect_detailed e
 																					 left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
 			 WHERE f.`status` = 5 and e.collect_type = #{collectTypeId}
-			 GROUP BY e.collect_type) b
-			on a.ware_house_type = b.collect_type
+			 GROUP BY e.goods_name) b
+			on a.trade_name = b.goods_name
 				LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
 				left join psi_management_type c on a.ware_house_type = c.id
-		where a.ware_house_type = #{collectTypeId}
+		where a.trade_name = #{goodsName}
+		  and a.ware_house_type = #{collectTypeId}
 		  and a.del_flag = 0
 		ORDER BY a.produce_date asc
 	</select>
@@ -584,36 +567,36 @@
 		left join psi_management_type c on a.ware_house_type = c.id
 
 		left join
-		(select sum(collect_number) as collect_number,collect_type from psi_management_collect_detailed e
+		(select sum(collect_number) as collect_number,goods_name,status from psi_management_collect_detailed e
 		left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
-		WHERE f.`status` = 5 and e.del_flag = 0 and e.produce_date &lt;= #{produceDate} and e.collect_type = #{wareHouseType} and e.goods_name = #{tradeName}
-		GROUP BY e.collect_type) b
-		on a.ware_house_type = b.collect_type
+		WHERE f.`status` = 5 and e.del_flag = 0 and e.produce_date &lt;= #{produceDate} and e.collect_type = #{wareHouseType} and e.goods_name = #{tradeName}) b
+		on a.trade_name = b.goods_name
 
 		WHERE a.ware_house_type = #{wareHouseType}
 		and a.del_flag = 0
+		and a.trade_name = #{tradeName}
 		and a.produce_date &lt;= #{produceDate}
-		GROUP BY a.ware_house_type
+		GROUP BY a.trade_name,a.ware_house_type
 		ORDER BY a.ware_house_type DESC
 	</select>
 	<select id="getCollectInfoByTime" resultType="java.lang.String">
 		SELECT
-			GREATEST( IFNULL(SUM(trade_number) - collect_number, SUM(trade_number)), 0 ) AS tradeNumber
+		IFNULL((sum(trade_number) - collect_number),sum(trade_number)) as tradeNumber
 		FROM
 		psi_management_warehouse_detailed a
 		left join psi_management_type c on a.ware_house_type = c.id
 
 		left join
-		(select sum(collect_number) as collect_number,collect_type from psi_management_collect_detailed e
+		(select sum(collect_number) as collect_number,goods_name,status from psi_management_collect_detailed e
 		left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
-		WHERE f.`status` = 5 and e.del_flag = 0 and e.create_time &lt;= #{createDate} and e.collect_type = #{wareHouseType}
-		GROUP BY e.collect_type) b
-		on a.ware_house_type = b.collect_type
+		WHERE f.`status` = 5 and e.del_flag = 0 and e.create_time &lt;= #{createDate} and e.collect_type = #{wareHouseType} and e.goods_name = #{tradeName}) b
+		on a.trade_name = b.goods_name
 
 		WHERE a.ware_house_type = #{wareHouseType}
 		and a.del_flag = 0
+		and a.trade_name = #{tradeName}
 		and a.create_time &lt;= #{createDate}
-		GROUP BY a.ware_house_type
+		GROUP BY a.trade_name,a.ware_house_type
 		ORDER BY a.ware_house_type DESC
 	</select>
 	<select id="getCollectNumByType" resultType="java.lang.String">

+ 10 - 6
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/mapper/xml/PsiWareHouseSummaryMapper.xml

@@ -13,21 +13,23 @@
             LEFT JOIN (
             SELECT
                 sum( b.collect_number ) AS num2,
-                b.collect_type
+                b.collect_type,
+                b.goods_name
             FROM
                 psi_management_collect_detailed b
                 LEFT JOIN psi_management_collect_basics c ON b.basic_id = c.id
                 AND c.del_flag = 0
             WHERE
                 b.collect_type = #{wareHouseType}
+                AND b.goods_name = #{tradeName}
 
             AND b.del_flag = 0
             AND c.`status` = 5
-            GROUP BY b.collect_type
             ) AS c ON a.ware_house_type = c.collect_type
-
+            AND a.trade_name = c.goods_name
         WHERE
             a.ware_house_type = #{wareHouseType}
+            AND a.trade_name = #{tradeName}
             AND a.del_flag = 0
     </select>
     <select id="getInfoByBasicId"
@@ -52,7 +54,7 @@
             -- 只查当前批次、当前生产日期对应的领用数量
                 LEFT JOIN (
                 SELECT
-                    b.collect_type,
+                    b.goods_name,
                     b.produce_date,  -- 必须加上生产日期
                     sum(b.collect_number) AS num2
                 FROM
@@ -61,15 +63,17 @@
                                   ON b.basic_id = c.id AND c.del_flag = 0
                 WHERE
                     b.collect_type = #{wareHouseType}
+                  AND b.goods_name = #{tradeName}
                   AND b.del_flag = 0
                   AND c.`status` = 5
                 -- 按商品  生产日期分组
-                GROUP BY b.collect_type, b.produce_date
+                GROUP BY b.goods_name, b.produce_date
             ) c
-                          ON a.ware_house_type = c.collect_type
+                          ON a.trade_name = c.goods_name
                               AND a.produce_date = c.produce_date  -- 关键:按生产日期匹配
         WHERE
             a.ware_house_type = #{wareHouseType}
+          AND a.trade_name = #{tradeName}
           AND a.del_flag = 0
 
         GROUP BY a.id  -- 按库存分组

+ 25 - 103
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/service/PsiWareHouseBasicService.java

@@ -126,6 +126,11 @@ public class PsiWareHouseBasicService {
             queryWrapper.eq("b.id", dto.getDetailId());
         }
 
+        if (StringUtils.isNotEmpty(dto.getTradeName())) {
+            queryWrapper.eq("b.trade_name", dto.getTradeName());
+        }
+
+
         if (StringUtils.isNotEmpty(dto.getWareHouseType())) {
             queryWrapper.eq("b.ware_house_type", dto.getWareHouseType());
         }
@@ -150,8 +155,8 @@ public class PsiWareHouseBasicService {
         //根据时间查询当前库存
         iPage.getRecords().stream().forEach(i->{
             //根据商品名称,物品类型,时间查当前库存
-            //String d = basicMapper.getWareHouseInfoByTime(i.getTradeName(),i.getWareHouseType(),i.getProduceDate());
-            //i.setCurrentInventory(d);
+            String d = basicMapper.getWareHouseInfoByTime(i.getTradeName(),i.getWareHouseType(),i.getProduceDate());
+            i.setCurrentInventory(d);
         });
         //根据查询领用明细
         return iPage;
@@ -165,13 +170,17 @@ public class PsiWareHouseBasicService {
 
         queryWrapper.eq("a.del_flag", "0");
         queryWrapper.eq("a.status", "5");
+        if (StringUtils.isNotEmpty(dto.getTradeName())) {
+            queryWrapper.eq("b.goods_name", dto.getTradeName());
+        }
+
         if (StringUtils.isNotEmpty(dto.getCollectNo())) {
             queryWrapper.eq("a.collect_no", dto.getCollectNo());
         }
 
 
         if (StringUtils.isNotEmpty(dto.getWareHouseType())) {
-            queryWrapper.eq("b.collect_type", dto.getWareHouseType());
+            queryWrapper.eq("b.ware_house_type", dto.getWareHouseType());
         }
 
         String[] collectDates = dto.getCollectDates();
@@ -314,7 +323,6 @@ public class PsiWareHouseBasicService {
         // 获取当前登录人信息
 //        UserDTO userDTO = UserUtils.getCurrentUserDTO();
         UserDTO userDTO = SpringUtil.getBean ( IUserApi.class ).getByToken (TokenProvider.getCurrentToken ( ));
-        normalizeWareHouseAmounts(dto);
         if (StringUtils.isNotEmpty(dto.getId())) {
             return update(dto, userDTO);
         } else {
@@ -339,7 +347,6 @@ public class PsiWareHouseBasicService {
                     warehouseUpHi.setEndflag("0"); // endflag = 0 代表此数据为原数据,在回退数据的时候使用
                     warehouseUpHi.setJsonData(jsonString);
                     warehouseUpHi.setWarehouseId(dto.getId());
-                    fillWarehouseUpHiTradeName(warehouseUpHi, dto.getWareHouse());
                     psiWarehouseUpHiMapper.insert(warehouseUpHi);
                 }
             }
@@ -352,24 +359,17 @@ public class PsiWareHouseBasicService {
                 if (ObjectUtil.isNotEmpty(byId)) {
                     // 获取修改数据的商品名称、商品类型
                     if (CollectionUtil.isNotEmpty(byId.getWareHouse())){
-                        List<PsiWareHouseDetailed> updateTradeNameData = byId.getWareHouse().stream()
-                                .filter(this::isWareHouseUpdateHistoryDetail)
-                                .collect(Collectors.toList());
-                        List<String> updateTradeNameList = updateTradeNameData.stream()
-                                .map(this::resolveWareHouseTradeName)
-                                .filter(StringUtils::isNotBlank)
-                                .distinct()
-                                .collect(Collectors.toList());
-                        if (CollectionUtil.isNotEmpty(updateTradeNameList)) {
-                            //获取修改数据的商品名称
-                            warehouseUpHi.setUpdateTradeName(String.join(",",updateTradeNameList));
-                        }
                         List<PsiWareHouseDetailed> updateData = byId.getWareHouse().stream().filter(i -> {
                             if ("1".equals(i.getUpFlag()) || "2".equals(i.getUpFlag())) {
                                 return true;
                             }
                             return false;
                         }).collect(Collectors.toList());
+                        List<String> updateTradeNameList = updateData.stream().map(PsiWareHouseDetailed::getTradeName).collect(Collectors.toList());
+                        if (CollectionUtil.isNotEmpty(updateTradeNameList)) {
+                            //获取修改数据的商品名称
+                            warehouseUpHi.setUpdateTradeName(String.join(",",updateTradeNameList));
+                        }
                         List<String> updateTradeTypeList = updateData.stream().map(PsiWareHouseDetailed::getWareHouseType).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
                         if (CollectionUtil.isNotEmpty(updateTradeTypeList)) {
                             //获取修改数据的商品类型
@@ -432,7 +432,7 @@ public class PsiWareHouseBasicService {
                 List<UserDTO> notifiedPartyUsers = new ArrayList<>();
                 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                 String day = format.format(new Date());
-                String title = "[入库修改:"+dto.getWareHouseNumber()+"]-入库修改申请审批通过";
+                String title = "[入库修改:"+dto.getPurchaseNo()+"]-入库修改申请审批通过";
                 UserDTO initiator = SpringUtil.getBean(IUserApi.class).getById(dto.getHandledById());
                 notifiedPartyUsers.add(initiator);
                 //向用户发起通知
@@ -473,7 +473,6 @@ public class PsiWareHouseBasicService {
                 if (CollectionUtils.isNotEmpty(dto.getWareHouse())) {
                     dto.getWareHouse().stream().forEach(item -> {
                         item.setWareHouseMan(item.getWareHouseManId());
-                        fillWareHouseLegacyTradeName(item);
                         item.setWareHouseType(item.getWareHouseTypeId());
                         psiDetailedMapper.insert(item);
                         // 保存附件信息列表
@@ -506,7 +505,6 @@ public class PsiWareHouseBasicService {
             });
             dto.getWareHouse().stream().forEach(detailInfo -> {
                 detailInfo.setWareHouseMan(detailInfo.getWareHouseManId());
-                fillWareHouseLegacyTradeName(detailInfo);
                 detailInfo.setWareHouseType(detailInfo.getWareHouseTypeId());
                 detailInfo.setBasicId(dto.getId()); // 保存基础表信息主键值
                 detailInfo.setTradeTotalPrice(dto.getWareHouseTotalPrice());
@@ -660,13 +658,12 @@ public class PsiWareHouseBasicService {
                 detailed.setUpdateById(userDTO.getId());
                 detailed.setUpdateTime(new Date());
                 detailed.setDelFlag(0);
-                fillWareHouseLegacyTradeName(detailed);
                 detailed.setWareHouseType(detailed.getWareHouseTypeId());
                 // 保存基础表信息主键值
                 detailed.setBasicId(id);
                 detailed.setTradeTotalPrice(dto.getWareHouseTotalPrice());
                 detailed.setUpFlag("0");
-                if ("0".equals(detailed.getSpec())) {
+                if(detailed.getSpec().equals("0")){
                     detailed.setSpec("1");
                 }
                 if (StringUtils.isNotBlank(detailed.getWareHouseType()) && StringUtils.isNotBlank(detailed.getTradeName())) {
@@ -866,78 +863,6 @@ public class PsiWareHouseBasicService {
         }
     }
 
-    private void normalizeWareHouseAmounts(PsiWareHouseDto dto) {
-        if (dto == null) {
-            return;
-        }
-        dto.setTradePrice(blankToNull(dto.getTradePrice()));
-        dto.setTradeNumber(blankToNull(dto.getTradeNumber()));
-        dto.setWareHouseTotalPrice(blankToNull(dto.getWareHouseTotalPrice()));
-        dto.setWareHouseActualPrice(blankToNull(dto.getWareHouseActualPrice()));
-        dto.setActualPrice(blankToNull(dto.getActualPrice()));
-        if (CollectionUtils.isEmpty(dto.getWareHouse())) {
-            return;
-        }
-        dto.getWareHouse().forEach(detail -> {
-            detail.setTradePrice(blankToNull(detail.getTradePrice()));
-            detail.setTradeNumber(blankToNull(detail.getTradeNumber()));
-            detail.setTradeTotalPrice(blankToNull(detail.getTradeTotalPrice()));
-            detail.setActualPrice(blankToNull(detail.getActualPrice()));
-            detail.setCurrentInventory(blankToNull(detail.getCurrentInventory()));
-            if (StringUtils.isBlank(detail.getSpec())) {
-                detail.setSpec("1");
-            }
-        });
-    }
-
-    private String blankToNull(String value) {
-        return StringUtils.isBlank(value) ? null : value;
-    }
-
-    private void fillWareHouseLegacyTradeName(PsiWareHouseDetailed detail) {
-        if (detail == null) {
-            return;
-        }
-        if (StringUtils.isBlank(detail.getTradeName()) && StringUtils.isNotBlank(detail.getWareHouseType())) {
-            detail.setTradeName(detail.getWareHouseType());
-        }
-    }
-
-    private void fillWarehouseUpHiTradeName(PsiWarehouseUpHi warehouseUpHi, List<PsiWareHouseDetailed> wareHouseList) {
-        if (warehouseUpHi == null || CollectionUtils.isEmpty(wareHouseList)) {
-            return;
-        }
-        List<String> tradeNameList = wareHouseList.stream()
-                .map(this::resolveWareHouseTradeName)
-                .filter(StringUtils::isNotBlank)
-                .distinct()
-                .collect(Collectors.toList());
-        if (CollectionUtil.isNotEmpty(tradeNameList)) {
-            warehouseUpHi.setUpdateTradeName(String.join(",", tradeNameList));
-        }
-    }
-
-    private boolean isWareHouseUpdateHistoryDetail(PsiWareHouseDetailed detail) {
-        if (detail == null) {
-            return false;
-        }
-        return "1".equals(detail.getUpFlag()) || "2".equals(detail.getUpFlag())
-                || ("0".equals(detail.getUpFlag()) && StringUtils.isNotBlank(detail.getSourceId()));
-    }
-
-    private String resolveWareHouseTradeName(PsiWareHouseDetailed detail) {
-        if (detail == null) {
-            return "";
-        }
-        if (StringUtils.isNotBlank(detail.getTradeName())) {
-            return detail.getTradeName();
-        }
-        if (StringUtils.isNotBlank(detail.getWareHouseType())) {
-            return detail.getWareHouseType();
-        }
-        return "";
-    }
-
     private String formatShelfLife(String shelfLife, String shelfLifeUnit) {
         if (StringUtils.isBlank(shelfLife)) {
             return "";
@@ -958,7 +883,7 @@ public class PsiWareHouseBasicService {
 //            queryWrapper.like("c.ware_house_number", dto.getWareHouseNumber());
 //        }
         if (StringUtils.isNotEmpty(dto.getTradeName())) {
-            queryWrapper.like("c.name", dto.getTradeName());
+            queryWrapper.like("a.trade_name", dto.getTradeName());
         }
         if (StringUtils.isNotEmpty(dto.getBasicId())) {
             queryWrapper.eq("b.mmcId", dto.getBasicId());
@@ -1001,10 +926,7 @@ public class PsiWareHouseBasicService {
 //            queryWrapper.like("c.ware_house_number", dto.getWareHouseNumber());
 //        }
         if (StringUtils.isNotEmpty(dto.getTradeName())) {
-            queryWrapper.like("c.name", dto.getTradeName());
-        }
-        if (StringUtils.isNotEmpty(dto.getBrand())) {
-            queryWrapper.like("c.brand", dto.getBrand());
+            queryWrapper.like("a.trade_name", dto.getTradeName());
         }
         queryWrapper.and(wq ->{
             wq.eq("bas.`status`","0")
@@ -1083,7 +1005,7 @@ public class PsiWareHouseBasicService {
 
         queryWrapper.eq("a.del_flag", "0");
         if (StringUtils.isNotEmpty(dto.getTradeName())) {
-            queryWrapper.like("c.name", dto.getTradeName());
+            queryWrapper.like("a.trade_name", dto.getTradeName());
         }
         queryWrapper.and(wq ->{
             wq.eq("bas.`status`","0")
@@ -1254,7 +1176,7 @@ public class PsiWareHouseBasicService {
         queryWrapper.eq("a.del_flag", "0");
 
         if (StringUtils.isNotEmpty(dto.getTradeName())) {
-            queryWrapper.like("c.name", dto.getTradeName());
+            queryWrapper.like("a.trade_name", dto.getTradeName());
         }
         queryWrapper.and(wq ->{
             wq.eq("bas.`status`","0")
@@ -1449,7 +1371,7 @@ public class PsiWareHouseBasicService {
         queryWrapper.eq("a.del_flag", "0");
 
         if (StringUtils.isNotEmpty(dto.getTradeName())) {
-            queryWrapper.like("c.name", dto.getTradeName());
+            queryWrapper.like("a.trade_name", dto.getTradeName());
         }
         queryWrapper.and(wq ->{
             wq.eq("bas.`status`","0")
@@ -1514,7 +1436,7 @@ public class PsiWareHouseBasicService {
         queryWrapper.eq("a.del_flag", "0");
 
         if (StringUtils.isNotEmpty(dto.getTradeName())) {
-            queryWrapper.like("c.name", dto.getTradeName());
+            queryWrapper.like("a.trade_name", dto.getTradeName());
         }
         queryWrapper.and(wq ->{
             wq.eq("bas.`status`","0")

+ 0 - 10
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/service/dto/PsiWareHouseDto.java

@@ -102,11 +102,6 @@ public class PsiWareHouseDto {
      */
     private String company;
 
-    /**
-     * 品牌
-     */
-    private String brand;
-
 
 
     /**
@@ -340,11 +335,6 @@ public class PsiWareHouseDto {
     private String spec;
 
     /**
-     * 规格
-     */
-    private String specification;
-
-    /**
      * 生产日期
      */
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")

+ 0 - 10
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/purchase/domain/PsiMaterialDetailed.java

@@ -107,16 +107,6 @@ public class PsiMaterialDetailed extends BaseEntity {
     private String spec;
 
     /**
-     * 规格
-     */
-    private String specification;
-
-    /**
-     * 品牌
-     */
-    private String brand;
-
-    /**
      * 生产日期
      */
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")

+ 0 - 35
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/purchase/service/PsiMaterialService.java

@@ -248,7 +248,6 @@ public class PsiMaterialService {
         String bearerToken = authentication.getCredentials().toString();
         // 获取当前登录人信息
         UserDTO userDTO = SpringUtil.getBean ( IUserApi.class ).getByToken (TokenProvider.getCurrentToken ( ));
-        normalizePurchaseAmounts(dto);
         if (StringUtils.isNotEmpty(dto.getId()) && !dto.getId().equals("false")) {
             return update(dto, userDTO);
         } else {
@@ -280,7 +279,6 @@ public class PsiMaterialService {
                 // 生成id
                 String detailId = UUID.randomUUID().toString().replace("-", "");
                 detailed.setId(detailId);
-                fillPurchaseLegacyTradeName(detailed);
                 detailed.setPurchaserAgent(detailed.getPurchaserAgentId());
                 detailed.setProcurementType(detailed.getProcurementTypeId());
                 detailed.setCreateById(userDTO.getId());
@@ -375,7 +373,6 @@ public class PsiMaterialService {
                     // 生成id
                     String detailId = UUID.randomUUID().toString().replace("-", "");
                     detailInfo.setId(detailId);
-                    fillPurchaseLegacyTradeName(detailInfo);
                     detailInfo.setPurchaserAgent(detailInfo.getPurchaserAgentId());
                     detailInfo.setProcurementType(detailInfo.getProcurementTypeId());
                     detailInfo.setCreateById(userDTO.getId());
@@ -392,7 +389,6 @@ public class PsiMaterialService {
                         saveFiles(detailInfo.getFileInfoLost(), userDTO, detailInfo.getId());
                     }
                 } else {
-                    fillPurchaseLegacyTradeName(detailInfo);
                     detailInfo.setPurchaserAgent(detailInfo.getPurchaserAgentId());
                     detailInfo.setProcurementType(detailInfo.getProcurementTypeId());
                     detailInfo.setUpdateById(userDTO.getId());
@@ -414,37 +410,6 @@ public class PsiMaterialService {
         return dto.getId();
     }
 
-    private void normalizePurchaseAmounts(PsiMaterialInfoDto dto) {
-        if (dto == null) {
-            return;
-        }
-        dto.setTradeTotalPrice(blankToNull(dto.getTradeTotalPrice()));
-        if (CollectionUtils.isEmpty(dto.getDetailInfos())) {
-            return;
-        }
-        dto.getDetailInfos().forEach(detail -> {
-            detail.setTradePrice(blankToNull(detail.getTradePrice()));
-            detail.setTradeNumber(blankToNull(detail.getTradeNumber()));
-            detail.setTradeTotalPrice(blankToNull(detail.getTradeTotalPrice()));
-            if (StringUtils.isBlank(detail.getSpec())) {
-                detail.setSpec("1");
-            }
-        });
-    }
-
-    private String blankToNull(String value) {
-        return StringUtils.isBlank(value) ? null : value;
-    }
-
-    private void fillPurchaseLegacyTradeName(PsiMaterialDetailed detail) {
-        if (detail == null) {
-            return;
-        }
-        if (StringUtils.isBlank(detail.getTradeName()) && StringUtils.isNotBlank(detail.getProcurementType())) {
-            detail.setTradeName(detail.getProcurementType());
-        }
-    }
-
     public PsiMaterialInfoDto findById(String id) {
         PsiMaterialInfoDto dto = new PsiMaterialInfoDto();
         // 查询基础信息表

+ 1 - 1
jeeplus-modules/jeeplus-xxl-job-executor-sample/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java

@@ -1208,7 +1208,7 @@ public class SampleXxlJob {
     @XxlJob("nearExpiryList")
     public void nearExpiryList() {
         try {
-            //SpringUtil.getBean(IPsiManagementApi.class).nearExpiryList();
+            SpringUtil.getBean(IPsiManagementApi.class).nearExpiryList();
         } catch (Exception e) {
             logger.warn("调用失败,可能服务不存在", e);
         }