forked from I3-YF/i3plus-mes-pcn-yfai
解决冲突
commit
a7bb6ae289
@ -0,0 +1,15 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.api.busi;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesPackageRuleContext;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesWorkOrderExtModel;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
public interface IMesFengRenBatchReportService {
|
||||
|
||||
@ApiOperation(value = "缝纫批量汇报获取默认标包")
|
||||
MesPackageRuleContext queryPackSpecQtyFengRenBatchReport(String organizeCode, String partNo);
|
||||
|
||||
@ApiOperation(value = "缝纫批量汇报")
|
||||
MesProduceSnPrintModel doFengRenBatchReport(MesWorkOrderExtModel model);
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesFengRenBatchReportService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.method.IMesPackageNoGenerateStepService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesWorkOrderExtModel;
|
||||
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
||||
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
||||
import cn.estsh.impp.framework.boot.util.ResultBean;
|
||||
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StopWatch;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Api("缝纫批量汇报")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping(MesCommonConstant.MES_YANFEN)
|
||||
public class MesFengRenBatchReportController {
|
||||
|
||||
@Autowired
|
||||
private IMesPackageNoGenerateStepService packageNoGenerateStepService;
|
||||
|
||||
@Autowired
|
||||
private IMesFengRenBatchReportService fengRenBatchReportService;
|
||||
|
||||
@GetMapping("/feng-ren-batch-report/get-pack-spec-qty")
|
||||
@ApiOperation(value = "缝纫批量汇报获取默认标包")
|
||||
public ResultBean queryPackSpecQtyFengRenBatchReport(String organizeCode, String partNo) {
|
||||
try {
|
||||
ValidatorBean.checkNotNull(organizeCode, "工厂代码不能为空");
|
||||
ValidatorBean.checkNotNull(partNo, "零件编码不能为空");
|
||||
return ResultBean.success("查询成功").setResultObject(fengRenBatchReportService.queryPackSpecQtyFengRenBatchReport(organizeCode, partNo));
|
||||
} catch (ImppBusiException imppException) {
|
||||
return ResultBean.fail(imppException);
|
||||
} catch (Exception e) {
|
||||
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/feng-ren-batch-report/do")
|
||||
@ApiOperation(value = "缝纫批量汇报")
|
||||
public ResultBean doFengRenBatchReport(MesWorkOrderExtModel model) {
|
||||
log.info("工厂{}缝纫批量汇报 --- START --- PARAM:{} --- {}", model.getOrganizeCode(), JSONObject.toJSONString(model), Thread.currentThread().getName());
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
try {
|
||||
ValidatorBean.checkNotNull(model.getOrganizeCode(), "工厂代码不能为空");
|
||||
ValidatorBean.checkNotNull(model.getModifyUser(), "操作人不能为空");
|
||||
ValidatorBean.checkNotNull(model.getPartNo(), "零件编码不能为空");
|
||||
ValidatorBean.checkNotNull(model.getWorkOrderNo(), "生产工单号不能为空");
|
||||
ValidatorBean.checkNotNull(model.getId(), "生产工单ID不能为空");
|
||||
return ResultBean.success("汇报成功").setResultObject(fengRenBatchReportService.doFengRenBatchReport(model));
|
||||
} catch (ImppBusiException imppException) {
|
||||
log.info("工厂{}缝纫批量汇报 --- ImppBusiException --- {} --- {}", model.getOrganizeCode(), imppException.getErrorMsg(), Thread.currentThread().getName());
|
||||
return ResultBean.fail(imppException);
|
||||
} catch (Exception e) {
|
||||
log.info("工厂{}缝纫批量汇报 --- Exception --- {} --- {}", model.getOrganizeCode(), JSONObject.toJSONString(e), Thread.currentThread().getName());
|
||||
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
||||
} finally {
|
||||
stopWatch.stop();
|
||||
log.info("工厂{}缝纫批量汇报 --- FINALLY --- 耗时:{} --- {}", model.getOrganizeCode(), stopWatch.getTotalTimeMillis(), Thread.currentThread().getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,290 +1,293 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.daoimpl;
|
||||
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.dao.IMesEquipmentLogDao;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipVariableCollectContext;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
||||
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentRecord;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class MesEquipmentLogDao implements IMesEquipmentLogDao {
|
||||
|
||||
@Value("${mes.sharding.append.org:}")
|
||||
public String mesShardingAppendOrg;
|
||||
|
||||
@Autowired
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Autowired
|
||||
private SnowflakeIdMaker snowflakeIdMaker;
|
||||
|
||||
private final static String TWO_S_APPEND = "%s_%s";
|
||||
|
||||
private final static String[] equipmentLogDetailFields = {MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.IS_DELETED,
|
||||
MesPcnExtConstWords.CREATE_USER, MesPcnExtConstWords.CREATE_DATE_TIME, MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME,
|
||||
MesPcnExtConstWords.DESCRIPTION, MesPcnExtConstWords.REMARK, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS,
|
||||
MesPcnExtConstWords.AREA_CODE, MesPcnExtConstWords.WORK_CENTER_CODE, MesPcnExtConstWords.WORK_CELL_CODE, MesPcnExtConstWords.EQUIPMENT_CODE,
|
||||
MesPcnExtConstWords.PROCESS_CODE, MesPcnExtConstWords.CRAFT_CODE, MesPcnExtConstWords.MOULD_RECORD_ID, MesPcnExtConstWords.EXTEND,
|
||||
MesPcnExtConstWords.ORG_EQUIP_ID, MesPcnExtConstWords.EQUIP_ID, MesPcnExtConstWords.EQUIP_VARIABLE_ID, MesPcnExtConstWords.EQUIP_VARIABLE_NAME,
|
||||
MesPcnExtConstWords.EQUIP_VARIABLE_DESC, MesPcnExtConstWords.READ_WRITE_FLAG, MesPcnExtConstWords.DATA_TYPE, MesPcnExtConstWords.EQUIP_VARIABLE_VALUE,
|
||||
MesPcnExtConstWords.VARIABLE_TYPE, MesPcnExtConstWords.CATEGORY_LEVEL_TWO, MesPcnExtConstWords.QUALITY};
|
||||
|
||||
@Override
|
||||
public List<MesEquipVariableCollectContext> queryMesEquipmentLog(List<MesEquipmentVariable> equipmentVariableList, String organizeCode, Integer equipId, Integer variableType) {
|
||||
|
||||
List<MesEquipVariableCollectContext> equipVariableCollectContextList = generateEquipVariableCollectContextList(equipmentVariableList);
|
||||
|
||||
if (CollectionUtils.isEmpty(equipmentVariableList) || StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(equipId) || StringUtils.isEmpty(variableType)) return null;
|
||||
|
||||
StringBuffer builder = new StringBuffer();
|
||||
|
||||
builder.append(" select e.equip_variable_id, e.equip_variable_value, e.equip_variable_status, e.quality, e.modify_date_time, e.id ");
|
||||
builder.append(" from mes_equipment_log_");
|
||||
if (!StringUtils.isEmpty(mesShardingAppendOrg) && mesShardingAppendOrg.toUpperCase().equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.name())) builder.append(organizeCode.toLowerCase()).append(MesPcnExtConstWords.E_UNDERLINE);
|
||||
builder.append(equipId);
|
||||
builder.append(" e where e.organize_code = :organizeCode and e.variable_type = :variableType ");
|
||||
|
||||
Query query = entityManager.createNativeQuery(builder.toString());
|
||||
query.setParameter(MesPcnExtConstWords.ORGANIZE_CODE, organizeCode);
|
||||
query.setParameter(MesPcnExtConstWords.VARIABLE_TYPE, variableType);
|
||||
List list = query.getResultList();
|
||||
|
||||
if (CollectionUtils.isEmpty(list)) return equipVariableCollectContextList;
|
||||
|
||||
List<String> equipVariableIdList = equipmentVariableList.stream().filter(o -> null != o).map(o -> o.getId().toString()).collect(Collectors.toList());
|
||||
|
||||
for (Object equipmentLog : list) {
|
||||
|
||||
if (null == equipmentLog) continue;
|
||||
|
||||
Object[] equipmentLogArr = (Object[]) equipmentLog;
|
||||
|
||||
if (null == equipmentLogArr || equipmentLogArr.length != 6 || StringUtils.isEmpty(equipmentLogArr[0]) || !equipVariableIdList.contains(equipmentLogArr[0].toString())) continue;
|
||||
|
||||
equipVariableCollectContextList.stream().filter(o -> (null != o && o.getEquipVariableId().toString().equals(equipmentLogArr[0].toString()))).findFirst().get().copyValue(equipmentLogArr[1], equipmentLogArr[2], equipmentLogArr[3], equipmentLogArr[4], equipmentLogArr[5]);
|
||||
|
||||
}
|
||||
|
||||
return equipVariableCollectContextList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEquipVariableStatus(String organizeCode, Integer equipId, Map<Long, String> equipmentLogIdMap, Integer equipVariableStatus) {
|
||||
|
||||
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(equipId) || CollectionUtils.isEmpty(equipmentLogIdMap) || StringUtils.isEmpty(equipVariableStatus)) return;
|
||||
|
||||
StringBuffer builder = new StringBuffer();
|
||||
|
||||
for (int i = 0; i < equipmentLogIdMap.size(); i ++) {
|
||||
|
||||
builder.append(" update mes_equipment_log_");
|
||||
if (!StringUtils.isEmpty(mesShardingAppendOrg) && mesShardingAppendOrg.toUpperCase().equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.name())) builder.append(organizeCode.toLowerCase()).append(MesPcnExtConstWords.E_UNDERLINE);
|
||||
builder.append(equipId);
|
||||
builder.append(" set equip_variable_status = :equipVariableStatus_");
|
||||
builder.append(i);
|
||||
builder.append(" where id = :id_");
|
||||
builder.append(i);
|
||||
builder.append(" and modify_date_time = :modifyDatetime_");
|
||||
builder.append(i);
|
||||
builder.append(" ;");
|
||||
|
||||
}
|
||||
|
||||
Query update = entityManager.createNativeQuery(builder.toString());
|
||||
|
||||
Integer index = 0;
|
||||
for (Map.Entry<Long, String> entry : equipmentLogIdMap.entrySet()) {
|
||||
if (null == entry) continue;
|
||||
update.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EQUIP_VARIABLE_STATUS, index), equipVariableStatus);
|
||||
update.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.ID, index), entry.getKey());
|
||||
update.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.MODIFY_DATE_TIME, index), entry.getValue());
|
||||
index ++;
|
||||
}
|
||||
|
||||
update.executeUpdate();
|
||||
|
||||
}
|
||||
|
||||
private List<MesEquipVariableCollectContext> generateEquipVariableCollectContextList(List<MesEquipmentVariable> equipmentVariableList) {
|
||||
List<MesEquipVariableCollectContext> equipVariableCollectContextList = new ArrayList<>();
|
||||
if (CollectionUtils.isEmpty(equipmentVariableList)) return equipVariableCollectContextList;
|
||||
equipmentVariableList.stream().filter(o -> null != o).forEach(o -> {
|
||||
MesEquipVariableCollectContext equipVariableCollectContext = new MesEquipVariableCollectContext(o.getId());
|
||||
BeanUtils.copyProperties(o, equipVariableCollectContext);
|
||||
equipVariableCollectContextList.add(equipVariableCollectContext);
|
||||
});
|
||||
return equipVariableCollectContextList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MesEquipVariableCollectContext> queryMesEquipmentLog(String organizeCode, Integer equipId, Integer variableType, List<Long> equipVariableIdList) {
|
||||
|
||||
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(equipId) || StringUtils.isEmpty(variableType) || CollectionUtils.isEmpty(equipVariableIdList)) return null;
|
||||
|
||||
equipVariableIdList = equipVariableIdList.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
|
||||
|
||||
StringBuffer builder = new StringBuffer();
|
||||
|
||||
builder.append(" select e.equip_variable_id, e.equip_variable_value, e.equip_variable_status, e.quality, e.modify_date_time, e.id ");
|
||||
builder.append(" from mes_equipment_log_");
|
||||
if (!StringUtils.isEmpty(mesShardingAppendOrg) && mesShardingAppendOrg.toUpperCase().equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.name())) builder.append(organizeCode.toLowerCase()).append(MesPcnExtConstWords.E_UNDERLINE);
|
||||
builder.append(equipId);
|
||||
builder.append(" e where e.organize_code = :organizeCode and e.variable_type = :variableType ");
|
||||
if (equipVariableIdList.size() == 1) builder.append(" and e.equip_variable_id = :equipVariableId ");
|
||||
else builder.append(" and e.equip_variable_id in (:equipVariableId) ");
|
||||
|
||||
Query query = entityManager.createNativeQuery(builder.toString());
|
||||
query.setParameter(MesPcnExtConstWords.ORGANIZE_CODE, organizeCode);
|
||||
query.setParameter(MesPcnExtConstWords.VARIABLE_TYPE, variableType);
|
||||
if (equipVariableIdList.size() == 1) query.setParameter(MesPcnExtConstWords.EQUIP_VARIABLE_ID, equipVariableIdList.get(0));
|
||||
else query.setParameter(MesPcnExtConstWords.EQUIP_VARIABLE_ID, equipVariableIdList);
|
||||
List list = query.getResultList();
|
||||
|
||||
return backEquipVariableCollectContextList(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MesEquipVariableCollectContext> queryMesEquipmentLog(String organizeCode, Integer equipId, Integer variableType) {
|
||||
|
||||
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(equipId) || StringUtils.isEmpty(variableType)) return null;
|
||||
|
||||
StringBuffer builder = new StringBuffer();
|
||||
|
||||
builder.append(" select e.equip_variable_id, e.equip_variable_value, e.equip_variable_status, e.quality, e.modify_date_time, e.id ");
|
||||
builder.append(" from mes_equipment_log_");
|
||||
if (!StringUtils.isEmpty(mesShardingAppendOrg) && mesShardingAppendOrg.toUpperCase().equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.name())) builder.append(organizeCode.toLowerCase()).append(MesPcnExtConstWords.E_UNDERLINE);
|
||||
builder.append(equipId);
|
||||
builder.append(" e where e.organize_code = :organizeCode and e.variable_type = :variableType ");
|
||||
|
||||
Query query = entityManager.createNativeQuery(builder.toString());
|
||||
query.setParameter(MesPcnExtConstWords.ORGANIZE_CODE, organizeCode);
|
||||
query.setParameter(MesPcnExtConstWords.VARIABLE_TYPE, variableType);
|
||||
List list = query.getResultList();
|
||||
|
||||
return backEquipVariableCollectContextList(list);
|
||||
|
||||
}
|
||||
|
||||
private List<MesEquipVariableCollectContext> backEquipVariableCollectContextList(List list) {
|
||||
|
||||
if (CollectionUtils.isEmpty(list)) return null;
|
||||
|
||||
List<MesEquipVariableCollectContext> equipVariableCollectContextList = new ArrayList<>();
|
||||
|
||||
for (Object equipmentLog : list) {
|
||||
|
||||
if (null == equipmentLog) continue;
|
||||
|
||||
Object[] equipmentLogArr = (Object[]) equipmentLog;
|
||||
|
||||
if (null == equipmentLogArr || equipmentLogArr.length != 6 || StringUtils.isEmpty(equipmentLogArr[0])) continue;
|
||||
|
||||
equipVariableCollectContextList.add(new MesEquipVariableCollectContext(Long.valueOf(equipmentLogArr[0].toString())).copyValue(equipmentLogArr[1], equipmentLogArr[2], equipmentLogArr[3], equipmentLogArr[4], equipmentLogArr[5]));
|
||||
|
||||
}
|
||||
|
||||
return equipVariableCollectContextList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertBatchEquipmentLogDetail(String organizeCode, Integer equipId, String userInfo, MesEquipmentRecord equipmentRecord, List<MesEquipVariableCollectContext> equipmentLogList) {
|
||||
|
||||
StringBuffer builder = new StringBuffer();
|
||||
|
||||
Integer index = 0;
|
||||
for (MesEquipVariableCollectContext equipmentLog : equipmentLogList) {
|
||||
if (null == equipmentLog) continue;
|
||||
|
||||
builder.append(" insert into mes_equipment_log_detail_");
|
||||
if (!StringUtils.isEmpty(mesShardingAppendOrg) && mesShardingAppendOrg.toUpperCase().equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.name())) builder.append(organizeCode.toLowerCase()).append(MesPcnExtConstWords.E_UNDERLINE);
|
||||
builder.append(equipId);
|
||||
builder.append("( id, organize_code, is_valid, is_deleted, create_user, create_date_time, modify_user, modify_date_time,");
|
||||
builder.append(" description, remark, system_sync_date_time, system_sync_status,");
|
||||
builder.append(" area_code, work_center_code, work_cell_code, equipment_code, process_code, craft_code,");
|
||||
builder.append(" mould_record_id, extend, org_equip_id, equip_id, equip_variable_id, equip_variable_name, equip_variable_desc,");
|
||||
builder.append(" read_write_flag, data_type, equip_variable_value, variable_type, category_level_two, quality)");
|
||||
builder.append(" values ( ");
|
||||
|
||||
for (int i = 0; i < equipmentLogDetailFields.length; i ++) {
|
||||
if (StringUtils.isEmpty(equipmentLogDetailFields[i])) continue;
|
||||
|
||||
builder.append(MesPcnExtConstWords.COLON);
|
||||
builder.append(equipmentLogDetailFields[i]);
|
||||
builder.append(MesPcnExtConstWords.E_UNDERLINE);
|
||||
builder.append(index);
|
||||
if (i != equipmentLogDetailFields.length - 1) builder.append(" , ");
|
||||
}
|
||||
|
||||
builder.append(" );");
|
||||
|
||||
index ++;
|
||||
|
||||
}
|
||||
|
||||
Query insert = entityManager.createNativeQuery(builder.toString());
|
||||
|
||||
String nowTime = TimeTool.getNowTime(true);
|
||||
String orgEquipId = new StringJoiner(MesPcnExtConstWords.E_UNDERLINE).add(organizeCode).add(equipId.toString()).toString();
|
||||
|
||||
index = 0;
|
||||
for (MesEquipVariableCollectContext equipmentLog : equipmentLogList) {
|
||||
if (null == equipmentLog) continue;
|
||||
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.ID, index), snowflakeIdMaker.nextId());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.ORGANIZE_CODE, index), organizeCode);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.IS_VALID, index), CommonEnumUtil.IS_VAILD.VAILD.getValue());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.IS_DELETED, index), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.CREATE_USER, index), userInfo);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.CREATE_DATE_TIME, index), nowTime);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.MODIFY_USER, index), userInfo);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.MODIFY_DATE_TIME, index), nowTime);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.DESCRIPTION, index), null);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.REMARK, index), null);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME, index), null);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.SYSTEM_SYNC_STATUS, index), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.AREA_CODE, index), equipmentRecord.getAreaCode());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.WORK_CENTER_CODE, index), equipmentRecord.getWorkCenterCode());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.WORK_CELL_CODE, index), equipmentRecord.getWorkCellCode());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EQUIPMENT_CODE, index), equipmentRecord.getEquipmentCode());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.PROCESS_CODE, index), equipmentRecord.getProcessCode());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.CRAFT_CODE, index), equipmentRecord.getCraftCode());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.MOULD_RECORD_ID, index), equipmentRecord.getId());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EXTEND, index), equipmentRecord.getProduceSnJson());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.ORG_EQUIP_ID, index), orgEquipId);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EQUIP_ID, index), equipId);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EQUIP_VARIABLE_ID, index), equipmentLog.getEquipVariableId());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EQUIP_VARIABLE_NAME, index), equipmentLog.getEquipVariableName());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EQUIP_VARIABLE_DESC, index), equipmentLog.getEquipVariableDesc());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.READ_WRITE_FLAG, index), equipmentLog.getReadWriteFlag());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.DATA_TYPE, index), equipmentLog.getDataType());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EQUIP_VARIABLE_VALUE, index), equipmentLog.getEquipVariableValue());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.VARIABLE_TYPE, index), equipmentLog.getVariableType());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.CATEGORY_LEVEL_TWO, index), equipmentLog.getCategoryLevelTwo());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.QUALITY, index), equipmentLog.getQuality());
|
||||
|
||||
index ++;
|
||||
}
|
||||
|
||||
insert.executeUpdate();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.daoimpl;
|
||||
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.dao.IMesEquipmentLogDao;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipVariableCollectContext;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
||||
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentRecord;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class MesEquipmentLogDao implements IMesEquipmentLogDao {
|
||||
|
||||
@Value("${mes.sharding.append.org:}")
|
||||
public String mesShardingAppendOrg;
|
||||
|
||||
@Autowired
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Autowired
|
||||
private SnowflakeIdMaker snowflakeIdMaker;
|
||||
|
||||
private final static String TWO_S_APPEND = "%s_%s";
|
||||
|
||||
private final static String[] equipmentLogDetailFields = {MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.IS_DELETED,
|
||||
MesPcnExtConstWords.CREATE_USER, MesPcnExtConstWords.CREATE_DATE_TIME, MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME,
|
||||
MesPcnExtConstWords.DESCRIPTION, MesPcnExtConstWords.REMARK, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS,
|
||||
MesPcnExtConstWords.AREA_CODE, MesPcnExtConstWords.WORK_CENTER_CODE, MesPcnExtConstWords.WORK_CELL_CODE, MesPcnExtConstWords.EQUIPMENT_CODE,
|
||||
MesPcnExtConstWords.PROCESS_CODE, MesPcnExtConstWords.CRAFT_CODE, MesPcnExtConstWords.MOULD_RECORD_ID, MesPcnExtConstWords.EXTEND,
|
||||
MesPcnExtConstWords.ORG_EQUIP_ID, MesPcnExtConstWords.EQUIP_ID, MesPcnExtConstWords.EQUIP_VARIABLE_ID, MesPcnExtConstWords.EQUIP_VARIABLE_NAME,
|
||||
MesPcnExtConstWords.EQUIP_VARIABLE_DESC, MesPcnExtConstWords.READ_WRITE_FLAG, MesPcnExtConstWords.DATA_TYPE, MesPcnExtConstWords.EQUIP_VARIABLE_VALUE,
|
||||
MesPcnExtConstWords.VARIABLE_TYPE, MesPcnExtConstWords.CATEGORY_LEVEL_TWO, MesPcnExtConstWords.QUALITY};
|
||||
|
||||
@Override
|
||||
public List<MesEquipVariableCollectContext> queryMesEquipmentLog(List<MesEquipmentVariable> equipmentVariableList, String organizeCode, Integer equipId, Integer variableType) {
|
||||
|
||||
List<MesEquipVariableCollectContext> equipVariableCollectContextList = generateEquipVariableCollectContextList(equipmentVariableList);
|
||||
|
||||
if (CollectionUtils.isEmpty(equipmentVariableList) || StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(equipId) || StringUtils.isEmpty(variableType)) return null;
|
||||
|
||||
StringBuffer builder = new StringBuffer();
|
||||
|
||||
builder.append(" select e.equip_variable_id, e.equip_variable_value, e.equip_variable_status, e.quality, e.modify_date_time, e.id ");
|
||||
builder.append(" from mes_equipment_log_");
|
||||
if (!StringUtils.isEmpty(mesShardingAppendOrg) && mesShardingAppendOrg.toUpperCase().equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.name())) builder.append(organizeCode.toLowerCase()).append(MesPcnExtConstWords.E_UNDERLINE);
|
||||
builder.append(equipId);
|
||||
builder.append(" e where e.organize_code = :organizeCode and e.variable_type = :variableType ");
|
||||
|
||||
Query query = entityManager.createNativeQuery(builder.toString());
|
||||
query.setParameter(MesPcnExtConstWords.ORGANIZE_CODE, organizeCode);
|
||||
query.setParameter(MesPcnExtConstWords.VARIABLE_TYPE, variableType);
|
||||
List list = query.getResultList();
|
||||
|
||||
if (CollectionUtils.isEmpty(list)) return equipVariableCollectContextList;
|
||||
|
||||
List<String> equipVariableIdList = equipmentVariableList.stream().filter(o -> null != o).map(o -> o.getId().toString()).collect(Collectors.toList());
|
||||
|
||||
for (Object equipmentLog : list) {
|
||||
|
||||
if (null == equipmentLog) continue;
|
||||
|
||||
Object[] equipmentLogArr = (Object[]) equipmentLog;
|
||||
|
||||
if (null == equipmentLogArr || equipmentLogArr.length != 6 || StringUtils.isEmpty(equipmentLogArr[0]) || !equipVariableIdList.contains(equipmentLogArr[0].toString())) continue;
|
||||
|
||||
equipVariableCollectContextList.stream().filter(o -> (null != o && o.getEquipVariableId().toString().equals(equipmentLogArr[0].toString()))).findFirst().get().copyValue(equipmentLogArr[1], equipmentLogArr[2], equipmentLogArr[3], equipmentLogArr[4], equipmentLogArr[5]);
|
||||
|
||||
}
|
||||
|
||||
return equipVariableCollectContextList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEquipVariableStatus(String organizeCode, Integer equipId, Map<Long, String> equipmentLogIdMap, Integer equipVariableStatus) {
|
||||
|
||||
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(equipId) || CollectionUtils.isEmpty(equipmentLogIdMap) || StringUtils.isEmpty(equipVariableStatus)) return;
|
||||
|
||||
StringBuffer builder = new StringBuffer();
|
||||
|
||||
for (int i = 0; i < equipmentLogIdMap.size(); i ++) {
|
||||
|
||||
builder.append(" update mes_equipment_log_");
|
||||
if (!StringUtils.isEmpty(mesShardingAppendOrg) && mesShardingAppendOrg.toUpperCase().equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.name())) builder.append(organizeCode.toLowerCase()).append(MesPcnExtConstWords.E_UNDERLINE);
|
||||
builder.append(equipId);
|
||||
builder.append(" set equip_variable_status = :equipVariableStatus_");
|
||||
builder.append(i);
|
||||
builder.append(" where id = :id_");
|
||||
builder.append(i);
|
||||
builder.append(" and modify_date_time = :modifyDatetime_");
|
||||
builder.append(i);
|
||||
builder.append(" ;");
|
||||
|
||||
}
|
||||
|
||||
Query update = entityManager.createNativeQuery(builder.toString());
|
||||
|
||||
Integer index = 0;
|
||||
for (Map.Entry<Long, String> entry : equipmentLogIdMap.entrySet()) {
|
||||
if (null == entry) continue;
|
||||
update.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EQUIP_VARIABLE_STATUS, index), equipVariableStatus);
|
||||
update.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.ID, index), entry.getKey());
|
||||
update.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.MODIFY_DATE_TIME, index), entry.getValue());
|
||||
index ++;
|
||||
}
|
||||
|
||||
update.executeUpdate();
|
||||
|
||||
}
|
||||
|
||||
private List<MesEquipVariableCollectContext> generateEquipVariableCollectContextList(List<MesEquipmentVariable> equipmentVariableList) {
|
||||
List<MesEquipVariableCollectContext> equipVariableCollectContextList = new ArrayList<>();
|
||||
if (CollectionUtils.isEmpty(equipmentVariableList)) return equipVariableCollectContextList;
|
||||
equipmentVariableList.stream().filter(o -> null != o).forEach(o -> {
|
||||
MesEquipVariableCollectContext equipVariableCollectContext = new MesEquipVariableCollectContext(o.getId());
|
||||
BeanUtils.copyProperties(o, equipVariableCollectContext);
|
||||
equipVariableCollectContextList.add(equipVariableCollectContext);
|
||||
});
|
||||
return equipVariableCollectContextList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MesEquipVariableCollectContext> queryMesEquipmentLog(String organizeCode, Integer equipId, Integer variableType, List<Long> equipVariableIdList) {
|
||||
|
||||
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(equipId) || StringUtils.isEmpty(variableType) || CollectionUtils.isEmpty(equipVariableIdList)) return null;
|
||||
|
||||
equipVariableIdList = equipVariableIdList.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
|
||||
|
||||
StringBuffer builder = new StringBuffer();
|
||||
|
||||
builder.append(" select e.equip_variable_id, e.equip_variable_value, e.equip_variable_status, e.quality, e.modify_date_time, e.id ");
|
||||
builder.append(" from mes_equipment_log_");
|
||||
if (!StringUtils.isEmpty(mesShardingAppendOrg) && mesShardingAppendOrg.toUpperCase().equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.name())) builder.append(organizeCode.toLowerCase()).append(MesPcnExtConstWords.E_UNDERLINE);
|
||||
builder.append(equipId);
|
||||
builder.append(" e where e.organize_code = :organizeCode and e.variable_type = :variableType ");
|
||||
if (equipVariableIdList.size() == 1) builder.append(" and e.equip_variable_id = :equipVariableId ");
|
||||
else builder.append(" and e.equip_variable_id in (:equipVariableId) ");
|
||||
|
||||
Query query = entityManager.createNativeQuery(builder.toString());
|
||||
query.setParameter(MesPcnExtConstWords.ORGANIZE_CODE, organizeCode);
|
||||
query.setParameter(MesPcnExtConstWords.VARIABLE_TYPE, variableType);
|
||||
if (equipVariableIdList.size() == 1) query.setParameter(MesPcnExtConstWords.EQUIP_VARIABLE_ID, equipVariableIdList.get(0));
|
||||
else query.setParameter(MesPcnExtConstWords.EQUIP_VARIABLE_ID, equipVariableIdList);
|
||||
List list = query.getResultList();
|
||||
|
||||
return backEquipVariableCollectContextList(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MesEquipVariableCollectContext> queryMesEquipmentLog(String organizeCode, Integer equipId, Integer variableType) {
|
||||
|
||||
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(equipId) || StringUtils.isEmpty(variableType)) return null;
|
||||
|
||||
StringBuffer builder = new StringBuffer();
|
||||
|
||||
builder.append(" select e.equip_variable_id, e.equip_variable_value, e.equip_variable_status, e.quality, e.modify_date_time, e.id ");
|
||||
builder.append(" from mes_equipment_log_");
|
||||
if (!StringUtils.isEmpty(mesShardingAppendOrg) && mesShardingAppendOrg.toUpperCase().equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.name())) builder.append(organizeCode.toLowerCase()).append(MesPcnExtConstWords.E_UNDERLINE);
|
||||
builder.append(equipId);
|
||||
builder.append(" e where e.organize_code = :organizeCode and e.variable_type = :variableType ");
|
||||
|
||||
Query query = entityManager.createNativeQuery(builder.toString());
|
||||
query.setParameter(MesPcnExtConstWords.ORGANIZE_CODE, organizeCode);
|
||||
query.setParameter(MesPcnExtConstWords.VARIABLE_TYPE, variableType);
|
||||
List list = query.getResultList();
|
||||
|
||||
return backEquipVariableCollectContextList(list);
|
||||
|
||||
}
|
||||
|
||||
private List<MesEquipVariableCollectContext> backEquipVariableCollectContextList(List list) {
|
||||
|
||||
if (CollectionUtils.isEmpty(list)) return null;
|
||||
|
||||
List<MesEquipVariableCollectContext> equipVariableCollectContextList = new ArrayList<>();
|
||||
|
||||
for (Object equipmentLog : list) {
|
||||
|
||||
if (null == equipmentLog) continue;
|
||||
|
||||
Object[] equipmentLogArr = (Object[]) equipmentLog;
|
||||
|
||||
if (null == equipmentLogArr || equipmentLogArr.length != 6 || StringUtils.isEmpty(equipmentLogArr[0])) continue;
|
||||
|
||||
equipVariableCollectContextList.add(new MesEquipVariableCollectContext(Long.valueOf(equipmentLogArr[0].toString())).copyValue(equipmentLogArr[1], equipmentLogArr[2], equipmentLogArr[3], equipmentLogArr[4], equipmentLogArr[5]));
|
||||
|
||||
}
|
||||
|
||||
return equipVariableCollectContextList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertBatchEquipmentLogDetail(String organizeCode, Integer equipId, String userInfo, MesEquipmentRecord equipmentRecord, List<MesEquipVariableCollectContext> equipmentLogList) {
|
||||
|
||||
StringBuffer builder = new StringBuffer();
|
||||
|
||||
Integer index = 0;
|
||||
|
||||
builder.append(" insert into mes_equipment_log_detail_");
|
||||
if (!StringUtils.isEmpty(mesShardingAppendOrg) && mesShardingAppendOrg.toUpperCase().equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.name())) builder.append(organizeCode.toLowerCase()).append(MesPcnExtConstWords.E_UNDERLINE);
|
||||
builder.append(equipId);
|
||||
builder.append("( id, organize_code, is_valid, is_deleted, create_user, create_date_time, modify_user, modify_date_time,");
|
||||
builder.append(" description, remark, system_sync_date_time, system_sync_status,");
|
||||
builder.append(" area_code, work_center_code, work_cell_code, equipment_code, process_code, craft_code,");
|
||||
builder.append(" mould_record_id, extend, org_equip_id, equip_id, equip_variable_id, equip_variable_name, equip_variable_desc,");
|
||||
builder.append(" read_write_flag, data_type, equip_variable_value, variable_type, category_level_two, quality) values ");
|
||||
|
||||
for (MesEquipVariableCollectContext equipmentLog : equipmentLogList) {
|
||||
if (null == equipmentLog) continue;
|
||||
|
||||
builder.append(" ( ");
|
||||
|
||||
for (int i = 0; i < equipmentLogDetailFields.length; i ++) {
|
||||
if (StringUtils.isEmpty(equipmentLogDetailFields[i])) continue;
|
||||
|
||||
builder.append(MesPcnExtConstWords.COLON);
|
||||
builder.append(equipmentLogDetailFields[i]);
|
||||
builder.append(MesPcnExtConstWords.E_UNDERLINE);
|
||||
builder.append(index);
|
||||
if (i != equipmentLogDetailFields.length - 1) builder.append(" , ");
|
||||
}
|
||||
|
||||
builder.append(" ) ");
|
||||
if (index != equipmentLogList.size() - 1) builder.append(" , ");
|
||||
|
||||
index ++;
|
||||
|
||||
}
|
||||
|
||||
Query insert = entityManager.createNativeQuery(builder.toString());
|
||||
|
||||
String nowTime = TimeTool.getNowTime(true);
|
||||
String orgEquipId = new StringJoiner(MesPcnExtConstWords.E_UNDERLINE).add(organizeCode).add(equipId.toString()).toString();
|
||||
|
||||
index = 0;
|
||||
for (MesEquipVariableCollectContext equipmentLog : equipmentLogList) {
|
||||
if (null == equipmentLog) continue;
|
||||
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.ID, index), snowflakeIdMaker.nextId());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.ORGANIZE_CODE, index), organizeCode);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.IS_VALID, index), CommonEnumUtil.IS_VAILD.VAILD.getValue());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.IS_DELETED, index), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.CREATE_USER, index), userInfo);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.CREATE_DATE_TIME, index), StringUtils.isEmpty(equipmentLog.getWriteDatetime()) ? nowTime : equipmentLog.getWriteDatetime());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.MODIFY_USER, index), userInfo);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.MODIFY_DATE_TIME, index), StringUtils.isEmpty(equipmentLog.getWriteDatetime()) ? nowTime : equipmentLog.getWriteDatetime());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.DESCRIPTION, index), null);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.REMARK, index), null);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME, index), null);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.SYSTEM_SYNC_STATUS, index), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.AREA_CODE, index), equipmentRecord.getAreaCode());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.WORK_CENTER_CODE, index), equipmentRecord.getWorkCenterCode());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.WORK_CELL_CODE, index), equipmentRecord.getWorkCellCode());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EQUIPMENT_CODE, index), equipmentRecord.getEquipmentCode());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.PROCESS_CODE, index), equipmentRecord.getProcessCode());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.CRAFT_CODE, index), equipmentRecord.getCraftCode());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.MOULD_RECORD_ID, index), equipmentRecord.getId());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EXTEND, index), equipmentRecord.getProduceSnJson());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.ORG_EQUIP_ID, index), orgEquipId);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EQUIP_ID, index), equipId);
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EQUIP_VARIABLE_ID, index), equipmentLog.getEquipVariableId());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EQUIP_VARIABLE_NAME, index), equipmentLog.getTagName());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EQUIP_VARIABLE_DESC, index), equipmentLog.getTagAddress());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.READ_WRITE_FLAG, index), equipmentLog.getReadWriteFlag());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.DATA_TYPE, index), equipmentLog.getDataType());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.EQUIP_VARIABLE_VALUE, index), equipmentLog.getEquipVariableValue());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.VARIABLE_TYPE, index), equipmentLog.getVariableType());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.CATEGORY_LEVEL_TWO, index), StringUtils.isEmpty(equipmentLog.getCategoryLevelTwo()) ? null : equipmentLog.getCategoryLevelTwo());
|
||||
insert.setParameter(String.format(TWO_S_APPEND, MesPcnExtConstWords.QUALITY, index), equipmentLog.getQuality());
|
||||
|
||||
index ++;
|
||||
}
|
||||
|
||||
insert.executeUpdate();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,97 @@
|
||||
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesCustomerPartService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
|
||||
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesNumberRule;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesPackage;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesPrintedSnLog;
|
||||
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
|
||||
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
|
||||
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description : 包装条码打印
|
||||
* @Reference :
|
||||
* @Author : wangjie
|
||||
* @CreateDate : 2024/9/29 16:43
|
||||
* @Modify:
|
||||
**/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class YfaiPackageNoFengRenPrintStrategy implements IPrintTemplateStrategyService {
|
||||
|
||||
@Autowired
|
||||
private IMesCustomerPartService mesCustomerPartService;
|
||||
|
||||
@Override
|
||||
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel model,
|
||||
MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean,
|
||||
Boolean isStep) {
|
||||
|
||||
MesCustomerPart customerPart = (!Objects.isNull(genSerialNoModel) &&
|
||||
!CollectionUtils.isEmpty(genSerialNoModel.getDataMap()) && genSerialNoModel.getDataMap().containsKey(MesCustomerPart.class.getSimpleName()))
|
||||
? (MesCustomerPart) genSerialNoModel.getDataMap().get(MesCustomerPart.class.getSimpleName())
|
||||
: mesCustomerPartService.getMesCustomerPart(model.getOrganizeCode(), model.getPartNo());
|
||||
|
||||
// 返回的结果集合
|
||||
List<Map<String, Object>> printDataMapList = new ArrayList<>();
|
||||
if (!isStep) {
|
||||
model.getPackageList().forEach(o -> printDataMapList.add(getPrintMap(model, o, customerPart)));
|
||||
model.setPrintContextList(printDataMapList);
|
||||
} else {
|
||||
model.getPackageList().forEach(o -> printDataMapList.add(getPrintMap(model, o, customerPart)));
|
||||
model.getPrintContextList().add(packResultMap(model, printDataMapList));
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
private Map<String, Object> packResultMap(MesProduceSnPrintModel printModel, List<Map<String, Object>> printTemplateDateList) {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
resultMap.put(MesPcnExtConstWords.LABEL_TEMPLATE, printModel.getMesLabelTemplate());
|
||||
resultMap.put(MesPcnExtConstWords.TEMPLATE_DATA, printTemplateDateList);
|
||||
resultMap.put(MesPcnExtConstWords.TEMPLATE_CODE, printModel.getMesLabelTemplate().getTemplateCode());
|
||||
resultMap.put(MesPcnExtConstWords.PRINTER, printModel.getPrinter());
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
private MesPrintedSnLog getMesPrintedSnLog(MesPackage packageDb, String userName, String printData) {
|
||||
MesPrintedSnLog snLog = new MesPrintedSnLog();
|
||||
snLog.setBarcode(packageDb.getPackageNo());
|
||||
snLog.setPartNo(packageDb.getPartNo());
|
||||
snLog.setPartName(packageDb.getPartName());
|
||||
snLog.setPrintData(printData);
|
||||
snLog.setOrganizeCode(packageDb.getOrganizeCode());
|
||||
ConvertBean.serviceModelInitialize(snLog, userName);
|
||||
return snLog;
|
||||
}
|
||||
|
||||
private Map<String, Object> getPrintMap(MesProduceSnPrintModel model, MesPackage packageDb, MesCustomerPart customerPart) {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
resultMap.put(MesPcnExtConstWords.PART_NO, packageDb.getPartNo());
|
||||
resultMap.put(MesPcnExtConstWords.PART_NAME, packageDb.getPartName());
|
||||
resultMap.put(MesPcnExtConstWords.CUST_PART_NO, null == customerPart ? MesPcnExtConstWords.EMPTY : customerPart.getCustPartNo());
|
||||
resultMap.put(MesPcnExtConstWords.QR_CODE, packageDb.getPackageNo());
|
||||
resultMap.put(MesPcnExtConstWords.QTY, packageDb.getQty().intValue());
|
||||
resultMap.put(MesPcnExtConstWords.UNIT, packageDb.getUnit());
|
||||
resultMap.put(MesPcnExtConstWords.PACK_SPEC_QTY, packageDb.getPackSpecQty().intValue());
|
||||
resultMap.put(MesPcnExtConstWords.LOT_NO, packageDb.getLotNo().replaceAll(MesPcnExtConstWords.SEPARATOR, MesPcnExtConstWords.SLANT_R));
|
||||
resultMap.put(MesPcnExtConstWords.BAR_CODE, packageDb.getPackageOneCode());
|
||||
resultMap.put(MesPcnExtConstWords.MODIFY_DATE_TIME, packageDb.getModifyDatetime().replaceAll(MesPcnExtConstWords.SEPARATOR, MesPcnExtConstWords.SLANT_R));
|
||||
model.getMesPrintedSnLogList().add(getMesPrintedSnLog(packageDb, model.getUserName(), JSONObject.toJSONString(resultMap)));
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue