Merge branch 'dev' into dev-wuhan

tags/yfai-mes-ext-v2.3
王杰 7 months ago
commit 18efcb1c04

@ -1,8 +1,11 @@
package cn.estsh.i3plus.ext.mes.api.base; package cn.estsh.i3plus.ext.mes.api.base;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.mes.bean.MesDowntimeRecord; import cn.estsh.i3plus.pojo.mes.bean.MesDowntimeRecord;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipment; import cn.estsh.i3plus.pojo.mes.bean.MesEquipment;
import cn.estsh.i3plus.pojo.mes.model.report.MesDowntimeRecordResModel;
import java.util.List; import java.util.List;
@ -20,4 +23,6 @@ public interface IMesDowntimeRecordService extends IBaseMesService<MesDowntimeRe
* @param mesEquipmentList * @param mesEquipmentList
*/ */
void doMesDowntimeRecordJob(String organizeCode, List<MesEquipment> mesEquipmentList); void doMesDowntimeRecordJob(String organizeCode, List<MesEquipment> mesEquipmentList);
ListPager<MesDowntimeRecordResModel> queryRecordList(MesDowntimeRecord downtimeRecord, Pager pager);
} }

@ -2,6 +2,9 @@ package cn.estsh.i3plus.ext.mes.api.base;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentProdParamCfg; import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentProdParamCfg;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentSpotCheckDetail; import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentSpotCheckDetail;
import io.swagger.annotations.ApiOperation;
import java.util.List;
/** /**
* @Description : * @Description :
@ -12,5 +15,6 @@ import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentSpotCheckDetail;
**/ **/
public interface IMesEquipmentSpotCheckDetailService extends IBaseMesService<MesEquipmentSpotCheckDetail>{ public interface IMesEquipmentSpotCheckDetailService extends IBaseMesService<MesEquipmentSpotCheckDetail>{
@ApiOperation(value = "校验并返回导入数据", notes = "校验并返回导入数据")
List<MesEquipmentSpotCheckDetail> validateReturnImport(List<MesEquipmentSpotCheckDetail> bean, String equipmentCode);
} }

@ -1,9 +1,25 @@
package cn.estsh.i3plus.ext.mes.apiservice.controller.base; package cn.estsh.i3plus.ext.mes.apiservice.controller.base;
import cn.estsh.i3plus.ext.mes.api.base.IMesEquipmentSpotCheckDetailService;
import cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.excel.MesExcelTool;
import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant; import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentSpotCheckDetail; import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentSpotCheckDetail;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.RedisCacheTool;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/** /**
* *
@ -11,4 +27,37 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping(MesCommonConstant.MES_YANFEN + "/mesEquipmentCheckDetail") @RequestMapping(MesCommonConstant.MES_YANFEN + "/mesEquipmentCheckDetail")
public class MesEquipmentCheckDetailController extends BaseMesController<MesEquipmentSpotCheckDetail>{ public class MesEquipmentCheckDetailController extends BaseMesController<MesEquipmentSpotCheckDetail>{
@Autowired
private IMesEquipmentSpotCheckDetailService mesEquipmentSpotCheckDetailService;
@PostMapping(value = "/data/import")
@ApiOperation(value = "导入数据校验返回")
public ResultBean importExtExcel(@RequestParam("file") MultipartFile file, @RequestParam("equipmentCode") String equipmentCode) {
try {
MesExcelTool excelTool = new MesExcelTool(entityManager, RedisCacheTool.getImppRedis());
List<MesEquipmentSpotCheckDetail> beanList = excelTool.importData(file.getOriginalFilename(), file.getInputStream(), mesClass);
// 校验导入数据
List<MesEquipmentSpotCheckDetail> returnImport = mesEquipmentSpotCheckDetailService.validateReturnImport(beanList, equipmentCode);
String userName = AuthUtil.getSessionUser().getUserName();
String organizeCode = AuthUtil.getOrganize().getOrganizeCode();
// 导入数据初始化
/* String userName = "zxw";
String organizeCode = "CK01";*/
for (MesEquipmentSpotCheckDetail bean : returnImport) {
ConvertBean.serviceModelInitialize(bean, userName);
bean.setOrganizeCode(organizeCode);
}
baseService.insertBatch(returnImport);
// 导入后
afterImport(returnImport);
return ResultBean.success("导入成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
} catch (ImppBusiException e) {
return ResultBean.fail(e);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
} }

