Commit b2b1a11e authored by 温志超's avatar 温志超

更新报表

parent 19b1a5ac
package com.ximai.mes.report.controller;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ximai.common.annotation.Log;
import com.ximai.common.core.controller.BaseController;
import com.ximai.common.core.domain.AjaxResult;
import com.ximai.common.core.page.TableDataInfo;
import com.ximai.common.enums.BusinessType;
import com.ximai.mes.report.request.DailyProductionReportRequest;
import com.ximai.mes.report.request.FeedbackRequest;
import com.ximai.mes.report.response.FeedbackResponse;
import com.ximai.mes.report.service.DailyProductionReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Api("日产能对比统计")
@RestController
@RequestMapping("/dailyProductionReport")
public class DailyProductionReportController extends BaseController {
@Autowired
DailyProductionReportService dailyProductionReportService;
@ApiOperation("日产能对比统计:获取日期表头")
@PreAuthorize("@ss.hasPermi('mes:pro:dailyProductionReport:get')")
@Log(title = "日产能对比统计:获取日期表头", businessType = BusinessType.QUERY)
@GetMapping("/getDatas")
public AjaxResult<List> getDatas(DailyProductionReportRequest dailyProductionReportRequest) {
List data = dailyProductionReportService.getDatas(dailyProductionReportRequest);
return AjaxResult.success(data);
}
@ApiOperation("日产能对比统计:统计方式工序")
@PreAuthorize("@ss.hasPermi('mes:pro:dailyProductionReport:get')")
@Log(title = "日产能对比统计:统计方式工序", businessType = BusinessType.QUERY)
@GetMapping("/getListByProcess")
public AjaxResult<List> getListByWorkOrder(DailyProductionReportRequest dailyProductionReportRequest) {
List data = dailyProductionReportService.getListByProcess(dailyProductionReportRequest);
return AjaxResult.success(data);
}
@ApiOperation("日产能对比统计:统计方式车间")
@PreAuthorize("@ss.hasPermi('mes:pro:dailyProductionReport:get')")
@Log(title = "日产能对比统计:统计方式车间", businessType = BusinessType.QUERY)
@GetMapping("/getListByWorkshop")
public AjaxResult<List> getListByWorkshop(DailyProductionReportRequest dailyProductionReportRequest) {
List data = dailyProductionReportService.getListByWorkshop(dailyProductionReportRequest);
return AjaxResult.success(data);
}
@ApiOperation("日产能对比统计:统计方式工作中心")
@PreAuthorize("@ss.hasPermi('mes:pro:dailyProductionReport:get')")
@Log(title = "日产能对比统计:统计方式工作中心", businessType = BusinessType.QUERY)
@GetMapping("/getListByWorkstation")
public AjaxResult<List> getListByWorkstation(DailyProductionReportRequest dailyProductionReportRequest) {
List data = dailyProductionReportService.getListByWorkstation(dailyProductionReportRequest);
return AjaxResult.success(data);
}
@ApiOperation("日产能对比统计:统计方式工作单元")
@PreAuthorize("@ss.hasPermi('mes:pro:dailyProductionReport:get')")
@Log(title = "日产能对比统计:统计方式工作单元", businessType = BusinessType.QUERY)
@GetMapping("/getListByWorkunit")
public AjaxResult<List> getListByWorkunit(DailyProductionReportRequest dailyProductionReportRequest) {
List data = dailyProductionReportService.getListByWorkunit(dailyProductionReportRequest);
return AjaxResult.success(data);
}
@ApiOperation("日产能对比统计:统计方式报工人员")
@PreAuthorize("@ss.hasPermi('mes:pro:dailyProductionReport:get')")
@Log(title = "日产能对比统计:统计方式报工人员", businessType = BusinessType.QUERY)
@GetMapping("/getListByUser")
public AjaxResult<List> getListByUser(DailyProductionReportRequest dailyProductionReportRequest) {
List data = dailyProductionReportService.getListByUser(dailyProductionReportRequest);
return AjaxResult.success(data);
}
}
package com.ximai.mes.report.mapper;
import com.ximai.mes.report.request.DailyProductionReportRequest;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
@Mapper
public interface DailyProductionReportMapper {
List<Map> getListByProcess(DailyProductionReportRequest dailyProductionReportRequest);
List<Map> getListByWorkshop(DailyProductionReportRequest dailyProductionReportRequest);
List<Map> getListByWorkstation(DailyProductionReportRequest dailyProductionReportRequest);
List<Map> getListByWorkunit(DailyProductionReportRequest dailyProductionReportRequest);
List<Map> getListByUser(DailyProductionReportRequest dailyProductionReportRequest);
}
package com.ximai.mes.report.request;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class DailyProductionReportRequest {
@ApiModelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startDate;
@ApiModelProperty("结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endDate;
/**
* 工序ID
*/
@ApiModelProperty( "工序ID")
private Long processId;
/**
* 工序编码
*/
@ApiModelProperty( "工序编码")
private String processCode;
/**
* 工序编码
*/
@ApiModelProperty( "工序名称")
private String processName;
/**
* 车间ID
*/
@ApiModelProperty("车间ID")
private Long workshopId;
@ApiModelProperty("车间名称")
private String workshopName;
/**
* 工作中心ID
*/
@ApiModelProperty( "工作中心ID")
private Long workstationId;
/**
* 工作中心名称
*/
@ApiModelProperty( "工作中心名称")
private String workstationName;
/**
*
*/
@ApiModelProperty("工作单元ID")
private Long workunitId;
@ApiModelProperty("作业单元名称")
private String workunitName;
@ApiModelProperty("报工人员名称")
private String userName;
@ApiModelProperty("报工人员昵称")
private String nickName;
}
package com.ximai.mes.report.service;
import com.ximai.mes.report.request.DailyProductionReportRequest;
import java.util.List;
import java.util.Map;
public interface DailyProductionReportService {
List getListByProcess(DailyProductionReportRequest dailyProductionReportRequest);
List getDatas(DailyProductionReportRequest dailyProductionReportRequest);
List getListByWorkshop(DailyProductionReportRequest dailyProductionReportRequest);
List getListByWorkstation(DailyProductionReportRequest dailyProductionReportRequest);
List getListByWorkunit(DailyProductionReportRequest dailyProductionReportRequest);
List getListByUser(DailyProductionReportRequest dailyProductionReportRequest);
}
package com.ximai.mes.report.service.impl;
import com.ximai.common.utils.MessageUtils;
import com.ximai.common.utils.data.ExceptionUtil;
import com.ximai.mes.report.mapper.DailyProductionReportMapper;
import com.ximai.mes.report.request.DailyProductionReportRequest;
import com.ximai.mes.report.service.DailyProductionReportService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@Service
public class DailyProductionReportServiceImp implements DailyProductionReportService {
@Autowired
DailyProductionReportMapper dailyProductionReportMapper;
@Override
public List getListByProcess(DailyProductionReportRequest dailyProductionReportRequest) {
ExceptionUtil.checkTrueThrowException(dailyProductionReportRequest.getStartDate() == null
&& dailyProductionReportRequest.getEndDate() == null,
"请传入开始和结束时间");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<Map> processDataList = dailyProductionReportMapper.getListByProcess(dailyProductionReportRequest);
String startDate = simpleDateFormat.format(dailyProductionReportRequest.getStartDate());
String endDate = simpleDateFormat.format(dailyProductionReportRequest.getEndDate());
List<String> dateList = getAscDateList(startDate, endDate);
List<Map> returnList = groupList(processDataList,"工序名称","工序编码","工序",dateList);
// Map<String,List<Map>> processDataMap = processDataList.stream().collect(Collectors.groupingBy(map -> (String)map.get("工序编码")));
// /**
// * [{工序名称:abc,工序编码:cbd,工序总结:1,日期a:{合格数}}]
// */
// List<Map> returnList = new ArrayList<>();
// if(dailyProductionReportRequest.getStartDate() != null && dailyProductionReportRequest.getEndDate() != null){
// String startDate = simpleDateFormat.format(dailyProductionReportRequest.getStartDate());
// String endDate = simpleDateFormat.format(dailyProductionReportRequest.getEndDate());
// List<String> dateList = getAscDateList(startDate, endDate);
// for (String processCode : processDataMap.keySet()){
// HashMap processHashMap = new HashMap();
// returnList.add(processHashMap);
// processHashMap.put("工序编码",processCode);
// processHashMap.put("工序名称",processDataMap.get(processCode).get(0).get("工序名称"));
// processHashMap.put("工序统计合格数量", new Double(0));
// processHashMap.put("工序统计不合格数量",new Double(0));
// processHashMap.put("工序统计报工数量",new Double(0));
// Map<String,List<Map>> dateDataMap = processDataMap.get(processCode).stream().collect(Collectors.groupingBy(map -> (String)map.get("报工日期")));
// for (String date : dateList){
// HashMap dateHashMap = new HashMap();
// processHashMap.put(date,dateHashMap);
// if(dateDataMap.get(date) != null){
// for (Map data : dateDataMap.get(date)){
// //PS这里其实做多只有一条Map data
// dateHashMap.put("合格数量",data.get("合格数量"));
// dateHashMap.put("不合格数量",data.get("不合格数量"));
// dateHashMap.put("报工数量",data.get("报工数量"));
// dateHashMap.put("合格率",(new BigDecimal((Double) data.get("合格数量")).multiply(new BigDecimal(100))).divide( new BigDecimal((Double) data.get("报工数量")),2, RoundingMode.HALF_UP));
// processHashMap.put("工序统计合格数量", ((Double)processHashMap.get("工序统计合格数量")) + ((Double)data.get("合格数量")));
// processHashMap.put("工序统计不合格数量",((Double)processHashMap.get("工序统计不合格数量")) + ((Double)data.get("不合格数量")));
// processHashMap.put("工序统计报工数量",((Double)processHashMap.get("工序统计报工数量")) + ((Double)data.get("报工数量")));
// }
// }
// }
// processHashMap.put("工序统计合格率",(new BigDecimal((Double) processHashMap.get("工序统计合格数量")).multiply(new BigDecimal(100))).divide(new BigDecimal((Double)processHashMap.get("工序统计报工数量")),2, RoundingMode.HALF_UP));
// }
//
//
// //用于统计最后一行的日期综合统计性数据
// Map<String,List<Map>> dateDataMap = processDataList.stream().collect(Collectors.groupingBy(map -> (String)map.get("报工日期")));
// HashMap dateHashMap = new HashMap();
// returnList.add(dateHashMap);
// for (String date : dateList){
// HashMap dateStatisticsHashMap = new HashMap();
// dateHashMap.put(date,dateStatisticsHashMap);
// dateStatisticsHashMap.put("日期统计合格数量", new Double(0));
// dateStatisticsHashMap.put("日期统计不合格数量",new Double(0));
// dateStatisticsHashMap.put("日期统计报工数量",new Double(0));
// if(dateDataMap.get(date) != null){
// for (Map data : dateDataMap.get(date)){
// dateStatisticsHashMap.put("日期统计合格数量", ((Double)dateStatisticsHashMap.get("日期统计合格数量")) + ((Double)data.get("合格数量")));
// dateStatisticsHashMap.put("日期统计不合格数量",((Double)dateStatisticsHashMap.get("日期统计不合格数量")) + ((Double)data.get("不合格数量")));
// dateStatisticsHashMap.put("日期统计报工数量",((Double)dateStatisticsHashMap.get("日期统计报工数量")) + ((Double)data.get("报工数量")));
// }
// }
// if(((Double)dateStatisticsHashMap.get("日期统计报工数量")) > 0){
// dateStatisticsHashMap.put("日期统计合格率",new BigDecimal((Double)dateStatisticsHashMap.get("日期统计合格数量")).multiply(new BigDecimal(100).divide(new BigDecimal((Double)dateStatisticsHashMap.get("日期统计报工数量")),2, RoundingMode.HALF_UP)));
// }else{
// dateStatisticsHashMap.put("日期统计合格率",BigDecimal.ZERO);
// }
// }
// }
return returnList;
}
@Override
public List getListByWorkshop(DailyProductionReportRequest dailyProductionReportRequest) {
ExceptionUtil.checkTrueThrowException(dailyProductionReportRequest.getStartDate() == null
&& dailyProductionReportRequest.getEndDate() == null,
"请传入开始和结束时间");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<Map> processDataList = dailyProductionReportMapper.getListByWorkshop(dailyProductionReportRequest);
String startDate = simpleDateFormat.format(dailyProductionReportRequest.getStartDate());
String endDate = simpleDateFormat.format(dailyProductionReportRequest.getEndDate());
List<String> dateList = getAscDateList(startDate, endDate);
List<Map> returnList = groupList(processDataList,"车间名称","车间编码","车间",dateList);
return returnList;
}
@Override
public List getListByWorkstation(DailyProductionReportRequest dailyProductionReportRequest) {
ExceptionUtil.checkTrueThrowException(dailyProductionReportRequest.getStartDate() == null
&& dailyProductionReportRequest.getEndDate() == null,
"请传入开始和结束时间");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<Map> processDataList = dailyProductionReportMapper.getListByWorkstation(dailyProductionReportRequest);
String startDate = simpleDateFormat.format(dailyProductionReportRequest.getStartDate());
String endDate = simpleDateFormat.format(dailyProductionReportRequest.getEndDate());
List<String> dateList = getAscDateList(startDate, endDate);
List<Map> returnList = groupList(processDataList,"工作中心名称","工作中心编码","工作中心",dateList);
return returnList;
}
@Override
public List getListByWorkunit(DailyProductionReportRequest dailyProductionReportRequest) {
ExceptionUtil.checkTrueThrowException(dailyProductionReportRequest.getStartDate() == null
&& dailyProductionReportRequest.getEndDate() == null,
"请传入开始和结束时间");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<Map> processDataList = dailyProductionReportMapper.getListByWorkunit(dailyProductionReportRequest);
String startDate = simpleDateFormat.format(dailyProductionReportRequest.getStartDate());
String endDate = simpleDateFormat.format(dailyProductionReportRequest.getEndDate());
List<String> dateList = getAscDateList(startDate, endDate);
List<Map> returnList = groupList(processDataList,"工作单元名称","工作单元编码","工作单元",dateList);
return returnList;
}
@Override
public List getListByUser(DailyProductionReportRequest dailyProductionReportRequest) {
ExceptionUtil.checkTrueThrowException(dailyProductionReportRequest.getStartDate() == null
&& dailyProductionReportRequest.getEndDate() == null,
"请传入开始和结束时间");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<Map> processDataList = dailyProductionReportMapper.getListByUser(dailyProductionReportRequest);
String startDate = simpleDateFormat.format(dailyProductionReportRequest.getStartDate());
String endDate = simpleDateFormat.format(dailyProductionReportRequest.getEndDate());
List<String> dateList = getAscDateList(startDate, endDate);
List<Map> returnList = groupList(processDataList,"报工人员名称","报工人员编码","报工人员",dateList);
return returnList;
}
@Override
public List getDatas(DailyProductionReportRequest dailyProductionReportRequest) {
ExceptionUtil.checkTrueThrowException(dailyProductionReportRequest.getStartDate() == null
&& dailyProductionReportRequest.getEndDate() == null,
"请传入开始和结束时间");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String startDate = simpleDateFormat.format(dailyProductionReportRequest.getStartDate());
String endDate = simpleDateFormat.format(dailyProductionReportRequest.getEndDate());
List<String> dateList = getAscDateList(startDate, endDate);
return null;
}
public static List<String> getAscDateList(String start, String end) {
LocalDate startDate = LocalDate.parse(start);
LocalDate endDate = LocalDate.parse(end);
List<String> result = new ArrayList<>();
if (endDate.compareTo(startDate) < 0) {
return result;
}
while (true) {
result.add(startDate.toString());
if (startDate.compareTo(endDate) >= 0) {
break;
}
startDate = startDate.plusDays(1);
}
return result;
}
public List groupList(List<Map> processDataList,String name,String code,String key,List<String> dateList ){
Map<String,List<Map>> processDataMap = processDataList.stream().collect(Collectors.groupingBy(map -> (String)map.get(code)));
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
/**
* [{工序名称:abc,工序编码:cbd,工序总结:1,日期a:{合格数}}]
*/
List<Map> returnList = new ArrayList<>();
for (String processCode : processDataMap.keySet()){
HashMap processHashMap = new HashMap();
returnList.add(processHashMap);
processHashMap.put(code,processCode);
processHashMap.put(name,processDataMap.get(processCode).get(0).get(name));
processHashMap.put(key + "统计合格数量", new Double(0));
processHashMap.put(key + "统计不合格数量",new Double(0));
processHashMap.put(key + "统计报工数量",new Double(0));
Map<String,List<Map>> dateDataMap = processDataMap.get(processCode).stream().collect(Collectors.groupingBy(map -> (String)map.get("报工日期")));
for (String date : dateList){
HashMap dateHashMap = new HashMap();
processHashMap.put(date,dateHashMap);
if(dateDataMap.get(date) != null){
for (Map data : dateDataMap.get(date)){
//PS这里其实做多只有一条Map data
dateHashMap.put("合格数量",data.get("合格数量"));
dateHashMap.put("不合格数量",data.get("不合格数量"));
dateHashMap.put("报工数量",data.get("报工数量"));
dateHashMap.put("合格率",(new BigDecimal((Double) data.get("合格数量")).multiply(new BigDecimal(100))).divide( new BigDecimal((Double) data.get("报工数量")),2, RoundingMode.HALF_UP));
processHashMap.put(key + "统计合格数量", ((Double)processHashMap.get(key + "统计合格数量")) + ((Double)data.get("合格数量")));
processHashMap.put(key + "统计不合格数量",((Double)processHashMap.get(key + "统计不合格数量")) + ((Double)data.get("不合格数量")));
processHashMap.put(key + "统计报工数量",((Double)processHashMap.get(key + "统计报工数量")) + ((Double)data.get("报工数量")));
}
}
}
processHashMap.put(key + "统计合格率",(new BigDecimal((Double) processHashMap.get(key + "统计合格数量")).multiply(new BigDecimal(100))).divide(new BigDecimal((Double)processHashMap.get(key + "统计报工数量")),2, RoundingMode.HALF_UP));
}
//用于统计最后一行的日期综合统计性数据
Map<String,List<Map>> dateDataMap = processDataList.stream().collect(Collectors.groupingBy(map -> (String)map.get("报工日期")));
HashMap dateHashMap = new HashMap();
returnList.add(dateHashMap);
for (String date : dateList){
HashMap dateStatisticsHashMap = new HashMap();
dateHashMap.put(date,dateStatisticsHashMap);
dateStatisticsHashMap.put("日期统计合格数量", new Double(0));
dateStatisticsHashMap.put("日期统计不合格数量",new Double(0));
dateStatisticsHashMap.put("日期统计报工数量",new Double(0));
if(dateDataMap.get(date) != null){
for (Map data : dateDataMap.get(date)){
dateStatisticsHashMap.put("日期统计合格数量", ((Double)dateStatisticsHashMap.get("日期统计合格数量")) + ((Double)data.get("合格数量")));
dateStatisticsHashMap.put("日期统计不合格数量",((Double)dateStatisticsHashMap.get("日期统计不合格数量")) + ((Double)data.get("不合格数量")));
dateStatisticsHashMap.put("日期统计报工数量",((Double)dateStatisticsHashMap.get("日期统计报工数量")) + ((Double)data.get("报工数量")));
}
}
if(((Double)dateStatisticsHashMap.get("日期统计报工数量")) > 0){
dateStatisticsHashMap.put("日期统计合格率",new BigDecimal((Double)dateStatisticsHashMap.get("日期统计合格数量")).multiply(new BigDecimal(100).divide(new BigDecimal((Double)dateStatisticsHashMap.get("日期统计报工数量")),2, RoundingMode.HALF_UP)));
}else{
dateStatisticsHashMap.put("日期统计合格率",BigDecimal.ZERO);
}
}
return returnList;
}
}
......@@ -375,7 +375,7 @@
<select id="getListByWorkunit" resultType="com.ximai.mes.report.response.FeedbackResponse">
select
mw.workunit_code,
workunit.workunit_name,
mw.workunit_name,
sum(f.quantity) quantity,
sum(f.quantity_qualify) quantity_qualify,
sum(f.quantity_unqualify) quantity_unqualify,
......@@ -415,7 +415,7 @@
</where>
group by
mw.workunit_code,
workunit.workunit_name
mw.workunit_name
</select>
<select id="getListByProcess" resultType="com.ximai.mes.report.response.FeedbackResponse">
select
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ximai.mes.report.mapper.DailyProductionReportMapper">
<select id="getListByProcess" resultType="java.util.Map">
SELECT
process.process_code AS "工序编号",
process.process_name AS "工序名称",
DATE_FORMAT( f.feedback_time, '%Y-%m-%d' ) AS "报工日期",
sum( f.quantity ) AS quantity,
sum( f.quantity_qualify ) AS '合格数量',
sum( f.quantity_unqualify ) AS '不合格数量',
sum( f.quantity_qualify + f.quantity_unqualify) AS "报工数量"
FROM
pro_feedback f
JOIN pro_task_workunit workunit ON workunit.task_id = f.task_id
JOIN pro_task pt ON f.task_id = pt.task_id
JOIN pro_process process ON process.process_id = pt.process_id
<where>
<if test=" processId != null ">and process.process_id = #{processId}</if>
<if test=" processName != null and processName != '' ">and process.process_name like '%${processName}%'</if>
<if test=" startDate != null and endDate != null">and feedback_time BETWEEN #{startDate} AND #{endDate}</if>
</where>
GROUP BY
process.process_code,
process.process_name,
DATE_FORMAT( f.feedback_time, '%Y-%m-%d' )
</select>
<select id="getListByWorkshop" resultType="java.util.Map">
SELECT
workstation.workshop_code as '车间编码',
workstation.workshop_name as '车间名称',
DATE_FORMAT( f.feedback_time, '%Y-%m-%d' ) AS "报工日期",
sum( f.quantity ) AS quantity,
sum( f.quantity_qualify ) AS '合格数量',
sum( f.quantity_unqualify ) AS '不合格数量',
sum( f.quantity_qualify + f.quantity_unqualify) AS "报工数量"
FROM
pro_feedback f
JOIN pro_task_workunit workunit ON workunit.task_id = f.task_id
JOIN pro_task pt ON f.task_id = pt.task_id
JOIN pro_process process ON process.process_id = pt.process_id
join pro_workorder workorder on workorder.workorder_id = f.workorder_id
JOIN md_item it ON it.item_id = f.item_id
join md_workunit mw on workunit.workunit_id = mw.workunit_id
join md_workstation workstation on workstation.workstation_id = mw.workstation_id
<where>
<if test=" workshopId != null">and workstation.workshop_Id = #{workshopId}</if>
<if test=" workshopName != null and workshopName != '' ">and workstation.workshop_name like '%${workshopName}%'</if>
<if test=" startDate != null and endDate != null">and feedback_time BETWEEN #{startDate} AND #{endDate}</if>
</where>
group by
workstation.workshop_code,
workstation.workshop_name,
DATE_FORMAT( f.feedback_time, '%Y-%m-%d' )
</select>
<select id="getListByWorkstation" resultType="java.util.Map">
SELECT
workstation.workstation_code AS "工作中心编码",
workstation.workstation_name AS "工作中心名称",
DATE_FORMAT( f.feedback_time, '%Y-%m-%d' ) AS "报工日期",
sum( f.quantity ) AS quantity,
sum( f.quantity_qualify ) AS '合格数量',
sum( f.quantity_unqualify ) AS '不合格数量',
sum( f.quantity_qualify + f.quantity_unqualify) AS "报工数量"
FROM
pro_feedback f
JOIN pro_task_workunit workunit ON workunit.task_id = f.task_id
JOIN pro_task pt ON f.task_id = pt.task_id
JOIN pro_process process ON process.process_id = pt.process_id
join pro_workorder workorder on workorder.workorder_id = f.workorder_id
JOIN md_item it ON it.item_id = f.item_id
join md_workunit mw on workunit.workunit_id = mw.workunit_id
join md_workstation workstation on workstation.workstation_id = mw.workstation_id
<where>
<if test=" workstationId != null">and workstation.workstation_id = #{workstationId} </if>
<if test=" workstationName != null and workstationName != '' ">and workstation.workstation_name like '%${workstationName}%'</if>
<if test=" startDate != null and endDate != null">and feedback_time BETWEEN #{startDate} AND #{endDate}</if>
</where>
group by
workstation.workstation_code,
workstation.workstation_name,
DATE_FORMAT( f.feedback_time, '%Y-%m-%d' )
</select>
<select id="getListByWorkunit" resultType="java.util.Map">
SELECT
mw.workunit_code AS "工作单元编码",
mw.workunit_name AS "工作单元名称",
DATE_FORMAT( f.feedback_time, '%Y-%m-%d' ) AS "报工日期",
sum( f.quantity ) AS quantity,
sum( f.quantity_qualify ) AS '合格数量',
sum( f.quantity_unqualify ) AS '不合格数量',
sum( f.quantity_qualify + f.quantity_unqualify) AS "报工数量"
FROM
pro_feedback f
JOIN pro_task_workunit workunit ON workunit.task_id = f.task_id
JOIN pro_task pt ON f.task_id = pt.task_id
JOIN pro_process process ON process.process_id = pt.process_id
join pro_workorder workorder on workorder.workorder_id = f.workorder_id
JOIN md_item it ON it.item_id = f.item_id
join md_workunit mw on workunit.workunit_id = mw.workunit_id
join md_workstation workstation on workstation.workstation_id = mw.workstation_id
<where>
<if test=" workunitId != null">and workunit.workunit_id = #{workunitId}</if>
<if test=" workunitName != null and workunitName != '' ">and mw.workunit_name like '%${workunitName}%'</if>
<if test=" startDate != null and endDate != null">and feedback_time BETWEEN #{startDate} AND #{endDate}</if>
</where>
group by
mw.workunit_code,
mw.workunit_name,
DATE_FORMAT( f.feedback_time, '%Y-%m-%d' )
</select>
<select id="getListByUser" resultType="java.util.Map">
SELECT
IFNULL(f.user_name,'无') AS "报工人员编码",
f.nick_name AS "报工人员名称",
DATE_FORMAT( f.feedback_time, '%Y-%m-%d' ) AS "报工日期",
sum( f.quantity ) AS quantity,
sum( f.quantity_qualify ) AS '合格数量',
sum( f.quantity_unqualify ) AS '不合格数量',
sum( f.quantity_qualify + f.quantity_unqualify) AS "报工数量"
FROM
pro_feedback f
JOIN pro_task_workunit workunit ON workunit.task_id = f.task_id
JOIN pro_task pt ON f.task_id = pt.task_id
JOIN pro_process process ON process.process_id = pt.process_id
join pro_workorder workorder on workorder.workorder_id = f.workorder_id
JOIN md_item it ON it.item_id = f.item_id
join md_workunit mw on workunit.workunit_id = mw.workunit_id
join md_workstation workstation on workstation.workstation_id = mw.workstation_id
<where>
<if test="userName != null and userName != ''">and f.user_name like concat('%', #{userName}, '%')</if>
<if test=" nickName != null and nickName != '' ">and f.nick_Name like '%${nickName}%'</if>
<if test=" startDate != null and endDate != null">and feedback_time BETWEEN #{startDate} AND #{endDate}</if>
</where>
group by
IFNULL(f.user_name,'无'),
f.nick_name,
DATE_FORMAT( f.feedback_time, '%Y-%m-%d' )
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment