forked from I3-YF/i3plus-mes-yfai
产线看板-“异常停线时间”部分需求未明确
parent
aa6c6f58b3
commit
dfa12c6df5
@ -0,0 +1,46 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.dao.board;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pojo.model.board.MesWorkCenterBoardResultModel;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesShift;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 看板-数据方法实现
|
||||||
|
* @Reference :
|
||||||
|
* @Author : logic
|
||||||
|
* @CreateDate : 2024/6/24 18:22
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
public interface IMesYfBoardDao {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询指定产线在当前时间节点有效的班次信息
|
||||||
|
* @param workCenterCodeList 指定产线代码集合
|
||||||
|
* @param organizeCode 组织代码
|
||||||
|
* @param nowDateTime 当前时间
|
||||||
|
* @return 指定产线在当前时间节点有效的班次信息
|
||||||
|
*/
|
||||||
|
List<MesShift> queryMesShift(List<String> workCenterCodeList, String organizeCode, String nowDateTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询指定产线在指定时间区间内的生产汇报数据
|
||||||
|
* @param workCenterCode 产线代码
|
||||||
|
* @param organizeCode 组织代码
|
||||||
|
* @param startTime 查询起始时间
|
||||||
|
* @param endTime 查询结束时间
|
||||||
|
* @return 生产汇报数据
|
||||||
|
*/
|
||||||
|
List<MesWorkCenterBoardResultModel> queryMesProductOffLineModel(String workCenterCode, String organizeCode, String startTime, String endTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询指定产线在指定时间区间内的生产加工完成条码及状态
|
||||||
|
* @param workCenterCode 产线代码
|
||||||
|
* @param organizeCode 组织代码
|
||||||
|
* @param startTime 查询起始时间
|
||||||
|
* @param endTime 查询结束时间
|
||||||
|
* @return 加工完成条码及其质量状态
|
||||||
|
*/
|
||||||
|
List<MesWorkCenterBoardResultModel> queryCompletedSnInfo(String workCenterCode, String organizeCode, String startTime, String endTime);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,127 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.daoimpl.board;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.apiservice.dao.board.IMesYfBoardDao;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pojo.model.board.MesWorkCenterBoardResultModel;
|
||||||
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesShift;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.Query;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 看板-数据方法实现
|
||||||
|
* @Reference :
|
||||||
|
* @Author : logic
|
||||||
|
* @CreateDate : 2024/6/24 18:22
|
||||||
|
* @Modify:
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
public class MesYfBoardDaoImpl implements IMesYfBoardDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MesShift> queryMesShift(List<String> workCenterCodeList, String organizeCode, String nowDateTime) {
|
||||||
|
StringBuffer queryShiftSql = new StringBuffer();
|
||||||
|
queryShiftSql.append("from MesShift " +
|
||||||
|
"where isValid = :isValid " +
|
||||||
|
"and isDeleted = :isDeleted " +
|
||||||
|
"and organizeCode = :organizeCode " +
|
||||||
|
"and workCenterCode in (:workCenterCodeList) " +
|
||||||
|
"and beginDate <= :nowDateTime " +
|
||||||
|
"and endDate >= :nowDateTime ");
|
||||||
|
Query shiftQuery = entityManager.createQuery(queryShiftSql.toString(), MesShift.class);
|
||||||
|
shiftQuery.setParameter("isValid", CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
||||||
|
shiftQuery.setParameter("isDeleted", CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
||||||
|
shiftQuery.setParameter("organizeCode", organizeCode);
|
||||||
|
shiftQuery.setParameter("workCenterCodeList", workCenterCodeList);
|
||||||
|
shiftQuery.setParameter("nowDateTime", nowDateTime);
|
||||||
|
return shiftQuery.getResultList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MesWorkCenterBoardResultModel> queryMesProductOffLineModel(String workCenterCode, String organizeCode,
|
||||||
|
String startTime, String endTime) {
|
||||||
|
StringBuffer queryMesProductOffLineSql = new StringBuffer();
|
||||||
|
queryMesProductOffLineSql.append("select distinct new " + MesWorkCenterBoardResultModel.class.getName() +
|
||||||
|
"(serialNumber, " +
|
||||||
|
"createDatetime) " +
|
||||||
|
"from MesProductOffLine " +
|
||||||
|
"where isValid = :isValid " +
|
||||||
|
"and isDeleted = :isDeleted " +
|
||||||
|
"and organizeCode = :organizeCode " +
|
||||||
|
"and workCenterCode = :workCenterCode " +
|
||||||
|
"and createDatetime >= :startTime " +
|
||||||
|
"and createDatetime <= :endTime ");
|
||||||
|
Query shiftQuery = entityManager.createQuery(queryMesProductOffLineSql.toString(), MesWorkCenterBoardResultModel.class);
|
||||||
|
shiftQuery.setParameter("isValid", CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
||||||
|
shiftQuery.setParameter("isDeleted", CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
||||||
|
shiftQuery.setParameter("organizeCode", organizeCode);
|
||||||
|
shiftQuery.setParameter("workCenterCode", workCenterCode);
|
||||||
|
shiftQuery.setParameter("startTime", startTime);
|
||||||
|
shiftQuery.setParameter("endTime", endTime);
|
||||||
|
return shiftQuery.getResultList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MesWorkCenterBoardResultModel> queryCompletedSnInfo(String workCenterCode, String organizeCode, String startTime, String endTime) {
|
||||||
|
//先查询生产加工表中指定时间区间、指定产线已加工完成的数据
|
||||||
|
StringBuffer queryMesProductionRecordSql = new StringBuffer();
|
||||||
|
queryMesProductionRecordSql.append("select distinct new " + MesWorkCenterBoardResultModel.class.getName() +
|
||||||
|
"(serialNumber, " +
|
||||||
|
"createDatetime) " +
|
||||||
|
"from MesProductionRecord " +
|
||||||
|
"where isValid = :isValid " +
|
||||||
|
"and isDeleted = :isDeleted " +
|
||||||
|
"and organizeCode = :organizeCode " +
|
||||||
|
"and workCenterCode = :workCenterCode " +
|
||||||
|
"and isComplete = :isComplete " +
|
||||||
|
"and createDatetime >= :startTime " +
|
||||||
|
"and createDatetime <= :endTime ");
|
||||||
|
Query mesProductionRecordQuery = entityManager.createQuery(queryMesProductionRecordSql.toString(), MesWorkCenterBoardResultModel.class);
|
||||||
|
mesProductionRecordQuery.setParameter("isValid", CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
||||||
|
mesProductionRecordQuery.setParameter("isDeleted", CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
||||||
|
mesProductionRecordQuery.setParameter("organizeCode", organizeCode);
|
||||||
|
mesProductionRecordQuery.setParameter("workCenterCode", workCenterCode);
|
||||||
|
mesProductionRecordQuery.setParameter("isComplete", CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
||||||
|
mesProductionRecordQuery.setParameter("startTime", startTime);
|
||||||
|
mesProductionRecordQuery.setParameter("endTime", endTime);
|
||||||
|
List<MesWorkCenterBoardResultModel> productionRecordQueryResultList = mesProductionRecordQuery.getResultList();
|
||||||
|
if (!CollectionUtils.isEmpty(productionRecordQueryResultList)) {
|
||||||
|
//取出所有过程条码
|
||||||
|
List<String> serialNumberList = productionRecordQueryResultList.
|
||||||
|
stream().map(MesWorkCenterBoardResultModel::getSerialNumber).collect(Collectors.toList());
|
||||||
|
StringBuffer queryMesProduceSnSql = new StringBuffer();
|
||||||
|
queryMesProduceSnSql.append("select distinct serialNumber " +
|
||||||
|
"from MesProduceSn " +
|
||||||
|
"where isValid = :isValid " +
|
||||||
|
"and isDeleted = :isDeleted " +
|
||||||
|
"and organizeCode = :organizeCode " +
|
||||||
|
"and qcStatus = :qcStatus " +
|
||||||
|
"and serialNumber in ( :serialNumberList )");
|
||||||
|
Query mesProduceSnQuery = entityManager.createQuery(queryMesProduceSnSql.toString());
|
||||||
|
mesProduceSnQuery.setParameter("isValid", CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
||||||
|
mesProduceSnQuery.setParameter("isDeleted", CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
||||||
|
mesProduceSnQuery.setParameter("organizeCode", organizeCode);
|
||||||
|
mesProduceSnQuery.setParameter("qcStatus", MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
|
||||||
|
mesProduceSnQuery.setParameter("serialNumberList", serialNumberList);
|
||||||
|
List<String> resultList = mesProduceSnQuery.getResultList();
|
||||||
|
for (MesWorkCenterBoardResultModel resultModel : productionRecordQueryResultList) {
|
||||||
|
if (resultList.contains(resultModel.getSerialNumber())) {
|
||||||
|
resultModel.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
|
||||||
|
}else {
|
||||||
|
resultModel.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return productionRecordQueryResultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue