sucheng 7 ماه پیش
والد
کامیت
36b98f6706

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

@@ -1079,6 +1079,7 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             setMiddleData();
         } catch (Exception e) {
             log.error("生成大屏中间数据失败");
+            e.printStackTrace();
         }
         //订单完成情况表格
         try {
@@ -1086,6 +1087,7 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             setOrderFinishTable();
         } catch (Exception e) {
             log.error("生成大屏订单完成情况表格失败");
+            e.printStackTrace();
         }
         //订单完成情况趋势图
         try {
@@ -1093,6 +1095,7 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             setOrderFinishTrend();
         } catch (Exception e) {
             log.error("生成大屏订单完成情况趋势图失败");
+            e.printStackTrace();
         }
         //铸轧生产情况表格
         try {
@@ -1100,6 +1103,7 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             setCastRollData();
         } catch (Exception e) {
             log.error("生成大屏铸轧生产情况表格失败");
+            e.printStackTrace();
         }
         //铸轧生产情况趋势图
         try {
@@ -1107,6 +1111,7 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             setCastRollTrend();
         } catch (Exception e) {
             log.error("生成大屏铸轧生产情况趋势图失败");
+            e.printStackTrace();
         }
         //精整生产情况表格
         try {
@@ -1114,6 +1119,7 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             setProcessTable();
         } catch (Exception e) {
             log.error("生成大屏精整生产情况表格失败");
+            e.printStackTrace();
         }
         //精整生产情况趋势图
         try {
@@ -1121,6 +1127,7 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             setProcessTrend();
         } catch (Exception e) {
             log.error("生成大屏精整生产情况趋势图失败");
+            e.printStackTrace();
         }
         //轧机生产情况表格
         try {
@@ -1128,6 +1135,7 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             setZjProcessTable();
         } catch (Exception e) {
             log.error("生成大屏轧机生产情况表格失败");
+            e.printStackTrace();
         }
         //轧机生产情况趋势图
         try {
@@ -1135,6 +1143,7 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             setZjProcessTrend();
         } catch (Exception e) {
             log.error("生成大屏轧机生产情况趋势图失败");
+            e.printStackTrace();
         }
         //退火生产情况表格
         try {
@@ -1142,6 +1151,7 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             setThProcessTable();
         } catch (Exception e) {
             log.error("生成大屏退火生产情况表格失败");
+            e.printStackTrace();
         }
         //退火生产情况趋势图
         try {
@@ -1149,6 +1159,7 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             setThProcessTrend();
         } catch (Exception e) {
             log.error("生成大屏退火生产情况趋势图失败");
+            e.printStackTrace();
         }
 
     }
