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

更新报表

parent 95b502d9
...@@ -47,7 +47,7 @@ public class DailyProductionReportController extends BaseController { ...@@ -47,7 +47,7 @@ public class DailyProductionReportController extends BaseController {
@PreAuthorize("@ss.hasPermi('mes:pro:dailyProductionReport:get')") @PreAuthorize("@ss.hasPermi('mes:pro:dailyProductionReport:get')")
@Log(title = "日产能对比统计:统计方式工序", businessType = BusinessType.QUERY) @Log(title = "日产能对比统计:统计方式工序", businessType = BusinessType.QUERY)
@GetMapping("/getListByProcess") @GetMapping("/getListByProcess")
public AjaxResult<List> getListByWorkOrder(DailyProductionReportRequest dailyProductionReportRequest) { public AjaxResult<List> getListByProcess(DailyProductionReportRequest dailyProductionReportRequest) {
List data = dailyProductionReportService.getListByProcess(dailyProductionReportRequest); List data = dailyProductionReportService.getListByProcess(dailyProductionReportRequest);
return AjaxResult.success(data); return AjaxResult.success(data);
} }
......
package com.ximai.mes.report.controller;
import com.ximai.common.annotation.Log;
import com.ximai.common.core.domain.AjaxResult;
import com.ximai.common.enums.BusinessType;
import com.ximai.mes.report.request.MonthlyProductionReportRequest;
import com.ximai.mes.report.request.MonthlyProductionReportRequest;
import com.ximai.mes.report.service.MonthlyProductionReportService;
import io.swagger.annotations.Api;
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.util.List;
@Api("月产能对比统计")
@RestController
@RequestMapping("/monthlyProductionReport")
public class MonthlyProductionReportController {
@Autowired
MonthlyProductionReportService monthlyProductionReportService;
@ApiOperation("月产能对比统计:统计方式工序")
@PreAuthorize("@ss.hasPermi('mes:pro:dailyProductionReport:get')")
@Log(title = "月产能对比统计:统计方式工序", businessType = BusinessType.QUERY)
@GetMapping("/getListByProcess")
public AjaxResult<List> getListByProcess(MonthlyProductionReportRequest monthlyProductionReportRequest) {
List data = monthlyProductionReportService.getListByProcess(monthlyProductionReportRequest);
return AjaxResult.success(data);
}
@ApiOperation("日产能对比统计:统计方式车间")
@PreAuthorize("@ss.hasPermi('mes:pro:dailyProductionReport:get')")
@Log(title = "日产能对比统计:统计方式车间", businessType = BusinessType.QUERY)
@GetMapping("/getListByWorkshop")
public AjaxResult<List> getListByWorkshop(MonthlyProductionReportRequest dailyProductionReportRequest) {
List data = monthlyProductionReportService.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(MonthlyProductionReportRequest dailyProductionReportRequest) {
List data = monthlyProductionReportService.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(MonthlyProductionReportRequest dailyProductionReportRequest) {
List data = monthlyProductionReportService.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(MonthlyProductionReportRequest dailyProductionReportRequest) {
List data = monthlyProductionReportService.getListByUser(dailyProductionReportRequest);
return AjaxResult.success(data);
}
}
package com.ximai.mes.report.controller;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api("周产能对比统计")
@RestController
@RequestMapping("/weeklyProductionReport")
public class WeeklyProductionReportController {
}
package com.ximai.mes.report.mapper;
import com.ximai.mes.report.request.MonthlyProductionReportRequest;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
@Mapper
public interface MonthlyProductionReportMapper {
List<Map> getListByProcess(MonthlyProductionReportRequest dailyProductionReportRequest);
List<Map> getListByWorkshop(MonthlyProductionReportRequest dailyProductionReportRequest);
List<Map> getListByWorkstation(MonthlyProductionReportRequest dailyProductionReportRequest);
List<Map> getListByWorkunit(MonthlyProductionReportRequest dailyProductionReportRequest);
List<Map> getListByUser(MonthlyProductionReportRequest dailyProductionReportRequest);
}
package com.ximai.mes.report.mapper;
public interface WeeklyProductionReportMapper {
}
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 MonthlyProductionReportRequest {
@ApiModelProperty("年份")
private String dateYear;
/**
* 工序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.request;
import lombok.Data;
@Data
public class WeeklyProductionReportRequest {
}
package com.ximai.mes.report.service;
import com.ximai.mes.report.request.MonthlyProductionReportRequest;
import java.util.List;
public interface MonthlyProductionReportService {
List getListByProcess(MonthlyProductionReportRequest monthlyProductionReportRequest);
List getListByWorkshop(MonthlyProductionReportRequest dailyProductionReportRequest);
List getListByWorkstation(MonthlyProductionReportRequest dailyProductionReportRequest);
List getListByWorkunit(MonthlyProductionReportRequest dailyProductionReportRequest);
List getListByUser(MonthlyProductionReportRequest dailyProductionReportRequest);
}
package com.ximai.mes.report.service;
public interface WeeklyProductionReportService {
}
...@@ -42,68 +42,6 @@ public class DailyProductionReportServiceImp implements DailyProductionReportSer ...@@ -42,68 +42,6 @@ public class DailyProductionReportServiceImp implements DailyProductionReportSer
String endDate = simpleDateFormat.format(dailyProductionReportRequest.getEndDate()); String endDate = simpleDateFormat.format(dailyProductionReportRequest.getEndDate());
List<String> dateList = getAscDateList(startDate, endDate); List<String> dateList = getAscDateList(startDate, endDate);
List<Map> returnList = groupList(processDataList,"工序名称","工序编码","工序",dateList); 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; return returnList;
} }
......
package com.ximai.mes.report.service.impl;
import com.ximai.common.utils.data.ExceptionUtil;
import com.ximai.mes.report.mapper.MonthlyProductionReportMapper;
import com.ximai.mes.report.request.MonthlyProductionReportRequest;
import com.ximai.mes.report.request.MonthlyProductionReportRequest;
import com.ximai.mes.report.service.MonthlyProductionReportService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
public class MonthlyProductionReportServiceImp implements MonthlyProductionReportService {
private List<String> dateList =new ArrayList<String>(
Arrays.asList( "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"));
@Autowired
DailyProductionReportServiceImp dailyProductionReportServiceImp;
@Autowired
MonthlyProductionReportMapper monthlyProductionReportMapper;
@Override
public List getListByProcess(MonthlyProductionReportRequest dailyProductionReportRequest) {
ExceptionUtil.checkTrueThrowException(dailyProductionReportRequest.getDateYear() == null,
"请传入年份");
List<Map> processDataList = monthlyProductionReportMapper.getListByProcess(dailyProductionReportRequest);
List<Map> returnList = dailyProductionReportServiceImp.groupList(processDataList,"工序名称","工序编码","工序",dateList);
return returnList;
}
@Override
public List getListByWorkshop(MonthlyProductionReportRequest dailyProductionReportRequest) {
ExceptionUtil.checkTrueThrowException(dailyProductionReportRequest.getDateYear() == null,
"请传入年份");
List<Map> processDataList = monthlyProductionReportMapper.getListByWorkshop(dailyProductionReportRequest);
List<Map> returnList = dailyProductionReportServiceImp.groupList(processDataList,"车间名称","车间编码","车间",dateList);
return returnList;
}
@Override
public List getListByWorkstation(MonthlyProductionReportRequest dailyProductionReportRequest) {
ExceptionUtil.checkTrueThrowException(dailyProductionReportRequest.getDateYear() == null,
"请传入年份");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<Map> processDataList = monthlyProductionReportMapper.getListByWorkstation(dailyProductionReportRequest);
List<Map> returnList = dailyProductionReportServiceImp.groupList(processDataList,"工作中心名称","工作中心编码","工作中心",dateList);
return returnList;
}
@Override
public List getListByWorkunit(MonthlyProductionReportRequest dailyProductionReportRequest) {
ExceptionUtil.checkTrueThrowException(dailyProductionReportRequest.getDateYear() == null,
"请传入年份");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<Map> processDataList = monthlyProductionReportMapper.getListByWorkunit(dailyProductionReportRequest);
List<Map> returnList = dailyProductionReportServiceImp.groupList(processDataList,"工作单元名称","工作单元编码","工作单元",dateList);
return returnList;
}
@Override
public List getListByUser(MonthlyProductionReportRequest dailyProductionReportRequest) {
ExceptionUtil.checkTrueThrowException(dailyProductionReportRequest.getDateYear() == null,
"请传入年份");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<Map> processDataList = monthlyProductionReportMapper.getListByUser(dailyProductionReportRequest);
List<Map> returnList = dailyProductionReportServiceImp.groupList(processDataList,"报工人员名称","报工人员编码","报工人员",dateList);
return returnList;
}
}
package com.ximai.mes.report.service.impl;
import com.ximai.mes.report.service.WeeklyProductionReportService;
public class WeeklyProductionReportServiceImp implements WeeklyProductionReportService {
}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<select id="getListByProcess" resultType="java.util.Map"> <select id="getListByProcess" resultType="java.util.Map">
SELECT SELECT
process.process_code AS "工序编", process.process_code AS "工序编",
process.process_name AS "工序名称", process.process_name AS "工序名称",
DATE_FORMAT( f.feedback_time, '%Y-%m-%d' ) AS "报工日期", DATE_FORMAT( f.feedback_time, '%Y-%m-%d' ) AS "报工日期",
sum( f.quantity ) AS quantity, sum( f.quantity ) AS quantity,
......
<?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.MonthlyProductionReportMapper">
<select id="getListByProcess" resultType="java.util.Map">
SELECT
process.process_code AS "工序编码",
process.process_name AS "工序名称",
DATE_FORMAT( f.feedback_time, '%m' ) 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="dateYear != null">and DATE_FORMAT(f.feedback_time, '%Y') = #{dateYear}</if>
</where>
GROUP BY
process.process_code,
process.process_name,
DATE_FORMAT( f.feedback_time, '%m' )
</select>
<select id="getListByWorkshop" resultType="java.util.Map">
SELECT
workstation.workshop_code as '车间编码',
workstation.workshop_name as '车间名称',
DATE_FORMAT( f.feedback_time, '%m' ) 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="dateYear != null">and DATE_FORMAT(f.feedback_time, '%Y') = #{dateYear}</if>
</where>
group by
workstation.workshop_code,
workstation.workshop_name,
DATE_FORMAT( f.feedback_time, '%m' )
</select>
<select id="getListByWorkstation" resultType="java.util.Map">
SELECT
workstation.workstation_code AS "工作中心编码",
workstation.workstation_name AS "工作中心名称",
DATE_FORMAT( f.feedback_time, '%m' ) 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="dateYear != null">and DATE_FORMAT(f.feedback_time, '%Y') = #{dateYear}</if>
</where>
group by
workstation.workstation_code,
workstation.workstation_name,
DATE_FORMAT( f.feedback_time, '%m' )
</select>
<select id="getListByWorkunit" resultType="java.util.Map">
SELECT
mw.workunit_code AS "工作单元编码",
mw.workunit_name AS "工作单元名称",
DATE_FORMAT( f.feedback_time, '%m' ) 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="dateYear != null">and DATE_FORMAT(f.feedback_time, '%Y') = #{dateYear}</if>
</where>
group by
mw.workunit_code,
mw.workunit_name,
DATE_FORMAT( f.feedback_time, '%m' )
</select>
<select id="getListByUser" resultType="java.util.Map">
SELECT
IFNULL(f.user_name,'无') AS "报工人员编码",
f.nick_name AS "报工人员名称",
DATE_FORMAT( f.feedback_time, '%m' ) 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="dateYear != null">and DATE_FORMAT(f.feedback_time, '%Y') = #{dateYear}</if>
</where>
group by
IFNULL(f.user_name,'无'),
f.nick_name,
DATE_FORMAT( f.feedback_time, '%m' )
</select>
</mapper>
<?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.WeeklyProductionReportMapper">
<select id="getListByProcess" resultType="java.util.Map">
SELECT
process.process_code AS "工序编码",
process.process_name AS "工序名称",
DATE_FORMAT( f.feedback_time, '%m' ) 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="dateYear != null">and DATE_FORMAT(f.feedback_time, '%Y') = #{dateYear}</if>
</where>
GROUP BY
process.process_code,
process.process_name,
DATE_FORMAT( f.feedback_time, '%m' )
</select>
<select id="getListByWorkshop" resultType="java.util.Map">
SELECT
workstation.workshop_code as '车间编码',
workstation.workshop_name as '车间名称',
DATE_FORMAT( f.feedback_time, '%m' ) 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="dateYear != null">and DATE_FORMAT(f.feedback_time, '%Y') = #{dateYear}</if>
</where>
group by
workstation.workshop_code,
workstation.workshop_name,
DATE_FORMAT( f.feedback_time, '%m' )
</select>
<select id="getListByWorkstation" resultType="java.util.Map">
SELECT
workstation.workstation_code AS "工作中心编码",
workstation.workstation_name AS "工作中心名称",
DATE_FORMAT( f.feedback_time, '%m' ) 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="dateYear != null">and DATE_FORMAT(f.feedback_time, '%Y') = #{dateYear}</if>
</where>
group by
workstation.workstation_code,
workstation.workstation_name,
DATE_FORMAT( f.feedback_time, '%m' )
</select>
<select id="getListByWorkunit" resultType="java.util.Map">
SELECT
mw.workunit_code AS "工作单元编码",
mw.workunit_name AS "工作单元名称",
DATE_FORMAT( f.feedback_time, '%m' ) 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="dateYear != null">and DATE_FORMAT(f.feedback_time, '%Y') = #{dateYear}</if>
</where>
group by
mw.workunit_code,
mw.workunit_name,
DATE_FORMAT( f.feedback_time, '%m' )
</select>
<select id="getListByUser" resultType="java.util.Map">
SELECT
IFNULL(f.user_name,'无') AS "报工人员编码",
f.nick_name AS "报工人员名称",
DATE_FORMAT( f.feedback_time, '%m' ) 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="dateYear != null">and DATE_FORMAT(f.feedback_time, '%Y') = #{dateYear}</if>
</where>
group by
IFNULL(f.user_name,'无'),
f.nick_name,
DATE_FORMAT( f.feedback_time, '%m' )
</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