质量报表功能

highway
zhaoxiaolin 1 year ago
parent d210876154
commit 2b16e9e96d

@ -244,7 +244,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
private int createOrderPlan(EquPlan plan){ private int createOrderPlan(EquPlan plan){
Date nowtime = DateUtils.getNowDate(); Date nowtime = DateUtils.getNowDate();
String createBy = SecurityUtils.getUsername(); String createBy = "job";
int sce = 0; int sce = 0;
/**equ_plan->equ_order********************************************************************/ /**equ_plan->equ_order********************************************************************/
EquOrder order = new EquOrder(); EquOrder order = new EquOrder();

@ -44,13 +44,13 @@ public class QcCheckReportIncomeController extends BaseController {
public TableDataInfo list(QcCheckReportIncome qcCheckReportIncome) { public TableDataInfo list(QcCheckReportIncome qcCheckReportIncome) {
//默认时间范围T 00:00:00~T+1 00:00:00 //默认时间范围T 00:00:00~T+1 00:00:00
if(StringUtils.isEmpty(qcCheckReportIncome.getIncomeTimeStart())){ if(StringUtils.isEmpty(qcCheckReportIncome.getCheckTimeStart())){
qcCheckReportIncome.setIncomeTimeStart(DateUtils.getDate()+" 00:00:00");//start qcCheckReportIncome.setCheckTimeStart(DateUtils.getDate()+" 00:00:00");//start
LocalDate date = LocalDate.now(); LocalDate date = LocalDate.now();
LocalDate dateEnd = date.plusDays(1); LocalDate dateEnd = date.plusDays(1);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd"); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String dateEndStr = dtf.format(dateEnd)+" 00:00:00"; String dateEndStr = dtf.format(dateEnd)+" 00:00:00";
qcCheckReportIncome.setIncomeTimeEnd(dateEndStr);//end qcCheckReportIncome.setCheckTimeEnd(dateEndStr);//end
} }
// if(StringUtils.isEmpty(qcCheckReportIncome.getCheckTimeStart())){ // if(StringUtils.isEmpty(qcCheckReportIncome.getCheckTimeStart())){

@ -44,13 +44,13 @@ public class QcCheckReportProduceController extends BaseController {
public TableDataInfo list(QcCheckReportIncome qcCheckReportIncome) { public TableDataInfo list(QcCheckReportIncome qcCheckReportIncome) {
//默认时间范围T 00:00:00~T+1 00:00:00 //默认时间范围T 00:00:00~T+1 00:00:00
if(StringUtils.isEmpty(qcCheckReportIncome.getIncomeTimeStart())){ if(StringUtils.isEmpty(qcCheckReportIncome.getCheckTimeStart())){
qcCheckReportIncome.setIncomeTimeStart(DateUtils.getDate()+" 00:00:00");//start qcCheckReportIncome.setCheckTimeStart(DateUtils.getDate()+" 00:00:00");//start
LocalDate date = LocalDate.now(); LocalDate date = LocalDate.now();
LocalDate dateEnd = date.plusDays(1); LocalDate dateEnd = date.plusDays(1);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd"); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String dateEndStr = dtf.format(dateEnd)+" 00:00:00"; String dateEndStr = dtf.format(dateEnd)+" 00:00:00";
qcCheckReportIncome.setIncomeTimeEnd(dateEndStr);//end qcCheckReportIncome.setCheckTimeEnd(dateEndStr);//end
} }
startPage(); startPage();

@ -44,13 +44,13 @@ public class QcCheckReportProductController extends BaseController {
public TableDataInfo list(QcCheckReportIncome qcCheckReportIncome) { public TableDataInfo list(QcCheckReportIncome qcCheckReportIncome) {
//默认时间范围T 00:00:00~T+1 00:00:00 //默认时间范围T 00:00:00~T+1 00:00:00
if(StringUtils.isEmpty(qcCheckReportIncome.getIncomeTimeStart())){ if(StringUtils.isEmpty(qcCheckReportIncome.getCheckTimeStart())){
qcCheckReportIncome.setIncomeTimeStart(DateUtils.getDate()+" 00:00:00");//start qcCheckReportIncome.setCheckTimeStart(DateUtils.getDate()+" 00:00:00");//start
LocalDate date = LocalDate.now(); LocalDate date = LocalDate.now();
LocalDate dateEnd = date.plusDays(1); LocalDate dateEnd = date.plusDays(1);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd"); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String dateEndStr = dtf.format(dateEnd)+" 00:00:00"; String dateEndStr = dtf.format(dateEnd)+" 00:00:00";
qcCheckReportIncome.setIncomeTimeEnd(dateEndStr);//end qcCheckReportIncome.setCheckTimeEnd(dateEndStr);//end
} }
// if(StringUtils.isEmpty(qcCheckReportIncome.getCheckTimeStart())){ // if(StringUtils.isEmpty(qcCheckReportIncome.getCheckTimeStart())){

@ -1,7 +1,13 @@
package com.op.quality.controller; package com.op.quality.controller;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.op.common.core.utils.DateUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -39,6 +45,17 @@ public class QcStaticTableController extends BaseController {
@RequiresPermissions("quality:qcTableIncome:list") @RequiresPermissions("quality:qcTableIncome:list")
@GetMapping("/getIncomeTableList") @GetMapping("/getIncomeTableList")
public TableDataInfo getIncomeTableList(QcStaticTable qcStaticTable) { public TableDataInfo getIncomeTableList(QcStaticTable qcStaticTable) {
if(StringUtils.isNotBlank(qcStaticTable.getSupplierCode())){
List<String> codes = Arrays.asList(qcStaticTable.getSupplierCode().split(","));
qcStaticTable.setSupplierCodes(codes);
}
//默认时间范围T 00:00:00~T+1 00:00:00
if(StringUtils.isEmpty(qcStaticTable.getYearMonth())){
LocalDate date = LocalDate.now();
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM");
String ymStr = dtf.format(date);
qcStaticTable.setYearMonth(ymStr);//end
}
startPage(); startPage();
List<QcStaticTable> list = qcStaticTableService.selectQcStaticTableList(qcStaticTable); List<QcStaticTable> list = qcStaticTableService.selectQcStaticTableList(qcStaticTable);
return getDataTable(list); return getDataTable(list);

@ -1,10 +1,10 @@
package com.op.quality.domain; package com.op.quality.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.op.common.core.annotation.Excel; import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity; import com.op.common.core.web.domain.BaseEntity;
import java.util.List;
/** /**
* qc_static_table * qc_static_table
* *
@ -14,110 +14,146 @@ import com.op.common.core.web.domain.BaseEntity;
public class QcStaticTable extends BaseEntity { public class QcStaticTable extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** ID */ private String supplierId;
private String id;
@Excel(name = "供应商编号")
private String supplierCode;
@Excel(name = "供应商名称")
private String supplierName;
private List<String> supplierCodes;
private String yearMonth;
private int batchs;
private int okBatchs;
private int noOkBatchs;
private int nums;
private int okNums;
private int noOkNums;
private String typeCode;
private String checkResult;
private String noOkBatchRate;
private String noOkNumRate;
public String getNoOkNumRate() {
return noOkNumRate;
}
public void setNoOkNumRate(String noOkNumRate) {
this.noOkNumRate = noOkNumRate;
}
public String getNoOkBatchRate() {
return noOkBatchRate;
}
public void setNoOkBatchRate(String noOkBatchRate) {
this.noOkBatchRate = noOkBatchRate;
}
public int getOkBatchs() {
return okBatchs;
}
public void setOkBatchs(int okBatchs) {
this.okBatchs = okBatchs;
}
/** 文件名称 */ public int getNoOkBatchs() {
@Excel(name = "文件名称") return noOkBatchs;
private String fileName; }
/** 文件地址 */ public void setNoOkBatchs(int noOkBatchs) {
@Excel(name = "文件地址") this.noOkBatchs = noOkBatchs;
private String fileAddress; }
/** 版本号 */ public int getNums() {
@Excel(name = "版本号") return nums;
private String version; }
/** 备用1 */ public void setNums(int nums) {
@Excel(name = "备用1") this.nums = nums;
private String attr1; }
/** 备用2 */ public int getOkNums() {
@Excel(name = "备用2") return okNums;
private String attr2; }
/** 备用3 */ public void setOkNums(int okNums) {
@Excel(name = "备用3") this.okNums = okNums;
private String attr3; }
/** 备用4 */ public int getNoOkNums() {
@Excel(name = "备用4") return noOkNums;
private String attr4; }
public void setId(String id) { public void setNoOkNums(int noOkNums) {
this.id = id; this.noOkNums = noOkNums;
} }
public String getId() { public String getCheckResult() {
return id; return checkResult;
} }
public void setFileName(String fileName) {
this.fileName = fileName; public void setCheckResult(String checkResult) {
this.checkResult = checkResult;
} }
public String getFileName() { public String getTypeCode() {
return fileName; return typeCode;
} }
public void setFileAddress(String fileAddress) {
this.fileAddress = fileAddress; public void setTypeCode(String typeCode) {
this.typeCode = typeCode;
} }
public String getFileAddress() { public int getBatchs() {
return fileAddress; return batchs;
} }
public void setVersion(String version) {
this.version = version; public void setBatchs(int batchs) {
this.batchs = batchs;
} }
public String getVersion() { public String getYearMonth() {
return version; return yearMonth;
} }
public void setAttr1(String attr1) {
this.attr1 = attr1; public void setYearMonth(String yearMonth) {
this.yearMonth = yearMonth;
} }
public String getAttr1() { public List<String> getSupplierCodes() {
return attr1; return supplierCodes;
} }
public void setAttr2(String attr2) {
this.attr2 = attr2; public void setSupplierCodes(List<String> supplierCodes) {
this.supplierCodes = supplierCodes;
} }
public String getAttr2() { public String getSupplierId() {
return attr2; return supplierId;
} }
public void setAttr3(String attr3) {
this.attr3 = attr3; public void setSupplierId(String supplierId) {
this.supplierId = supplierId;
} }
public String getAttr3() { public String getSupplierCode() {
return attr3; return supplierCode;
} }
public void setAttr4(String attr4) {
this.attr4 = attr4; public void setSupplierCode(String supplierCode) {
this.supplierCode = supplierCode;
} }
public String getAttr4() { public String getSupplierName() {
return attr4; return supplierName;
} }
@Override public void setSupplierName(String supplierName) {
public String toString() { this.supplierName = supplierName;
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("fileName", getFileName())
.append("fileAddress", getFileAddress())
.append("version", getVersion())
.append("attr1", getAttr1())
.append("attr2", getAttr2())
.append("attr3", getAttr3())
.append("attr4", getAttr4())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
} }
} }

@ -1,9 +1,12 @@
package com.op.quality.mapper; package com.op.quality.mapper;
import java.util.List; import java.util.List;
import java.util.Map;
import com.op.quality.domain.QcStaticTable; import com.op.quality.domain.QcStaticTable;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* Mapper * Mapper
@ -21,5 +24,10 @@ public interface QcStaticTableMapper {
* @return * @return
*/ */
public List<QcStaticTable> selectQcStaticTableList(QcStaticTable qcStaticTable); public List<QcStaticTable> selectQcStaticTableList(QcStaticTable qcStaticTable);
@MapKey("supplierCode")
public Map<String, QcStaticTable> selectPcMap(@Param("qc")QcStaticTable qcStaticTable,
@Param("codes")List<QcStaticTable> tabledtos);
@MapKey("supplierCode")
public Map<String, QcStaticTable> selectNumMap(@Param("qc")QcStaticTable qcStaticTable,
@Param("codes")List<QcStaticTable> tabledtos);
} }

@ -1,6 +1,8 @@
package com.op.quality.service.impl; package com.op.quality.service.impl;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Map;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.DateUtils;
@ -9,6 +11,7 @@ import org.springframework.stereotype.Service;
import com.op.quality.mapper.QcStaticTableMapper; import com.op.quality.mapper.QcStaticTableMapper;
import com.op.quality.domain.QcStaticTable; import com.op.quality.domain.QcStaticTable;
import com.op.quality.service.IQcStaticTableService; import com.op.quality.service.IQcStaticTableService;
import org.springframework.util.CollectionUtils;
/** /**
* Service * Service
@ -29,8 +32,76 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
*/ */
@Override @Override
@DS("#header.poolName") @DS("#header.poolName")
public List<QcStaticTable> selectQcStaticTableList(QcStaticTable qcStaticTable) { public List<QcStaticTable> selectQcStaticTableList(QcStaticTable qcStaticTable) {
return qcStaticTableMapper.selectQcStaticTableList(qcStaticTable); qcStaticTable.setTypeCode("material");
/**base_supplier**供应商**/
List<QcStaticTable> tabledtos = qcStaticTableMapper.selectQcStaticTableList(qcStaticTable);
if(CollectionUtils.isEmpty(tabledtos)){
return null;
}
/**qc_check_task**总批数**/
Map<String,QcStaticTable> pcMap = qcStaticTableMapper.selectPcMap(qcStaticTable,tabledtos);
if(pcMap==null){
return null;
}
/**qc_check_task**不合格批次数**/
qcStaticTable.setCheckResult("N");
Map<String,QcStaticTable> noOkPcMap = qcStaticTableMapper.selectPcMap(qcStaticTable,tabledtos);
/**qc_check_task**不合格数量**/
qcStaticTable.setCheckResult("N");
Map<String,QcStaticTable> noOkNumMap = qcStaticTableMapper.selectNumMap(qcStaticTable,tabledtos);
for(QcStaticTable tabledto:tabledtos){
QcStaticTable pcdto = pcMap.get(tabledto.getSupplierCode());
QcStaticTable numdto = noOkPcMap.get(tabledto.getSupplierCode());
QcStaticTable noOkNumdto = noOkNumMap.get(tabledto.getSupplierCode());
if(pcdto!=null){
//总批次
tabledto.setBatchs(pcdto.getBatchs());
//总数量
tabledto.setNums(pcdto.getNums());
}else{
tabledto.setBatchs(0);
tabledto.setNums(0);
}
if(numdto!=null){
//不合格批次
tabledto.setNoOkBatchs(numdto.getBatchs());
}else{
tabledto.setNoOkBatchs(0);
}
//合格批次
int okBatchs = tabledto.getBatchs()-tabledto.getNoOkBatchs();
tabledto.setOkBatchs(okBatchs);
//批次合格率
if(tabledto.getBatchs() != 0){
BigDecimal noOkBatchRate = new BigDecimal(tabledto.getNoOkBatchs()).multiply(new BigDecimal("100.00"))
.divide(new BigDecimal(tabledto.getBatchs()))
.setScale(2,BigDecimal.ROUND_HALF_UP);
tabledto.setNoOkBatchRate(noOkBatchRate.toString()+"%");
}else{
tabledto.setNoOkBatchRate("0.00%");
}
//不合格数量
if(noOkNumdto!=null){
tabledto.setNoOkNums(noOkNumdto.getNoOkNums());
}else{
tabledto.setNoOkNums(0);
}
//合格数量
tabledto.setOkNums(tabledto.getNums()-tabledto.getNoOkNums());
//数量不良率
if(tabledto.getNums() != 0){
BigDecimal noOkNumRate = new BigDecimal(tabledto.getNoOkNums()).multiply(new BigDecimal("100.00"))
.divide(new BigDecimal(tabledto.getNums()))
.setScale(2,BigDecimal.ROUND_HALF_UP);
tabledto.setNoOkNumRate(noOkNumRate.toString()+"%");
}else{
tabledto.setNoOkNumRate("0.00%");
}
}
return tabledtos;
} }
} }

@ -5,8 +5,56 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.op.quality.mapper.QcStaticTableMapper"> <mapper namespace="com.op.quality.mapper.QcStaticTableMapper">
<select id="selectQcStaticTableList" parameterType="QcStaticTable" resultType="QcStaticTable"> <select id="selectQcStaticTableList" parameterType="com.op.quality.domain.QcStaticTable" resultType="com.op.quality.domain.QcStaticTable">
SELECT
bs.supplier_id supplierId,
bs.supplier_code supplierCode,
bs.zh_desc supplierName
from base_supplier bs
where bs.del_flag = '0' and bs.active_flag = '1'
<if test="supplierCodes != null and supplierCodes.size()>0">
and bs.supplier_code in
<foreach collection="supplierCodes" item="supplierCode" index="index" separator="," open="(" close=")">
#{supplierCode}
</foreach>
</if>
</select>
<select id="selectPcMap" resultType="com.op.quality.domain.QcStaticTable">
SELECT
qct.supplier_code supplierCode,qct.supplier_name supplierName,
count(0) batchs,sum(qct.quality) nums
from qc_check_task qct
left join qc_check_type qc on qc.order_code = qct.check_type
where qc.type_code = #{qc.typeCode}
and qct.del_flag = '0'
and CONVERT(varchar(7),qct.income_time, 120) = #{qc.yearMonth}
<if test="qc.checkResult != null">
and qct.check_result = #{qc.checkResult}
</if>
<if test="codes != null and codes.size()>0">
and qct.supplier_code in
<foreach collection="codes" item="item" index="index" separator="," open="(" close=")">
#{item.supplierCode}
</foreach>
</if>
group by qct.supplier_code,qct.supplier_name
</select>
<select id="selectNumMap" resultType="com.op.quality.domain.QcStaticTable">
SELECT
qct.supplier_code supplierCode,qct.supplier_name supplierName,
sum(qct.noOk_quality) noOkNums
from qc_check_task qct
left join qc_check_type qc on qc.order_code = qct.check_type
where qc.type_code = #{qc.typeCode}
and qct.del_flag = '0'
and CONVERT(varchar(7),qct.income_time, 120) = #{qc.yearMonth}
<if test="codes != null and codes.size()>0">
and qct.supplier_code in
<foreach collection="codes" item="item" index="index" separator="," open="(" close=")">
#{item.supplierCode}
</foreach>
</if>
group by qct.supplier_code,qct.supplier_name
</select> </select>
</mapper> </mapper>

Loading…
Cancel
Save