@@ -1162,6 +1173,33 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             //近12月数据
             List<ApsReportThProcessPhoto> list = this.baseMapper.selectThProcessPhoto(key);
             if (ObjectUtil.isNotEmpty(list)) {
+                //按日期升序
+                list.sort(Comparator.comparing(a -> DateUtil.parse(a.getYearmonth(), "yyyy-MM")));
+                String nowYear = DateUtil.year(new Date()) + "";
+                //如果第一个月是今年的数据,全年只取月份
+                if (list.get(0).getYearmonth().split("-")[0].equals(nowYear)) {
+                    list.forEach(item -> {
+                        item.setYearmonth(item.getYearmonth().split("-")[1] + "月");
+                    });
+                }
+                //如果第一个月不是今年的,第一个月取年月,第二年第一个月取年月,其余只取月份
+                else {
+                    //判断是否触发今年数据
+                    boolean isNowYear = false;
+                    for (int i = 0; i < list.size(); i++) {
+                        ApsReportThProcessPhoto item = list.get(i);
+                        if (i == 0) {
+                            item.setYearmonth(item.getYearmonth().split("-")[0] + "年" + item.getYearmonth().split("-")[1] + "月");
+                            continue;
+                        }
+                        if (!isNowYear && item.getYearmonth().split("-")[0].equals(nowYear)) {
+                            isNowYear = true;
+                            item.setYearmonth(item.getYearmonth().split("-")[0] + "年" + item.getYearmonth().split("-")[1] + "月");
+                        } else {
+                            item.setYearmonth(item.getYearmonth().split("-")[1] + "月");
+                        }
+                    }
+                }
                 int index = 1;
                 for (ApsReportThProcessPhoto item : list) {
                     item.setId(key + String.format("%02d", index));
@@ -1210,6 +1248,33 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             //近12月数据
             List<ApsReportZjProcessPhoto> list = this.baseMapper.selectZjProcessPhoto(key);
             if (ObjectUtil.isNotEmpty(list)) {
+                //按日期升序
+                list.sort(Comparator.comparing(a -> DateUtil.parse(a.getYearmonth(), "yyyy-MM")));
+                String nowYear = DateUtil.year(new Date()) + "";
+                //如果第一个月是今年的数据,全年只取月份
+                if (list.get(0).getYearmonth().split("-")[0].equals(nowYear)) {
+                    list.forEach(item -> {
+                        item.setYearmonth(item.getYearmonth().split("-")[1] + "月");
+                    });
+                }
+                //如果第一个月不是今年的,第一个月取年月,第二年第一个月取年月,其余只取月份
+                else {
+                    //判断是否触发今年数据
+                    boolean isNowYear = false;
+                    for (int i = 0; i < list.size(); i++) {
+                        ApsReportZjProcessPhoto item = list.get(i);
+                        if (i == 0) {
+                            item.setYearmonth(item.getYearmonth().split("-")[0] + "年" + item.getYearmonth().split("-")[1] + "月");
+                            continue;
+                        }
+                        if (!isNowYear && item.getYearmonth().split("-")[0].equals(nowYear)) {
+                            isNowYear = true;
+                            item.setYearmonth(item.getYearmonth().split("-")[0] + "年" + item.getYearmonth().split("-")[1] + "月");
+                        } else {
+                            item.setYearmonth(item.getYearmonth().split("-")[1] + "月");
+                        }
+                    }
+                }
                 int index = 1;
                 for (ApsReportZjProcessPhoto item : list) {
                     item.setId(key + String.format("%02d", index));
@@ -1259,6 +1324,33 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             //近12月数据
             List<ApsReportJzProcessPhoto> list = this.baseMapper.selectProcessTrend(key);
             if (ObjectUtil.isNotEmpty(list)) {
+                //按日期升序
+                list.sort(Comparator.comparing(a -> DateUtil.parse(a.getYearmonth(), "yyyy-MM")));
+                String nowYear = DateUtil.year(new Date()) + "";
+                //如果第一个月是今年的数据,全年只取月份
+                if (list.get(0).getYearmonth().split("-")[0].equals(nowYear)) {
+                    list.forEach(item -> {
+                        item.setYearmonth(item.getYearmonth().split("-")[1] + "月");
+                    });
+                }
+                //如果第一个月不是今年的,第一个月取年月,第二年第一个月取年月,其余只取月份
+                else {
+                    //判断是否触发今年数据
+                    boolean isNowYear = false;
+                    for (int i = 0; i < list.size(); i++) {
+                        ApsReportJzProcessPhoto item = list.get(i);
+                        if (i == 0) {
+                            item.setYearmonth(item.getYearmonth().split("-")[0] + "年" + item.getYearmonth().split("-")[1] + "月");
+                            continue;
+                        }
+                        if (!isNowYear && item.getYearmonth().split("-")[0].equals(nowYear)) {
+                            isNowYear = true;
+                            item.setYearmonth(item.getYearmonth().split("-")[0] + "年" + item.getYearmonth().split("-")[1] + "月");
+                        } else {
+                            item.setYearmonth(item.getYearmonth().split("-")[1] + "月");
+                        }
+                    }
+                }
                 int index = 1;
                 for (ApsReportJzProcessPhoto item : list) {
                     item.setId(key + String.format("%02d", index));
@@ -1308,6 +1400,34 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             //近12月份值
             List<ApsReportCastRollPhoto> list = this.baseMapper.selectCastRollPhoto(key);
             if (ObjectUtil.isNotEmpty(list)) {
+                //按日期升序
+                list.sort(Comparator.comparing(a -> DateUtil.parse(a.getYearmonth(), "yyyy-MM")));
+                String nowYear = DateUtil.year(new Date()) + "";
+                //如果第一个月是今年的数据,全年只取月份
+                if (list.get(0).getYearmonth().split("-")[0].equals(nowYear)) {
+                    list.forEach(item -> {
+                        item.setYearmonth(item.getYearmonth().split("-")[1] + "月");
+                    });
+                }
+                //如果第一个月不是今年的,第一个月取年月,第二年第一个月取年月,其余只取月份
+                else {
+                    //判断是否触发今年数据
+                    boolean isNowYear = false;
+                    for (int i = 0; i < list.size(); i++) {
+                        ApsReportCastRollPhoto item = list.get(i);
+                        if (i == 0) {
+                            item.setYearmonth(item.getYearmonth().split("-")[0] + "年" + item.getYearmonth().split("-")[1] + "月");
+                            continue;
+                        }
+                        if (!isNowYear && item.getYearmonth().split("-")[0].equals(nowYear)) {
+                            isNowYear = true;
+                            item.setYearmonth(item.getYearmonth().split("-")[0] + "年" + item.getYearmonth().split("-")[1] + "月");
+                        } else {
+                            item.setYearmonth(item.getYearmonth().split("-")[1] + "月");
+                        }
+                    }
+                }
+
                 int index = 1;
                 for (ApsReportCastRollPhoto item : list) {
                     item.setId(key + String.format("%02d", index));
@@ -1349,7 +1469,7 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
         }
     }
 
-    private void setOrderFinishTrend() throws InterruptedException {
+    private void setOrderFinishTrend() {
         List<ApsReportOrderFinishPhoto> resInsertList = new LinkedList<>();
         //根据工厂分别生成指定数据
         SaveConstans.COMPANY_MAP.forEach((key, value) -> {
@@ -1358,6 +1478,34 @@ public class ApsProductionOrderServiceImpl extends ServiceImpl<ApsProductionOrde
             //近12月值
             List<ApsReportOrderFinishPhoto> list = this.baseMapper.selectOrderFinishPhotoByMonth(key);
             if (ObjectUtil.isNotEmpty(list)) {
+                //按日期升序
+                list.sort(Comparator.comparing(a -> DateUtil.parse(a.getYearmonth(), "yyyy-MM")));
+                String nowYear = DateUtil.year(new Date()) + "";
+                //如果第一个月是今年的数据,全年只取月份
+                if (list.get(0).getYearmonth().split("-")[0].equals(nowYear)) {
+                    list.forEach(item -> {
+                        item.setYearmonth(item.getYearmonth().split("-")[1] + "月");
+                    });
+                }
+                //如果第一个月不是今年的,第一个月取年月,第二年第一个月取年月,其余只取月份
+                else {
+                    //判断是否触发今年数据
+                    boolean isNowYear = false;
+                    for (int i = 0; i < list.size(); i++) {
+                        ApsReportOrderFinishPhoto item = list.get(i);
+                        if (i == 0) {
+                            item.setYearmonth(item.getYearmonth().split("-")[0] + "年" + item.getYearmonth().split("-")[1] + "月");
+                            continue;
+                        }
+                        if (!isNowYear && item.getYearmonth().split("-")[0].equals(nowYear)) {
+                            isNowYear = true;
+                            item.setYearmonth(item.getYearmonth().split("-")[0] + "年" + item.getYearmonth().split("-")[1] + "月");
+                        } else {
+                            item.setYearmonth(item.getYearmonth().split("-")[1] + "月");
+                        }
+                    }
+                }
+
                 int index = 1;
                 for (ApsReportOrderFinishPhoto item : list) {
                     item.setId(key + String.format("%02d", index));