|
|
|
@ -321,8 +321,8 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
"\n" +
|
|
|
|
|
"UNION\n" +
|
|
|
|
|
"SELECT\n" +
|
|
|
|
|
"\tmprnc.out_part_no part_no,\n" +
|
|
|
|
|
"\tmprnc.equipment_code ,\n" +
|
|
|
|
|
"\teqcount.part_no,\n" +
|
|
|
|
|
"\teqcount.equipment_code ,\n" +
|
|
|
|
|
"\tme.equipment_name ,\n" +
|
|
|
|
|
"\tme.work_cell_code ,\n" +
|
|
|
|
|
"\tme.work_center_code ,\n" +
|
|
|
|
@ -331,8 +331,8 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
"\t null error_reason \n" +
|
|
|
|
|
"FROM\n" +
|
|
|
|
|
"\tmes_prod_rule_nosort_cfg mprnc\n" +
|
|
|
|
|
"\tLEFT JOIN mes_wc_equipment me ON mprnc.equipment_code = me.equipment_code and me.is_deleted = 2 and me.is_valid = 1 \n" +
|
|
|
|
|
"\tLEFT JOIN (\n" +
|
|
|
|
|
"\tRIGHT JOIN mes_wc_equipment me ON mprnc.equipment_code = me.equipment_code and me.is_deleted = 2 and me.is_valid = 1 \n" +
|
|
|
|
|
"\tRIGHT JOIN (\n" +
|
|
|
|
|
"\tSELECT\n" +
|
|
|
|
|
"\t\tequipment_code,\n" +
|
|
|
|
|
"\t\tpart_no,\n" +
|
|
|
|
@ -349,11 +349,12 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
"\t\t\t\t) detail_count \n" +
|
|
|
|
|
"\t\t\tFROM\n" +
|
|
|
|
|
"\t\t\t\tmes_product_record_log \n" +
|
|
|
|
|
"\t\t\tWHERE 1 = 1 \n";
|
|
|
|
|
"\t\t\tWHERE 1 = 1 and equipment_code not like '%HT%' \n";
|
|
|
|
|
if (!StringUtils.isEmpty(productAccountModel.getEquipmentCode())) {
|
|
|
|
|
sqlStr += "\t\t\t and equipment_code = :equipmentCode \n";
|
|
|
|
|
} if (!StringUtils.isEmpty(productAccountModel.getPartNo())) {
|
|
|
|
|
sqlStr += "\t\t\t and part_no= :partNo \n";
|
|
|
|
|
sqlStr += " and part_no like '%' :partNo '%' ";
|
|
|
|
|
|
|
|
|
|
} if (!StringUtils.isEmpty(productAccountModel.getStartTime())) {
|
|
|
|
|
sqlStr += "\t\t\t and create_date_time >= :startTime \n";
|
|
|
|
|
} if (!StringUtils.isEmpty(productAccountModel.getEndTime())) {
|
|
|
|
@ -366,16 +367,16 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
"\t\t\t\tequipment_code,\n" +
|
|
|
|
|
"\t\t\t\tpart_no \n" +
|
|
|
|
|
"\t\t\t) eqcount ON mprnc.equipment_code = eqcount.equipment_code \n" +
|
|
|
|
|
"\t AND mprnc.out_part_no = eqcount.part_no where 1=1 ";
|
|
|
|
|
"\t AND mprnc.out_part_no = eqcount.part_no where eqcount.equipment_code not LIKE '%HT%' ";
|
|
|
|
|
if (!StringUtils.isEmpty(productAccountModel.getEquipmentCode())) {
|
|
|
|
|
sqlStr += "and mprnc.equipment_code= :equipmentCode ";
|
|
|
|
|
sqlStr += "and eqcount.equipment_code= :equipmentCode ";
|
|
|
|
|
}
|
|
|
|
|
sqlStr += "\tand eqcount.product_count is not null and eqcount.detail_count is not null ) mpr \n" +
|
|
|
|
|
"\t\n" +
|
|
|
|
|
"\tleft join mes_equipment me\n" +
|
|
|
|
|
"\ton mpr.equipment_code = me.equipment_code\n" +
|
|
|
|
|
"\n" +
|
|
|
|
|
"where mpr.product_count != 0 and mpr.detail_count != 0\n" +
|
|
|
|
|
"where (mpr.product_count != 0 or mpr.detail_count != 0)\n" +
|
|
|
|
|
"and me.equipment_type = 10 order by me.equipment_code asc";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -544,7 +545,7 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
List<MesProductAccountResModel> partitionList = partition(mesProductAccountResModels, pager.getPageSize(), pager.getCurrentPage());
|
|
|
|
|
for (MesProductAccountResModel mesProductAccountResModel : partitionList) {
|
|
|
|
|
boolean isErrorCount = false;
|
|
|
|
|
int size = mesProductAccountResModel.getPartNo().split(",").length;
|
|
|
|
|
int size = mesProductAccountResModel.getPartNo().split(",").length == 1 ? mesProductAccountResModel.getPartNo().split(";").length : 1;
|
|
|
|
|
int productCount = Integer.valueOf(mesProductAccountResModel.getProductCount());
|
|
|
|
|
int detailCount = Integer.valueOf(mesProductAccountResModel.getDetailCount());
|
|
|
|
|
if (detailCount * size > productCount) {
|
|
|
|
@ -562,6 +563,10 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
|
|
|
|
|
DdlPreparedPack.getOrderBy("createDatetime", CommonEnumUtil.ASC_OR_DESC.ASC.getValue(), packBean);
|
|
|
|
|
List<MesProductRecordLog> recordLogs = mesProductRecordLogRepository.findByHqlWhere(packBean);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mesProductAccountResModel.getEquipmentCode().contains("HT")) {
|
|
|
|
|
// 1 判断2个 shotcount之间有没有加工记录,如果没有,就需要看 设备是不是192,然后看是否是网络原因
|
|
|
|
|
|
|
|
|
@ -584,16 +589,17 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
int result = 0;
|
|
|
|
|
String startTime = "";
|
|
|
|
|
String endTime = "";
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
String reason = "";
|
|
|
|
|
String reasonOffline = "【%s】到【%s】,客户端下线,导致【%s】个完成信号丢失";
|
|
|
|
|
String reasonQuality = "【%s】到【%s】设备信号质量为0,导致【%s】个完成信号丢失";
|
|
|
|
|
String reasonBypass = "【%s】到【%s】设备打BYPASS,导致【%s】个完成信号丢失";
|
|
|
|
|
String reasonOffline = "因其他原因:系统,网络,发版等,导致【%s】的完成信号丢失【%s】个;";
|
|
|
|
|
String reasonQuality = "【%s】设备信号质量为0,导致【%s】个完成信号丢失;";
|
|
|
|
|
String reasonBypass = "【%s】设备打BYPASS,导致【%s】个完成信号丢失;";
|
|
|
|
|
boolean bypassFlag = false;
|
|
|
|
|
|
|
|
|
|
List<String> finishList = Stream.of("Product_finish","Part_Finish").collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
for (MesProductRecordLog recordLog : recordLogs) {
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
|
|
|
|
|
if (Objects.equal(recordLog.getCategoryLevelTwo(), "BYPASS")) {
|
|
|
|
|
if (Objects.equal(recordLog.getEquipVariableValue(), "True")) {
|
|
|
|
|
if (StringUtils.isEmpty(startTime)) {
|
|
|
|
@ -613,7 +619,7 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
}
|
|
|
|
|
if (bypassFlag && recordLog.getType().equals("record")) {
|
|
|
|
|
errorCount ++;
|
|
|
|
|
reason = String.format(reasonBypass,startTime, endTime, errorCount +"");
|
|
|
|
|
reason += String.format(reasonBypass,startTime, errorCount +"");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -631,9 +637,9 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
errorCount ++;
|
|
|
|
|
endTime = recordLog.getCreateDatetime();
|
|
|
|
|
if (Objects.equal(recordLog.getQuality(), "192")) {
|
|
|
|
|
reason = String.format(reasonOffline,startTime, endTime, errorCount +"");
|
|
|
|
|
reason += String.format(reasonOffline,startTime, errorCount +"");
|
|
|
|
|
} else {
|
|
|
|
|
reason = String.format(reasonQuality,startTime, endTime, errorCount +"");
|
|
|
|
|
reason += String.format(reasonQuality,startTime, errorCount +"");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (recordLog.getType().equals("record")) {
|
|
|
|
@ -646,47 +652,64 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
|
|
|
|
|
private String handleNotHTAndHasRelease(List<MesProductRecordLog> recordLogs) {
|
|
|
|
|
int result = 0;
|
|
|
|
|
// 定义有问题的开始时间
|
|
|
|
|
String startTime = "";
|
|
|
|
|
// 定义有问题的结束时间
|
|
|
|
|
String endTime = "";
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
// 错误个数
|
|
|
|
|
// 异常原因
|
|
|
|
|
String reason = "";
|
|
|
|
|
String reasonOffline = "【%s】到【%s】,客户端下线,导致【%s】个完成信号丢失";
|
|
|
|
|
String reasonQuality = "【%s】到【%s】设备信号质量为0,导致【%s】个完成信号丢失";
|
|
|
|
|
String reasonBypass = "【%s】到【%s】设备打BYPASS,导致【%s】个完成信号丢失";
|
|
|
|
|
String releaseBypass = "【%s】到【%s】设备在MES没有发允许加工指令的情况下,给了【%s】个完成信号";
|
|
|
|
|
String reasonOffline = "因其他原因:系统,网络,发版等,导致【%s】的完成信号丢失【%s】个;";
|
|
|
|
|
|
|
|
|
|
//String reasonOffline = "【%s】,客户端下线,导致【%s】个完成信号丢失";
|
|
|
|
|
String reasonQuality = "【%s】设备信号质量为0,导致【%s】个完成信号丢失;";
|
|
|
|
|
String reasonBypass = "【%s】设备打BYPASS,导致【%s】个完成信号丢失;";
|
|
|
|
|
String releaseBypass = "【%s】设备在MES没有发允许加工指令的情况下,给了【%s】个完成信号;";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// BYPASS 默认fasle
|
|
|
|
|
boolean bypassFlag = false;
|
|
|
|
|
// release 默认false
|
|
|
|
|
boolean releaseFlag = false;
|
|
|
|
|
|
|
|
|
|
//List<String> finishList = Stream.of("Product_finish","PART_OK","Part_Finish","Product_OK").collect(Collectors.toList());
|
|
|
|
|
List<String> finishList = Stream.of("Product_finish","Part_Finish").collect(Collectors.toList());
|
|
|
|
|
String singleReason = "";
|
|
|
|
|
|
|
|
|
|
for (MesProductRecordLog recordLog : recordLogs) {
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
|
|
|
|
|
// BYPASS 逻辑开始
|
|
|
|
|
// 第一次遇到BYPASS = true, 取下开始时间,后面的加工记录一直增加errorCount 直到出现 BYPASS = FALSE,
|
|
|
|
|
if (Objects.equal(recordLog.getCategoryLevelTwo(), "BYPASS") && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
|
|
|
|
|
if (StringUtils.isEmpty(startTime)) {
|
|
|
|
|
startTime = recordLog.getCreateDatetime();
|
|
|
|
|
}
|
|
|
|
|
startTime = recordLog.getCreateDatetime();
|
|
|
|
|
|
|
|
|
|
endTime = recordLog.getCreateDatetime();
|
|
|
|
|
// 每次都取反,第一次是打开,那第二次就是关闭了
|
|
|
|
|
bypassFlag = !bypassFlag;
|
|
|
|
|
if (!bypassFlag) {
|
|
|
|
|
errorCount = 0;
|
|
|
|
|
}
|
|
|
|
|
bypassFlag = true;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (bypassFlag && recordLog.getType().equals("record")) {
|
|
|
|
|
errorCount ++;
|
|
|
|
|
reason = String.format(reasonBypass,startTime, endTime, errorCount +"");
|
|
|
|
|
singleReason += String.format(reasonBypass,startTime, errorCount +"");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (bypassFlag && Objects.equal(recordLog.getCategoryLevelTwo(), "BYPASS") && Objects.equal(recordLog.getEquipVariableValue(), "False")) {
|
|
|
|
|
endTime = recordLog.getCreateDatetime();
|
|
|
|
|
reason += singleReason + ";";
|
|
|
|
|
singleReason = "";
|
|
|
|
|
errorCount = 0;
|
|
|
|
|
bypassFlag = false;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!releaseFlag) {
|
|
|
|
|
if (finishList.contains(recordLog.getCategoryLevelTwo()) && Objects.equal(recordLog.getEquipVariableValue(), "True")) { startTime = recordLog.getCreateDatetime();
|
|
|
|
|
errorCount ++;
|
|
|
|
|
reason += String.format(releaseBypass, startTime, errorCount + "");
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// BYPASS 逻辑结束 result = 1 代表一个成功新型号,遇到一个加工记录就会-1 变成0
|
|
|
|
|
if (result == 0) {
|
|
|
|
|
if (Objects.equal(recordLog.getCategoryLevelTwo(), "Work_Allow") && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
|
|
|
|
|
releaseFlag = true;
|
|
|
|
@ -702,22 +725,19 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if (finishList.contains(recordLog.getCategoryLevelTwo()) && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
|
|
|
|
|
if (StringUtils.isEmpty(startTime)) {
|
|
|
|
|
startTime = recordLog.getCreateDatetime();
|
|
|
|
|
}
|
|
|
|
|
startTime = recordLog.getCreateDatetime();
|
|
|
|
|
|
|
|
|
|
errorCount ++;
|
|
|
|
|
endTime = recordLog.getCreateDatetime();
|
|
|
|
|
if (!releaseFlag) {
|
|
|
|
|
reason = String.format(releaseBypass,startTime, endTime, errorCount +"");
|
|
|
|
|
if (Objects.equal(recordLog.getQuality(), "192")) {
|
|
|
|
|
reason += String.format(reasonOffline,startTime, errorCount +"");
|
|
|
|
|
} else {
|
|
|
|
|
if (Objects.equal(recordLog.getQuality(), "192")) {
|
|
|
|
|
reason = String.format(reasonOffline,startTime, endTime, errorCount +"");
|
|
|
|
|
} else {
|
|
|
|
|
reason = String.format(reasonQuality,startTime, endTime, errorCount +"");
|
|
|
|
|
}
|
|
|
|
|
reason += String.format(reasonQuality,startTime, errorCount +"");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (recordLog.getType().equals("record")) {
|
|
|
|
|
releaseFlag = false;
|
|
|
|
|
result --;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -729,12 +749,13 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
int result = 0;
|
|
|
|
|
String startTime = "";
|
|
|
|
|
String endTime = "";
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
String reason = "";
|
|
|
|
|
String reasonOffline = "【%s】到【%s】,客户端下线,导致【%s】个完成信号丢失";
|
|
|
|
|
String reasonQuality = "【%s】到【%s】设备信号质量为0,导致【%s】个完成信号丢失";
|
|
|
|
|
String reasonOffline = "因其他原因:系统,网络,发版等,导致【%s】的完成信号丢失【%s】个;";
|
|
|
|
|
String reasonQuality = "【%s】设备信号质量为0,导致【%s】个完成信号丢失;";
|
|
|
|
|
|
|
|
|
|
for (MesProductRecordLog recordLog : recordLogs) {
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
|
|
|
|
|
if (result == 0) {
|
|
|
|
|
if (!Objects.equal(recordLog.getCategoryLevelTwo(),"shot_counter") ) {
|
|
|
|
|
continue;
|
|
|
|
@ -744,15 +765,14 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (Objects.equal(recordLog.getCategoryLevelTwo(),"shot_counter") && recordLog.getEquipVariableValue().compareTo("0") > 0) {
|
|
|
|
|
if (StringUtils.isEmpty(startTime)) {
|
|
|
|
|
startTime = recordLog.getCreateDatetime();
|
|
|
|
|
}
|
|
|
|
|
startTime = recordLog.getCreateDatetime();
|
|
|
|
|
|
|
|
|
|
errorCount ++;
|
|
|
|
|
endTime = recordLog.getCreateDatetime();
|
|
|
|
|
if (Objects.equal(recordLog.getQuality(), "192")) {
|
|
|
|
|
reason = String.format(reasonOffline,startTime, endTime, errorCount +"");
|
|
|
|
|
reason += String.format(reasonOffline,startTime, errorCount +"");
|
|
|
|
|
} else {
|
|
|
|
|
reason = String.format(reasonQuality,startTime, endTime, errorCount +"");
|
|
|
|
|
reason += String.format(reasonQuality,startTime, errorCount +"");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (recordLog.getType().equals("record")) {
|
|
|
|
@ -768,6 +788,7 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
List<List<MesProductAccountResModel>> partition = Lists.partition(list, pageSize);
|
|
|
|
|
// 总页数
|
|
|
|
|
int pages = partition.size();
|
|
|
|
|
pageNum = pageNum -1;
|
|
|
|
|
pageNum = pageNum <= 0 ? 0 : (pageNum <= (pages - 1) ? pageNum : (pages - 1));
|
|
|
|
|
return partition.get(pageNum);
|
|
|
|
|
}
|
|
|
|
|