|
|
|
@ -5,6 +5,7 @@ import cn.estsh.i3plus.ext.mes.apiservice.dao.IMesProdRuleNosortCfgDao;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.apiservice.utils.BeanUtil;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.apiservice.utils.MesException;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pojo.model.MesLoadingListDetailModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pojo.model.MesShippingOrderManagementDetailModel;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
@ -14,15 +15,19 @@ import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.util.StringUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProdRuleNosortCfg;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProductRecordLog;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesLoadingListDetail;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.MesProductionRecordModel;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.report.MesProductAccountModel;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.report.MesProductAccountResModel;
|
|
|
|
|
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 lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.hibernate.SQLQuery;
|
|
|
|
|
import org.hibernate.query.internal.NativeQueryImpl;
|
|
|
|
|
import org.hibernate.transform.Transformers;
|
|
|
|
|
import org.mvel2.util.Make;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
@ -38,6 +43,7 @@ import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description : 设备加工记录表
|
|
|
|
@ -58,6 +64,9 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesProduceSnRepository mesProduceSnRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesProductRecordLogRepository mesProductRecordLogRepository;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<MesProductionRecord> findMesProductionRecord(String organizeCode, String sn) {
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
@ -115,14 +124,20 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ListPager<MesProductAccountResModel> queryProductAccount(MesProductAccountModel productAccountModel, Pager pager) {
|
|
|
|
|
String sqlStr = "SELECT\n" +
|
|
|
|
|
"\tmpr.part_no,\n" +
|
|
|
|
|
"\tmpr.equipment_code,\n" +
|
|
|
|
|
"\tme.equipment_name,\n" +
|
|
|
|
|
"\tme.work_cell_code,\n" +
|
|
|
|
|
"\tme.work_center_code,\n" +
|
|
|
|
|
"\tmpr.product_count,\n" +
|
|
|
|
|
"\tmpr.detail_count\n" +
|
|
|
|
|
List<MesProductAccountResModel> resList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
String sqlStr = "select mpr.part_no,mpr.equipment_code,mpr.equipment_name,mpr.work_cell_code,mpr.work_center_code," +
|
|
|
|
|
"mpr.product_count,mpr.detail_count,error_reason from (\n" +
|
|
|
|
|
"\n" +
|
|
|
|
|
"SELECT\n" +
|
|
|
|
|
"\tmpr.part_no ,\n" +
|
|
|
|
|
"\tmpr.equipment_code ,\n" +
|
|
|
|
|
"\tme.equipment_name ,\n" +
|
|
|
|
|
"\tme.work_cell_code ,\n" +
|
|
|
|
|
"\tme.work_center_code ,\n" +
|
|
|
|
|
"\tmpr.product_count ,\n" +
|
|
|
|
|
"\tmpr.detail_count , \n" +
|
|
|
|
|
"\t null error_reason\n" +
|
|
|
|
|
"\t\n" +
|
|
|
|
|
"FROM\n" +
|
|
|
|
|
"\t(\n" +
|
|
|
|
@ -158,16 +173,17 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
"\n" +
|
|
|
|
|
"UNION\n" +
|
|
|
|
|
"SELECT\n" +
|
|
|
|
|
"\tmprnc.out_part_no,\n" +
|
|
|
|
|
"\tmprnc.equipment_code,\n" +
|
|
|
|
|
"\tme.equipment_name,\n" +
|
|
|
|
|
"\tme.work_cell_code,\n" +
|
|
|
|
|
"\tme.work_center_code,\n" +
|
|
|
|
|
"\teqcount.product_count,\n" +
|
|
|
|
|
"\teqcount.detail_count \n" +
|
|
|
|
|
"\tmprnc.out_part_no part_no,\n" +
|
|
|
|
|
"\tmprnc.equipment_code ,\n" +
|
|
|
|
|
"\tme.equipment_name ,\n" +
|
|
|
|
|
"\tme.work_cell_code ,\n" +
|
|
|
|
|
"\tme.work_center_code ,\n" +
|
|
|
|
|
"\teqcount.product_count ,\n" +
|
|
|
|
|
"\teqcount.detail_count , \n" +
|
|
|
|
|
"\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 \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" +
|
|
|
|
|
"\tSELECT\n" +
|
|
|
|
|
"\t\tequipment_code,\n" +
|
|
|
|
@ -205,7 +221,160 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
if (!StringUtils.isEmpty(productAccountModel.getEquipmentCode())) {
|
|
|
|
|
sqlStr += "and mprnc.equipment_code= :equipmentCode ";
|
|
|
|
|
}
|
|
|
|
|
sqlStr += "\tand eqcount.product_count is not null and eqcount.detail_count is not null";
|
|
|
|
|
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" +
|
|
|
|
|
"and me.equipment_type = 10";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Query query = entityManager.createNativeQuery(sqlStr);
|
|
|
|
|
if (!StringUtils.isEmpty(productAccountModel.getEquipmentCode())) {
|
|
|
|
|
query.setParameter("equipmentCode", productAccountModel.getEquipmentCode());
|
|
|
|
|
}
|
|
|
|
|
if (!StringUtils.isEmpty(productAccountModel.getPartNo())) {
|
|
|
|
|
query.setParameter("partNo", productAccountModel.getPartNo());
|
|
|
|
|
}
|
|
|
|
|
if (!StringUtils.isEmpty(productAccountModel.getStartTime())) {
|
|
|
|
|
query.setParameter("startTime", productAccountModel.getStartTime());
|
|
|
|
|
}
|
|
|
|
|
if (!StringUtils.isEmpty(productAccountModel.getEndTime())) {
|
|
|
|
|
query.setParameter("endTime", productAccountModel.getEndTime());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.aliasToBean(MesProductAccountResModel.class));
|
|
|
|
|
List<MesProductAccountResModel> results = query.getResultList();*/
|
|
|
|
|
List results = query.getResultList();
|
|
|
|
|
for (Object result : results) {
|
|
|
|
|
Object[] cells = (Object[]) result;
|
|
|
|
|
MesProductAccountResModel model = new MesProductAccountResModel();
|
|
|
|
|
model.setPartNo(StringUtils.isEmpty(cells[0]) ? "" : String.valueOf(cells[0]));
|
|
|
|
|
model.setEquipmentCode(StringUtils.isEmpty(cells[1]) ? "" : String.valueOf(cells[1]));
|
|
|
|
|
model.setWorkCellCode(StringUtils.isEmpty(cells[3]) ? "" : String.valueOf(cells[3]));
|
|
|
|
|
model.setWorkCenterCode(StringUtils.isEmpty(cells[4]) ? "" : String.valueOf(cells[4]));
|
|
|
|
|
model.setProductCount(StringUtils.isEmpty(cells[5]) ? "" : String.valueOf(cells[5]));
|
|
|
|
|
model.setDetailCount(StringUtils.isEmpty(cells[6]) ? "" : String.valueOf(cells[6]));
|
|
|
|
|
model.setErrorReason(StringUtils.isEmpty(cells[7]) ? "" : String.valueOf(cells[7]));
|
|
|
|
|
|
|
|
|
|
resList.add(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.aliasToBean(MesProductAccountResModel.class));
|
|
|
|
|
//List<MesProductAccountResModel> results = query.getResultList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new ListPager<>(resList,pager);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<MesProductAccountResModel> queryProductAccount(MesProductAccountModel productAccountModel) {
|
|
|
|
|
List<MesProductAccountResModel> resList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
String sqlStr = "select mpr.part_no,mpr.equipment_code,mpr.equipment_name,mpr.work_cell_code,mpr.work_center_code," +
|
|
|
|
|
"mpr.product_count,mpr.detail_count,error_reason from (\n" +
|
|
|
|
|
"\n" +
|
|
|
|
|
"SELECT\n" +
|
|
|
|
|
"\tmpr.part_no ,\n" +
|
|
|
|
|
"\tmpr.equipment_code ,\n" +
|
|
|
|
|
"\tme.equipment_name ,\n" +
|
|
|
|
|
"\tme.work_cell_code ,\n" +
|
|
|
|
|
"\tme.work_center_code ,\n" +
|
|
|
|
|
"\tmpr.product_count ,\n" +
|
|
|
|
|
"\tmpr.detail_count , \n" +
|
|
|
|
|
"\t null error_reason\n" +
|
|
|
|
|
"\t\n" +
|
|
|
|
|
"FROM\n" +
|
|
|
|
|
"\t(\n" +
|
|
|
|
|
"\tSELECT\n" +
|
|
|
|
|
"\t\tequipment_code,\n" +
|
|
|
|
|
"\t\tpart_no,\n" +
|
|
|
|
|
"\t\tsum( CASE WHEN type = 'record' THEN 1 ELSE 0 END ) product_count,\n" +
|
|
|
|
|
"\t\tsum( CASE WHEN type = 'logdetail' and CATEGORY_LEVEL_TWO ='shot_counter' and EQUIP_VARIABLE_VALUE > 0 THEN 1 ELSE 0 END ) detail_count \n" +
|
|
|
|
|
"\tFROM\n" +
|
|
|
|
|
"\t\tmes_product_record_log \n" +
|
|
|
|
|
"\tWHERE\n" +
|
|
|
|
|
"\t\tequipment_code LIKE '%HT%' \n";
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(productAccountModel.getEquipmentCode())) {
|
|
|
|
|
sqlStr += " and equipment_code = :equipmentCode ";
|
|
|
|
|
} if (!StringUtils.isEmpty(productAccountModel.getPartNo())) {
|
|
|
|
|
sqlStr += " and part_no like '%' :partNo '%' ";
|
|
|
|
|
} if (!StringUtils.isEmpty(productAccountModel.getStartTime())) {
|
|
|
|
|
sqlStr += " and create_date_time >= :startTime ";
|
|
|
|
|
} if (!StringUtils.isEmpty(productAccountModel.getEndTime())) {
|
|
|
|
|
sqlStr += " and create_date_time < :endTime ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sqlStr +=
|
|
|
|
|
"\t\tAND part_no IS NOT NULL \n" +
|
|
|
|
|
"\tGROUP BY\n" +
|
|
|
|
|
"\t\tequipment_code,\n" +
|
|
|
|
|
"\t\tpart_no \n" +
|
|
|
|
|
"\t) mpr\n" +
|
|
|
|
|
"\tLEFT JOIN mes_wc_equipment me ON mpr.equipment_code = me.equipment_code \n" +
|
|
|
|
|
"\n" +
|
|
|
|
|
"\n" +
|
|
|
|
|
"UNION\n" +
|
|
|
|
|
"SELECT\n" +
|
|
|
|
|
"\tmprnc.out_part_no part_no,\n" +
|
|
|
|
|
"\tmprnc.equipment_code ,\n" +
|
|
|
|
|
"\tme.equipment_name ,\n" +
|
|
|
|
|
"\tme.work_cell_code ,\n" +
|
|
|
|
|
"\tme.work_center_code ,\n" +
|
|
|
|
|
"\teqcount.product_count ,\n" +
|
|
|
|
|
"\teqcount.detail_count , \n" +
|
|
|
|
|
"\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" +
|
|
|
|
|
"\tSELECT\n" +
|
|
|
|
|
"\t\tequipment_code,\n" +
|
|
|
|
|
"\t\tpart_no,\n" +
|
|
|
|
|
"\t\tsum( CASE WHEN type = 'record' THEN 1 ELSE 0 END ) product_count,\n" +
|
|
|
|
|
"\t\tsum(\n" +
|
|
|
|
|
"\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" +
|
|
|
|
|
"\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\t) detail_count \n" +
|
|
|
|
|
"\t\t\tFROM\n" +
|
|
|
|
|
"\t\t\t\tmes_product_record_log \n" +
|
|
|
|
|
"\t\t\tWHERE 1 = 1 \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";
|
|
|
|
|
} if (!StringUtils.isEmpty(productAccountModel.getStartTime())) {
|
|
|
|
|
sqlStr += "\t\t\t and create_date_time >= :startTime \n";
|
|
|
|
|
} if (!StringUtils.isEmpty(productAccountModel.getEndTime())) {
|
|
|
|
|
sqlStr += "\t\t\t and create_date_time < :endTime \n";
|
|
|
|
|
}
|
|
|
|
|
sqlStr +=
|
|
|
|
|
"\t\t\t and \n" +
|
|
|
|
|
"\t\t\t\tpart_no IS NOT NULL \n" +
|
|
|
|
|
"\t\t\tGROUP BY\n" +
|
|
|
|
|
"\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 ";
|
|
|
|
|
if (!StringUtils.isEmpty(productAccountModel.getEquipmentCode())) {
|
|
|
|
|
sqlStr += "and mprnc.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" +
|
|
|
|
|
"and me.equipment_type = 10";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Query query = entityManager.createNativeQuery(sqlStr);
|
|
|
|
@ -222,11 +391,29 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
query.setParameter("endTime", productAccountModel.getEndTime());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<MesProductAccountResModel> list = query.getResultList();
|
|
|
|
|
/* query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.aliasToBean(MesProductAccountResModel.class));
|
|
|
|
|
List<MesProductAccountResModel> results = query.getResultList();*/
|
|
|
|
|
List results = query.getResultList();
|
|
|
|
|
for (Object result : results) {
|
|
|
|
|
Object[] cells = (Object[]) result;
|
|
|
|
|
MesProductAccountResModel model = new MesProductAccountResModel();
|
|
|
|
|
model.setPartNo(StringUtils.isEmpty(cells[0]) ? "" : String.valueOf(cells[0]));
|
|
|
|
|
model.setEquipmentCode(StringUtils.isEmpty(cells[1]) ? "" : String.valueOf(cells[1]));
|
|
|
|
|
model.setWorkCellCode(StringUtils.isEmpty(cells[3]) ? "" : String.valueOf(cells[3]));
|
|
|
|
|
model.setWorkCenterCode(StringUtils.isEmpty(cells[4]) ? "" : String.valueOf(cells[4]));
|
|
|
|
|
model.setProductCount(StringUtils.isEmpty(cells[5]) ? "" : String.valueOf(cells[5]));
|
|
|
|
|
model.setDetailCount(StringUtils.isEmpty(cells[6]) ? "" : String.valueOf(cells[6]));
|
|
|
|
|
model.setErrorReason(StringUtils.isEmpty(cells[7]) ? "" : String.valueOf(cells[7]));
|
|
|
|
|
|
|
|
|
|
resList.add(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.aliasToBean(MesProductAccountResModel.class));
|
|
|
|
|
//List<MesProductAccountResModel> results = query.getResultList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new ListPager<>(list,pager);
|
|
|
|
|
return resList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<MesProduceSn> getMesProduceSnList(MesProductionRecordModel mesProductionRecordModel) {
|
|
|
|
@ -339,4 +526,227 @@ public class MesProductionRecordServiceImpl extends BaseMesService<MesProduction
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<MesProductAccountResModel> transferAccount(List<MesProductAccountResModel> mesProductAccountResModels, MesProductAccountModel productAccountModel) {
|
|
|
|
|
/**
|
|
|
|
|
* 760B_A58_ReMaoHan 只有finish信号
|
|
|
|
|
* 760BFoaming
|
|
|
|
|
* 760B_LaserCutting
|
|
|
|
|
* 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return mesProductAccountResModels;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String handleNotHT(List<MesProductRecordLog> recordLogs) {
|
|
|
|
|
int result = 0;
|
|
|
|
|
String startTime = "";
|
|
|
|
|
String endTime = "";
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
String reason = "";
|
|
|
|
|
String reasonOffline = "【%s】到【%s】,客户端下线,导致【%s】个完成信号丢失";
|
|
|
|
|
String reasonQuality = "【%s】到【%s】设备信号质量有问题,导致【%s】个完成信号丢失";
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
|
|
for (MesProductRecordLog recordLog : recordLogs) {
|
|
|
|
|
if (Objects.equal(recordLog.getCategoryLevelTwo(), "BYPASS")) {
|
|
|
|
|
if (Objects.equal(recordLog.getEquipVariableValue(), "True")) {
|
|
|
|
|
if (StringUtils.isEmpty(startTime)) {
|
|
|
|
|
startTime = recordLog.getCreateDatetime();
|
|
|
|
|
}
|
|
|
|
|
endTime = recordLog.getCreateDatetime();
|
|
|
|
|
// 每次都取反,第一次是打开,那第二次就是关闭了
|
|
|
|
|
bypassFlag = true;
|
|
|
|
|
continue;
|
|
|
|
|
} else {
|
|
|
|
|
if (bypassFlag) {
|
|
|
|
|
bypassFlag = false;
|
|
|
|
|
errorCount = 0;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (bypassFlag && recordLog.getType().equals("record")) {
|
|
|
|
|
errorCount ++;
|
|
|
|
|
reason = String.format(reasonBypass,startTime, endTime, errorCount +"");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result == 0) {
|
|
|
|
|
if (!finishList.contains(recordLog.getCategoryLevelTwo()) || !Objects.equal(recordLog.getEquipVariableValue(), "True")) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
result ++;
|
|
|
|
|
} else {
|
|
|
|
|
if (finishList.contains(recordLog.getCategoryLevelTwo()) && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
|
|
|
|
|
if (StringUtils.isEmpty(startTime)) {
|
|
|
|
|
startTime = recordLog.getCreateDatetime();
|
|
|
|
|
}
|
|
|
|
|
errorCount ++;
|
|
|
|
|
endTime = recordLog.getCreateDatetime();
|
|
|
|
|
if (Objects.equal(recordLog.getQuality(), "192")) {
|
|
|
|
|
reason = String.format(reasonOffline,startTime, endTime, errorCount +"");
|
|
|
|
|
} else {
|
|
|
|
|
reason = String.format(reasonQuality,startTime, endTime, errorCount +"");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (recordLog.getType().equals("record")) {
|
|
|
|
|
result --;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return reason;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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】设备信号质量有问题,导致【%s】个完成信号丢失";
|
|
|
|
|
String reasonBypass = "【%s】到【%s】设备信号Bypass,【%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());
|
|
|
|
|
|
|
|
|
|
for (MesProductRecordLog recordLog : recordLogs) {
|
|
|
|
|
if (Objects.equal(recordLog.getCategoryLevelTwo(), "BYPASS") && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
|
|
|
|
|
if (StringUtils.isEmpty(startTime)) {
|
|
|
|
|
startTime = recordLog.getCreateDatetime();
|
|
|
|
|
}
|
|
|
|
|
endTime = recordLog.getCreateDatetime();
|
|
|
|
|
// 每次都取反,第一次是打开,那第二次就是关闭了
|
|
|
|
|
bypassFlag = !bypassFlag;
|
|
|
|
|
if (!bypassFlag) {
|
|
|
|
|
errorCount = 0;
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (bypassFlag && recordLog.getType().equals("record")) {
|
|
|
|
|
errorCount ++;
|
|
|
|
|
reason = String.format(reasonBypass,startTime, endTime, errorCount +"");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (result == 0) {
|
|
|
|
|
if (Objects.equal(recordLog.getCategoryLevelTwo(), "Work_Allow") && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
|
|
|
|
|
releaseFlag = true;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!finishList.contains(recordLog.getCategoryLevelTwo()) || !Objects.equal(recordLog.getEquipVariableValue(), "True")) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
result ++;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if (finishList.contains(recordLog.getCategoryLevelTwo()) && Objects.equal(recordLog.getEquipVariableValue(), "True")) {
|
|
|
|
|
if (StringUtils.isEmpty(startTime)) {
|
|
|
|
|
startTime = recordLog.getCreateDatetime();
|
|
|
|
|
}
|
|
|
|
|
errorCount ++;
|
|
|
|
|
endTime = recordLog.getCreateDatetime();
|
|
|
|
|
if (!releaseFlag) {
|
|
|
|
|
reason = String.format(releaseBypass,startTime, endTime, errorCount +"");
|
|
|
|
|
} else {
|
|
|
|
|
if (Objects.equal(recordLog.getQuality(), "192")) {
|
|
|
|
|
reason = String.format(reasonOffline,startTime, endTime, errorCount +"");
|
|
|
|
|
} else {
|
|
|
|
|
reason = String.format(reasonQuality,startTime, endTime, errorCount +"");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (recordLog.getType().equals("record")) {
|
|
|
|
|
result --;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return reason;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String handleHT(List<MesProductRecordLog> recordLogs) {
|
|
|
|
|
int result = 0;
|
|
|
|
|
String startTime = "";
|
|
|
|
|
String endTime = "";
|
|
|
|
|
int errorCount = 0;
|
|
|
|
|
String reason = "";
|
|
|
|
|
String reasonOffline = "【%s】到【%s】,客户端下线,导致【%s】个完成信号丢失";
|
|
|
|
|
String reasonQuality = "【%s】到【%s】设备信号质量有问题,导致【%s】个完成信号丢失";
|
|
|
|
|
|
|
|
|
|
for (MesProductRecordLog recordLog : recordLogs) {
|
|
|
|
|
if (result == 0) {
|
|
|
|
|
if (!Objects.equal(recordLog.getCategoryLevelTwo(),"shot_counter") ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (recordLog.getEquipVariableValue().compareTo("0") > 0) {
|
|
|
|
|
result ++;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (Objects.equal(recordLog.getCategoryLevelTwo(),"shot_counter") && recordLog.getEquipVariableValue().compareTo("0") > 0) {
|
|
|
|
|
if (StringUtils.isEmpty(startTime)) {
|
|
|
|
|
startTime = recordLog.getCreateDatetime();
|
|
|
|
|
}
|
|
|
|
|
errorCount ++;
|
|
|
|
|
endTime = recordLog.getCreateDatetime();
|
|
|
|
|
if (Objects.equal(recordLog.getQuality(), "192")) {
|
|
|
|
|
reason = String.format(reasonOffline,startTime, endTime, errorCount +"");
|
|
|
|
|
} else {
|
|
|
|
|
reason = String.format(reasonQuality,startTime, endTime, errorCount +"");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (recordLog.getType().equals("record")) {
|
|
|
|
|
result --;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return reason;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|