forked from I3-YF/i3plus-mes-yfai
跨工厂防错功能开发
parent
56f285e1cf
commit
8f88fcadac
@ -0,0 +1,17 @@
|
||||
package cn.estsh.i3plus.ext.mes.api.base;
|
||||
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesCorssOrganizeErrorProofing;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* @Description : 跨工厂防错
|
||||
* @Reference :
|
||||
* @Author : junsheng.li
|
||||
* @CreateDate 2024/7/4 16:49
|
||||
* @Modify:
|
||||
**/
|
||||
public interface IMesCorssOrganizeErrorProofingService extends IBaseMesService<MesCorssOrganizeErrorProofing> {
|
||||
|
||||
@ApiOperation("跨工厂防错JOB")
|
||||
void doMesCorssOrganizeErrorProofing(String organizeCode ,Integer pageSize,String userName);
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cn.estsh.i3plus.ext.mes.apiservice.controller.base;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesCorssOrganizeErrorProofing;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Description : 跨工厂防错
|
||||
* @Reference :
|
||||
* @Author : junsheng.li
|
||||
* @CreateDate 2024/7/4 16:48
|
||||
* @Modify:
|
||||
**/
|
||||
@Api(tags = "跨工厂防错")
|
||||
@RestController
|
||||
@RequestMapping(MesCommonConstant.MES_YANFEN + "/mesCorssOrganizeErrorProofing")
|
||||
public class MesCorssOrganizeErrorProofingController extends BaseMesController<MesCorssOrganizeErrorProofing> {
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cn.estsh.i3plus.ext.mes.apiservice.dao;
|
||||
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesCorssOrganizeErrorProofing;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description : 跨工厂防错
|
||||
* @Reference :
|
||||
* @Author : junsheng.li
|
||||
* @CreateDate 2024/7/4 18:03
|
||||
* @Modify:
|
||||
**/
|
||||
public interface IMesCorssOrganizeErrorProofingDao {
|
||||
|
||||
@ApiOperation("根据工厂物料,查询产品条码信息")
|
||||
List<MesProduceSn> findMesProduceSnByOrganizeCodeAndPart(MesCorssOrganizeErrorProofing mesCorssOrganizeErrorProofing, Integer pageSize);
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package cn.estsh.i3plus.ext.mes.apiservice.daoimpl;
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.apiservice.dao.IMesCorssOrganizeErrorProofingDao;
|
||||
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesCorssOrganizeErrorProofing;
|
||||
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description : 跨工厂防错
|
||||
* @Reference :
|
||||
* @Author : junsheng.li
|
||||
* @CreateDate 2024/7/4 17:59
|
||||
* @Modify:
|
||||
**/
|
||||
@Service
|
||||
public class MesCorssOrganizeErrorProofingDaoImpl implements IMesCorssOrganizeErrorProofingDao {
|
||||
|
||||
@Autowired
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Override
|
||||
public List<MesProduceSn> findMesProduceSnByOrganizeCodeAndPart(MesCorssOrganizeErrorProofing mesCorssOrganizeErrorProofing, Integer pageSize) {
|
||||
String sql = "select srcSn from MesProduceSn srcSn left join MesProduceSn destSn on srcSn.serialNumber = destSn.serialNumber " +
|
||||
" and destSn.organizeCode=:destOrganizeCode and destSn.isDeleted=:isDeleted and destSn.isValid = :isValid " +
|
||||
" where srcSn.createDatetime >= :createDatetime and srcSn.organizeCode = :srcOrganizeCode " +
|
||||
" and srcSn.isDeleted=:isDeleted and srcSn.isValid = :isValid and srcSn.partNo = :partNo " +
|
||||
" and srcSn.snStatus in (10,20) and srcSn.qcStatus in (10,15) and destSn.serialNumber is null " +
|
||||
" order by srcSn.createDatetime asc";
|
||||
Query query = entityManager.createQuery(sql, MesProduceSn.class);
|
||||
query.setParameter("srcOrganizeCode", mesCorssOrganizeErrorProofing.getSrcOrganizeCode());
|
||||
query.setParameter("destOrganizeCode", mesCorssOrganizeErrorProofing.getOrganizeCode());
|
||||
query.setParameter("isValid", CommonEnumUtil.VALID);
|
||||
query.setParameter("isDeleted", CommonEnumUtil.FALSE);
|
||||
query.setParameter("partNo", mesCorssOrganizeErrorProofing.getPartNo());
|
||||
if (StringUtils.isEmpty(mesCorssOrganizeErrorProofing.getLastCreateDatetime())) {
|
||||
query.setParameter("createDatetime", TimeTool.pareDateToString(new Date(0)));
|
||||
} else {
|
||||
query.setParameter("createDatetime", mesCorssOrganizeErrorProofing.getLastCreateDatetime());
|
||||
}
|
||||
query.setFirstResult(0).setMaxResults(pageSize);
|
||||
return query.getResultList();
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package cn.estsh.i3plus.ext.mes.apiservice.schedulejob;
|
||||
|
||||
|
||||
import cn.estsh.i3plus.ext.mes.api.base.IMesCorssOrganizeErrorProofingService;
|
||||
import cn.estsh.i3plus.mes.apiservice.schedulejob.BaseMesScheduleJob;
|
||||
import cn.estsh.i3plus.platform.common.tool.JsonUtilTool;
|
||||
import cn.estsh.i3plus.pojo.model.wms.WmsJobParamModel;
|
||||
import cn.estsh.impp.framework.boot.init.ApplicationProperties;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.DisallowConcurrentExecution;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description : 跨工厂防错JOB
|
||||
* @Reference :
|
||||
* @Author : junsheng.li
|
||||
* @CreateDate 2024/7/5 11:07
|
||||
* @Modify:
|
||||
**/
|
||||
@Slf4j
|
||||
@DisallowConcurrentExecution
|
||||
@Component
|
||||
@ApiOperation("跨工厂防错JOB")
|
||||
public class MesCorssOrganizeErrorProofingJob extends BaseMesScheduleJob {
|
||||
|
||||
@Autowired
|
||||
private IMesCorssOrganizeErrorProofingService mesCorssOrganizeErrorProofingService;
|
||||
|
||||
public MesCorssOrganizeErrorProofingJob() {
|
||||
super(MesCorssOrganizeErrorProofingJob.class, "跨工厂防错JOB");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeMesJob(JobExecutionContext context, ApplicationProperties applicationProperties) {
|
||||
List<WmsJobParamModel> wmsJobParamModelList = JsonUtilTool.toList(this.getJobParam(), WmsJobParamModel.class);
|
||||
if (!CollectionUtils.isEmpty(wmsJobParamModelList)) {
|
||||
for (WmsJobParamModel wmsJobParamModel : wmsJobParamModelList) {
|
||||
//统计数据
|
||||
try {
|
||||
long startTime = System.currentTimeMillis();
|
||||
mesCorssOrganizeErrorProofingService.doMesCorssOrganizeErrorProofing(wmsJobParamModel.getOrganizeCode(), wmsJobParamModel.getPageSize(), "job");
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info("工厂{}跨工厂防错job --- END --- 耗时: {} ms", wmsJobParamModel.getOrganizeCode(), endTime - startTime);
|
||||
} catch (Exception e) {
|
||||
log.info("工厂{}跨工厂防错job 执行失败{}", wmsJobParamModel.getOrganizeCode(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue