|
|
|
@ -3,6 +3,7 @@ package cn.estsh.i3plus.ext.mes.apiservice.daoimpl;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.apiservice.dao.IMesDefectRecordDao;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pojo.model.MesDefectRecordModel;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -31,19 +32,20 @@ public class MesDefectRecordDaoImpl implements IMesDefectRecordDao {
|
|
|
|
|
@Override
|
|
|
|
|
public List<MesDefectRecordModel> queryMesDefectRecordGroupBy(String organizeCode, Integer count, String createDateTimeStart, String createDateTimeEnd) {
|
|
|
|
|
|
|
|
|
|
StringBuffer hql = new StringBuffer("select mdr.part_no ,mp.part_type_code , mdr.sides ,mdr.defect_location_code ,mdr.defect_code ");
|
|
|
|
|
hql.append(" from mes_defect_record as mdr");
|
|
|
|
|
hql.append(" inner join mes_part as mp where mdr.part_no = mp.part_no and mdr.organize_code = mp.organize_code ");
|
|
|
|
|
hql.append(" and mdr.is_deleted = mp.is_deleted and mdr.is_valid = mp.is_valid ");
|
|
|
|
|
hql.append(" where mdr.organize_code = :organizeCode ");
|
|
|
|
|
hql.append(" and mdr.is_deleted = :isDeleted ");
|
|
|
|
|
hql.append(" and mdr.is_valid = :isValid ");
|
|
|
|
|
hql.append(" and mdr.nc_type = 0 ");
|
|
|
|
|
hql.append(" and sap.create_date_time >= :createDateTimeStart");
|
|
|
|
|
hql.append(" and sap.create_date_time <= :createDateTimeEnd");
|
|
|
|
|
|
|
|
|
|
hql.append(" group by mdr.part_no ,mp.part_type_code mdr.sides ,mdr.defect_location_code ,mdr.defect_code ");
|
|
|
|
|
hql.append(" having count() > " + count);
|
|
|
|
|
StringBuffer hql = new StringBuffer("select mpi.part_no, mp.part_type_code,mpid.front_back, mpid.defect_location, mpid.defect_type_code ");
|
|
|
|
|
hql.append(" from mes_part_inspection_detail as mpid");
|
|
|
|
|
hql.append(" INNER JOIN mes_part_inspection AS mpi ON mpid.pid = mpi.id ");
|
|
|
|
|
hql.append(" and mpid.organize_code = mpi.organize_code and mpid.is_deleted = mpi.is_deleted and mpid.is_valid = mpi.is_valid ");
|
|
|
|
|
hql.append(" INNER JOIN mes_part AS mp ON mp.part_no = mpi.part_no ");
|
|
|
|
|
hql.append(" and mp.organize_code = mpi.organize_code and mp.is_deleted = mpi.is_deleted and mp.is_valid = mpi.is_valid ");
|
|
|
|
|
hql.append(" where mpid.organize_code = :organizeCode ");
|
|
|
|
|
hql.append(" and mpid.is_deleted = :isDeleted ");
|
|
|
|
|
hql.append(" and mpid.is_valid = :isValid ");
|
|
|
|
|
// hql.append(" and mpi.inspection_status = :inspectionStatus ");
|
|
|
|
|
hql.append(" and mpid.create_date_time >= :createDateTimeStart");
|
|
|
|
|
hql.append(" and mpid.create_date_time <= :createDateTimeEnd");
|
|
|
|
|
hql.append(" GROUP BY mpi.part_no, mp.part_type_code, mpid.front_back, mpid.defect_location, mpid.defect_type_code ");
|
|
|
|
|
hql.append(" having count(1) >= " + count);
|
|
|
|
|
|
|
|
|
|
Query query = entityManager.createNativeQuery(hql.toString());
|
|
|
|
|
query.setParameter("organizeCode", organizeCode);
|
|
|
|
@ -51,6 +53,7 @@ public class MesDefectRecordDaoImpl implements IMesDefectRecordDao {
|
|
|
|
|
query.setParameter("isDeleted", CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
|
|
|
|
query.setParameter("createDateTimeStart", createDateTimeStart);
|
|
|
|
|
query.setParameter("createDateTimeEnd", createDateTimeEnd);
|
|
|
|
|
query.setParameter("inspectionStatus", MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue());
|
|
|
|
|
|
|
|
|
|
List list = query.getResultList();
|
|
|
|
|
|
|
|
|
|