|
|
|
@ -34,8 +34,7 @@ public class MesProductionRecordReportExtDao implements IMesProductionRecordRepo
|
|
|
|
|
private EntityManager entityManager;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ListPager<MesProductionRecordReportExtModel> queryProductionRecordUnionWorkOrderLogReport(
|
|
|
|
|
MesProductionRecordReportExtModel model, Pager pager, List<Integer> reportStatusList2Pr, List<Integer> reportStatusList2Wo) {
|
|
|
|
|
public ListPager<MesProductionRecordReportExtModel> queryProductionRecordUnionWorkOrderLogReport(MesProductionRecordReportExtModel model, Pager pager, List<Integer> reportStatusList) {
|
|
|
|
|
|
|
|
|
|
List<MesProductionRecordReportExtModel> resultList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
@ -49,7 +48,7 @@ public class MesProductionRecordReportExtDao implements IMesProductionRecordRepo
|
|
|
|
|
StringBuilder endHql = new StringBuilder();
|
|
|
|
|
StringBuilder limitHql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList2Pr) && !CollectionUtils.isEmpty(reportStatusList2Wo)) {
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList) && model.getIsQueryWo()) {
|
|
|
|
|
unionQueryHql.append("SELECT " +
|
|
|
|
|
" o.workCenterCode, " +
|
|
|
|
|
" o.workCellCode, " +
|
|
|
|
@ -71,7 +70,7 @@ public class MesProductionRecordReportExtDao implements IMesProductionRecordRepo
|
|
|
|
|
countQueryHql.append("SELECT count(1) FROM ( ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList2Pr)) {
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList)) {
|
|
|
|
|
prQueryHql.append("" +
|
|
|
|
|
" SELECT " +
|
|
|
|
|
" a.work_center_code AS workCenterCode, " +
|
|
|
|
@ -93,7 +92,7 @@ public class MesProductionRecordReportExtDao implements IMesProductionRecordRepo
|
|
|
|
|
" AND a.is_valid = :isValid " +
|
|
|
|
|
" AND a.complete_date_time >= :completeDateTimeStart " +
|
|
|
|
|
" AND a.complete_date_time <= :completeDateTimeEnd ");
|
|
|
|
|
if (reportStatusList2Pr.size() == 1) {
|
|
|
|
|
if (reportStatusList.size() == 1) {
|
|
|
|
|
prQueryHql.append(" AND a.report_status = :reportStatus ");
|
|
|
|
|
} else {
|
|
|
|
|
prQueryHql.append(" AND a.report_status in (:reportStatus) ");
|
|
|
|
@ -124,11 +123,11 @@ public class MesProductionRecordReportExtDao implements IMesProductionRecordRepo
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList2Pr) && !CollectionUtils.isEmpty(reportStatusList2Wo)) {
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList) && model.getIsQueryWo()) {
|
|
|
|
|
prQueryHql.append(" ) UNION ALL ( ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList2Wo)) {
|
|
|
|
|
if (model.getIsQueryWo()) {
|
|
|
|
|
woQueryHql.append("" +
|
|
|
|
|
" SELECT " +
|
|
|
|
|
" b.work_center_code AS workCenterCode, " +
|
|
|
|
@ -169,7 +168,7 @@ public class MesProductionRecordReportExtDao implements IMesProductionRecordRepo
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList2Pr) && !CollectionUtils.isEmpty(reportStatusList2Wo)) {
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList) && model.getIsQueryWo()) {
|
|
|
|
|
endHql.append(" )) AS o ");
|
|
|
|
|
} else {
|
|
|
|
|
endHql.append(" ) AS o ");
|
|
|
|
@ -177,11 +176,11 @@ public class MesProductionRecordReportExtDao implements IMesProductionRecordRepo
|
|
|
|
|
|
|
|
|
|
limitHql.append(" LIMIT :startRow , :pageSize ");
|
|
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList2Pr) && !CollectionUtils.isEmpty(reportStatusList2Wo)) {
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList) && model.getIsQueryWo()) {
|
|
|
|
|
queryHql.append(unionQueryHql).append(prQueryHql).append(woQueryHql).append(endHql).append(limitHql);
|
|
|
|
|
countHql.append(countQueryHql).append(prQueryHql).append(woQueryHql).append(endHql);
|
|
|
|
|
} else {
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList2Pr)) {
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList)) {
|
|
|
|
|
queryHql.append(prQueryHql).append(limitHql);
|
|
|
|
|
countHql.append(countQueryHql).append(prQueryHql).append(endHql);
|
|
|
|
|
} else {
|
|
|
|
@ -194,9 +193,9 @@ public class MesProductionRecordReportExtDao implements IMesProductionRecordRepo
|
|
|
|
|
// log.info("countHql: --- {}", countHql.toString());
|
|
|
|
|
|
|
|
|
|
Query dataQuery = entityManager.createNativeQuery(queryHql.toString());
|
|
|
|
|
setQueryParams(dataQuery, model, reportStatusList2Pr, reportStatusList2Wo, pager);
|
|
|
|
|
setQueryParams(dataQuery, model, reportStatusList, pager);
|
|
|
|
|
Query countQuery = entityManager.createNativeQuery(countHql.toString());
|
|
|
|
|
setQueryParams(countQuery, model, reportStatusList2Pr, reportStatusList2Wo, null);
|
|
|
|
|
setQueryParams(countQuery, model, reportStatusList, null);
|
|
|
|
|
|
|
|
|
|
Object o = countQuery.getSingleResult();
|
|
|
|
|
|
|
|
|
@ -232,26 +231,20 @@ public class MesProductionRecordReportExtDao implements IMesProductionRecordRepo
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setQueryParams(Query query, MesProductionRecordReportExtModel model, List<Integer> reportStatusList2Pr, List<Integer> reportStatusList2Wo, Pager pager) {
|
|
|
|
|
private void setQueryParams(Query query, MesProductionRecordReportExtModel model, List<Integer> reportStatusList, Pager pager) {
|
|
|
|
|
query.setParameter(MesExtConstWords.ORGANIZE_CODE, model.getOrganizeCode());
|
|
|
|
|
query.setParameter(MesExtConstWords.IS_DELETED, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
|
|
|
|
query.setParameter(MesExtConstWords.IS_VALID, CommonEnumUtil.IS_VAILD.VAILD.getValue());
|
|
|
|
|
query.setParameter(MesExtConstWords.COMPLETE_DATE_TIME_START, model.getCompleteDateTimeStart());
|
|
|
|
|
query.setParameter(MesExtConstWords.COMPLETE_DATE_TIME_END, model.getCompleteDateTimeEnd());
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList2Pr)) {
|
|
|
|
|
if (reportStatusList2Pr.size() == 1) {
|
|
|
|
|
query.setParameter(MesExtConstWords.REPORT_STATUS, reportStatusList2Pr.get(0));
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList)) {
|
|
|
|
|
if (reportStatusList.size() == 1) {
|
|
|
|
|
query.setParameter(MesExtConstWords.REPORT_STATUS, reportStatusList.get(0));
|
|
|
|
|
} else {
|
|
|
|
|
query.setParameter(MesExtConstWords.REPORT_STATUS, reportStatusList2Pr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!CollectionUtils.isEmpty(reportStatusList2Wo)) {
|
|
|
|
|
if (reportStatusList2Pr.size() == 1) {
|
|
|
|
|
query.setParameter(MesExtConstWords.MESSAGE_TYPE, reportStatusList2Wo.get(0));
|
|
|
|
|
} else {
|
|
|
|
|
query.setParameter(MesExtConstWords.MESSAGE_TYPE, reportStatusList2Wo);
|
|
|
|
|
query.setParameter(MesExtConstWords.REPORT_STATUS, reportStatusList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (model.getIsQueryWo()) query.setParameter(MesExtConstWords.MESSAGE_TYPE, MesExtEnumUtil.WORK_ORDER_LOG_TYPE.REPORT.getValue());
|
|
|
|
|
if (!StringUtils.isEmpty(model.getPartNo())) {
|
|
|
|
|
query.setParameter(MesExtConstWords.PART_NO, model.getPartNo());
|
|
|
|
|
}
|
|
|
|
|