Ver Fonte

aps-大屏

sucheng há 7 meses atrás
pai
commit
fc979091cd

+ 10 - 0
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/dao/ApsProductionOrderDao.java

@@ -87,6 +87,16 @@ public interface ApsProductionOrderDao extends BaseMapper<ApsProductionOrderDo>
     List<String> selectChangeAlloyByOrderId(@Param("id") String id);
 
     List<ApsReportYearAndMonth> selectNowYearPlanGetOrderNum();
+
+    List<ApsReportYearAndMonth> selectNowYearActualGetOrderNum();
+
+    List<ApsReportYearAndMonth> selectNowYearActualProduceNum();
+
+    List<ApsReportYearAndMonth> selectNowMonthPlanGetOrderNum();
+
+    List<ApsReportYearAndMonth> selectNowMonthActualGetOrderNum();
+
+    List<ApsReportYearAndMonth> selectNowMonthActualProduceNum();
 }
 
 

+ 165 - 2
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ApsProductionOrderServiceImpl.java

@@ -39,6 +39,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Collectors;
@@ -131,6 +133,10 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
     private ApsProductionTechnicalRequirementService apsProductionTechnicalRequirementService;
     @Autowired
     private ApsWorkInProgressInventoryService apsWorkInProgressInventoryService;
+    @Autowired
+    private ApsReportYearAndMonthService apsReportYearAndMonthService;
+    @Resource
+    private ApsReportYearAndMonthDao apsReportYearAndMonthDao;
 
 
     public static final String ERROR_MSG = "%s上诉订单的排程交货期大于承诺交货期";
