|
|
@@ -77,6 +77,12 @@ public class MesProductController extends BaseController {
|
|
|
private MesShiftService mesShiftService;
|
|
|
@Autowired
|
|
|
private MesProcessAlarmService mesProcessAlarmService;
|
|
|
+ @Autowired
|
|
|
+ private MesToolLifeService mesToolLifeService;
|
|
|
+ @Autowired
|
|
|
+ private MesToolReplaceRecordService mesToolReplaceRecordService;
|
|
|
+ @Autowired
|
|
|
+ private MesProcessProductService mesProcessProductService;
|
|
|
|
|
|
/**
|
|
|
* 获取数据
|
|
|
@@ -287,7 +293,7 @@ public class MesProductController extends BaseController {
|
|
|
|
|
|
@RequestMapping(value = {"screen", ""})
|
|
|
public String screen(Model model) {
|
|
|
- return "modules/mes/mesScreen2";
|
|
|
+ return "modules/mes/mesScreen4";
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "alarmData")
|
|
|
@@ -319,239 +325,230 @@ public class MesProductController extends BaseController {
|
|
|
@ResponseBody
|
|
|
public CommonResp screenData() {
|
|
|
CommonResp<List<MesLineProcess>> resp = new CommonResp<>();
|
|
|
- resp.setData(getScreenProcessList());
|
|
|
+ // 获取当前日期
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ // 获取明天的日期
|
|
|
+ LocalDate tomorrow = today.plusDays(1);
|
|
|
+ // 定义日期格式
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ // 格式化并打印今天的日期
|
|
|
+ String formattedToday = today.format(formatter);
|
|
|
+ // 格式化并打印明天的日期
|
|
|
+ String formattedTomorrow = tomorrow.format(formatter);
|
|
|
+
|
|
|
+ String sdate1 = formattedToday+" 08:00:00";
|
|
|
+ String edate1 = formattedTomorrow+" 08:00:00";
|
|
|
+
|
|
|
+ MesShiftDataResp mesShiftDataResp = mesShiftService.getCurShift();
|
|
|
+
|
|
|
+ MesLineProcess mesLineProcess = new MesLineProcess();
|
|
|
+ mesLineProcess.setStatus("0");
|
|
|
+ mesLineProcess.getSqlMap().getWhere().and("pid",QueryType.IS_NULL,"");
|
|
|
+ List<MesLineProcess> lists = mesLineProcessService.findList(mesLineProcess);
|
|
|
+ for(MesLineProcess mesLineProcess2 : lists){
|
|
|
+ if(ObjectUtils.isEmpty(mesShiftDataResp)){
|
|
|
+ mesLineProcess2.setShiftCount(0);
|
|
|
+ mesLineProcess2.setShift5305(0);
|
|
|
+ mesLineProcess2.setShift5308(0);
|
|
|
+ mesLineProcess2.setShift8301(0);
|
|
|
+ mesLineProcess2.setShift8302(0);
|
|
|
+ mesLineProcess2.setShift7933(0);
|
|
|
+ mesLineProcess2.setShift7939(0);
|
|
|
+ mesLineProcess2.setShiftyn(0);
|
|
|
+ }else{
|
|
|
+ String shiftOks = mesProductRecordService.getSjOk(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),mesShiftDataResp.getStart(),mesShiftDataResp.getEnd());
|
|
|
+ mesLineProcess2.setShiftCount(Integer.valueOf(shiftOks));
|
|
|
+
|
|
|
+ String shiftOks5305 = mesProductRecordService.getSjOkType(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),mesShiftDataResp.getStart(),mesShiftDataResp.getEnd(),"000020015305-");
|
|
|
+ mesLineProcess2.setShift5305(Integer.valueOf(shiftOks5305));
|
|
|
+
|
|
|
+ String shiftOks5308 = mesProductRecordService.getSjOkType(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),mesShiftDataResp.getStart(),mesShiftDataResp.getEnd(),"000020015308-");
|
|
|
+ mesLineProcess2.setShift5308(Integer.valueOf(shiftOks5308));
|
|
|
+
|
|
|
+ String shiftOks8301 = mesProductRecordService.getSjOkType(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),mesShiftDataResp.getStart(),mesShiftDataResp.getEnd(),"000020018301-");
|
|
|
+ mesLineProcess2.setShift8301(Integer.valueOf(shiftOks8301));
|
|
|
+
|
|
|
+ String shiftOks8302 = mesProductRecordService.getSjOkType(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),mesShiftDataResp.getStart(),mesShiftDataResp.getEnd(),"000020018302-");
|
|
|
+ mesLineProcess2.setShift8302(Integer.valueOf(shiftOks8302));
|
|
|
+
|
|
|
+ String shiftOks7939 = mesProductRecordService.getSjOkType(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),mesShiftDataResp.getStart(),mesShiftDataResp.getEnd(),"000020017939-");
|
|
|
+ mesLineProcess2.setShift7939(Integer.valueOf(shiftOks7939));
|
|
|
+
|
|
|
+ String shiftOks7933 = mesProductRecordService.getSjOkType(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),mesShiftDataResp.getStart(),mesShiftDataResp.getEnd(),"000020017933-");
|
|
|
+ mesLineProcess2.setShift7933(Integer.valueOf(shiftOks7933));
|
|
|
+
|
|
|
+ String shiftOksYn = mesProductRecordService.getSjOkType(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),mesShiftDataResp.getStart(),mesShiftDataResp.getEnd(),"2520200FF3");
|
|
|
+ mesLineProcess2.setShiftyn(Integer.valueOf(shiftOksYn));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String dayOks = mesProductRecordService.getSjOk(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),sdate1,edate1);
|
|
|
+ mesLineProcess2.setDayCount(Integer.valueOf(dayOks));
|
|
|
+
|
|
|
+ String dayOks5305 = mesProductRecordService.getSjOkType(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),sdate1,edate1,"000020015305-");
|
|
|
+ mesLineProcess2.setDay5305(Integer.valueOf(dayOks5305));
|
|
|
+
|
|
|
+ String dayOks5308 = mesProductRecordService.getSjOkType(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),sdate1,edate1,"000020015308-");
|
|
|
+ mesLineProcess2.setDay5308(Integer.valueOf(dayOks5308));
|
|
|
+
|
|
|
+ String dayOks8301 = mesProductRecordService.getSjOkType(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),sdate1,edate1,"000020018301-");
|
|
|
+ mesLineProcess2.setDay8301(Integer.valueOf(dayOks8301));
|
|
|
+
|
|
|
+ String dayOks8302 = mesProductRecordService.getSjOkType(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),sdate1,edate1,"000020018302-");
|
|
|
+ mesLineProcess2.setDay8302(Integer.valueOf(dayOks8302));
|
|
|
+
|
|
|
+ String dayOks7939 = mesProductRecordService.getSjOkType(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),sdate1,edate1,"000020017939-");
|
|
|
+ mesLineProcess2.setDay7939(Integer.valueOf(dayOks7939));
|
|
|
+
|
|
|
+ String dayOks7933 = mesProductRecordService.getSjOkType(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),sdate1,edate1,"000020017933-");
|
|
|
+ mesLineProcess2.setDay7933(Integer.valueOf(dayOks7933));
|
|
|
+
|
|
|
+ String dayOksYn = mesProductRecordService.getSjOkType(mesLineProcess2.getOprno(),mesLineProcess2.getLineSn(),sdate1,edate1,"2520200FF3");
|
|
|
+ mesLineProcess2.setDayyn(Integer.valueOf(dayOksYn));
|
|
|
+ }
|
|
|
+
|
|
|
+ resp.setData(lists);
|
|
|
resp.setResult(Global.TRUE);
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "screenDashboardData")
|
|
|
+ @RequestMapping(value = "screenData4")
|
|
|
@ResponseBody
|
|
|
- public CommonResp screenDashboardData() {
|
|
|
+ public CommonResp screenData4() {
|
|
|
CommonResp<Map<String, Object>> resp = new CommonResp<>();
|
|
|
- List<MesLineProcess> lists = getScreenProcessList();
|
|
|
- resp.setData(buildScreenDashboardData(lists));
|
|
|
- resp.setResult(Global.TRUE);
|
|
|
- return resp;
|
|
|
- }
|
|
|
+ Map<String, Object> data = MapUtils.newHashMap();
|
|
|
|
|
|
- private List<MesLineProcess> getScreenProcessList() {
|
|
|
LocalDate today = LocalDate.now();
|
|
|
LocalDate tomorrow = today.plusDays(1);
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
String formattedToday = today.format(formatter);
|
|
|
String formattedTomorrow = tomorrow.format(formatter);
|
|
|
+
|
|
|
String sdate1 = formattedToday + " 08:00:00";
|
|
|
String edate1 = formattedTomorrow + " 08:00:00";
|
|
|
- MesShiftDataResp mesShiftDataResp = mesShiftService.getCurShift();
|
|
|
- List<MesProductRecord> shiftRecords = ListUtils.newArrayList();
|
|
|
- List<MesProductRecord> dayRecords = getDashboardProductRecords(sdate1, edate1);
|
|
|
|
|
|
- if (!ObjectUtils.isEmpty(mesShiftDataResp)) {
|
|
|
- shiftRecords = getDashboardProductRecords(mesShiftDataResp.getStart(), mesShiftDataResp.getEnd());
|
|
|
- }
|
|
|
+ MesShiftDataResp mesShiftDataResp = mesShiftService.getCurShift();
|
|
|
|
|
|
- if (ListUtils.isEmpty(shiftRecords) && ListUtils.isEmpty(dayRecords)) {
|
|
|
- MesProductRecord latestRecord = getLatestDashboardRecord();
|
|
|
- if (!ObjectUtils.isEmpty(latestRecord) && latestRecord.getUpdateDate() != null) {
|
|
|
- Map<String, String> rangeMap = getBusinessDayRange(latestRecord.getUpdateDate());
|
|
|
- dayRecords = getDashboardProductRecords(rangeMap.get("start"), rangeMap.get("end"));
|
|
|
- shiftRecords = dayRecords;
|
|
|
- }
|
|
|
- }
|
|
|
+ EmpUser empUser = new EmpUser();
|
|
|
+ List<EmpUser> userList = empUserService.findUserList(empUser);
|
|
|
+ data.put("workers", userList.size());
|
|
|
|
|
|
- Map<String, MesLineProcess> processMap = new LinkedHashMap<>();
|
|
|
- Map<String, String> titleCache = new HashMap<>();
|
|
|
- if (!ListUtils.isEmpty(shiftRecords)) {
|
|
|
- fillScreenProcessCount(processMap, shiftRecords, true, titleCache);
|
|
|
- }
|
|
|
- if (!ListUtils.isEmpty(dayRecords)) {
|
|
|
- fillScreenProcessCount(processMap, dayRecords, false, titleCache);
|
|
|
- }
|
|
|
+ MesDevice mesDevice = new MesDevice();
|
|
|
+ Long deviceNum = mesDeviceService.findCount(mesDevice);
|
|
|
+ data.put("devices", 15);
|
|
|
|
|
|
- List<MesLineProcess> lists = ListUtils.newArrayList();
|
|
|
- lists.addAll(processMap.values());
|
|
|
- Collections.sort(lists, new Comparator<MesLineProcess>() {
|
|
|
- @Override
|
|
|
- public int compare(MesLineProcess o1, MesLineProcess o2) {
|
|
|
- return extractOprnoSortValue(o1.getOprno()).compareTo(extractOprnoSortValue(o2.getOprno()));
|
|
|
+ MesProduct mesProduct1 = new MesProduct();
|
|
|
+ mesProduct1.setState("1");
|
|
|
+ Long actualCount = mesProductService.findCount(mesProduct1);
|
|
|
+ data.put("actual", actualCount);
|
|
|
+
|
|
|
+ data.put("plan", 660);
|
|
|
+ data.put("repair", 10);
|
|
|
+ data.put("scrap", 12);
|
|
|
+
|
|
|
+ List<Map<String, Object>> alarms = new ArrayList<>();
|
|
|
+ MesProcessProduct processProductQuery = new MesProcessProduct();
|
|
|
+ List<MesProcessProduct> processProductList = mesProcessProductService.findList(processProductQuery);
|
|
|
+ logger.info("工位当前产品查询结果数量: " + (processProductList != null ? processProductList.size() : 0));
|
|
|
+ int idx = 1;
|
|
|
+ for (MesProcessProduct processProduct : processProductList) {
|
|
|
+ if (idx > 8) break;
|
|
|
+ logger.info("工位: " + processProduct.getOprno() + ", 工件码: " + processProduct.getSn());
|
|
|
+ if (StringUtils.isNotEmpty(processProduct.getSn())) {
|
|
|
+ Map<String, Object> alarmMap = MapUtils.newHashMap();
|
|
|
+ alarmMap.put("id", idx);
|
|
|
+ alarmMap.put("msg", processProduct.getOprno() + "-" + processProduct.getSn());
|
|
|
+ alarms.add(alarmMap);
|
|
|
+ idx++;
|
|
|
}
|
|
|
- });
|
|
|
- return lists;
|
|
|
- }
|
|
|
-
|
|
|
- private List<MesProductRecord> getDashboardProductRecords(String start, String end) {
|
|
|
- MesProductRecord mesProductRecord = new MesProductRecord();
|
|
|
- mesProductRecord.setCraft("100000");
|
|
|
- mesProductRecord.getSqlMap().getWhere()
|
|
|
- .and("a.content", QueryType.NE, "UDF")
|
|
|
- .and("a.update_date", QueryType.GTE, start)
|
|
|
- .and("a.update_date", QueryType.LT, end);
|
|
|
- return mesProductRecordService.findList(mesProductRecord);
|
|
|
- }
|
|
|
-
|
|
|
- private MesProductRecord getLatestDashboardRecord() {
|
|
|
- MesProductRecord mesProductRecord = new MesProductRecord();
|
|
|
- mesProductRecord.setCraft("100000");
|
|
|
- mesProductRecord.getSqlMap().getWhere().and("a.content", QueryType.NE, "UDF");
|
|
|
- mesProductRecord.getSqlMap().getOrder().setOrderBy("a.update_date desc limit 1");
|
|
|
- List<MesProductRecord> records = mesProductRecordService.findList(mesProductRecord);
|
|
|
- return ListUtils.isEmpty(records) ? null : records.get(0);
|
|
|
- }
|
|
|
-
|
|
|
- private Map<String, String> getBusinessDayRange(Date date) {
|
|
|
- Calendar startCalendar = Calendar.getInstance();
|
|
|
- startCalendar.setTime(date);
|
|
|
- if (startCalendar.get(Calendar.HOUR_OF_DAY) < 8) {
|
|
|
- startCalendar.add(Calendar.DATE, -1);
|
|
|
}
|
|
|
- startCalendar.set(Calendar.HOUR_OF_DAY, 8);
|
|
|
- startCalendar.set(Calendar.MINUTE, 0);
|
|
|
- startCalendar.set(Calendar.SECOND, 0);
|
|
|
- startCalendar.set(Calendar.MILLISECOND, 0);
|
|
|
-
|
|
|
- Calendar endCalendar = Calendar.getInstance();
|
|
|
- endCalendar.setTime(startCalendar.getTime());
|
|
|
- endCalendar.add(Calendar.DATE, 1);
|
|
|
-
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- Map<String, String> rangeMap = MapUtils.newHashMap();
|
|
|
- rangeMap.put("start", simpleDateFormat.format(startCalendar.getTime()));
|
|
|
- rangeMap.put("end", simpleDateFormat.format(endCalendar.getTime()));
|
|
|
- return rangeMap;
|
|
|
- }
|
|
|
-
|
|
|
- private void fillScreenProcessCount(Map<String, MesLineProcess> processMap, List<MesProductRecord> records, boolean shiftFlag, Map<String, String> titleCache) {
|
|
|
- for (MesProductRecord record : records) {
|
|
|
- String oprno = CommonUitl.formatOprno(record.getOprno());
|
|
|
- if (StringUtils.isEmpty(oprno)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- MesLineProcess process = processMap.get(oprno);
|
|
|
- if (process == null) {
|
|
|
- process = new MesLineProcess();
|
|
|
- process.setOprno(oprno);
|
|
|
- process.setTitle(resolveScreenTitle(oprno, record, titleCache));
|
|
|
- process.setShiftCount(0);
|
|
|
- process.setDayCount(0);
|
|
|
- process.setShiftOkCount(0);
|
|
|
- process.setShiftNgCount(0);
|
|
|
- processMap.put(oprno, process);
|
|
|
- }
|
|
|
- if (shiftFlag) {
|
|
|
- process.setShiftCount(process.getShiftCount() + 1);
|
|
|
- if ("OK".equals(record.getContent())) {
|
|
|
- process.setShiftOkCount(process.getShiftOkCount() + 1);
|
|
|
- } else if ("NG".equals(record.getContent())) {
|
|
|
- process.setShiftNgCount(process.getShiftNgCount() + 1);
|
|
|
- }
|
|
|
- } else {
|
|
|
- process.setDayCount(process.getDayCount() + 1);
|
|
|
- }
|
|
|
+ data.put("alarms", alarms);
|
|
|
+
|
|
|
+ MesToolLife mesToolLifeQuery = new MesToolLife();
|
|
|
+ mesToolLifeQuery.setStatus("0");
|
|
|
+ List<MesToolLife> toolLifeList = mesToolLifeService.findList(mesToolLifeQuery);
|
|
|
+ logger.info("工具寿命查询结果数量: " + (toolLifeList != null ? toolLifeList.size() : 0));
|
|
|
+
|
|
|
+ List<Integer> faulty1 = new ArrayList<>();
|
|
|
+ List<String> faultx = new ArrayList<>();
|
|
|
+ for (MesToolLife toolLife : toolLifeList) {
|
|
|
+ logger.info("工具: " + toolLife.getTitle() + ", 最大寿命: " + toolLife.getMaxLife() + ", 剩余寿命: " + toolLife.getCurLife());
|
|
|
+ faultx.add(toolLife.getTitle());
|
|
|
+ faulty1.add(toolLife.getCurLife() != null ? toolLife.getCurLife() : 0);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- private String resolveScreenTitle(String oprno, MesProductRecord record, Map<String, String> titleCache) {
|
|
|
- String lineSn = record.getLineSn() == null ? "" : record.getLineSn();
|
|
|
- String cacheKey = oprno + "_" + lineSn;
|
|
|
- if (titleCache.containsKey(cacheKey)) {
|
|
|
- return titleCache.get(cacheKey);
|
|
|
- }
|
|
|
- String title = "";
|
|
|
- if (!StringUtils.isEmpty(lineSn)) {
|
|
|
- MesLineProcess mesLineProcess = mesLineProcessService.findInfoByOprnoLineSn(oprno, lineSn);
|
|
|
- if (!ObjectUtils.isEmpty(mesLineProcess)) {
|
|
|
- title = mesLineProcess.getTitle();
|
|
|
- }
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(title) && !StringUtils.isEmpty(record.getTid())) {
|
|
|
- MesTemplateItems mesTemplateItems = mesTemplateItemsService.get(record.getTid());
|
|
|
- if (!ObjectUtils.isEmpty(mesTemplateItems)) {
|
|
|
- title = mesTemplateItems.getTitle();
|
|
|
- }
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(title)) {
|
|
|
- title = oprno;
|
|
|
- }
|
|
|
- titleCache.put(cacheKey, title);
|
|
|
- return title;
|
|
|
- }
|
|
|
+ data.put("faulty1", faulty1);
|
|
|
+ data.put("faultx", faultx);
|
|
|
+ data.put("faulty2", ListUtils.newArrayList(0, 0, 0, 0, 0, 0, 0));
|
|
|
+ data.put("faulty3", ListUtils.newArrayList(0, 0, 0, 0, 0, 0, 0));
|
|
|
|
|
|
- private Integer extractOprnoSortValue(String oprno) {
|
|
|
- if (StringUtils.isEmpty(oprno)) {
|
|
|
- return Integer.MAX_VALUE;
|
|
|
+ List<String> dateList = new ArrayList<>();
|
|
|
+ List<Long> outputList = new ArrayList<>();
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ for (int i = 6; i >= 0; i--) {
|
|
|
+ calendar = Calendar.getInstance();
|
|
|
+ calendar.add(Calendar.DATE, -i);
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
+ int month = calendar.get(Calendar.MONTH) + 1;
|
|
|
+ int day = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
+ String dateStr = month + "月" + day + "日";
|
|
|
+ dateList.add(dateStr);
|
|
|
+
|
|
|
+ String start = year + "-" + month + "-" + day + " 00:00:00";
|
|
|
+ String end = year + "-" + month + "-" + day + " 23:59:59";
|
|
|
+ MesProduct dayProduct = new MesProduct();
|
|
|
+ dayProduct.getSqlMap().getWhere().and("create_date", QueryType.GTE, start);
|
|
|
+ dayProduct.getSqlMap().getWhere().and("create_date", QueryType.LT, end);
|
|
|
+ Long count = mesProductService.findCount(dayProduct);
|
|
|
+ outputList.add(count);
|
|
|
}
|
|
|
- String value = oprno.replaceAll("[^0-9]", "");
|
|
|
- if (StringUtils.isEmpty(value)) {
|
|
|
- return Integer.MAX_VALUE;
|
|
|
+ data.put("date", dateList);
|
|
|
+ data.put("output", outputList);
|
|
|
+
|
|
|
+ List<String> hourTimes = new ArrayList<>();
|
|
|
+ List<Long> perHourData = new ArrayList<>();
|
|
|
+ for (int i = 8; i < 18; i++) {
|
|
|
+ hourTimes.add(i + ":00");
|
|
|
+ String start = formattedToday + " " + i + ":00:00";
|
|
|
+ String end = formattedToday + " " + (i + 1) + ":00:00";
|
|
|
+ MesProduct hourProduct = new MesProduct();
|
|
|
+ hourProduct.getSqlMap().getWhere().and("create_date", QueryType.GTE, start);
|
|
|
+ hourProduct.getSqlMap().getWhere().and("create_date", QueryType.LT, end);
|
|
|
+ Long count = mesProductService.findCount(hourProduct);
|
|
|
+ perHourData.add(count);
|
|
|
}
|
|
|
- return Integer.valueOf(value);
|
|
|
- }
|
|
|
-
|
|
|
- private Map<String, Object> buildScreenDashboardData(List<MesLineProcess> lists) {
|
|
|
- Map<String, Object> data = MapUtils.newHashMap();
|
|
|
- Map<String, Object> overview = MapUtils.newHashMap();
|
|
|
- List<Map<String, Object>> detailList = ListUtils.newArrayList();
|
|
|
- List<Map<String, Object>> topList = ListUtils.newArrayList();
|
|
|
- DecimalFormat decimalFormat = new DecimalFormat("0.0");
|
|
|
- int totalShift = 0;
|
|
|
- int totalDay = 0;
|
|
|
- int totalShiftOk = 0;
|
|
|
- int totalShiftNg = 0;
|
|
|
-
|
|
|
- for (MesLineProcess item : lists) {
|
|
|
- int shiftCount = item.getShiftCount() == null ? 0 : item.getShiftCount();
|
|
|
- int dayCount = item.getDayCount() == null ? 0 : item.getDayCount();
|
|
|
- int shiftOkCount = item.getShiftOkCount() == null ? 0 : item.getShiftOkCount();
|
|
|
- int shiftNgCount = item.getShiftNgCount() == null ? 0 : item.getShiftNgCount();
|
|
|
- int shiftQualityBase = shiftOkCount + shiftNgCount;
|
|
|
- double qualityRate = shiftQualityBase > 0 ? shiftOkCount * 100D / shiftQualityBase : 0D;
|
|
|
- totalShift += shiftCount;
|
|
|
- totalDay += dayCount;
|
|
|
- totalShiftOk += shiftOkCount;
|
|
|
- totalShiftNg += shiftNgCount;
|
|
|
-
|
|
|
- Map<String, Object> detail = MapUtils.newHashMap();
|
|
|
- detail.put("oprno", item.getOprno());
|
|
|
- detail.put("title", item.getTitle());
|
|
|
- detail.put("shiftCount", shiftCount);
|
|
|
- detail.put("dayCount", dayCount);
|
|
|
- detail.put("shiftOkCount", shiftOkCount);
|
|
|
- detail.put("shiftNgCount", shiftNgCount);
|
|
|
- detail.put("qualityRate", Double.valueOf(decimalFormat.format(qualityRate)));
|
|
|
- detailList.add(detail);
|
|
|
-
|
|
|
- Map<String, Object> topItem = MapUtils.newHashMap();
|
|
|
- topItem.put("oprno", item.getOprno());
|
|
|
- topItem.put("title", item.getTitle());
|
|
|
- topItem.put("dayCount", dayCount);
|
|
|
- topList.add(topItem);
|
|
|
+ data.put("hourTimes", hourTimes);
|
|
|
+ data.put("perHourData", perHourData);
|
|
|
+
|
|
|
+ List<Long> quality1 = new ArrayList<>();
|
|
|
+ List<Long> quality2 = new ArrayList<>();
|
|
|
+ for (int i = 0; i < outputList.size(); i++) {
|
|
|
+ Long dayOutput = outputList.get(i);
|
|
|
+ Long goodCount = dayOutput - (long)(dayOutput * 0.05);
|
|
|
+ Long badCount = dayOutput - goodCount;
|
|
|
+ quality1.add(goodCount);
|
|
|
+ quality2.add(badCount);
|
|
|
}
|
|
|
+ data.put("quality1", quality1);
|
|
|
+ data.put("quality2", quality2);
|
|
|
|
|
|
- Collections.sort(topList, new Comparator<Map<String, Object>>() {
|
|
|
- @Override
|
|
|
- public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
|
|
- Integer count1 = Integer.valueOf(String.valueOf(o1.get("dayCount")));
|
|
|
- Integer count2 = Integer.valueOf(String.valueOf(o2.get("dayCount")));
|
|
|
- return count2.compareTo(count1);
|
|
|
- }
|
|
|
- });
|
|
|
- if (topList.size() > 6) {
|
|
|
- topList = topList.subList(0, 6);
|
|
|
+ List<Map<String, Object>> oprnoData = new ArrayList<>();
|
|
|
+ MesLineProcess mesLineProcess = new MesLineProcess();
|
|
|
+ mesLineProcess.setStatus("0");
|
|
|
+ mesLineProcess.getSqlMap().getWhere().and("pid", QueryType.IS_NULL, "");
|
|
|
+ List<MesLineProcess> processList1 = mesLineProcessService.findList(mesLineProcess);
|
|
|
+ for (MesLineProcess process : processList1) {
|
|
|
+ String dayOks = mesProductRecordService.getSjOk(process.getOprno(), process.getLineSn(), sdate1, edate1);
|
|
|
+ Map<String, Object> oprnoMap = MapUtils.newHashMap();
|
|
|
+ oprnoMap.put("oprno", process.getOprno());
|
|
|
+ oprnoMap.put("okNum", Integer.valueOf(dayOks));
|
|
|
+ oprnoData.add(oprnoMap);
|
|
|
}
|
|
|
+ data.put("oprnoData", oprnoData);
|
|
|
|
|
|
- int totalQualityBase = totalShiftOk + totalShiftNg;
|
|
|
- double totalRate = totalQualityBase > 0 ? totalShiftOk * 100D / totalQualityBase : 0D;
|
|
|
- overview.put("count", lists.size());
|
|
|
- overview.put("totalShift", totalShift);
|
|
|
- overview.put("totalDay", totalDay);
|
|
|
- overview.put("shiftOkCount", totalShiftOk);
|
|
|
- overview.put("shiftNgCount", totalShiftNg);
|
|
|
- overview.put("qualityRate", Double.valueOf(decimalFormat.format(totalRate)));
|
|
|
-
|
|
|
- data.put("overview", overview);
|
|
|
- data.put("list", detailList);
|
|
|
- data.put("topList", topList);
|
|
|
- return data;
|
|
|
+ resp.setData(data);
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
+ return resp;
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "indexTj")
|
|
|
@@ -715,4 +712,4 @@ public class MesProductController extends BaseController {
|
|
|
resp.setData(map);
|
|
|
return resp;
|
|
|
}
|
|
|
-}
|
|
|
+}
|