对账单信息

tags/yfai-mes-ext-v2.0
xiangwei.zhang 8 months ago
parent 111b90fcb3
commit b86fbdbd3d

@ -34,5 +34,5 @@ public interface IMesProductionRecordService extends IBaseMesService<MesProducti
List<MesProductAccountResModel> queryProductAccount(MesProductAccountModel productAccountModel);
@ApiOperation(value = "线边库存报表")
List<MesProductAccountResModel> transferAccount(List<MesProductAccountResModel> list,MesProductAccountModel productAccountModel);
List<MesProductAccountResModel> transferAccount(List<MesProductAccountResModel> list,MesProductAccountModel productAccountModel, Pager pager);
}

@ -103,9 +103,9 @@ public class MesBusiReportController extends MesBaseController {
@ApiOperation(value = "对账报表", notes = "对账报表")
@GetMapping("/product/account/query")
public ResultBean queryProductAccount(MesProductAccountModel productAccountModel, Pager pager) {
try {
try {/*
ValidatorBean.beginValid(productAccountModel)
.notNull("equipmentCode", productAccountModel.getEquipmentCode());
.notNull("equipmentCode", productAccountModel.getEquipmentCode());*/
/*productAccountModel.setStartTime("2024-09-12 08:00:00");
productAccountModel.setEndTime("2024-09-13 08:00:00");
productAccountModel.setEquipmentCode("760BFoaming");
@ -113,12 +113,13 @@ public class MesBusiReportController extends MesBaseController {
List<MesProductAccountResModel> mesProductAccountResModels = mesProductionRecordService.queryProductAccount(productAccountModel);
List<MesProductAccountResModel> mesProductAccountResModelsRes = mesProductionRecordService.transferAccount(mesProductAccountResModels,productAccountModel);
List<MesProductAccountResModel> mesProductAccountResModelsRes = mesProductionRecordService.transferAccount(mesProductAccountResModels,productAccountModel, pager);
return ResultBean.success("查询成功").setResultList(mesProductAccountResModelsRes);
return ResultBean.success("查询成功").setResultList(mesProductAccountResModelsRes).setPager(pager);
} catch (ImppBusiException e) {
return ResultBean.fail(e);
} catch (Exception e) {
e.printStackTrace();
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}

@ -25,6 +25,7 @@ import cn.estsh.i3plus.pojo.mes.repository.MesProduceSnRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesProductRecordLogRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.SQLQuery;
import org.hibernate.query.internal.NativeQueryImpl;
@ -340,10 +341,11 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
"\t\tCASE\n" +
"\t\t\t\t\n" +
"\t\t\t\tWHEN type = 'logdetail' \n" +
"\t\t\t\tAND CATEGORY_LEVEL_TWO IN ( 'Product_finish', 'PART_OK', 'Part_Finish', 'Product_OK' ) \n" +
"AND ( (equipment_code != 'Geiss' and CATEGORY_LEVEL_TWO IN ( 'Product_finish', 'PART_OK', 'Part_Finish', 'Product_OK' ) )\n" +
"\t\t\t\tor (equipment_code = 'Geiss' and CATEGORY_LEVEL_TWO = 'Product_finish') )\n" +
"\t\t\t\tAND EQUIP_VARIABLE_VALUE = 'True' THEN\n" +
"\t\t\t\t\t1 ELSE 0 \n" +
"\t\t\t\tEND \n" +
"\t\t\t\tEND" +
"\t\t\t\t) detail_count \n" +
"\t\t\tFROM\n" +
"\t\t\t\tmes_product_record_log \n" +
@ -374,7 +376,7 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
"\ton mpr.equipment_code = me.equipment_code\n" +
"\n" +
"where mpr.product_count != 0 and mpr.detail_count != 0\n" +
"and me.equipment_type = 10";
"and me.equipment_type = 10 order by me.equipment_code asc";
Query query = entityManager.createNativeQuery(sqlStr);
@ -527,7 +529,7 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
}
@Override
public List<MesProductAccountResModel> transferAccount(List<MesProductAccountResModel> mesProductAccountResModels, MesProductAccountModel productAccountModel) {
public List<MesProductAccountResModel> transferAccount(List<MesProductAccountResModel> mesProductAccountResModels, MesProductAccountModel productAccountModel, Pager pager) {
/**
* 760B_A58_ReMaoHan finish
* 760BFoaming
@ -535,45 +537,46 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
* ZhenKong
*/
List<String> equimentList = Stream.of("760B_A58_ReMaoHan","760BFoaming","760B_LaserCutting","ZhenKong").collect(Collectors.toList());
if (!CollectionUtils.isEmpty(mesProductAccountResModels)) {
mesProductAccountResModels = mesProductAccountResModels.stream().filter(mesProductAccountResModel ->{
int size = mesProductAccountResModel.getPartNo().split(",").length;
int productCount = Integer.valueOf(mesProductAccountResModel.getProductCount());
int detailCount = Integer.valueOf(mesProductAccountResModel.getDetailCount());
if (detailCount * size > productCount) {
return true;
}
return false;
} ) .collect(Collectors.toList());
}
if (!CollectionUtils.isEmpty(mesProductAccountResModels)) {
for (MesProductAccountResModel mesProductAccountResModel : mesProductAccountResModels) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean("CK01");
DdlPreparedPack.getStringEqualPack(mesProductAccountResModel.getEquipmentCode(), "equipmentCode", packBean);
DdlPreparedPack.getStringSmallerNotEqualPack(productAccountModel.getEndTime(), "createDatetime", packBean);
DdlPreparedPack.getStringBiggerPack(productAccountModel.getStartTime(), "createDatetime", packBean);
DdlPreparedPack.getStringEqualPack(mesProductAccountResModel.getPartNo(), "partNo", packBean);
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然后看是否是网络原因
String reason = handleHT(recordLogs);
mesProductAccountResModel.setErrorReason(reason);
} else if (equimentList.contains(mesProductAccountResModel.getEquipmentCode())) {
// 1 判断2个 shotcount之间有没有加工记录如果没有就需要看 设备是不是192然后看是否是网络原因
String reason =handleNotHT(recordLogs);
mesProductAccountResModel.setErrorReason(reason);
} else {
String reason =handleNotHTAndHasRelease(recordLogs);
mesProductAccountResModel.setErrorReason(reason);
}
if (CollectionUtils.isEmpty(mesProductAccountResModels)) {
return null;
}
List<MesProductAccountResModel> partitionList = partition(mesProductAccountResModels, pager.getPageSize(), pager.getCurrentPage());
for (MesProductAccountResModel mesProductAccountResModel : partitionList) {
boolean isErrorCount = false;
int size = mesProductAccountResModel.getPartNo().split(",").length;
int productCount = Integer.valueOf(mesProductAccountResModel.getProductCount());
int detailCount = Integer.valueOf(mesProductAccountResModel.getDetailCount());
if (detailCount * size > productCount) {
isErrorCount = true;
}
if (!isErrorCount) {
continue;
}
DdlPackBean packBean = DdlPackBean.getDdlPackBean("CK01");
DdlPreparedPack.getStringEqualPack(mesProductAccountResModel.getEquipmentCode(), "equipmentCode", packBean);
DdlPreparedPack.getStringSmallerNotEqualPack(productAccountModel.getEndTime(), "createDatetime", packBean);
DdlPreparedPack.getStringBiggerPack(productAccountModel.getStartTime(), "createDatetime", packBean);
DdlPreparedPack.getStringEqualPack(mesProductAccountResModel.getPartNo(), "partNo", packBean);
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然后看是否是网络原因
String reason = handleHT(recordLogs);
mesProductAccountResModel.setErrorReason(reason);
} else if (equimentList.contains(mesProductAccountResModel.getEquipmentCode())) {
// 1 判断2个 shotcount之间有没有加工记录如果没有就需要看 设备是不是192然后看是否是网络原因
String reason =handleNotHT(recordLogs);
mesProductAccountResModel.setErrorReason(reason);
} else {
String reason =handleNotHTAndHasRelease(recordLogs);
mesProductAccountResModel.setErrorReason(reason);
}
}
return mesProductAccountResModels;
return partitionList;
}
private String handleNotHT(List<MesProductRecordLog> recordLogs) {
@ -587,7 +590,7 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
String reasonBypass = "【%s】到【%s】设备信号Bypass,【%s】个完成信号丢失";
boolean bypassFlag = 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());
for (MesProductRecordLog recordLog : recordLogs) {
if (Objects.equal(recordLog.getCategoryLevelTwo(), "BYPASS")) {
@ -649,14 +652,15 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
String reasonOffline = "【%s】到【%s】,客户端下线,导致【%s】个完成信号丢失";
String reasonQuality = "【%s】到【%s】设备信号质量有问题导致【%s】个完成信号丢失";
String reasonBypass = "【%s】到【%s】设备信号Bypass,【%s】个完成信号丢失";
String releaseBypass = "【%s】到【%s】设备信号没有release就给了完成新号,导致【%s】个完成信号丢失";
String releaseBypass = "【%s】到【%s】设备信号没有release就给了完成新号,导致【%s】个完成信号丢失";
boolean bypassFlag = 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_OK","Part_Finish","Product_OK").collect(Collectors.toList());
List<String> finishList = Stream.of("Product_finish","Part_Finish").collect(Collectors.toList());
for (MesProductRecordLog recordLog : recordLogs) {
if (Objects.equal(recordLog.getCategoryLevelTwo(), "BYPASS") && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
@ -676,12 +680,20 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
reason = String.format(reasonBypass,startTime, endTime, errorCount +"");
continue;
}
if (bypassFlag && Objects.equal(recordLog.getCategoryLevelTwo(), "BYPASS") && Objects.equal(recordLog.getEquipVariableValue(), "False")) {
endTime = recordLog.getCreateDatetime();
bypassFlag = false;
continue;
}
if (result == 0) {
if (Objects.equal(recordLog.getCategoryLevelTwo(), "Work_Allow") && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
releaseFlag = true;
continue;
}
/* // Geiss 设备是一组信号,但是以finish为主
if ()*/
if (!finishList.contains(recordLog.getCategoryLevelTwo()) || !Objects.equal(recordLog.getEquipVariableValue(), "True")) {
continue;
}
@ -749,4 +761,13 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
}
return reason;
}
private List<MesProductAccountResModel> partition(List<MesProductAccountResModel> list, int pageSize, int pageNum) {
// 将 List 按照 PageSzie 拆分成多个List
List<List<MesProductAccountResModel>> partition = Lists.partition(list, pageSize);
// 总页数
int pages = partition.size();
pageNum = pageNum <= 0 ? 0 : (pageNum <= (pages - 1) ? pageNum : (pages - 1));
return partition.get(pageNum);
}
}

Loading…
Cancel
Save