|
@@ -364,7 +364,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
@Override
|
|
|
public TableDataInfo enterpriseList(Enterprise enterprise) {
|
|
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
|
|
- Integer pageNum = pageDomain.getPageNum();
|
|
|
+ Integer pageNum = (pageDomain.getPageNum() - 1) * pageDomain.getPageSize();
|
|
|
Integer pageSize = pageDomain.getPageSize();
|
|
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
|
|
Boolean reasonable = pageDomain.getReasonable();
|
|
@@ -521,24 +521,28 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
@Override
|
|
|
public TableDataInfo reportList(String status, String enterpriseName, String startTime, String endTime) {
|
|
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
|
|
- Integer pageNum = pageDomain.getPageNum();
|
|
|
+ Integer pageNum = (pageDomain.getPageNum() - 1) * pageDomain.getPageSize();
|
|
|
Integer pageSize = pageDomain.getPageSize();
|
|
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
|
|
Boolean reasonable = pageDomain.getReasonable();
|
|
|
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
|
|
|
List<capacityReportDto> orderList = new ArrayList<>();
|
|
|
String condition = "";
|
|
|
+ String qualified = "";
|
|
|
+ String unQualified = "";
|
|
|
if (!ObjectUtils.isEmpty(enterpriseName)) {
|
|
|
condition += "and tfo.customer_name = '" + enterpriseName + "'";
|
|
|
}
|
|
|
- if (!ObjectUtils.isEmpty(status)) {
|
|
|
- condition += "and fo.start_time = '" + status + "'";
|
|
|
+ if ("1".equals(status)) {
|
|
|
+ qualified += "and defect_cause is null";
|
|
|
+ }else if ("2".equals(status)){
|
|
|
+ unQualified += "and defect_cause is not null";
|
|
|
}
|
|
|
if (!ObjectUtils.isEmpty(startTime)) {
|
|
|
- condition += "and tpo.complete_time >= '" + startTime + "'";
|
|
|
+ condition += "and DATE_FORMAT(tpo.execute_time, '%Y-%m-%d') >= '" + startTime + "'";
|
|
|
}
|
|
|
if (!ObjectUtils.isEmpty(endTime)) {
|
|
|
- condition += "and tpo.complete_time <= '" + endTime + "'";
|
|
|
+ condition += "and DATE_FORMAT(tpo.execute_time, '%Y-%m-%d') <= '" + endTime + "'";
|
|
|
}
|
|
|
try {
|
|
|
Map<String, JdbcTemplate> jdbcTemplateMap = databaseConnectionMap.getJdbcTemplate();
|
|
@@ -550,10 +554,10 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
+ "tfo.order_name AS orderName,tpo.order_num AS orderNumG,tpo.production_num AS reportingNum, " +
|
|
|
"(SELECT count(report_num) FROM t_work_report where order_id = tpo.id and process_id =" +
|
|
|
"(SELECT process_id FROM t_process_group_detail where group_id = tpo.process_group_id ORDER BY sort_num desc LIMIT 1)" +
|
|
|
- "and defect_cause is null)as qualifiedNum," +
|
|
|
+ (ObjectUtils.isEmpty(qualified) ? "" : qualified) +")as qualifiedNum," +
|
|
|
"(SELECT count(waste_num) FROM t_work_report where order_id = tpo.id and process_id =" +
|
|
|
"(SELECT process_id FROM t_process_group_detail where group_id = tpo.process_group_id ORDER BY sort_num desc LIMIT 1)" +
|
|
|
- "and defect_cause is not null) as unqualifiedNum," +
|
|
|
+ (ObjectUtils.isEmpty(unQualified) ? "" : unQualified) +") as unqualifiedNum," +
|
|
|
"(SELECT count(product_num) FROM t_work_report where order_id = tpo.id and process_id =" +
|
|
|
"(SELECT process_id FROM t_process_group_detail where group_id = tpo.process_group_id ORDER BY sort_num desc LIMIT 1))" +
|
|
|
"as dailyProduction," +
|
|
@@ -601,30 +605,34 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
for (String keyUrl : key) {
|
|
|
if (ObjectUtils.isEmpty(startTime) || ObjectUtils.isEmpty(endTime)) {
|
|
|
endTime = LocalDate.now().toString();
|
|
|
- startTime = LocalDate.parse(endTime).minusDays(7).toString();
|
|
|
+ startTime = LocalDate.parse(endTime).minusDays(7).toString();
|
|
|
}
|
|
|
LocalDate start = LocalDate.parse(startTime);
|
|
|
LocalDate end = LocalDate.parse(endTime);
|
|
|
// 判断是否到达结束日期
|
|
|
while (!start.isAfter(end)) {
|
|
|
String condition = "";
|
|
|
+ String qualified = "";
|
|
|
+ String unQualified = "";
|
|
|
+ if ("1".equals(status)) {
|
|
|
+ qualified += "and defect_cause is null";
|
|
|
+ }else if ("2".equals(status)){
|
|
|
+ unQualified += "and defect_cause is not null";
|
|
|
+ }
|
|
|
if (!ObjectUtils.isEmpty(enterpriseName)) {
|
|
|
condition += "and tfo.customer_name = '" + enterpriseName + "'";
|
|
|
}
|
|
|
- if (!ObjectUtils.isEmpty(status)) {
|
|
|
- condition += "and fo.start_time = '" + status + "'";
|
|
|
- }
|
|
|
- condition += "and DATE_FORMAT(tpo.complete_time, '%Y-%m-%d') >= '" + start.format(formatter) + "'";
|
|
|
- condition += "and DATE_FORMAT(tpo.complete_time, '%Y-%m-%d') <= '" + start.format(formatter) + "'";
|
|
|
+ condition += "and DATE_FORMAT(tpo.execute_time, '%Y-%m-%d') >= '" + start + "'";
|
|
|
+ condition += "and DATE_FORMAT(tpo.execute_time, '%Y-%m-%d') <= '" + start + "'";
|
|
|
JdbcTemplate template = jdbcTemplateMap.get(keyUrl);
|
|
|
List<capacityReportDto> orders = template.query("SELECT tfo.order_num AS orderNumD,tfo.customer_name AS customerName,"
|
|
|
+ "tfo.order_name AS orderName,tpo.order_num AS orderNumG,tpo.production_num AS reportingNum, " +
|
|
|
"(SELECT count(report_num) FROM t_work_report where order_id = tpo.id and process_id =" +
|
|
|
"(SELECT process_id FROM t_process_group_detail where group_id = tpo.process_group_id ORDER BY sort_num desc LIMIT 1)" +
|
|
|
- "and defect_cause is null)as qualifiedNum," +
|
|
|
+ (ObjectUtils.isEmpty(qualified) ? "" : qualified) +")as qualifiedNum," +
|
|
|
"(SELECT count(waste_num) FROM t_work_report where order_id = tpo.id and process_id =" +
|
|
|
"(SELECT process_id FROM t_process_group_detail where group_id = tpo.process_group_id ORDER BY sort_num desc LIMIT 1)" +
|
|
|
- "and defect_cause is not null) as unqualifiedNum," +
|
|
|
+ (ObjectUtils.isEmpty(unQualified) ? "" : unQualified) +") as unqualifiedNum," +
|
|
|
"(SELECT count(product_num) FROM t_work_report where order_id = tpo.id and process_id =" +
|
|
|
"(SELECT process_id FROM t_process_group_detail where group_id = tpo.process_group_id ORDER BY sort_num desc LIMIT 1))" +
|
|
|
"as dailyProduction," +
|
|
@@ -635,21 +643,36 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
" LEFT JOIN t_factory_order tfo ON tpo.task_id = tfo.id " +
|
|
|
"where 1=1 " + (ObjectUtils.isEmpty(condition) ? "" : condition) + ";",
|
|
|
new BeanPropertyRowMapper<capacityReportDto>(capacityReportDto.class));
|
|
|
- for (capacityReportDto item : orders) {
|
|
|
- if (!ObjectUtils.isEmpty(item.getQualifiedNum()) && !ObjectUtils.isEmpty(item.getUnqualifiedNum())
|
|
|
- && !ObjectUtils.isEmpty(item.getReportingNum())) {
|
|
|
- if ("0".equals(item.getQualifiedNum()) || "0".equals(item.getUnqualifiedNum())) {
|
|
|
- passRateList.add("0");
|
|
|
- } else {
|
|
|
- BigDecimal sum = new BigDecimal(item.getQualifiedNum()).add(new BigDecimal(item.getUnqualifiedNum()));
|
|
|
- passRateList.add(new BigDecimal(item.getQualifiedNum()).divide(sum, MathContext.DECIMAL32).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ if (orders.size() > 0) {
|
|
|
+ BigDecimal reportingNum = new BigDecimal("0");
|
|
|
+ BigDecimal qualifiedNum = new BigDecimal("0");
|
|
|
+ BigDecimal unqualifiedNum = new BigDecimal("0");
|
|
|
+ BigDecimal passRate = new BigDecimal("0");
|
|
|
+ for (capacityReportDto item : orders) {
|
|
|
+ if (!ObjectUtils.isEmpty(item.getQualifiedNum()) && !ObjectUtils.isEmpty(item.getUnqualifiedNum())
|
|
|
+ && !ObjectUtils.isEmpty(item.getReportingNum())) {
|
|
|
+ if ("0".equals(item.getQualifiedNum()) || "0".equals(item.getUnqualifiedNum())) {
|
|
|
+ passRate = passRate.add(new BigDecimal("0"));
|
|
|
+ } else {
|
|
|
+ BigDecimal sum = new BigDecimal(item.getQualifiedNum()).add(new BigDecimal(item.getUnqualifiedNum()));
|
|
|
+ passRate = passRate.add(new BigDecimal(item.getQualifiedNum()).divide(sum, MathContext.DECIMAL32).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+ reportingNum = reportingNum.add(new BigDecimal(item.getReportingNum()));
|
|
|
+ qualifiedNum = qualifiedNum.add(new BigDecimal(item.getQualifiedNum()));
|
|
|
+ unqualifiedNum = unqualifiedNum.add(new BigDecimal(item.getUnqualifiedNum()));
|
|
|
}
|
|
|
- yearList.add(start.format(formatter));
|
|
|
- reportingNumList.add(item.getReportingNum());
|
|
|
- qualifiedNumList.add(item.getQualifiedNum());
|
|
|
- unqualifiedNumList.add(item.getUnqualifiedNum());
|
|
|
}
|
|
|
+ passRateList.add(passRate.toString());
|
|
|
+ reportingNumList.add(reportingNum.toString());
|
|
|
+ qualifiedNumList.add(qualifiedNum.toString());
|
|
|
+ unqualifiedNumList.add(unqualifiedNum.toString());
|
|
|
+ } else {
|
|
|
+ reportingNumList.add("0");
|
|
|
+ qualifiedNumList.add("0");
|
|
|
+ unqualifiedNumList.add("0");
|
|
|
+ passRateList.add("0");
|
|
|
}
|
|
|
+ yearList.add(start.format(formatter));
|
|
|
// 日期加一天
|
|
|
start = start.plusDays(1);
|
|
|
}
|