@ -1,6 +1,7 @@
package cn.estsh.i3plus.ext.mes.apiservice.controller.busi; package cn.estsh.i3plus.ext.mes.apiservice.controller.busi;
import cn.estsh.i3plus.ext.mes.apiservice.schedulejob.MesAccountJob; import cn.estsh.i3plus.ext.mes.apiservice.schedulejob.MesAccountJob;
import cn.estsh.i3plus.ext.mes.apiservice.schedulejob.MesDowntimeRecordJob;
import cn.estsh.i3plus.ext.mes.apiservice.schedulejob.MesGenerateAccountJob; import cn.estsh.i3plus.ext.mes.apiservice.schedulejob.MesGenerateAccountJob;
import cn.estsh.i3plus.ext.mes.apiservice.schedulejob.MesWorkOrderUpdateQtyJob; import cn.estsh.i3plus.ext.mes.apiservice.schedulejob.MesWorkOrderUpdateQtyJob;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -23,6 +24,9 @@ public class TestController {
@Autowired @Autowired
private MesGenerateAccountJob mesGenerateAccountJob; private MesGenerateAccountJob mesGenerateAccountJob;
@Autowired
private MesDowntimeRecordJob mesDowntimeRecordJob;
@GetMapping("/reportOrder") @GetMapping("/reportOrder")
@ApiOperation(value = "报工") @ApiOperation(value = "报工")
public void reportOrder() { public void reportOrder() {
@ -40,4 +44,11 @@ public class TestController {
public void generateMesAccount() { public void generateMesAccount() {
mesGenerateAccountJob.executeMesJob(null, null); mesGenerateAccountJob.executeMesJob(null, null);
} }
@GetMapping("/mesDowntimeRecordJob")
@ApiOperation(value = "downtime")
public void mesDowntimeRecordJob() {
mesDowntimeRecordJob.executeMesJob(null, null);
}
} }

@ -1,13 +1,17 @@
package cn.estsh.i3plus.ext.mes.apiservice.controller.report; package cn.estsh.i3plus.ext.mes.apiservice.controller.report;
import cn.estsh.i3plus.ext.mes.api.base.IMesDowntimeRecordService;
import cn.estsh.i3plus.ext.mes.api.base.IMesProductionRecordService; import cn.estsh.i3plus.ext.mes.api.base.IMesProductionRecordService;
import cn.estsh.i3plus.ext.mes.api.busi.report.IMesYfReportService; import cn.estsh.i3plus.ext.mes.api.busi.report.IMesYfReportService;
import cn.estsh.i3plus.ext.mes.apiservice.config.AuthUtilExt; import cn.estsh.i3plus.ext.mes.apiservice.config.AuthUtilExt;
import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant; import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.mes.bean.MesDowntimeRecord;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn; import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord; import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord;
import cn.estsh.i3plus.pojo.mes.model.MesProductionRecordModel; import cn.estsh.i3plus.pojo.mes.model.MesProductionRecordModel;
import cn.estsh.i3plus.pojo.mes.model.report.MesDowntimeRecordResModel;
import cn.estsh.i3plus.pojo.mes.model.report.MesProductAccountModel; import cn.estsh.i3plus.pojo.mes.model.report.MesProductAccountModel;
import cn.estsh.i3plus.pojo.mes.model.report.MesProductAccountResModel; import cn.estsh.i3plus.pojo.mes.model.report.MesProductAccountResModel;
import cn.estsh.impp.framework.base.controller.MesBaseController; import cn.estsh.impp.framework.base.controller.MesBaseController;
@ -44,6 +48,9 @@ public class MesBusiReportController extends MesBaseController {
@Autowired @Autowired
private IMesProductionRecordService mesProductionRecordService; private IMesProductionRecordService mesProductionRecordService;
@Autowired
private IMesDowntimeRecordService mesDowntimeRecordService;
@ApiOperation(value = "查询追溯报表", notes = "查询追溯报表") @ApiOperation(value = "查询追溯报表", notes = "查询追溯报表")
@GetMapping("/traceability/find") @GetMapping("/traceability/find")
public ResultBean findTraceabilityReport(MesProduceSn mesProduceSn) { public ResultBean findTraceabilityReport(MesProduceSn mesProduceSn) {
@ -125,4 +132,20 @@ public class MesBusiReportController extends MesBaseController {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e); return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
} }
} }
@ApiOperation(value = "设备停机记录报表", notes = "设备停机记录报表")
@GetMapping("/equipment/downtime/record")
public ResultBean downtimeRecord(MesDowntimeRecord mesDowntimeRecord, Pager pager) {
try {
ListPager<MesDowntimeRecordResModel> recordList = mesDowntimeRecordService.queryRecordList(mesDowntimeRecord, pager);
return ResultBean.success("查询成功").setListPager(recordList);
} catch (ImppBusiException e) {
return ResultBean.fail(e);
} catch (Exception e) {
e.printStackTrace();
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
} }

@ -145,7 +145,7 @@ public class MesAccountJob extends BaseMesScheduleJob {
DdlPreparedPack.getStringEqualPack(detailLogs.get(0).getEquipVariableValue(), "mouldNo", mouldMultipackBeanTemp); DdlPreparedPack.getStringEqualPack(detailLogs.get(0).getEquipVariableValue(), "mouldNo", mouldMultipackBeanTemp);
List<MesMouldMultiCavity> mouldMultiCavities = mesMouldMultiCavityRepository.findByHqlWhere(mouldMultipackBeanTemp); List<MesMouldMultiCavity> mouldMultiCavities = mesMouldMultiCavityRepository.findByHqlWhere(mouldMultipackBeanTemp);
if (CollectionUtils.isEmpty(mouldMultiCavities)) { if (CollectionUtils.isEmpty(mouldMultiCavities)) {
continue; partNo = "";
} else { } else {
List<String> partList = mouldMultiCavities.stream().map(MesMouldMultiCavity::getPartNo).distinct().collect(Collectors.toList()); List<String> partList = mouldMultiCavities.stream().map(MesMouldMultiCavity::getPartNo).distinct().collect(Collectors.toList());
partNo = String.join(",", partList); partNo = String.join(",", partList);

@ -21,6 +21,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.List; import java.util.List;
@ -34,6 +35,7 @@ import java.util.List;
**/ **/
@DisallowConcurrentExecution @DisallowConcurrentExecution
@ApiOperation("MES设备生产停机记录") @ApiOperation("MES设备生产停机记录")
@Service
public class MesDowntimeRecordJob extends BaseMesScheduleJob { public class MesDowntimeRecordJob extends BaseMesScheduleJob {
public static final Logger LOGGER = LoggerFactory.getLogger(MesDowntimeRecordJob.class); public static final Logger LOGGER = LoggerFactory.getLogger(MesDowntimeRecordJob.class);
@ -60,9 +62,9 @@ public class MesDowntimeRecordJob extends BaseMesScheduleJob {
public void executeMesJob(JobExecutionContext context, ApplicationProperties applicationProperties) { public void executeMesJob(JobExecutionContext context, ApplicationProperties applicationProperties) {
try { try {
String jobParam = this.getJobParam(); String jobParam = this.getJobParam();
//String jobParam = "CK01";
if (StringUtils.isBlank(jobParam)) { if (StringUtils.isBlank(jobParam)) {
throw new IllegalArgumentException("job参数为空请检查参数"); jobParam = "CK01";
} }
String[] organizeCodeList = jobParam.split(","); String[] organizeCodeList = jobParam.split(",");
LOGGER.info("MES设备生产停机记录 -----start"); LOGGER.info("MES设备生产停机记录 -----start");

@ -113,7 +113,7 @@ public class MesBomService extends BaseMesService<MesBom> implements IMesBomServ
organize.setParentId(CommonEnumUtil.PARENT.DEFAULT.getValue()); organize.setParentId(CommonEnumUtil.PARENT.DEFAULT.getValue());
organize.setName(AuthUtil.getOrganize().getName()); organize.setName(AuthUtil.getOrganize().getName());
//organize.setName("zxw");
DdlPackBean packBean = DdlPackBean.getDdlPackBean(bom.getOrganizeCode()); DdlPackBean packBean = DdlPackBean.getDdlPackBean(bom.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(bom.getPartNo(), "partNo", packBean); DdlPreparedPack.getStringEqualPack(bom.getPartNo(), "partNo", packBean);
DdlPreparedPack.getStringEqualPack(bom.getBomVersion(), "bomVersion", packBean); DdlPreparedPack.getStringEqualPack(bom.getBomVersion(), "bomVersion", packBean);

@ -2,31 +2,38 @@ package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.base;
import cn.estsh.i3plus.ext.mes.api.base.IMesConfigService; import cn.estsh.i3plus.ext.mes.api.base.IMesConfigService;
import cn.estsh.i3plus.ext.mes.api.base.IMesDowntimeRecordService; import cn.estsh.i3plus.ext.mes.api.base.IMesDowntimeRecordService;
import cn.estsh.i3plus.ext.mes.apiservice.utils.BeanUtil;
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords; import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
import cn.estsh.i3plus.platform.common.convert.ConvertBean; import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum; import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
import cn.estsh.i3plus.platform.common.tool.TimeTool; import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.platform.common.util.MesConstWords; import cn.estsh.i3plus.platform.common.util.MesConstWords;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.base.util.StringUtil; import cn.estsh.i3plus.pojo.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.*; import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.repository.MesDowntimeRecordRepository; import cn.estsh.i3plus.pojo.mes.model.report.MesDowntimeRecordResModel;
import cn.estsh.i3plus.pojo.mes.repository.MesProductionRecordRepository; import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.repository.MesWcEquipmentRepository;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ValidatorBean; import cn.estsh.impp.framework.boot.util.ValidatorBean;
import cn.hutool.core.stream.CollectorUtil;
import com.codepoetics.protonpack.collectors.CollectorUtils;
import com.xxl.job.core.util.DateUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.*;
import java.util.Date; import java.util.stream.Collectors;
import java.util.List;
import java.util.Objects;
/** /**
@ -46,10 +53,26 @@ public class MesDowntimeRecordServiceImpl extends BaseMesService<MesDowntimeReco
private MesDowntimeRecordRepository mesDowntimeRecordRDao; private MesDowntimeRecordRepository mesDowntimeRecordRDao;
@Autowired @Autowired
private IMesConfigService mesConfigService; private IMesBasDowntimeReasonRepository downtimeReasonRepository;
@Autowired
private IMesBasDowntimeReasonTypeRepository downtimeReasonTypeRepository;
@Autowired @Autowired
private MesWcEquipmentRepository wcEquipmentRepository; private MesWcEquipmentRepository wcEquipmentRepository;
@Autowired
private MesEquipmentRepository equipmentRepository;
@Autowired
private IMesConfigService mesConfigService;
@Autowired
private MesWorkCenterRepository workCenterRepository;
@Autowired
private MesWorkCellRepository workCellRepository;
@Override @Override
protected void setPackQueryBean(MesDowntimeRecord bean, DdlPackBean packBean) { protected void setPackQueryBean(MesDowntimeRecord bean, DdlPackBean packBean) {
DdlPreparedPack.getStringEqualPack(bean.getWorkCenterCode(), "workCenterCode", packBean); DdlPreparedPack.getStringEqualPack(bean.getWorkCenterCode(), "workCenterCode", packBean);
@ -117,10 +140,12 @@ public class MesDowntimeRecordServiceImpl extends BaseMesService<MesDowntimeReco
if(!StringUtil.isEmpty(type)){ if(!StringUtil.isEmpty(type)){
DdlPreparedPack.getStringEqualPack(type, "reasonTypeCode", ddlPackBeanDowntime); DdlPreparedPack.getStringEqualPack(type, "reasonTypeCode", ddlPackBeanDowntime);
} }
MesDowntimeRecord mesDowntimeRecordDao = mesDowntimeRecordRDao.getByProperty(ddlPackBeanDowntime); DdlPreparedPack.getOrderBy("createDatetime", CommonEnumUtil.ASC_OR_DESC.DESC.getValue(), ddlPackBeanDowntime);
if (StringUtil.isEmpty(mesDowntimeRecordDao)) {
List<MesDowntimeRecord> mesDowntimeRecordDaoList = mesDowntimeRecordRDao.findByHqlTopWhere(ddlPackBeanDowntime, 1);
if (CollectionUtils.isEmpty(mesDowntimeRecordDaoList)) {
MesWcEquipment wcEquipmentDbList = wcEquipmentRepository.getByProperty( MesWcEquipment wcEquipmentDbList = wcEquipmentRepository.getByProperty(
new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED, MesConstWords.IS_VALID,""}, new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED, MesConstWords.IS_VALID,"equipmentCode"},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(),
mesEquipment.getEquipmentCode()}); mesEquipment.getEquipmentCode()});
//新增设备停机记录 //新增设备停机记录
@ -134,6 +159,8 @@ public class MesDowntimeRecordServiceImpl extends BaseMesService<MesDowntimeReco
mesDowntimeRecord.setReasonCode(StringUtil.isEmpty(reason)?"21":reason); mesDowntimeRecord.setReasonCode(StringUtil.isEmpty(reason)?"21":reason);
mesDowntimeRecord.setReasonTypeCode(StringUtil.isEmpty(type)?"6":type); mesDowntimeRecord.setReasonTypeCode(StringUtil.isEmpty(type)?"6":type);
ConvertBean.serviceModelInitialize(mesDowntimeRecord, "MesDowntimeRecordJob"); ConvertBean.serviceModelInitialize(mesDowntimeRecord, "MesDowntimeRecordJob");
mesDowntimeRecord.setSystemSyncStatus(2);
mesDowntimeRecord.setModifyDatetime(null);
//将当前新增数据的create_date_time时间些到上一条记录的modify_date_time字段 //将当前新增数据的create_date_time时间些到上一条记录的modify_date_time字段
DdlPackBean ddlPackBeanOt = DdlPackBean.getDdlPackBean(organizeCode); DdlPackBean ddlPackBeanOt = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(mesEquipment.getEquipmentCode(), "equipmentCode", ddlPackBeanOt); DdlPreparedPack.getStringEqualPack(mesEquipment.getEquipmentCode(), "equipmentCode", ddlPackBeanOt);
@ -147,12 +174,178 @@ public class MesDowntimeRecordServiceImpl extends BaseMesService<MesDowntimeReco
mesDowntimeRecordRDao.insert(mesDowntimeRecord); mesDowntimeRecordRDao.insert(mesDowntimeRecord);
}else { }else {
ConvertBean.serviceModelUpdate(mesDowntimeRecordDao, "MesDowntimeRecordJob"); // 如果上一次停机还未结束,则不需要再生成一条新的记录
if (StringUtils.isEmpty(mesDowntimeRecordDaoList.get(0).getModifyDatetime())) {
continue;
}
ConvertBean.serviceModelUpdate(mesDowntimeRecordDaoList.get(0), "MesDowntimeRecordJob");
mesDowntimeRecordDaoList.get(0).setSystemSyncStatus(2);
mesDowntimeRecordRDao.update(mesDowntimeRecordDaoList.get(0));
}
} else {
DdlPackBean ddlPackBeanDowntime = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(mesEquipment.getEquipmentCode(), "equipmentCode", ddlPackBeanDowntime);
if(!StringUtil.isEmpty(reason)){
DdlPreparedPack.getStringEqualPack(reason, "reasonCode", ddlPackBeanDowntime);
}
if(!StringUtil.isEmpty(type)){
DdlPreparedPack.getStringEqualPack(type, "reasonTypeCode", ddlPackBeanDowntime);
}
DdlPreparedPack.getOrderBy("createDatetime", CommonEnumUtil.ASC_OR_DESC.DESC.getValue(), ddlPackBeanDowntime);
MesDowntimeRecord mesDowntimeRecordDao = mesDowntimeRecordRDao.getByProperty(ddlPackBeanDowntime);
if (mesDowntimeRecordDao != null) {
mesDowntimeRecordDao.setModifyDatetime(mesProductionRecord.getCompleteDateTime());
mesDowntimeRecordRDao.update(mesDowntimeRecordDao); mesDowntimeRecordRDao.update(mesDowntimeRecordDao);
} }
} }
}
}
@Override
public ListPager<MesDowntimeRecordResModel> queryRecordList(MesDowntimeRecord downtimeRecord, Pager pager) {
ListPager pagerList = new ListPager();
List<MesDowntimeRecordResModel> list = new ArrayList<>();
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();
if (!StringUtils.isEmpty(downtimeRecord.getEquipmentCode())) {
DdlPreparedPack.getStringEqualPack(downtimeRecord.getEquipmentCode(), "equipmentCode", ddlPackBean);
}
if (!StringUtils.isEmpty(downtimeRecord.getWorkCenterCode())) {
DdlPreparedPack.getStringEqualPack(downtimeRecord.getWorkCenterCode(), "workCenterCode", ddlPackBean);
}
if (!StringUtils.isEmpty(downtimeRecord.getWorkCellCode())) {
DdlPreparedPack.getStringEqualPack(downtimeRecord.getWorkCellCode(), "workCellCode", ddlPackBean);
}
DdlPreparedPack.getStringEqualPack(downtimeRecord.getReasonTypeCode(),"reasonTypeCode", ddlPackBean);
if (!StringUtils.isEmpty(downtimeRecord.getCreateDatetime())) {
DdlPreparedPack.getStringBiggerPack(downtimeRecord.getCreateDatetime(), "createDatetime", ddlPackBean);
}
if (!StringUtils.isEmpty(downtimeRecord.getModifyDatetime())) {
DdlPreparedPack.getStringSmallerPack(downtimeRecord.getModifyDatetime(), "modifyDatetime", ddlPackBean);
}
pager = PagerHelper.getPager(pager, mesDowntimeRecordRDao.findByHqlWhereCount(ddlPackBean));
List<MesDowntimeRecord> recordList = mesDowntimeRecordRDao.findByHqlWherePage(ddlPackBean, pager);
if (!CollectionUtils.isEmpty(recordList)) {
List<String> reasonCodeList = recordList.stream().map(MesDowntimeRecord::getReasonCode).distinct().collect(Collectors.toList());
List<String> reasonTypeCodeList = recordList.stream().map(MesDowntimeRecord::getReasonTypeCode).distinct().collect(Collectors.toList());
List<String> equipmentInfoList = recordList.stream().map(MesDowntimeRecord::getEquipmentCode).distinct().collect(Collectors.toList());
List<String> workCellList = recordList.stream().map(MesDowntimeRecord::getWorkCellCode).distinct().collect(Collectors.toList());
List<String> workCenterList = recordList.stream().map(MesDowntimeRecord::getWorkCenterCode).distinct().collect(Collectors.toList());
Map<String, List<MesDowntimeReason>> reasonMap = getReason(reasonCodeList);
Map<String, MesEquipment> equipmentMap = getEquipment(equipmentInfoList);
Map<String, MesWorkCenter> workCenterMap = getWorkCenter(workCenterList);
Map<String, MesWorkCell> workCellMap = getWorkCell(workCellList);
Map<String, List<MesDowntimeReasonType>> reasonTypeMap = getReasonType(reasonTypeCodeList);
recordList.stream().forEach(record -> {
MesDowntimeRecordResModel mesDowntimeRecordResModel = new MesDowntimeRecordResModel();
BeanUtils.copyProperties(record, mesDowntimeRecordResModel);
if (!StringUtils.isEmpty(record.getReasonCode())) {
if (reasonMap.get(record.getReasonCode()) != null) {
mesDowntimeRecordResModel.setReasonName(reasonMap.get(record.getReasonCode()).get(0).getReasonName());
}
}
if (!StringUtils.isEmpty(record.getReasonTypeCode())) {
if (reasonTypeMap.get(record.getReasonTypeCode()) != null) {
mesDowntimeRecordResModel.setReasonTypeName(reasonTypeMap.get(record.getReasonTypeCode()).get(0).getReasonTypeName());
}
}
if (!StringUtils.isEmpty(record.getEquipmentCode())) {
mesDowntimeRecordResModel.setEquipmentName(equipmentMap.get(record.getEquipmentCode()).getEquipmentName());
}
if (!StringUtils.isEmpty(record.getWorkCenterCode())) {
mesDowntimeRecordResModel.setWorkCenterName(workCenterMap.get(record.getWorkCenterCode()).getWorkCenterName());
}
if (!StringUtils.isEmpty(record.getWorkCellCode())) {
mesDowntimeRecordResModel.setWorkCellName(workCellMap.get(record.getWorkCellCode()).getWorkCellName());
}
// 如果停机结束时间还在,则需要补充动态停机时间,否则需要有停机时间
if (StringUtils.isEmpty(mesDowntimeRecordResModel.getModifyDatetime())) {
Date startTime = DateUtil.parseDateTime(mesDowntimeRecordResModel.getCreateDatetime());
Date currentTime = new Date();
Long time = (currentTime.getTime() - startTime.getTime())/(1000 * 60);
mesDowntimeRecordResModel.setCurrentDownTime(time.intValue());
} else {
Date startTime = DateUtil.parseDateTime(mesDowntimeRecordResModel.getCreateDatetime());
Date endTime = DateUtil.parseDateTime(mesDowntimeRecordResModel.getModifyDatetime());
Long time = (endTime.getTime() - startTime.getTime())/(1000 * 60);
mesDowntimeRecordResModel.setDownTime(time.intValue());
}
list.add(mesDowntimeRecordResModel);
});
}
pagerList.setObjectList(list);
pagerList.setObjectPager(pager);
return pagerList;
}
private Map<String, List<MesDowntimeReason>> getReason(List<String> reasonCodeList) {
Map<String, List<MesDowntimeReason>> reasonMap = new HashedMap();
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();
DdlPreparedPack.getInPackList(reasonCodeList, "reasonCode", ddlPackBean);
List<MesDowntimeReason> downtimeReasons = downtimeReasonRepository.findByHqlWhere(ddlPackBean);
if (!CollectionUtils.isEmpty(downtimeReasons)) {
reasonMap = downtimeReasons.stream().distinct().collect(Collectors.groupingBy(MesDowntimeReason::getReasonCode));
}
return reasonMap;
}
private Map<String, List<MesDowntimeReasonType>> getReasonType(List<String> reasonTypeCodeList) {
Map<String, List<MesDowntimeReasonType>> reasonMap = new HashedMap();
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();
DdlPreparedPack.getInPackList(reasonTypeCodeList, "reasonTypeCode", ddlPackBean);
List<MesDowntimeReasonType> downtimeReasonTypes = downtimeReasonTypeRepository.findByHqlWhere(ddlPackBean);
if (!CollectionUtils.isEmpty(downtimeReasonTypes)) {
reasonMap = downtimeReasonTypes.stream().collect(Collectors.groupingBy(MesDowntimeReasonType::getReasonTypeCode));
}
return reasonMap;
}
private Map<String, MesEquipment> getEquipment(List<String> equipmentList) {
Map<String, MesEquipment> equipmentMap = new HashedMap();
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();
DdlPreparedPack.getInPackList(equipmentList, "equipmentCode", ddlPackBean);
List<MesEquipment> equipments = equipmentRepository.findByHqlWhere(ddlPackBean);
if (!CollectionUtils.isEmpty(equipments)) {
equipmentMap = equipments.stream().collect(Collectors.toMap(MesEquipment::getEquipmentCode, m -> m));
}
return equipmentMap;
}
private Map<String, MesWorkCenter> getWorkCenter(List<String> workCenterList) {
Map<String, MesWorkCenter> workCenterMap = new HashedMap();
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();
DdlPreparedPack.getInPackList(workCenterList, "workCenterCode", ddlPackBean);
List<MesWorkCenter> workCenters = workCenterRepository.findByHqlWhere(ddlPackBean);
if (!CollectionUtils.isEmpty(workCenters)) {
workCenterMap = workCenters.stream().collect(Collectors.toMap(MesWorkCenter::getWorkCenterCode, m -> m));
}
return workCenterMap;
}
private Map<String, MesWorkCell> getWorkCell(List<String> equipmentList) {
Map<String, MesWorkCell> workCellMap = new HashedMap();
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();
DdlPreparedPack.getInPackList(equipmentList, "workCellCode", ddlPackBean);
List<MesWorkCell> workCells = workCellRepository.findByHqlWhere(ddlPackBean);
if (!CollectionUtils.isEmpty(workCells)) {
workCellMap = workCells.stream().collect(Collectors.toMap(MesWorkCell::getWorkCellCode, m -> m));
} }
return workCellMap;
} }
/** /**

@ -3,6 +3,7 @@ package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.base;
import cn.estsh.i3plus.ext.mes.api.base.IMesEquipmentSpotCheckDetailService; import cn.estsh.i3plus.ext.mes.api.base.IMesEquipmentSpotCheckDetailService;
import cn.estsh.i3plus.ext.mes.apiservice.config.AuthUtilExt; import cn.estsh.i3plus.ext.mes.apiservice.config.AuthUtilExt;
import cn.estsh.i3plus.ext.mes.apiservice.utils.BeanMapUtilsExt; import cn.estsh.i3plus.ext.mes.apiservice.utils.BeanMapUtilsExt;
import cn.estsh.i3plus.ext.mes.apiservice.utils.MesException;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum; import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
@ -16,15 +17,13 @@ import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentVariableRepository;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ValidatorBean; import cn.estsh.impp.framework.boot.util.ValidatorBean;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@ -105,10 +104,10 @@ public class MesEquipmentSpotCheckDetailService extends BaseMesService<MesEquipm
} }
} }
@Override @Override
public List<MesEquipmentSpotCheckDetail> validateReturnImport(List<MesEquipmentSpotCheckDetail> beanList) { public List<MesEquipmentSpotCheckDetail> validateReturnImport(List<MesEquipmentSpotCheckDetail> beanList, String equipmentCode) {
if (CollectionUtils.isEmpty(beanList)) return beanList; if (CollectionUtils.isEmpty(beanList)) return beanList;
//设备变量MAP //设备变量MAP
Map<String, MesEquipmentVariable> variableMap = getEquipmentVariableMap(beanList); Map<String, MesEquipmentVariable> variableMap = getEquipmentVariableMap(beanList, equipmentCode);
for (MesEquipmentSpotCheckDetail item : beanList) { for (MesEquipmentSpotCheckDetail item : beanList) {
// 数据校验 // 数据校验
if(StringUtil.isEmpty(item.getPid())){ if(StringUtil.isEmpty(item.getPid())){
@ -154,8 +153,10 @@ public class MesEquipmentSpotCheckDetailService extends BaseMesService<MesEquipm
return beanList; return beanList;
} }
private Map<String, MesEquipmentVariable> getEquipmentVariableMap(List<MesEquipmentSpotCheckDetail> beanList) { private Map<String, MesEquipmentVariable> getEquipmentVariableMap(List<MesEquipmentSpotCheckDetail> beanList, String equipmentCode) {
String organizeCode = AuthUtilExt.getOrganizeCode(); String organizeCode = AuthUtilExt.getOrganizeCode();
//String organizeCode = "CK01";
List<String> addressList = new ArrayList<>(); List<String> addressList = new ArrayList<>();
//查询设备变量信息 //查询设备变量信息
List<String> realAddress = beanList.stream().map(MesEquipmentSpotCheckDetail::getRealValueAddress).filter(t-> !StringUtils.isEmpty(t)).distinct().collect(Collectors.toList()); List<String> realAddress = beanList.stream().map(MesEquipmentSpotCheckDetail::getRealValueAddress).filter(t-> !StringUtils.isEmpty(t)).distinct().collect(Collectors.toList());
@ -163,6 +164,19 @@ public class MesEquipmentSpotCheckDetailService extends BaseMesService<MesEquipm
if (!CollectionUtils.isEmpty(realAddress)) addressList.addAll(realAddress); if (!CollectionUtils.isEmpty(realAddress)) addressList.addAll(realAddress);
if (!CollectionUtils.isEmpty(setAddress)) addressList.addAll(setAddress); if (!CollectionUtils.isEmpty(setAddress)) addressList.addAll(setAddress);
if (CollectionUtils.isEmpty(addressList)) return null; if (CollectionUtils.isEmpty(addressList)) return null;
return BeanMapUtilsExt.getBeanMap(mesEquipmentVariableRepository, "tagName", organizeCode, addressList, "设备变量");
Map<String, MesEquipmentVariable> beanMap = new HashMap();
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(addressList, "tagName", packBean);
DdlPreparedPack.getStringEqualPack(equipmentCode, "equipmentCode", packBean);
List<MesEquipmentVariable> baseDataList = mesEquipmentVariableRepository.findByHqlWhere(packBean);
if (!CollectionUtils.isEmpty(baseDataList)) {
beanMap = baseDataList.stream().collect(Collectors.toMap(mesEquipmentVariable -> mesEquipmentVariable.getTagName(), o-> o));
} else {
MesException.throwMesBusiException(addressList + "信息不存在");
}
return beanMap;
} }
} }

@ -30,7 +30,7 @@ public class MesPartTransferDetailService extends BaseMesService<MesPartTransfer
ValidatorBean.checkNotNull(item.getPartNo(), "partNo不能为空"); ValidatorBean.checkNotNull(item.getPartNo(), "partNo不能为空");
ValidatorBean.checkNotNull(item.getCustPartNo(), "custPartNo不能为空" ); ValidatorBean.checkNotNull(item.getCustPartNo(), "custPartNo不能为空" );
ValidatorBean.checkNotNull(item.getFeatureNo(), "featureNo不能为空"); ValidatorBean.checkNotNull(item.getFeatureNo(), "featureNo不能为空");
// ValidatorBean.checkNotNull(item.getCustCode(), "custCode不能为空" ); // ValidatorBean.checkNotNull(item.getCustCode(), "custCode不能为空" );+
// ValidatorBean.checkNotNull(item.getMessageNo(), "messageNo不能为空"); // ValidatorBean.checkNotNull(item.getMessageNo(), "messageNo不能为空");
// ValidatorBean.checkNotNull(item.getCustOrganizeCode(), "custOrganizeCode不能为空" ); // ValidatorBean.checkNotNull(item.getCustOrganizeCode(), "custOrganizeCode不能为空" );

Loading…
Cancel
Save