فهرست منبع

应该是解决完所有问题了

wukai 3 هفته پیش
والد
کامیت
b8db316683

+ 14 - 23
jjt-biz/src/main/java/com/jjt/biz/service/impl/ApiServiceImpl.java

@@ -146,8 +146,6 @@ public class ApiServiceImpl implements IApiService {
         List<FormulaTotal> formulaTotal = new ArrayList<>();
         //配方明细数据
         List<FormulaDetail> formulaDetail = new ArrayList<>();
-        //配方记录
-        List<TwinFormulaInfo> formulaInfos = new ArrayList<>();
         //送经量
         List<WarpRunIn> warpList = new ArrayList<>();
         //平方米克重统计数据
@@ -257,26 +255,6 @@ public class ApiServiceImpl implements IApiService {
                 WarpRunIn warpRunIn = new WarpRunIn(isSmall, map);
                 warpList.add(warpRunIn);
 
-                if (isSmall) {
-                    TwinFormulaInfo formulaInfo = new TwinFormulaInfo(map);
-                    formulaInfos.add(formulaInfo);
-
-
-                    for (int i = 0; i < Tools.ALLOW_ALARM.length; i++) {
-                        //允许的告警编号
-                        boolean flag = (boolean) map.get("Alarm_unit_" + Tools.ALLOW_ALARM[i]);
-                        if (flag) {
-                            IndexAlarm indexAlarm = new IndexAlarm();
-                            indexAlarm.setCode(device.getDeviceCode());
-                            indexAlarm.setName(device.getDeviceName());
-                            indexAlarm.setType(i);
-                            alarmList.add(indexAlarm);
-                        }
-                    }
-                } else {
-//                    TwinFormulaInfo formulaInfo = new TwinFormulaInfo(map);
-//                    formulaInfos.add(formulaInfo);
-                }
                 //盘头小于200圈的统计--start
                 int len = 5;
                 if (!isSmall) {
@@ -296,12 +274,25 @@ public class ApiServiceImpl implements IApiService {
                     stopPan++;
                 }
                 //盘头小于200圈的统计--end
+
+                if (isSmall) {
+                    for (int i = 0; i < Tools.ALLOW_ALARM.length; i++) {
+                        //允许的告警编号
+                        boolean flag = (boolean) map.get("Alarm_unit_" + Tools.ALLOW_ALARM[i]);
+                        if (flag) {
+                            IndexAlarm indexAlarm = new IndexAlarm();
+                            indexAlarm.setCode(device.getDeviceCode());
+                            indexAlarm.setName(device.getDeviceName());
+                            indexAlarm.setType(i);
+                            alarmList.add(indexAlarm);
+                        }
+                    }
+                }
             }
         } catch (InterruptedException | ExecutionException e) {
             throw new RuntimeException(e);
         }
 
-        twinFormulaInfoService.update(formulaInfos);
         indexData.setAlarm(alarmList);
         IndexDevice device = new IndexDevice();
         device.setTotal(list.size());

+ 0 - 10
jjt-biz/src/main/java/com/jjt/biz/vo/FormulaDetail.java

@@ -104,16 +104,6 @@ public class FormulaDetail {
     private String yarnF;
     @ApiModelProperty("盘头根数信息")
     private String yarnPt;
-
-    @ApiModelProperty("大经编送经量")
-    private Float[] bigSj;
-
-    @ApiModelProperty("大经编盘头剩余周长")
-    private Float[] bigZc;
-    @ApiModelProperty("大经编盘头剩余圈数")
-    private Integer[] bigQs;
-
-
     public FormulaDetail(boolean isSmall, Map<String, Object> map) {
 
         TwinDevice twinDevice = (TwinDevice) map.get("device");

+ 9 - 11
jjt-biz/src/main/java/com/jjt/order/controller/OrderApiController.java

@@ -1,5 +1,6 @@
 package com.jjt.order.controller;
 
+import com.jjt.biz.vo.GramMassDetail;
 import com.jjt.calc.domain.TwinCalcDay;
 import com.jjt.calc.domain.TwinFormulaInfo;
 import com.jjt.calc.service.ITwinCalcDayService;
@@ -70,12 +71,8 @@ public class OrderApiController extends BaseController {
         List<TwinOrder> orderList = orderService.selectTwinOrderListByDate(start, end);
         //按订单ID分组
         Map<Long, TwinOrder> orderMap = orderList.stream().collect(Collectors.toMap(TwinOrder::getOderId, o -> o));
-        List<TwinFormulaInfo> infos = formulaInfoService.selectTwinFormulaInfoList(new TwinFormulaInfo());
-        LocalDateTime ldt = LocalDateTime.now();
-        Date sd = DateUtils.toDate(LocalDate.now().minusDays(2));
-        if (ldt.getHour() > 7) {
-            sd = DateUtils.toDate(LocalDate.now().minusDays(1));
-        }
+        List<GramMassDetail> infos = redisCache.getCacheObject(CacheConstants.INDEX_GRAM_MASS_DETAIL);
+        Date sd = DateUtils.toDate(LocalDateTime.now().minusHours(7).toLocalDate().minusDays(1));
         List<TwinCalcDay> dayList = dayService.selectTwinCalcDayListByTime(sd, sd);
         //按设备ID分组
         Map<Long, TwinCalcDay> dayMap = dayList.stream().collect(Collectors.toMap(TwinCalcDay::getDeviceId, o -> o));
@@ -149,9 +146,10 @@ public class OrderApiController extends BaseController {
 
         //白柸布库存
         List<VmsStock> stocks = mssqlService.vmsStock();
+        //设备配方信息
+        List<GramMassDetail> infos = redisCache.getCacheObject(CacheConstants.INDEX_GRAM_MASS_DETAIL);
+//        List<TwinFormulaInfo> infos = formulaInfoService.selectTwinFormulaInfoList(new TwinFormulaInfo());
         //当前产量处理
-        List<TwinFormulaInfo> infos = formulaInfoService.selectTwinFormulaInfoList(new TwinFormulaInfo());
-        LocalDateTime ldt = LocalDateTime.now();
         Date sd = DateUtils.toDate(LocalDateTime.now().minusHours(7).toLocalDate().minusDays(1));
         List<TwinCalcDay> dayList = dayService.selectTwinCalcDayListByTime(sd, sd);
         //按设备ID分组
@@ -171,10 +169,10 @@ public class OrderApiController extends BaseController {
                     kc = stock.getQty();
                 }
                 //匹配生产设备
-                List<TwinFormulaInfo> matchFormula = oe.matchFormula(spec, infos);
+                List<GramMassDetail> matchFormula = oe.matchFormula(spec, infos);
                 BigDecimal cl = BigDecimal.ZERO;
-                for (TwinFormulaInfo match : matchFormula) {
-                    TwinCalcDay day = dayMap.get(match.getDeviceId());
+                for (GramMassDetail match : matchFormula) {
+                    TwinCalcDay day = dayMap.get(match.getFormula_data_2());
                     if (day != null) {
                         cl = cl.add(day.getWeight());
                     }

+ 37 - 34
jjt-biz/src/main/java/com/jjt/order/utils/OrderExportUtil.java

@@ -1,5 +1,6 @@
 package com.jjt.order.utils;
 
+import com.jjt.biz.vo.GramMassDetail;
 import com.jjt.calc.domain.TwinCalcDay;
 import com.jjt.calc.domain.TwinFormulaInfo;
 import com.jjt.common.utils.DateUtils;
@@ -41,7 +42,7 @@ public class OrderExportUtil {
         p2.setVerticalAlignment(VerticalAlignment.CENTER);
     }
 
-    public void process(XSSFWorkbook wb, String sheetTitle, List<TwinOrder> orderList, List<TwinFormulaInfo> infos, Map<Long, TwinOrder> orderMap, Map<Long, TwinCalcDay> dayMap, List<VmsStock> stocks, Integer days) {
+    public void process(XSSFWorkbook wb, String sheetTitle, List<TwinOrder> orderList, List<GramMassDetail> infos, Map<Long, TwinOrder> orderMap, Map<Long, TwinCalcDay> dayMap, List<VmsStock> stocks, Integer days) {
         init(wb);
         List<TwinOrderDetail> all = new ArrayList<>();
         orderList.forEach(to -> all.addAll(to.getTwinOrderDetailList().stream().filter(tod -> tod.getBomSpec() != null).collect(Collectors.toList())));
@@ -58,15 +59,15 @@ public class OrderExportUtil {
                 kc = stock.getQty();
             }
             //匹配生产设备
-            List<TwinFormulaInfo> matchFormula = matchFormula(spec, infos);
+            List<GramMassDetail> matchFormula = matchFormula(spec, infos);
             BigDecimal cl = BigDecimal.ZERO;
             String deviceIds = "";
-            for (TwinFormulaInfo match : matchFormula) {
+            for (GramMassDetail match : matchFormula) {
                 if (org.apache.commons.lang3.StringUtils.isNotEmpty(deviceIds)) {
                     deviceIds += ",";
                 }
-                deviceIds += match.getDeviceId();
-                TwinCalcDay day = dayMap.get(match.getDeviceId());
+                deviceIds += match.getFormula_data_2();
+                TwinCalcDay day = dayMap.get(match.getFormula_data_2());
                 if (day != null) {
                     cl = cl.add(day.getWeight());
                 }
@@ -413,29 +414,31 @@ public class OrderExportUtil {
      * @param sheet sheet
      * @param infos 库存
      */
-    public void sheet4(Sheet sheet, List<TwinFormulaInfo> infos) {
+    public void sheet4(Sheet sheet, List<GramMassDetail> infos) {
         AtomicInteger num = new AtomicInteger(3);
-        infos.sort(Comparator.comparing(TwinFormulaInfo::getFd18).reversed().thenComparing(TwinFormulaInfo::getFd16).thenComparing(TwinFormulaInfo::getFd17).thenComparing(TwinFormulaInfo::getFd3));
+        infos.sort(Comparator.comparing(GramMassDetail::getFormula_data_18).reversed().thenComparing(GramMassDetail::getFormula_data_16).thenComparing(GramMassDetail::getFormula_data_17).thenComparing(GramMassDetail::getFormula_data_3));
         infos.forEach(info -> {
             Row row = sheet.createRow(num.getAndIncrement());
             Cell[] cells = new Cell[35];
             for (int i = 0; i < cells.length; i++) {
                 cells[i] = row.createCell(i);
             }
-            cells[0].setCellValue(info.getFd18());
-            cells[1].setCellValue(info.getFd16());
-            cells[2].setCellValue(info.getFd17());
-            cells[3].setCellValue(info.getFd3());
-            cells[4].setCellValue(info.getFd15());
-            cells[5].setCellValue(info.getFd4());
-            cells[6].setCellValue(info.getFd5());
-            cells[7].setCellValue(info.getFd6());
-            cells[8].setCellValue(info.getFd2());
-            cells[9].setCellValue(info.getFd1());
-            cells[10].setCellValue(info.getFd13());
-            cells[11].setCellValue(info.getFd14());
-            cells[12].setCellValue(info.getFd24());
-            cells[13].setCellValue(info.getFd25());
+            cells[0].setCellValue(info.getFormula_data_18());
+            cells[1].setCellValue(info.getFormula_data_16());
+            cells[2].setCellValue(info.getFormula_data_17());
+            cells[3].setCellValue(info.getFormula_data_3());
+            cells[4].setCellValue(info.getFormula_data_15());
+            cells[5].setCellValue(info.getFormula_data_4());
+            cells[6].setCellValue(info.getFormula_data_5());
+            cells[7].setCellValue(info.getFormula_data_6());
+            cells[8].setCellValue(info.getFormula_data_2());
+            cells[9].setCellValue(info.getFormula_data_1());
+            cells[10].setCellValue(info.getFormula_data_13());
+            cells[11].setCellValue(info.getFormula_data_14());
+            cells[12].setCellValue(info.getFormula_data_24());
+            if (info.getFormula_data_25() != null) {
+                cells[13].setCellValue(info.getFormula_data_25());
+            }
 
 //            cells[14].setCellValue(info.getCd10());
 //            cells[15].setCellValue(info.getCd11());
@@ -454,12 +457,12 @@ public class OrderExportUtil {
 //            cells[27].setCellValue(info.getFd22());
 //            cells[28].setCellValue(info.getFd23());
 
-            cells[14].setCellValue(info.getFd7());
-            cells[15].setCellValue(info.getFd8());
-            cells[16].setCellValue(info.getFd9());
-            cells[17].setCellValue(info.getFd10());
-            cells[18].setCellValue(info.getFd11());
-            cells[19].setCellValue(info.getFd12());
+            cells[14].setCellValue(info.getFormula_data_7());
+            cells[15].setCellValue(info.getFormula_data_8());
+            cells[16].setCellValue(info.getFormula_data_9());
+            cells[17].setCellValue(info.getFormula_data_10());
+            cells[18].setCellValue(info.getFormula_data_11());
+            cells[19].setCellValue(info.getFormula_data_12());
         });
     }
 
@@ -533,21 +536,21 @@ public class OrderExportUtil {
      * @param list 产线
      * @return 结果
      */
-    public List<TwinFormulaInfo> matchFormula(String spec, List<TwinFormulaInfo> list) {
-        List<TwinFormulaInfo> result = new ArrayList<>();
+    public List<GramMassDetail> matchFormula(String spec, List<GramMassDetail> list) {
+        List<GramMassDetail> result = new ArrayList<>();
         //按重量分组
-        Map<Float, List<TwinFormulaInfo>> formulaMap = list.stream().collect(Collectors.groupingBy(TwinFormulaInfo::getFd18, LinkedHashMap::new, Collectors.toList()));
+        Map<Float, List<GramMassDetail>> formulaMap = list.stream().collect(Collectors.groupingBy(GramMassDetail::getFormula_data_18, LinkedHashMap::new, Collectors.toList()));
         if (spec != null) {
             String[] tmp = spec.split("\\*");
             if (tmp.length == 3) {
                 Float length = Float.parseFloat(tmp[0]);
                 Float width = Float.parseFloat(tmp[1]);
                 Float weight = Float.parseFloat(tmp[2]);
-                List<TwinFormulaInfo> infos = formulaMap.get(weight);
+                List<GramMassDetail> infos = formulaMap.get(weight);
                 if (infos != null) {
-                    for (TwinFormulaInfo info : infos) {
-                        if (length.equals(info.getFd16()) && width.equals(info.getFd17()) ||
-                                length.equals(info.getFd17()) && width.equals(info.getFd16())) {
+                    for (GramMassDetail info : infos) {
+                        if (length.equals(info.getFormula_data_16()) && width.equals(info.getFormula_data_17()) ||
+                                length.equals(info.getFormula_data_17()) && width.equals(info.getFormula_data_16())) {
                             result.add(info);
                         }
                     }

+ 42 - 40
jjt-biz/src/main/java/com/jjt/order/utils/OrderGsmExportUtil.java

@@ -1,8 +1,9 @@
 package com.jjt.order.utils;
 
+import com.jjt.biz.vo.GramMassDetail;
 import com.jjt.calc.domain.TwinCalcDay;
-import com.jjt.calc.domain.TwinFormulaInfo;
 import com.jjt.common.utils.DateUtils;
+import com.jjt.common.utils.StringUtils;
 import com.jjt.order.domain.TwinOrder;
 import com.jjt.order.domain.TwinOrderDetail;
 import com.jjt.order.domain.VmsStock;
@@ -39,10 +40,9 @@ public class OrderGsmExportUtil {
         p2.setVerticalAlignment(VerticalAlignment.CENTER);
     }
 
-    public void process(XSSFWorkbook wb, String sheetTitle, List<TwinOrder> orderList, List<TwinFormulaInfo> infos, Map<Long, TwinOrder> orderMap, Map<Long, TwinCalcDay> dayMap, List<VmsStock> stocks, Integer days) {
+    public void process(XSSFWorkbook wb, String sheetTitle, List<TwinOrder> orderList, List<GramMassDetail> infos, Map<Long, TwinOrder> orderMap, Map<Long, TwinCalcDay> dayMap, List<VmsStock> stocks, Integer days) {
         init(wb);
-        infos.forEach(info -> info.setGsm());
-        infos.sort(Comparator.comparing(TwinFormulaInfo::getDeviceId));
+        infos.sort(Comparator.comparing(GramMassDetail::getFormula_data_2));
         List<TwinOrderDetail> all = new ArrayList<>();
         orderList.forEach(to -> all.addAll(to.getTwinOrderDetailList().stream().filter(tod -> tod.getBomSpec() != null).collect(Collectors.toList())));
         //按规格分组
@@ -59,15 +59,15 @@ public class OrderGsmExportUtil {
                 kc = stock.getQty();
             }
             //匹配生产设备
-            List<TwinFormulaInfo> matchFormula = matchFormula(spec, infos);
+            List<GramMassDetail> matchFormula = matchFormula(spec, infos);
             BigDecimal cl = BigDecimal.ZERO;
             String deviceIds = "";
-            for (TwinFormulaInfo match : matchFormula) {
-                if (org.apache.commons.lang3.StringUtils.isNotEmpty(deviceIds)) {
+            for (GramMassDetail match : matchFormula) {
+                if (StringUtils.isNotEmpty(deviceIds)) {
                     deviceIds += ",";
                 }
-                deviceIds += match.getDeviceId();
-                TwinCalcDay day = dayMap.get(match.getDeviceId());
+                deviceIds += match.getFormula_data_2();
+                TwinCalcDay day = dayMap.get(match.getFormula_data_2());
                 if (day != null) {
                     cl = cl.add(day.getWeight());
                 }
@@ -419,7 +419,7 @@ public class OrderGsmExportUtil {
      * @param sheet sheet
      * @param infos 库存
      */
-    public void sheet4(Sheet sheet, List<TwinFormulaInfo> infos) {
+    public void sheet4(Sheet sheet, List<GramMassDetail> infos) {
         AtomicInteger num = new AtomicInteger(3);
 //        infos.sort(Comparator.comparing(TwinFormulaInfo::getFd18).reversed().thenComparing(TwinFormulaInfo::getFd16).thenComparing(TwinFormulaInfo::getFd17).thenComparing(TwinFormulaInfo::getFd3));
         infos.forEach(info -> {
@@ -428,21 +428,23 @@ public class OrderGsmExportUtil {
             for (int i = 0; i < cells.length; i++) {
                 cells[i] = row.createCell(i);
             }
-            cells[0].setCellValue(info.getFd2());
-            cells[1].setCellValue(info.getFd18());
-            cells[2].setCellValue(info.getFd16());
-            cells[3].setCellValue(info.getFd17());
-            cells[4].setCellValue(info.getGsm().floatValue());
-            cells[5].setCellValue(info.getFd3());
-            cells[6].setCellValue(info.getFd15());
-            cells[7].setCellValue(info.getFd4());
-            cells[8].setCellValue(info.getFd5());
-            cells[9].setCellValue(info.getFd6());
-            cells[10].setCellValue(info.getFd1());
-            cells[11].setCellValue(info.getFd13());
-            cells[12].setCellValue(info.getFd14());
-            cells[13].setCellValue(info.getFd24());
-            cells[14].setCellValue(info.getFd25());
+            cells[0].setCellValue(info.getFormula_data_2());
+            cells[1].setCellValue(info.getFormula_data_18());
+            cells[2].setCellValue(info.getFormula_data_16());
+            cells[3].setCellValue(info.getFormula_data_17());
+            cells[4].setCellValue(info.getGramMass());
+            cells[5].setCellValue(info.getFormula_data_3());
+            cells[6].setCellValue(info.getFormula_data_15());
+            cells[7].setCellValue(info.getFormula_data_4());
+            cells[8].setCellValue(info.getFormula_data_5());
+            cells[9].setCellValue(info.getFormula_data_6());
+            cells[10].setCellValue(info.getFormula_data_1());
+            cells[11].setCellValue(info.getFormula_data_13());
+            cells[12].setCellValue(info.getFormula_data_14());
+            cells[13].setCellValue(info.getFormula_data_24());
+            if (info.getFormula_data_25() != null) {
+                cells[14].setCellValue(info.getFormula_data_25());
+            }
 
 //            cells[15].setCellValue(info.getCd10());
 //            cells[16].setCellValue(info.getCd11());
@@ -461,12 +463,12 @@ public class OrderGsmExportUtil {
 //            cells[28].setCellValue(info.getFd22());
 //            cells[29].setCellValue(info.getFd23());
 
-            cells[15].setCellValue(info.getFd7());
-            cells[16].setCellValue(info.getFd8());
-            cells[17].setCellValue(info.getFd9());
-            cells[18].setCellValue(info.getFd10());
-            cells[19].setCellValue(info.getFd11());
-            cells[20].setCellValue(info.getFd12());
+            cells[15].setCellValue(info.getFormula_data_7());
+            cells[16].setCellValue(info.getFormula_data_8());
+            cells[17].setCellValue(info.getFormula_data_9());
+            cells[18].setCellValue(info.getFormula_data_10());
+            cells[19].setCellValue(info.getFormula_data_11());
+            cells[20].setCellValue(info.getFormula_data_12());
         });
     }
 
@@ -533,29 +535,29 @@ public class OrderGsmExportUtil {
      * @param list 产线
      * @return 结果
      */
-    private List<TwinFormulaInfo> matchFormula(String spec, List<TwinFormulaInfo> list) {
-        List<TwinFormulaInfo> result = new ArrayList<>();
+    private List<GramMassDetail> matchFormula(String spec, List<GramMassDetail> list) {
+        List<GramMassDetail> result = new ArrayList<>();
         //按平方米克重分组
-        Map<BigDecimal, List<TwinFormulaInfo>> formulaMap = list.stream().collect(Collectors.groupingBy(TwinFormulaInfo::getGsm, LinkedHashMap::new, Collectors.toList()));
+        Map<Float, List<GramMassDetail>> formulaMap = list.stream().collect(Collectors.groupingBy(GramMassDetail::getGramMass, LinkedHashMap::new, Collectors.toList()));
         if (spec != null) {
             String[] tmp = spec.split("\\*");
             if (tmp.length == 3) {
                 Float length = Float.parseFloat(tmp[0]);
                 Float width = Float.parseFloat(tmp[1]);
                 BigDecimal gsm = CalcUtil.calcGsm(spec);
-                List<TwinFormulaInfo> tempList = new ArrayList<>();
-                for (BigDecimal key : formulaMap.keySet()) {
+                List<GramMassDetail> tempList = new ArrayList<>();
+                for (Float key : formulaMap.keySet()) {
                     // 计算 gsm 和 key 的差值
-                    BigDecimal difference = gsm.subtract(key).abs();
+                    BigDecimal difference = gsm.subtract(BigDecimal.valueOf(key)).abs();
                     // 如果差值在正负10之间
                     if (difference.compareTo(new BigDecimal(10)) <= 0) {
                         // 将对应的 VmsStock 列表添加到 tempList 中
                         tempList.addAll(formulaMap.get(key));
                     }
                 }
-                for (TwinFormulaInfo info : tempList) {
-                    if (info.getFd16() >= length && info.getFd17() >= width ||
-                            info.getFd17() >= length && info.getFd16() >= width) {
+                for (GramMassDetail info : tempList) {
+                    if (info.getFormula_data_16() >= length && info.getFormula_data_17() >= width ||
+                            info.getFormula_data_17() >= length && info.getFormula_data_16() >= width) {
                         result.add(info);
                     }
                 }