@@ -1046,10 +1052,25 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
     public void dataEyeReport() {
 
 
+        //生成大屏中间部分数据
+        try {
+            log.info("开始生成大屏中间的数据");
+            setMiddleData();
+        } catch (Exception e) {
+            log.error("生成大屏中间数据失败");
+        }
+        //
+
+
+
+    }
+
+    //生成大屏中间部分数据
+    private void setMiddleData() {
         //存储最终数据
         List<ApsReportYearAndMonth> resInsertList = new LinkedList<>();
         //初始化数据
-        SaveConstans.COMPANY_MAP.forEach((key,value) -> {
+        SaveConstans.COMPANY_MAP.forEach((key, value) -> {
             ApsReportYearAndMonth apsReportYearAndMonth = new ApsReportYearAndMonth();
             apsReportYearAndMonth.setId(SecurityUtil.getUUID());
             apsReportYearAndMonth.setTenantid(key);
@@ -1060,7 +1081,149 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
 
         //===================今年计划接单量==================
         List<ApsReportYearAndMonth> apsReportYearAndMonthList = this.baseMapper.selectNowYearPlanGetOrderNum();
-
+        for (ApsReportYearAndMonth apsReportYearAndMonth : apsReportYearAndMonthList) {
+            if (ObjectUtil.isEmpty(apsReportYearAndMonth)) {
+                continue;
+            }
+            if (ObjectUtil.isNotEmpty(apsReportYearAndMonth.getTenantid()) && SaveConstans.COMPANY_MAP.containsKey(apsReportYearAndMonth.getTenantid())) {
+                resInsertList.stream().filter(item -> item.getTenantid().equals(apsReportYearAndMonth.getTenantid())).findFirst().ifPresent(item -> {
+                    item.setPlanordernumyear(apsReportYearAndMonth.getPlanordernumyear());
+                });
+            }
+        }
+        //==================今年实际已接单===================
+        List<ApsReportYearAndMonth> apsReportYearAndMonthList1 = this.baseMapper.selectNowYearActualGetOrderNum();
+        for (ApsReportYearAndMonth apsReportYearAndMonth : apsReportYearAndMonthList1) {
+            if (ObjectUtil.isEmpty(apsReportYearAndMonth)) {
+                continue;
+            }
+            if (ObjectUtil.isNotEmpty(apsReportYearAndMonth.getTenantid()) && SaveConstans.COMPANY_MAP.containsKey(apsReportYearAndMonth.getTenantid())) {
+                resInsertList.stream().filter(item -> item.getTenantid().equals(apsReportYearAndMonth.getTenantid())).findFirst().ifPresent(item -> {
+                    item.setActualordernumyear(apsReportYearAndMonth.getActualordernumyear());
+                });
+            }
+        }
+        //==================今年实际已完成===================
+        List<ApsReportYearAndMonth> apsReportYearAndMonthList2 = this.baseMapper.selectNowYearActualProduceNum();
+        for (ApsReportYearAndMonth apsReportYearAndMonth : apsReportYearAndMonthList2) {
+            if (ObjectUtil.isEmpty(apsReportYearAndMonth)) {
+                continue;
+            }
+            if (ObjectUtil.isNotEmpty(apsReportYearAndMonth.getTenantid()) && SaveConstans.COMPANY_MAP.containsKey(apsReportYearAndMonth.getTenantid())) {
+                resInsertList.stream().filter(item -> item.getTenantid().equals(apsReportYearAndMonth.getTenantid())).findFirst().ifPresent(item -> {
+                    item.setActualfinishnumyear(apsReportYearAndMonth.getActualfinishnumyear());
+                });
+            }
+        }
+        //==================今年接单量完成比例 = 今年实际已接单/今年计划接单量===================
+        resInsertList.forEach(item -> {
+            if (ObjectUtil.isNotEmpty(item.getPlanordernumyear())
+                    && ObjectUtil.isNotEmpty(item.getActualordernumyear())
+                    && new BigDecimal(item.getPlanordernumyear()).compareTo(BigDecimal.ZERO) != 0
+                    && new BigDecimal(item.getActualordernumyear()).compareTo(BigDecimal.ZERO) != 0) {
+                //计算比例,保留4位小数,以便百分比保留两位小数
+                item.setPlanordernumyearpercent(
+                        new BigDecimal(item.getActualordernumyear()).divide(new BigDecimal(item.getPlanordernumyear()), 4, RoundingMode.HALF_UP).toString());
+            } else {
+                item.setPlanordernumyearpercent("0");
+            }
+            //拼接展示字段
+            String pre = new BigDecimal(item.getPlanordernumyearpercent()).multiply(BigDecimal.valueOf(100)).toString();
+            item.setActualordernumyearshow(
+                    item.getActualordernumyear() + "(" + pre + "%)");
+        });
+        //==================今年完成比例=今年实际已完成/今年实际已接单===================
+        resInsertList.forEach(item -> {
+            if (ObjectUtil.isNotEmpty(item.getActualordernumyear())
+                    && ObjectUtil.isNotEmpty(item.getActualfinishnumyear())
+                    && new BigDecimal(item.getActualordernumyear()).compareTo(BigDecimal.ZERO) != 0
+                    && new BigDecimal(item.getActualfinishnumyear()).compareTo(BigDecimal.ZERO) != 0) {
+                //计算比例,保留4位小数,以便百分比保留两位小数
+                item.setActualfinishnumyearpercent(
+                        new BigDecimal(item.getActualfinishnumyear()).divide(new BigDecimal(item.getActualordernumyear()), 4, RoundingMode.HALF_UP).toString());
+            } else {
+                item.setActualfinishnumyearpercent("0");
+            }
+            //拼接展示字段
+            String pre = new BigDecimal(item.getActualfinishnumyearpercent()).multiply(BigDecimal.valueOf(100)).toString();
+            item.setActualfinishnumyearshow(
+                    item.getActualfinishnumyear() + "(" + pre + "%)");
+        });
+        //==================本月计划接单量==================
+        List<ApsReportYearAndMonth> apsReportYearAndMonthList3 = this.baseMapper.selectNowMonthPlanGetOrderNum();
+        for (ApsReportYearAndMonth apsReportYearAndMonth : apsReportYearAndMonthList3) {
+            if (ObjectUtil.isEmpty(apsReportYearAndMonth)) {
+                continue;
+            }
+            if (ObjectUtil.isNotEmpty(apsReportYearAndMonth.getTenantid()) && SaveConstans.COMPANY_MAP.containsKey(apsReportYearAndMonth.getTenantid())) {
+                resInsertList.stream().filter(item -> item.getTenantid().equals(apsReportYearAndMonth.getTenantid())).findFirst().ifPresent(item -> {
+                    item.setPlanordernummonth(apsReportYearAndMonth.getPlanordernummonth());
+                });
+            }
+        }
+        //==================本月实际已接单===================
+        List<ApsReportYearAndMonth> apsReportYearAndMonthList4 = this.baseMapper.selectNowMonthActualGetOrderNum();
+        for (ApsReportYearAndMonth apsReportYearAndMonth : apsReportYearAndMonthList4) {
+            if (ObjectUtil.isEmpty(apsReportYearAndMonth)) {
+                continue;
+            }
+            if (ObjectUtil.isNotEmpty(apsReportYearAndMonth.getTenantid()) && SaveConstans.COMPANY_MAP.containsKey(apsReportYearAndMonth.getTenantid())) {
+                resInsertList.stream().filter(item -> item.getTenantid().equals(apsReportYearAndMonth.getTenantid())).findFirst().ifPresent(item -> {
+                    item.setActualordernummonth(apsReportYearAndMonth.getActualordernummonth());
+                });
+            }
+        }
+        //==================本月实际已完成===================
+        List<ApsReportYearAndMonth> apsReportYearAndMonthList5 = this.baseMapper.selectNowMonthActualProduceNum();
+        for (ApsReportYearAndMonth apsReportYearAndMonth : apsReportYearAndMonthList5) {
+            if (ObjectUtil.isEmpty(apsReportYearAndMonth)) {
+                continue;
+            }
+            if (ObjectUtil.isNotEmpty(apsReportYearAndMonth.getTenantid()) && SaveConstans.COMPANY_MAP.containsKey(apsReportYearAndMonth.getTenantid())) {
+                resInsertList.stream().filter(item -> item.getTenantid().equals(apsReportYearAndMonth.getTenantid())).findFirst().ifPresent(item -> {
+                    item.setActualfinishnummonth(apsReportYearAndMonth.getActualfinishnummonth());
+                });
+            }
+        }
+        //==================本月接单量完成比例 = 本月实际已接单/本月计划接单量===================
+        resInsertList.forEach(item -> {
+            if (ObjectUtil.isNotEmpty(item.getPlanordernummonth())
+                    && ObjectUtil.isNotEmpty(item.getActualordernummonth())
+                    && new BigDecimal(item.getPlanordernummonth()).compareTo(BigDecimal.ZERO) != 0
+                    && new BigDecimal(item.getActualordernummonth()).compareTo(BigDecimal.ZERO) != 0) {
+                //计算比例,保留4位小数,以便百分比保留两位小数
+                item.setPlanordernummonthpercent(
+                        new BigDecimal(item.getActualordernummonth()).divide(new BigDecimal(item.getPlanordernummonth()), 4, RoundingMode.HALF_UP).toString());
+            } else {
+                item.setPlanordernummonthpercent("0");
+            }
+            //拼接展示字段
+            String pre = new BigDecimal(item.getPlanordernummonthpercent()).multiply(BigDecimal.valueOf(100)).toString();
+            item.setActualordernummonthshow(
+                    item.getActualordernummonth() + "(" + pre + "%)");
+        });
+        //==================本月完成比例=本月实际已完成/本月实际已接单===================
+        resInsertList.forEach(item -> {
+            if (ObjectUtil.isNotEmpty(item.getActualordernummonth())
+                    && ObjectUtil.isNotEmpty(item.getActualfinishnummonth())
+                    && new BigDecimal(item.getActualordernummonth()).compareTo(BigDecimal.ZERO) != 0
+                    && new BigDecimal(item.getActualfinishnummonth()).compareTo(BigDecimal.ZERO) != 0) {
+                //计算比例,保留4位小数,以便百分比保留两位小数
+                item.setActualfinishnummonthpercent(
+                        new BigDecimal(item.getActualfinishnummonth()).divide(new BigDecimal(item.getActualordernummonth()), 4, RoundingMode.HALF_UP).toString());
+            } else {
+                item.setActualfinishnummonthpercent("0");
+            }
+            //拼接展示字段
+            String pre = new BigDecimal(item.getActualfinishnummonthpercent()).multiply(BigDecimal.valueOf(100)).toString();
+            item.setActualfinishnummonthshow(
+                    item.getActualfinishnummonth() + "(" + pre + "%)");
+        });
+        //================更新数据==================
+        //删除所有之前的数据
+        apsReportYearAndMonthService.remove(new QueryWrapper<ApsReportYearAndMonth>().lambda().eq(ApsReportYearAndMonth::getDeleted, "0"));
+        //插入新的数据
+        apsReportYearAndMonthService.saveBatch(resInsertList);
     }
 
 }

+ 125 - 0
cx-aps/cx-aps-common/src/main/resources/mybatis/ApsProductionOrderDao.xml

@@ -360,4 +360,129 @@
           and aop.PARTYEAR=YEAR(CURRENT_DATE)
         group by aop.TENANTID
     </select>
+    <select id="selectNowYearActualGetOrderNum" resultType="com.rongwei.bsentity.domain.ApsReportYearAndMonth">
+        select
+        apro.TENANTID AS 'tenantid',
+        IFNULL(sum((apope.PLANPROCESSRALL-apope.CANCELROLL)*apoom.PLANPRODROLLNUM/apo.PLANPROCESSRALL*apoom.SINGLEROLLWEIGHT),0) AS 'actualordernumyear' -- 实际接单量
+        from
+        aps_process_operation_process_equ apope
+        join aps_process_operation apo on apo.ID = apope.PROCESSID
+        join aps_process_operation_out_mater apoom on apo.id=apoom.MAINID-- 作业输出物料
+        join aps_blank_order abo on apo.BLANKID = abo.id
+        join aps_production_order apro on apro.ID = abo.PRODUCTIONORDERID
+        join aps_product_detail apd on apoom.ORDERDETAILID = apd.id -- 订单产品明细
+        left join aps_product_specs aps on apoom.THICKNESS > aps.THICKSTR and apoom.THICKNESS <= aps.THICKEND
+        left join aps_production_merge_order apmd on apmd.ID = apd.MERGEORDERNUMBER and apmd.DELETED='0'
+        where
+        apope.deleted='0' and apo.DELETED='0' and abo.DELETED='0' and apro.deleted='0'
+        and apd.DELETED='0' and apoom.DELETED='0' and aps.DELETED='0'
+        and (ifnull(apmd.ORDERTYPE, apro.ORDERTYPE) in ('客户订单','')) -- 订单类型为空默认为客户订单
+        and abo.PRODUCTSTATUS in ('30','40','50')
+        and (apope.PLANPROCESSRALL-apope.CANCELROLL)>0
+        and apoom.PLANPRODROLLNUM>0
+        and YEAR(apope.PLANENDDATE) = YEAR(CURRENT_DATE)
+        GROUP BY apro.TENANTID
+    </select>
+    <select id="selectNowYearActualProduceNum" resultType="com.rongwei.bsentity.domain.ApsReportYearAndMonth">
+        select
+            apro.TENANTID AS 'tenantid',
+            IFNULL(sum(aro.WEIGHT),0) AS 'actualfinishnumyear'
+        from
+            aps_process_operation_process_equ apope
+                join aps_process_operation apo on apo.ID = apope.PROCESSID
+                join aps_process_operation_out_mater apoom on apo.id=apoom.MAINID-- 作业输出物料
+                join aps_blank_order abo on apo.BLANKID = abo.id
+                join aps_production_order apro on apro.ID = abo.PRODUCTIONORDERID
+                join aps_product_detail apd on apoom.ORDERDETAILID = apd.id -- 订单产品明细
+                join aps_report_records arr on apope.id=arr.PROCESSEQUID
+                join aps_report_output aro on arr.id=aro.mainid
+                left join aps_production_merge_order apmd on apmd.ID = apd.MERGEORDERNUMBER and apmd.DELETED='0'
+        where
+            apope.deleted='0' and apo.DELETED='0' and abo.DELETED='0' and apro.deleted='0'
+          and apd.DELETED='0' and arr.deleted='0' and aro.DELETED='0'
+          and (ifnull(apmd.ORDERTYPE, apro.ORDERTYPE) in ('客户订单','')) -- 订单类型为空默认为客户订单
+          and arr.CHECKSTATUS='已检验'
+          and aro.QUALIFIED='是'
+          and apoom.PLANPRODROLLNUM>0
+          and YEAR(apope.ACTUALFINISHDATE) = YEAR(CURRENT_DATE)
+        GROUP BY apro.TENANTID
+    </select>
+    <select id="selectNowMonthPlanGetOrderNum" resultType="com.rongwei.bsentity.domain.ApsReportYearAndMonth">
+        select
+            aop.TENANTID AS 'tenantid',
+            ifnull(sum(
+                           CASE MONTH(CURRENT_DATE)
+                               WHEN '1' THEN ONEM
+                               WHEN '2' THEN TWOM
+                               WHEN '3' THEN THREEM
+                               WHEN '4' THEN FOURM
+                               WHEN '5' THEN FIVEM
+                               WHEN '6' THEN SIXM
+                               WHEN '7' THEN SEVENM
+                               WHEN '8' THEN EIGHTM
+                               WHEN '9' THEN NINEM
+                               WHEN '10' THEN TENM
+                               WHEN '11' THEN ELEVENM
+                               WHEN '12' THEN TWELVEM
+                               ELSE null
+                               END
+                   ),0) AS 'planordernummonth'
+        from
+            aps_accept_order_plan aop
+                join aps_accept_order_plan_detail aopd on aop.id=aopd.MAINID
+        where
+            aop.deleted='0' and aopd.deleted='0'
+          and aop.PARTYEAR=YEAR(CURRENT_DATE)
+        GROUP BY aop.TENANTID
+    </select>
+    <select id="selectNowMonthActualGetOrderNum"
+            resultType="com.rongwei.bsentity.domain.ApsReportYearAndMonth">
+        select
+        apro.TENANTID AS 'tenantid',
+        ifnull(sum((apope.PLANPROCESSRALL-apope.CANCELROLL)*apoom.PLANPRODROLLNUM/apo.PLANPROCESSRALL*apoom.SINGLEROLLWEIGHT),0) AS 'actualordernummonth' -- 本月实际接单量
+        from
+        aps_process_operation_process_equ apope
+        join aps_process_operation apo on apo.ID = apope.PROCESSID
+        join aps_process_operation_out_mater apoom on apo.id=apoom.MAINID-- 作业输出物料
+        join aps_blank_order abo on apo.BLANKID = abo.id
+        join aps_production_order apro on apro.ID = abo.PRODUCTIONORDERID
+        join aps_product_detail apd on apoom.ORDERDETAILID = apd.id -- 订单产品明细
+        left join aps_product_specs aps on apoom.THICKNESS > aps.THICKSTR and apoom.THICKNESS <= aps.THICKEND
+        left join aps_production_merge_order apmd on apmd.ID = apd.MERGEORDERNUMBER and apmd.DELETED='0'
+        where
+        apope.deleted='0' and apo.DELETED='0' and abo.DELETED='0' and apro.deleted='0'
+        and apd.DELETED='0' and apoom.DELETED='0' and aps.DELETED='0'
+        and (ifnull(apmd.ORDERTYPE, apro.ORDERTYPE) in ('客户订单','')) -- 订单类型为空默认为客户订单
+        and abo.PRODUCTSTATUS in ('30','40','50')
+        and (apope.PLANPROCESSRALL-apope.CANCELROLL)>0
+        and apoom.PLANPRODROLLNUM>0
+        and YEAR(apope.PLANENDDATE) = YEAR(CURRENT_DATE)
+        and MONTH(apope.PLANENDDATE) = MONTH(CURRENT_DATE)
+        GROUP BY apro.TENANTID
+    </select>
+    <select id="selectNowMonthActualProduceNum" resultType="com.rongwei.bsentity.domain.ApsReportYearAndMonth">
+        select
+            apro.TENANTID AS 'tenantid',
+            ifnull(sum(aro.WEIGHT),0) AS 'actualfinishnummonth'
+        from
+            aps_process_operation_process_equ apope
+                join aps_process_operation apo on apo.ID = apope.PROCESSID
+                join aps_process_operation_out_mater apoom on apo.id=apoom.MAINID-- 作业输出物料
+                join aps_blank_order abo on apo.BLANKID = abo.id
+                join aps_production_order apro on apro.ID = abo.PRODUCTIONORDERID
+                join aps_product_detail apd on apoom.ORDERDETAILID = apd.id -- 订单产品明细
+                join aps_report_records arr on apope.id=arr.PROCESSEQUID
+                join aps_report_output aro on arr.id=aro.mainid
+                left join aps_production_merge_order apmd on apmd.ID = apd.MERGEORDERNUMBER and apmd.DELETED='0'
+        where
+            apope.deleted='0' and apo.DELETED='0' and abo.DELETED='0' and apro.deleted='0'
+          and apd.DELETED='0' and arr.deleted='0' and aro.DELETED='0'
+          and (ifnull(apmd.ORDERTYPE, apro.ORDERTYPE) in ('客户订单','')) -- 订单类型为空默认为客户订单
+          and arr.CHECKSTATUS='已检验'
+          and aro.QUALIFIED='是'
+          and apoom.PLANPRODROLLNUM>0
+          and YEAR(apope.ACTUALFINISHDATE) = YEAR(CURRENT_DATE)
+          and MONTH(apope.ACTUALFINISHDATE) = MONTH(CURRENT_DATE)
+        GROUP BY apro.TENANTID
+    </select>
 </mapper>

+ 4 - 4
cx-aps/cx-aps-entity/src/main/java/com/rongwei/bsentity/domain/ApsReportYearAndMonth.java

@@ -62,13 +62,13 @@ public class ApsReportYearAndMonth extends BaseDo implements Serializable {
      * 今年接单量完成比例
      */
     @TableField(value = "PLANORDERNUMYEARPERCENT")
-    private String planordernumyearpercent = "0%";
+    private String planordernumyearpercent = "0";
 
     /**
      * 今年完成比例
      */
     @TableField(value = "ACTUALFINISHNUMYEARPERCENT")
-    private String actualfinishnumyearpercent = "0%";
+    private String actualfinishnumyearpercent = "0";
 
     /**
      * 本月计划接单量
@@ -92,13 +92,13 @@ public class ApsReportYearAndMonth extends BaseDo implements Serializable {
      * 本月接单量完成比例
      */
     @TableField(value = "PLANORDERNUMMONTHPERCENT")
-    private String planordernummonthpercent = "0%";
+    private String planordernummonthpercent = "0";
 
     /**
      * 本月实际完成比例
      */
     @TableField(value = "ACTUALFINISHNUMMONTHPERCENT")
-    private String actualfinishnummonthpercent = "0%";
+    private String actualfinishnummonthpercent = "0";
 
     /**
      * 今年实际已接单-展示