对账单信息

tags/yfai-mes-ext-v2.1
xiangwei.zhang 7 months ago
parent 20690c2ae2
commit d6a9d33105

@ -68,15 +68,19 @@ public class MesAccountJob extends BaseMesScheduleJob {
public void executeMesJob(JobExecutionContext context, ApplicationProperties applicationProperties) {
JSONObject jsonObject = new JSONObject();
String json = this.getJobParam();
//String json = "{\"startTime\":\"2024-09-13 07:50:00\",\"endTime\":\"2024-09-19 08:00:00\"}";
com.alibaba.fastjson.JSONObject reqJson = com.alibaba.fastjson.JSONObject.parseObject(json);
String startDateTime = reqJson.getString("startTime");
String endDateTime = reqJson.getString("endTime");
if (reqJson == null || (StringUtils.isEmpty(startDateTime) && StringUtils.isEmpty(endDateTime))) {
//String json = "{\"startTime\":\"2024-09-25 08:00:00\",\"endTime\":\"2024-09-26 08:00:00\"}";
String startDateTime = "";
String endDateTime = "";
if (StringUtils.isEmpty(json)) {
Date yesterday = TimeTool.getDateBefore(new Date(), 1);
startDateTime = FORMAT_YYYY_MM_DD.format(yesterday) + " " + " 07:50:00";
endDateTime = TimeTool.getToday() + " 08:00:00";
} else {
com.alibaba.fastjson.JSONObject reqJson = com.alibaba.fastjson.JSONObject.parseObject(json);
startDateTime = reqJson.getString("startTime");
endDateTime = reqJson.getString("endTime");
}
jsonObject.putIfAbsent("organizeCode", "CK01");
@ -96,7 +100,7 @@ public class MesAccountJob extends BaseMesScheduleJob {
//String endDateTime = TimeTool.getToday() + " 08:00:00";
//String startDateTime = "2024-09-14 07:50:00";
//String endDateTime = "2024-09-15 08:00:00";
//List<String> list = Stream.of("A88_EOL_Electric_inspection").collect(Collectors.toList());
//List<String> list = Stream.of("HT2800MIX").collect(Collectors.toList());
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
//DdlPreparedPack.getInPackList(list, "equipmentCode", ddlPackBean);
DdlPreparedPack.getNumEqualPack(10, "equipmentType", ddlPackBean);
@ -148,10 +152,13 @@ public class MesAccountJob extends BaseMesScheduleJob {
}
for (MesProductRecordLog log : recordLogs) {
if (!StringUtils.isEmpty(log.getPartNo()) && log.getEquipVariableName() != null
/*if (log.getId() == 1288497096009187355l) {
int i = 1;
}*/
/*if (!StringUtils.isEmpty(log.getPartNo()) && log.getEquipVariableName() != null
&& !log.getEquipVariableName().contains("InjDataSeries")) {
continue;
}
}*/
if (log.getType().equals("logdetail") && log.getEquipVariableName().contains("InjDataSeries")) {
if (StringUtils.isEmpty(log.getEquipVariableValue())) {
continue;

@ -44,7 +44,7 @@ public class MesEquipmentSpotCheckDetailService extends BaseMesService<MesEquipm
DdlPreparedPack.getNumEqualPack(bean.getDataType(), "dataType", packBean);
DdlPreparedPack.getNumEqualPack(bean.getSpotCheckItemType(), "spotCheckItemType", packBean);
//43100 设备点检设置明细导入完成后,期望序列号可以正排
packBean.setOrderByStr(" order by seqCode ");
packBean.setOrderByStr(" order by convert(spot_check_item_code, SIGNED) ");
}

@ -20,6 +20,7 @@ import org.apache.shiro.util.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@ -76,6 +77,9 @@ public class MesPartInspectionService extends BaseMesService<MesPartInspection>
String inventoryLocationCode = bean.getInventoryLocationCode();
List<String> collect = orgList.stream().filter(o->o.getInventoryLocationCode().equals(inventoryLocationCode))
.map(MesOrg::getResponsibleParty).collect(Collectors.toList());
if (CollectionUtils.isEmpty(collect) || collect.get(0) == null) {
return new ListPager<>(new ArrayList<>(), pager);
}
DdlPreparedPack.getInPackList(collect,"responsibleParty", packBean);
}
}

@ -319,6 +319,17 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
"\n" +
"\n" +
"UNION\n" +
"select \n" +
"eqcount.part_no,\n" +
"eqcount.equipment_code,\n" +
"me.equipment_name,\n" +
"me.work_cell_code,\n" +
"me.work_center_code,\n" +
"eqcount.product_count,\n" +
"eqcount.detail_count,\n" +
"eqcount.error_reason\n" +
"\n" +
"from (" +
"SELECT\n" +
"\teqcount.part_no,\n" +
"\teqcount.equipment_code ,\n" +
@ -370,11 +381,14 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
if (!StringUtils.isEmpty(productAccountModel.getEquipmentCode())) {
sqlStr += "and eqcount.equipment_code= :equipmentCode ";
}
sqlStr += "\tand eqcount.product_count is not null and eqcount.detail_count is not null ) mpr \n" +
sqlStr += "\tand eqcount.product_count is not null and eqcount.detail_count is not null " +
") eqcount \t \n" +
"left join mes_wc_equipment me ON eqcount.equipment_code = me.equipment_code and me.is_deleted = 2 and me.is_valid = 1 "+
") mpr \n" +
"\t\n" +
"\tleft join mes_equipment me\n" +
"\ton mpr.equipment_code = me.equipment_code\n" +
"\n" +
"\t " +
"where (mpr.product_count != 0 or mpr.detail_count != 0)\n" +
"and me.equipment_type = 10 order by me.equipment_code asc";
@ -597,7 +611,7 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
return partitionList;
}
private String handleNotHT(List<MesProductRecordLog> recordLogs) {
/*private String handleNotHT(List<MesProductRecordLog> recordLogs) {
int result = 0;
String startTime = "";
String endTime = "";
@ -614,9 +628,9 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
for (MesProductRecordLog recordLog : recordLogs) {
int errorCount = 0;
/*if (recordLog.getId() ==1834566428726444032l) {
if (recordLog.getId() == 1838536402558042112l) {
int a = 1;
}*/
}
if (Objects.equal(recordLog.getType(), "monitor") && recordLog.getMessage().contains("客户端下线")) {
startTime = recordLog.getCreateDatetime();
offlineFlag = true;
@ -625,8 +639,9 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
if (Objects.equal(recordLog.getType(), "monitor") && recordLog.getMessage().contains("客户端上线") ) {
endTime = recordLog.getCreateDatetime();
offlineFlag = false;
if (errorCount > 0) {
reason += String.format(offlineReason, startTime, endTime, errorCount + "");
if (result > 0) {
reason += String.format(offlineReason, startTime, endTime, 1 + "");
result = 0;
errorCount = 0;
}
//result = 0;
@ -690,6 +705,158 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
}
}
}
// 如果走到最后,还有预编译的错误,则直接加上
if (!StringUtils.isEmpty(preReason)) {
reason += preReason;
}
return reason;
}*/
private String handleNotHT(List<MesProductRecordLog> recordLogs) {
int result = 0;
// 定义有问题的开始时间
String startTime = "";
// 定义有问题的结束时间
String endTime = "";
// 错误个数
// 异常原因
String reason = "";
String reasonOffline = "因其他原因:系统,网络,发版等,导致【%s】的完成信号丢失;";
String offlineReason = "【%s】到【%s】,客户端下线,导致【%s】个完成信号丢失;";
String reasonQuality = "【%s】设备信号质量为0视为无效;";
String reasonBypass = "【%s】的完成信号,设备打BYPASS,视为无效;";
// BYPASS 默认fasle
boolean bypassFlag = false;
// BYPASS 默认fasle
boolean offlineFlag = 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 preReason = "";
for (MesProductRecordLog recordLog : recordLogs) {
int errorCount = 0;
if (recordLog.getId() ==1838536264741601280l) {
int a = 1;
}
if (Objects.equal(recordLog.getType(), "monitor") && recordLog.getMessage().contains("客户端下线")) {
startTime = recordLog.getCreateDatetime();
offlineFlag = true;
continue;
}
if (Objects.equal(recordLog.getType(), "monitor") && recordLog.getMessage().contains("客户端上线") ) {
endTime = recordLog.getCreateDatetime();
offlineFlag = false;
if (result > 0) {
reason += String.format(offlineReason, startTime, endTime, 1 + "");
preReason = "";
result = 0;
errorCount = 0;
}
//result = 0;
continue;
}
// 如果是bypass 遇到的所有加工完成指令 都计数并且原因是bypass导致
if (bypassFlag && finishList.contains(recordLog.getCategoryLevelTwo()) && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
if (!StringUtils.isEmpty(preReason)) {
reason += preReason;
}
preReason = String.format(reasonBypass,startTime, 1 +"");
//reason += String.format(reasonBypass,startTime, 1 +"");
continue;
}
if (offlineFlag && finishList.contains(recordLog.getCategoryLevelTwo()) && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
// 如果经过了1个finish然后再经过客户端下线再遇到finish则认为是客户端下线引起,如果没有需要预处理一个下线的原因
errorCount ++;
if (result > 0) {
reason += preReason;
preReason = String.format(offlineReason, endTime, recordLog.getCreateDatetime(), errorCount + "");
endTime = recordLog.getCreateDatetime();
continue;
} else {
endTime = recordLog.getCreateDatetime();
preReason = String.format(offlineReason, startTime,endTime, errorCount + "");
}
result++;
continue ;
}
if (Objects.equal(recordLog.getCategoryLevelTwo(), "BYPASS") && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
// 如果有finish然后遇到bypass 需要预处理
if (result > 0) {
reason += String.format(reasonBypass,startTime, 1 +"");
result = 0;
}
startTime = recordLog.getCreateDatetime();
endTime = recordLog.getCreateDatetime();
bypassFlag = true;
continue;
}
// 遇到bypass = false 则重置错误次数
if (bypassFlag && Objects.equal(recordLog.getCategoryLevelTwo(), "BYPASS") && Objects.equal(recordLog.getEquipVariableValue(), "False")) {
endTime = recordLog.getCreateDatetime();
errorCount = 0;
bypassFlag = false;
continue;
}
// BYPASS 逻辑结束 result = 1 代表一个成功新型号,遇到一个加工记录就会-1 变成0
if (result == 0) {
// 没有加工完成指令或者没有release指令但是有加工记录则也需要重置
if (recordLog.getType().equals("record")) {
bypassFlag = false;
preReason = "";
}
if (!finishList.contains(recordLog.getCategoryLevelTwo()) || !Objects.equal(recordLog.getEquipVariableValue(), "True")) {
continue;
}
if (!StringUtils.isEmpty(preReason)) {
reason += preReason;
preReason = "";
}
result ++;
startTime = recordLog.getCreateDatetime();
} else {
if (finishList.contains(recordLog.getCategoryLevelTwo()) && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
// 上一个加工记录信号还没走完这边又继续发一个加工记录且没有release 两个都要判定问题
if (!StringUtils.isEmpty(preReason)) {
reason += preReason;
}
if (Objects.equal(recordLog.getQuality(), "192")) {
reason += String.format(reasonOffline,startTime, 1 +"");
} else {
reason += String.format(reasonQuality,startTime, 1 +"");
}
// 每次preReason附完值都需要更新startTime完成信号
startTime = recordLog.getCreateDatetime();
}
if (recordLog.getType().equals("record")) {
bypassFlag = false;
offlineFlag = false;
result --;
preReason = "";
startTime = "";
errorCount = 0;
}
}
}
// 如果走到最后,还有预编译的错误,则直接加上
if (!StringUtils.isEmpty(preReason)) {
reason += preReason;
} else {
if (result > 0) {
reason += String.format(reasonOffline,startTime, 1 +"");
}
}
return reason;
}
@ -723,7 +890,7 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
for (MesProductRecordLog recordLog : recordLogs) {
int errorCount = 0;
if (recordLog.getId() ==1288411771211612170l) {
if (recordLog.getId() ==1838551951325315072l) {
int a = 1;
}
if (Objects.equal(recordLog.getType(), "monitor") && recordLog.getMessage().contains("客户端下线")) {
@ -735,7 +902,15 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
endTime = recordLog.getCreateDatetime();
offlineFlag = false;
if (result > 0) {
// 如果preReason已经有则代表已经判定过可以直接获取
if (!StringUtils.isEmpty(preReason)) {
reason += preReason;
startTime = recordLog.getCreateDatetime();
preReason = "";
} else {
reason += String.format(offlineReason, startTime, endTime, 1 + "");
}
result = 0;
errorCount = 0;
}
//result = 0;
@ -751,21 +926,26 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
continue;
}
if (offlineFlag && finishList.contains(recordLog.getCategoryLevelTwo()) && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
// 如果经过了1个finish然后再经过客户端下线再遇到finish则认为是客户端下线引起
if (result > 0) {
//endTime = recordLog.getCreateDatetime();
// 如果经过了1个finish然后再经过客户端下线再遇到finish则认为是客户端下线引起,如果没有需要预处理一个下线的原因
errorCount ++;
if (result > 0) {
reason += String.format(offlineReason, startTime, startTime, errorCount + "");
continue;
} else {
endTime = recordLog.getCreateDatetime();
preReason = String.format(offlineReason, startTime,endTime, errorCount + "");
}
errorCount ++;
result++;
continue ;
}
if (Objects.equal(recordLog.getCategoryLevelTwo(), "BYPASS") && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
// 如果有finish然后遇到bypass 需要预处理
if (result > 0) {
reason += String.format(reasonBypass,startTime, 1 +"");
result = 0;
}
startTime = recordLog.getCreateDatetime();
endTime = recordLog.getCreateDatetime();
bypassFlag = true;
continue;
@ -821,6 +1001,7 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
continue;
} if (!StringUtils.isEmpty(preReason)) {
reason += preReason;
preReason = "";
}
result ++;
startTime = recordLog.getCreateDatetime();
@ -828,15 +1009,20 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
} else {
if (finishList.contains(recordLog.getCategoryLevelTwo()) && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
// 上一个加工记录信号还没走完这边又继续发一个加工记录且没有release 两个都要判定问题
if (!StringUtils.isEmpty(preReason)) {
reason += preReason;
}
if (!releaseFlag) {
startTime = recordLog.getCreateDatetime();
reason += String.format(releaseBypass, startTime, 1 + "");
preReason = String.format(releaseBypass, startTime, 1 + "");
} else {
if (Objects.equal(recordLog.getQuality(), "192")) {
reason += String.format(reasonOffline,startTime, 1 +"");
} else {
reason += String.format(reasonQuality,startTime, 1 +"");
}
// 每次preReason附完值都需要更新startTime完成信号
startTime = recordLog.getCreateDatetime();
}
}

Loading…
Cancel
Save