Browse Source

优化计划单统计表查询,导出

zengtx 1 năm trước cách đây
mục cha
commit
7fb458a394

+ 72 - 57
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/costLossReview/controller/SyCostLossReviewController.java

@@ -195,64 +195,79 @@ public class SyCostLossReviewController extends JeecgController<SyOrderData, ISy
                pageList.setTotal(syCostLossReviewMapper.querylistCount(syCostLossReview, sumList, new ArrayList<>()));
            }
 
-       for (SyCostLossReview sy:pageList.getRecords()) {
-
-               //赋值制单人
-               List<String> list = syCostLossReviewService.queryMakerByplanNo(sy.getPlanNo());
-               if (list.size() == 0) {
-                   sy.setMaker("");
-               } else {
-                   for (int i = 0; i < list.size(); i++) {
-                       if (i == 0) {
-                           sy.setMaker(list.get(0));
-                       } else {
-                           sy.setMaker(sy.getMaker() + "," + list.get(i));
-                       }
+       //赋值制单人
+       List<SyCostLossReview> listPlanNo = syCostLossReviewService.queryMakerByplanNo();
+       Map<String, String> nameByCode = listPlanNo.stream()
+               .collect(Collectors.toMap(SyCostLossReview::getPlanNo, SyCostLossReview::getMaker));
+       //赋值面损审批数据
+       List<SyCostLossReview> list2 = syCostLossReviewService.querySyFabricLossByCode();
+       Map<String, SyCostLossReview> map2 = list2.stream()
+               .collect(Collectors.toMap(SyCostLossReview::getPlanNo, c2 -> c2));
+       //赋值成本审批数据
+       List<SyCostLossReview> list3 = syCostLossReviewService.queryCostAllocationByCode();
+       Map<String, SyCostLossReview> map3 = list3.stream()
+               .collect(Collectors.toMap(SyCostLossReview::getPlanNo, c3 -> c3));
+
+       //赋值计划统计单保存的数据
+       QueryWrapper wrapper = new QueryWrapper();
+       List<SyPlanStatistics> planStatistics =syPlanStatisticsService.list(wrapper);
+       Map<String, SyPlanStatistics> map4 = planStatistics.stream()
+               .collect(Collectors.toMap(SyPlanStatistics::getPlanNum, c4 -> c4));
+
+       //将制单人集合放进原始数据中去
+       pageList.getRecords().forEach(data -> data.setMaker(nameByCode.get(data.getPlanNo())));
+
+       pageList.getRecords().stream()
+               .map(c1 -> {
+                   SyCostLossReview c2 = map2.get(c1.getPlanNo());
+                   if (c2 != null) {
+                       c1.setFsubmitDate(c2.getFsubmitDate());
+                       c1.setFfirstApproveDate(c2.getFfirstApproveDate());
+                       c1.setFfinalApproveDate(c2.getFfinalApproveDate());
+                       c1.setFrejectDate(c2.getFrejectDate());
+                       c1.setFstatus(c2.getFstatus());
                    }
-               }
-
-           //赋值面损审批数据
-           SyCostLossReview f = syCostLossReviewService.querySyFabricLossByCode(sy.getPlanNo());
-           if(f!=null){
-               sy.setFsubmitDate(f.getFsubmitDate());
-               sy.setFfirstApproveDate(f.getFfirstApproveDate());
-               sy.setFfinalApproveDate(f.getFfinalApproveDate());
-               sy.setFrejectDate(f.getFrejectDate());
-               sy.setFstatus(f.getFstatus());
-//               //赋值成本审批数据
-//               sy.setCsubmitDate(f.getCsubmitDate());
-//               sy.setCfirstApproveDate(f.getCfirstApproveDate());
-//               sy.setCfinalApproveDate(f.getCfinalApproveDate());
-//               sy.setCrejectDate(f.getCrejectDate());
-//               sy.setCstatus(f.getCstatus());
-//               //计划单数据
-//               sy.setPlanMan(f.getPlanMan());
-//               sy.setRemarks(f.getRemarks());
-//               sy.setId(f.getId());
-           }
-
-           //赋值成本审批数据
-           SyCostLossReview c = syCostLossReviewService.queryCostAllocationByCode(sy.getPlanNo());
-           if(c!=null){
-               sy.setCsubmitDate(c.getCsubmitDate());
-               sy.setCfirstApproveDate(c.getCfirstApproveDate());
-               sy.setCfinalApproveDate(c.getCfinalApproveDate());
-               sy.setCrejectDate(c.getCrejectDate());
-               sy.setCstatus(c.getCstatus());
-           }
-
-           QueryWrapper wrapper = new QueryWrapper();
-           wrapper.eq("plan_num",sy.getPlanNo());
-           List<SyPlanStatistics> planStatistics =syPlanStatisticsService.list(wrapper);
-           if(planStatistics!=null && planStatistics.size()>0){
-               sy.setPlanMan(planStatistics.get(0).getPlanMan());
-               sy.setRemarks(planStatistics.get(0).getRemarks());
-               sy.setId(planStatistics.get(0).getId());
-               //刷成衣结束日期
-               sy.setReadyEndDate(planStatistics.get(0).getReadyEndDate());
-           }
-
-       }
+                   return c1;
+               })
+               .collect(Collectors.toList());
+
+       pageList.getRecords().stream()
+               .map(c1 -> {
+                   SyCostLossReview c2 = map3.get(c1.getPlanNo());
+                   if (c2 != null) {
+                       c1.setCsubmitDate(c2.getCsubmitDate());
+                       c1.setCfirstApproveDate(c2.getCfirstApproveDate());
+                       c1.setCfinalApproveDate(c2.getCfinalApproveDate());
+                       c1.setCrejectDate(c2.getCrejectDate());
+                       c1.setCstatus(c2.getCstatus());
+                   }
+                   return c1;
+               })
+               .collect(Collectors.toList());
+
+       pageList.getRecords().stream()
+               .map(c1 -> {
+                   SyPlanStatistics c2 = map4.get(c1.getPlanNo());
+                   if (c2 != null) {
+                       c1.setPlanMan(c2.getPlanMan());
+                       c1.setRemarks(c2.getRemarks());
+                       c1.setId(c2.getId());
+                       //刷成衣结束日期
+                       c1.setReadyEndDate(c2.getReadyEndDate());
+                   }
+                   return c1;
+               })
+               .collect(Collectors.toList());
+
+
+//       for (SyCostLossReview sy:pageList.getRecords()) {
+//
+//
+//           if(planStatistics!=null && planStatistics.size()>0){
+//
+//           }
+//
+//       }
        result.setResult(pageList);
        result.setSuccess(true);
        result.setMessage("查询成功!");

+ 3 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/costLossReview/mapper/SyCostLossReviewMapper.java

@@ -27,13 +27,13 @@ public interface SyCostLossReviewMapper extends BaseMapper<SyCostLossReview> {
     int querylistCount(@Param("e")SyCostLossReview syCostLossReview,@Param("list")List<String> list,@Param("planlist") List<String> planlist);//@Param("pageNO")int pageNO,@Param("pageSize")int pageSize
 
     @DS("multi-one")
-    List<String> queryMakerByplanNo(@Param("planNo")String planNo);
+    List<SyCostLossReview> queryMakerByplanNo();
 
     IPage<FabricLossReview> querySyFabricLossReport(@Param("status") List<String> status,@Param("sy")FabricLossReview sy, Page<FabricLossReview> page);
     IPage<CostAllocationReview> queryCostAllocation(@Param("status") List<String> status,@Param("sy")CostAllocationReview sy, Page<CostAllocationReview> page);
 
-    SyCostLossReview querySyFabricLossByCode(@Param("planCode")String planCode);
-    SyCostLossReview queryCostAllocationByCode(@Param("planCode")String planCode);
+    List<SyCostLossReview> querySyFabricLossByCode();
+    List<SyCostLossReview> queryCostAllocationByCode();
 
     @DS("multi-one")
     List<String> queryCodeBymaker(@Param("maker")String maker);

+ 14 - 10
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/costLossReview/mapper/xml/SyCostLossReviewMapper.xml

@@ -149,9 +149,12 @@
 
     </select>
 
-    <select id="queryMakerByplanNo" resultType="String">
-        select maker from (
-            select LEFT(cSOCode,CHARINDEX('-',cSOCode)-1) as planNo,cMaker as maker from UFDATA_103_2021.dbo.SO_SOMain s
+    <select id="queryMakerByplanNo" resultType="org.jeecg.modules.documents.costLossReview.entity.SyCostLossReview">
+        SELECT planNo, STRING_AGG(maker, ',') AS maker
+FROM (
+    SELECT DISTINCT planNo, maker
+    FROM (
+       select LEFT(cSOCode,CHARINDEX('-',cSOCode)-1) as planNo,cMaker as maker from UFDATA_103_2021.dbo.SO_SOMain s
                     JOIN UFDATA_103_2021.dbo.Department de ON s.cDepCode = de.cDepCode
                     JOIN UFDATA_103_2021.dbo.Person  pe ON s.cMaker = pe.cPersonName
                     where cSOCode like 'sy%' and CHARINDEX('-',cSOCode)>0 and pe.cdepcode='TPD02'
@@ -197,9 +200,9 @@
                     JOIN UFDATA_102_2021.dbo.Department de ON s.cDepCode = de.cDepCode
                     JOIN UFDATA_102_2021.dbo.Person  pe ON s.cMaker = pe.cPersonName
                     where cSOCode like 'sy%' and CHARINDEX('-',cSOCode)>0 and pe.cdepcode='TPD02'
-        ) as views
-        where planNo =#{planNo}
-        group by planNo,maker
+    ) AS subquery
+) AS views
+GROUP BY planNo;
     </select>
 
     <select id="querySyFabricLossReport" resultType="org.jeecg.modules.documents.costLossReview.entity.FabricLossReview">
@@ -357,19 +360,20 @@
     </select>
 
     <select id="querySyFabricLossByCode" resultType="org.jeecg.modules.documents.costLossReview.entity.SyCostLossReview">
-        select
+        select UPPER(plan_code) as planNo,
         submit_date as fsubmitDate,reject_date as frejectDate,first_approve_date as ffirstApproveDate,
         final_approve_date as ffinalApproveDate,status as fstatus
         from sy_fabric_loss_report
-        where plan_code=#{planCode}
+
     </select>
 
     <select id="queryCostAllocationByCode" resultType="org.jeecg.modules.documents.costLossReview.entity.SyCostLossReview">
-        select
+        select UPPER(plan_num) as planNo,
         submit_date as csubmitDate,reject_date as frejectDate,first_approve_date as ffirstApproveDate,
         final_approve_date as cfinalApproveDate,status as cstatus
         from sy_cost_json
-        where plan_num=#{planCode}
+
+
     </select>
 
 

+ 4 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/costLossReview/service/ISyCostLossReviewService.java

@@ -10,6 +10,7 @@ import org.jeecg.modules.documents.costLossReview.entity.SyApprovalHistory;
 import org.jeecg.modules.documents.costLossReview.entity.SyCostLossReview;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 成本损失列表
@@ -19,11 +20,11 @@ import java.util.List;
  */
 public interface ISyCostLossReviewService extends IService<SyCostLossReview> {
      IPage<SyCostLossReview> querylist(SyCostLossReview syCostLossReview,List<String> list, Page<SyCostLossReview> page,List<String> planlist);
-     List<String> queryMakerByplanNo(String planNo);
+     List<SyCostLossReview> queryMakerByplanNo();
      IPage<FabricLossReview> querySyFabricLossReport(List<String> status,FabricLossReview sy, Page<FabricLossReview> page);
      IPage<CostAllocationReview> queryCostAllocation(List<String> status,CostAllocationReview sy, Page<CostAllocationReview> page);
-     SyCostLossReview querySyFabricLossByCode(String planCode);
-     SyCostLossReview queryCostAllocationByCode(String planCode);
+     List<SyCostLossReview> querySyFabricLossByCode();
+     List<SyCostLossReview> queryCostAllocationByCode();
      List<String> queryCodeBymaker(String maker);
      List<String> queryCodeByfstatus(List<String> status,String ffirstApproveDateB,String ffirstApproveDateE);
      List<String> queryCodeBycstatus(List<String> status);

+ 7 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/costLossReview/service/impl/SyCostLossReviewServiceImpl.java

@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 成本损失列表
@@ -44,8 +45,8 @@ public class SyCostLossReviewServiceImpl extends ServiceImpl<SyCostLossReviewMap
     }
 
     @Override
-    public List<String> queryMakerByplanNo(String planNo) {
-        return syCostLossReviewMapper.queryMakerByplanNo(planNo);
+    public List<SyCostLossReview> queryMakerByplanNo() {
+        return syCostLossReviewMapper.queryMakerByplanNo();
     }
 
     @Override
@@ -59,13 +60,13 @@ public class SyCostLossReviewServiceImpl extends ServiceImpl<SyCostLossReviewMap
     }
 
     @Override
-    public SyCostLossReview querySyFabricLossByCode(String planCode) {
-        return syCostLossReviewMapper.querySyFabricLossByCode(planCode);
+    public List<SyCostLossReview> querySyFabricLossByCode() {
+        return syCostLossReviewMapper.querySyFabricLossByCode();
     }
 
     @Override
-    public SyCostLossReview queryCostAllocationByCode(String planCode) {
-        return syCostLossReviewMapper.queryCostAllocationByCode(planCode);
+    public List<SyCostLossReview> queryCostAllocationByCode() {
+        return syCostLossReviewMapper.queryCostAllocationByCode();
     }
 
     @Override

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/quartz/job/AddOrderJob.java

@@ -182,6 +182,7 @@ public class AddOrderJob implements Job,ApplicationContextAware {
                         "s.cInvCode AS inventoryCode," +
                         "c.cInvCcode AS inventoryCcode," +
                         "c.cInvName AS inventoryName," +
+                        "c.cCurrencyName as inventoryCurrencyName,"+
                         "s.cFree1 AS colour," +
                         "s.cFree2 AS size," +
                         "s.cFree3 AS codingRules," +