Commit b0cab846 by lijingjing

磷生铁统计报表逻辑优化;

原始记录生成优化;
样品编号在提交时生成;
parent eb5f1604
...@@ -10,6 +10,14 @@ public class HttpConst { ...@@ -10,6 +10,14 @@ public class HttpConst {
public static final String ACCEPT_ENCODING = "identity"; public static final String ACCEPT_ENCODING = "identity";
public static final String CONTENT_TYPE = "application/json"; public static final String CONTENT_TYPE = "application/json";
public static final String ERP_URL = "http://192.168.0.22/api/LimsData/SaveData";
/**
* 正式:"http://192.168.0.22/api/LimsData/SaveData";
* 测试:"http://192.168.0.19:5050/api/LimsData/SaveData";
*/
public static final String ERP_URL = "http://192.168.0.19:5050/api/LimsData/SaveData";
/**
* GmHu6SqGdmmtY6Aup5kp1jlWenQz+vzQ6TBN6x/3dOwfNULkTNLx2/QA9Vhq1F7LEEXP6UKzFCxt99srTFd59DjGOgmrDnvVOYBgtSYbSTD2JNeRRD8AKe/v3TW9rWFtOMfGHtTkh6AxbovaSXa99tI5HUInT2wi2xwkdo9DKOQ=
*/
public static final String ERP_TOKEN = "GmHu6SqGdmmtY6Aup5kp1jlWenQz+vzQ6TBN6x/3dOwfNULkTNLx2/QA9Vhq1F7LEEXP6UKzFCxt99srTFd59DjGOgmrDnvVOYBgtSYbSTD2JNeRRD8AKe/v3TW9rWFtOMfGHtTkh6AxbovaSXa99tI5HUInT2wi2xwkdo9DKOQ="; public static final String ERP_TOKEN = "GmHu6SqGdmmtY6Aup5kp1jlWenQz+vzQ6TBN6x/3dOwfNULkTNLx2/QA9Vhq1F7LEEXP6UKzFCxt99srTFd59DjGOgmrDnvVOYBgtSYbSTD2JNeRRD8AKe/v3TW9rWFtOMfGHtTkh6AxbovaSXa99tI5HUInT2wi2xwkdo9DKOQ=";
} }
...@@ -280,7 +280,7 @@ public class EntrustController extends ServiceController { ...@@ -280,7 +280,7 @@ public class EntrustController extends ServiceController {
public RestResult<Boolean> addEntrust(@RequestBody EntrustDTO dto) { public RestResult<Boolean> addEntrust(@RequestBody EntrustDTO dto) {
dto.setStatus(EntrustStatusEnum.DRAFT); dto.setStatus(EntrustStatusEnum.DRAFT);
dto.setProgress(EntrustStatusEnum.DRAFT); dto.setProgress(EntrustStatusEnum.DRAFT);
return success(entrustService.saveEntrustDTO(dto, getAccount())); return success(entrustService.saveEntrustDTO(dto, false, getAccount()));
} }
...@@ -988,6 +988,6 @@ public class EntrustController extends ServiceController { ...@@ -988,6 +988,6 @@ public class EntrustController extends ServiceController {
@ApiOperation("确认生成复检委托") @ApiOperation("确认生成复检委托")
@RequestMapping(value = "/confirm_recheck", method = {RequestMethod.POST, RequestMethod.GET}) @RequestMapping(value = "/confirm_recheck", method = {RequestMethod.POST, RequestMethod.GET})
public RestResult<Boolean> confirmRecheck(@RequestBody EntrustDTO entrustDTO) { public RestResult<Boolean> confirmRecheck(@RequestBody EntrustDTO entrustDTO) {
return success(entrustService.confirmRecheck(entrustDTO,getAccount())); return success(entrustService.confirmRecheck(entrustDTO, getAccount()));
} }
} }
...@@ -12,13 +12,15 @@ import org.apache.poi.ss.util.CellRangeAddress; ...@@ -12,13 +12,15 @@ import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*; import org.apache.poi.xssf.usermodel.*;
import java.util.List; import java.util.List;
import java.util.Objects;
public class MoreItemMoreOperation implements Operation { public class MoreItemMoreOperation implements Operation {
private OriginalTemplate template; private OriginalTemplate template;
private List<EntrustSampleVO> voList; private List<EntrustSampleVO> voList;
private Entrust entrust ; private Entrust entrust;
private List<OriginalTemplateConfig> configList; private List<OriginalTemplateConfig> configList;
private XSSFWorkbook xssfWorkbook; private XSSFWorkbook xssfWorkbook;
public MoreItemMoreOperation(OriginalTemplate template, List<EntrustSampleVO> voList, Entrust entrust, List<OriginalTemplateConfig> configList, XSSFWorkbook xssfWorkbook) { public MoreItemMoreOperation(OriginalTemplate template, List<EntrustSampleVO> voList, Entrust entrust, List<OriginalTemplateConfig> configList, XSSFWorkbook xssfWorkbook) {
this.template = template; this.template = template;
this.voList = voList; this.voList = voList;
...@@ -31,7 +33,7 @@ public class MoreItemMoreOperation implements Operation { ...@@ -31,7 +33,7 @@ public class MoreItemMoreOperation implements Operation {
@Override @Override
public void doMakeOriginal() { public void doMakeOriginal() {
OriginalUtil.doReplace(xssfWorkbook,entrust); OriginalUtil.doReplace(xssfWorkbook, entrust);
XSSFSheet sheetOne = xssfWorkbook.getSheetAt(0); XSSFSheet sheetOne = xssfWorkbook.getSheetAt(0);
sheetOne.setForceFormulaRecalculation(true); sheetOne.setForceFormulaRecalculation(true);
...@@ -40,28 +42,26 @@ public class MoreItemMoreOperation implements Operation { ...@@ -40,28 +42,26 @@ public class MoreItemMoreOperation implements Operation {
XSSFRow zeroRow = sheetOne.getRow(template.getSampleBeginRow()); XSSFRow zeroRow = sheetOne.getRow(template.getSampleBeginRow());
XSSFCellStyle cellStyle = zeroRow.getCell(0).getCellStyle(); XSSFCellStyle cellStyle = zeroRow.getCell(0).getCellStyle();
int lastCellNum = zeroRow.getLastCellNum(); int lastCellNum = zeroRow.getLastCellNum();
if(template.getMoreSheet()==1){ if (template.getMoreSheet() == 1) {
//生成多个sheet的原始记录 //生成多个sheet的原始记录
//判断要生成几份sheet //判断要生成几份sheet
int total = voList.size(); int total = voList.size();
int totalSheetSize = (total+templateSampleNum-1)/templateSampleNum; int totalSheetSize = (total + templateSampleNum - 1) / templateSampleNum;
List<List<EntrustSampleVO>> listList = Lists.partition(voList,templateSampleNum); List<List<EntrustSampleVO>> listList = Lists.partition(voList, templateSampleNum);
for (int i = 1; i < totalSheetSize; i++) { for (int i = 1; i < totalSheetSize; i++) {
xssfWorkbook.cloneSheet(0,sheetOne.getSheetName()+(i+1)); xssfWorkbook.cloneSheet(0, sheetOne.getSheetName() + (i + 1));
} }
for (int m = 0; m < listList.size(); m++) { for (int m = 0; m < listList.size(); m++) {
List<EntrustSampleVO> sampleVOListIndex = listList.get(m); List<EntrustSampleVO> sampleVOListIndex = listList.get(m);
XSSFSheet sheetIndex= xssfWorkbook.getSheetAt(m); XSSFSheet sheetIndex = xssfWorkbook.getSheetAt(m);
Integer beginRow = template.getSampleBeginRow(); Integer beginRow = template.getSampleBeginRow();
for (EntrustSampleVO vo:sampleVOListIndex) { for (EntrustSampleVO vo : sampleVOListIndex) {
XSSFRow xssfRow = sheetIndex.getRow(beginRow); XSSFRow xssfRow = sheetIndex.getRow(beginRow);
XSSFRow xssfRowTwo = null; XSSFRow xssfRowTwo = null;
XSSFRow xssfRowThree = null; XSSFRow xssfRowThree = null;
...@@ -78,8 +78,8 @@ public class MoreItemMoreOperation implements Operation { ...@@ -78,8 +78,8 @@ public class MoreItemMoreOperation implements Operation {
xssfRowThree = sheetOne.getRow(beginRow + 2); xssfRowThree = sheetOne.getRow(beginRow + 2);
xssfRow4 = sheetOne.getRow(beginRow + 3); xssfRow4 = sheetOne.getRow(beginRow + 3);
} }
for (OriginalTemplateConfig config:configList) { for (OriginalTemplateConfig config : configList) {
XSSFCell cell = xssfRow.getCell(config.getColumnPlace()); XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
XSSFCell cell2 = null; XSSFCell cell2 = null;
XSSFCell cell3 = null; XSSFCell cell3 = null;
XSSFCell cell4 = null; XSSFCell cell4 = null;
...@@ -92,74 +92,74 @@ public class MoreItemMoreOperation implements Operation { ...@@ -92,74 +92,74 @@ public class MoreItemMoreOperation implements Operation {
if (null != xssfRow4) { if (null != xssfRow4) {
cell4 = xssfRow4.getCell(config.getColumnPlace()); cell4 = xssfRow4.getCell(config.getColumnPlace());
} }
if ("sn".equals(config.getDataAttribute())){ if ("sn".equals(config.getDataAttribute())) {
continue; continue;
} }
if (StringUtils.isBlank(config.getDataAttribute())){ if (StringUtils.isBlank(config.getDataAttribute())) {
continue; continue;
} }
if (config.getDataAttribute().startsWith("clc.")) { if (config.getDataAttribute().startsWith("clc.")) {
String mapKey = config.getDataAttribute().substring(4); String mapKey = config.getDataAttribute().substring(4);
if (CollectionUtils.isNotEmpty(vo.getCollectionDataList())) { if (CollectionUtils.isNotEmpty(vo.getCollectionDataList())) {
cell.setCellValue(vo.getCollectionDataList().get(0).get(mapKey)); cell.setCellValue(getValueFillZero(vo.getCollectionDataList().get(0).get(mapKey)));
if (null != cell2 && vo.getCollectionDataList().size() >= 2) { if (null != cell2 && vo.getCollectionDataList().size() >= 2) {
cell2.setCellValue(vo.getCollectionDataList().get(1).get(mapKey)); cell2.setCellValue(getValueFillZero(vo.getCollectionDataList().get(1).get(mapKey)));
} }
if (null != cell3 && vo.getCollectionDataList().size() >= 3) { if (null != cell3 && vo.getCollectionDataList().size() >= 3) {
cell3.setCellValue(vo.getCollectionDataList().get(2).get(mapKey)); cell3.setCellValue(getValueFillZero(vo.getCollectionDataList().get(2).get(mapKey)));
} }
if (null != cell4 && vo.getCollectionDataList().size() >= 4) { if (null != cell4 && vo.getCollectionDataList().size() >= 4) {
cell4.setCellValue(vo.getCollectionDataList().get(3).get(mapKey)); cell4.setCellValue(getValueFillZero(vo.getCollectionDataList().get(3).get(mapKey)));
} }
} }
continue; continue;
} }
cell.setCellValue(StringHandleUtils.getFieldValue(config.getDataAttribute(),vo)); cell.setCellValue(getValueFillZero(StringHandleUtils.getFieldValue(config.getDataAttribute(), vo)));
} }
beginRow+=sampleMergerNum; beginRow += sampleMergerNum;
} }
Integer sampleBgMum = template.getSampleBeginRow(); Integer sampleBgMum = template.getSampleBeginRow();
for (OriginalTemplateConfig config:configList) { for (OriginalTemplateConfig config : configList) {
if (null == config.getMergeRowNum()){ if (null == config.getMergeRowNum()) {
config.setMergeRowNum(1); config.setMergeRowNum(1);
} }
String formula = config.getFormula(); String formula = config.getFormula();
if (StringUtils.isBlank(formula)){ if (StringUtils.isBlank(formula)) {
continue; continue;
} }
Integer columnPlace = config.getColumnPlace(); Integer columnPlace = config.getColumnPlace();
if (null == config.getColumnPlace()){ if (null == config.getColumnPlace()) {
continue; continue;
} }
if (null == config.getMergeRowNum()){ if (null == config.getMergeRowNum()) {
continue; continue;
} }
Integer mergeRowNum = config.getMergeRowNum(); Integer mergeRowNum = config.getMergeRowNum();
int formulaNum = template.getSampleBeginRow()+sampleMergerNum*templateSampleNum-1 ; int formulaNum = template.getSampleBeginRow() + sampleMergerNum * templateSampleNum - 1;
for (int i =sampleBgMum ; i <= formulaNum; i+=mergeRowNum) { for (int i = sampleBgMum; i <= formulaNum; i += mergeRowNum) {
XSSFRow row = sheetOne.getRow(i); XSSFRow row = sheetOne.getRow(i);
XSSFCell cell = row.getCell(columnPlace); XSSFCell cell = row.getCell(columnPlace);
cell.setCellFormula(OriginalUtil.initFormula(formula,i)); cell.setCellFormula(OriginalUtil.initFormula(formula, i));
} }
} }
} }
}else{ } else {
Integer beginRow = template.getSampleBeginRow(); Integer beginRow = template.getSampleBeginRow();
int insertRow = beginRow+sampleMergerNum*templateSampleNum; int insertRow = beginRow + sampleMergerNum * templateSampleNum;
int insertCount = voList.size()-templateSampleNum; int insertCount = voList.size() - templateSampleNum;
for (int m = 0 ; m<insertCount ;m++) { for (int m = 0; m < insertCount; m++) {
for (int i = 0; i < sampleMergerNum; i++) { for (int i = 0; i < sampleMergerNum; i++) {
sheetOne.shiftRows(insertRow, sheetOne.getLastRowNum(), 1,true,false); sheetOne.shiftRows(insertRow, sheetOne.getLastRowNum(), 1, true, false);
XSSFRow row = sheetOne.createRow(insertRow); XSSFRow row = sheetOne.createRow(insertRow);
row.setHeight(zeroRow.getHeight()); row.setHeight(zeroRow.getHeight());
for (int j = 0; j < lastCellNum; j++) { for (int j = 0; j < lastCellNum; j++) {
XSSFCell xssfCell = row.createCell(j); XSSFCell xssfCell = row.createCell(j);
xssfCell.setCellStyle(cellStyle); xssfCell.setCellStyle(cellStyle);
} }
insertRow++; insertRow++;
...@@ -167,67 +167,67 @@ public class MoreItemMoreOperation implements Operation { ...@@ -167,67 +167,67 @@ public class MoreItemMoreOperation implements Operation {
} }
} }
int sn = 1; int sn = 1;
for (EntrustSampleVO vo:voList) { for (EntrustSampleVO vo : voList) {
XSSFRow xssfRow = sheetOne.getRow(beginRow); XSSFRow xssfRow = sheetOne.getRow(beginRow);
for (OriginalTemplateConfig config:configList) { for (OriginalTemplateConfig config : configList) {
if (null == config.getColumnPlace()){ if (null == config.getColumnPlace()) {
continue; continue;
} }
XSSFCell cell = xssfRow.getCell(config.getColumnPlace()); XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
if ("sn".equals(config.getDataAttribute())){ if ("sn".equals(config.getDataAttribute())) {
cell.setCellValue(sn); cell.setCellValue(sn);
}else{ } else {
cell.setCellValue(StringHandleUtils.getFieldValue(config.getDataAttribute(),vo)); cell.setCellValue(getValueFillZero(StringHandleUtils.getFieldValue(config.getDataAttribute(), vo)));
} }
} }
beginRow+=sampleMergerNum; beginRow += sampleMergerNum;
sn++; sn++;
} }
for (OriginalTemplateConfig config:configList) { for (OriginalTemplateConfig config : configList) {
if (null==config.getMergeRowNum()){ if (null == config.getMergeRowNum()) {
config.setMergeRowNum(1); config.setMergeRowNum(1);
} }
if (StringUtils.isNotBlank(config.getFormula())&&null != config.getColumnPlace() && null != config.getMergeRowNum()){ if (StringUtils.isNotBlank(config.getFormula()) && null != config.getColumnPlace() && null != config.getMergeRowNum()) {
Integer sampleBgMum = template.getSampleBeginRow(); Integer sampleBgMum = template.getSampleBeginRow();
Integer mergeRowNum = config.getMergeRowNum(); Integer mergeRowNum = config.getMergeRowNum();
int formulaNum = template.getSampleBeginRow()+sampleMergerNum*voList.size()-1 ; int formulaNum = template.getSampleBeginRow() + sampleMergerNum * voList.size() - 1;
for (int i =sampleBgMum ; i <= formulaNum; i+=mergeRowNum) { for (int i = sampleBgMum; i <= formulaNum; i += mergeRowNum) {
XSSFRow row = sheetOne.getRow(i); XSSFRow row = sheetOne.getRow(i);
if (null == row){ if (null == row) {
continue; continue;
} }
XSSFCell cell = row.getCell(config.getColumnPlace()); XSSFCell cell = row.getCell(config.getColumnPlace());
if (null == cell){ if (null == cell) {
continue; continue;
} }
String formula = config.getFormula(); String formula = config.getFormula();
cell.setCellFormula(OriginalUtil.initFormula(formula,i)); cell.setCellFormula(OriginalUtil.initFormula(formula, i));
} }
} }
} }
for (OriginalTemplateConfig config:configList) { for (OriginalTemplateConfig config : configList) {
if (null==config.getMergeRowNum()){ if (null == config.getMergeRowNum()) {
config.setMergeRowNum(1); config.setMergeRowNum(1);
} }
if (null == config.getMergeBegin()){ if (null == config.getMergeBegin()) {
continue; continue;
} }
if (null == config.getMergeEnd()){ if (null == config.getMergeEnd()) {
continue; continue;
} }
int step= config.getMergeRowNum(); int step = config.getMergeRowNum();
if (step==1 && config.getMergeEnd() == config.getMergeBegin()){ if (step == 1 && Objects.equals(config.getMergeEnd(), config.getMergeBegin())) {
continue; continue;
} }
if (null != config.getColumnPlace() && null != config.getMergeRowNum()){ if (null != config.getColumnPlace() && null != config.getMergeRowNum()) {
Integer sampleBgMum = template.getSampleBeginRow()+templateSampleNum*sampleMergerNum; int sampleBgMum = template.getSampleBeginRow() + templateSampleNum * sampleMergerNum;
Integer sampleEnMum = template.getSampleBeginRow()+voList.size()*sampleMergerNum-1; int sampleEnMum = template.getSampleBeginRow() + voList.size() * sampleMergerNum - 1;
while (sampleBgMum<=sampleEnMum) { while (sampleBgMum <= sampleEnMum) {
sheetOne.addMergedRegion(new CellRangeAddress(sampleBgMum,sampleBgMum+step-1,config.getMergeBegin(),config.getMergeEnd())); sheetOne.addMergedRegion(new CellRangeAddress(sampleBgMum, sampleBgMum + step - 1, config.getMergeBegin(), config.getMergeEnd()));
sampleBgMum=sampleBgMum+step; sampleBgMum = sampleBgMum + step;
} }
} }
} }
......
package com.patzn.cloud.service.lims.hmhj.original; package com.patzn.cloud.service.lims.hmhj.original;
import com.baomidou.mybatisplus.toolkit.CollectionUtils; import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.patzn.cloud.service.hmhj.entity.Entrust; import com.patzn.cloud.service.hmhj.entity.Entrust;
import com.patzn.cloud.service.hmhj.entity.OriginalTemplate; import com.patzn.cloud.service.hmhj.entity.OriginalTemplate;
...@@ -16,10 +17,11 @@ import java.util.List; ...@@ -16,10 +17,11 @@ import java.util.List;
public class MoreItemOperation implements Operation { public class MoreItemOperation implements Operation {
private OriginalTemplate template; private OriginalTemplate template;
private List<EntrustSampleVO> voList; private List<EntrustSampleVO> voList;
private Entrust entrust ; private Entrust entrust;
private List<OriginalTemplateConfig> configList; private List<OriginalTemplateConfig> configList;
private XSSFWorkbook xssfWorkbook; private XSSFWorkbook xssfWorkbook;
public MoreItemOperation(OriginalTemplate template, List<EntrustSampleVO> voList, Entrust entrust, List<OriginalTemplateConfig> configList, XSSFWorkbook xssfWorkbook) { public MoreItemOperation(OriginalTemplate template, List<EntrustSampleVO> voList, Entrust entrust, List<OriginalTemplateConfig> configList, XSSFWorkbook xssfWorkbook) {
this.template = template; this.template = template;
this.voList = voList; this.voList = voList;
...@@ -30,15 +32,15 @@ public class MoreItemOperation implements Operation { ...@@ -30,15 +32,15 @@ public class MoreItemOperation implements Operation {
@Override @Override
public void doMakeOriginal() { public void doMakeOriginal() {
OriginalUtil.doReplace(xssfWorkbook,entrust); OriginalUtil.doReplace(xssfWorkbook, entrust);
XSSFSheet sheetOne = xssfWorkbook.getSheetAt(0); XSSFSheet sheetOne = xssfWorkbook.getSheetAt(0);
String sheetName = sheetOne.getSheetName(); String sheetName = sheetOne.getSheetName();
System.out.println(sheetName); System.out.println(sheetName);
sheetOne.setForceFormulaRecalculation(true); sheetOne.setForceFormulaRecalculation(true);
Integer beginRow = template.getSampleBeginRow(); Integer beginRow = template.getSampleBeginRow();
int sampleMergerNum = template.getSampleMergerNum(); int sampleMergerNum = template.getSampleMergerNum();
int templateSampleNum = template.getTemplateSampleNum(); int templateSampleNum = template.getTemplateSampleNum();
for (EntrustSampleVO vo:voList) { for (EntrustSampleVO vo : voList) {
XSSFRow xssfRow = sheetOne.getRow(beginRow); XSSFRow xssfRow = sheetOne.getRow(beginRow);
XSSFRow xssfRowTwo = null; XSSFRow xssfRowTwo = null;
XSSFRow xssfRowThree = null; XSSFRow xssfRowThree = null;
...@@ -49,8 +51,8 @@ public class MoreItemOperation implements Operation { ...@@ -49,8 +51,8 @@ public class MoreItemOperation implements Operation {
xssfRowTwo = sheetOne.getRow(beginRow + 1); xssfRowTwo = sheetOne.getRow(beginRow + 1);
xssfRowThree = sheetOne.getRow(beginRow + 2); xssfRowThree = sheetOne.getRow(beginRow + 2);
} }
for (OriginalTemplateConfig config:configList) { for (OriginalTemplateConfig config : configList) {
XSSFCell cell = xssfRow.getCell(config.getColumnPlace()); XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
XSSFCell cell2 = null; XSSFCell cell2 = null;
XSSFCell cell3 = null; XSSFCell cell3 = null;
if (null != xssfRowTwo) { if (null != xssfRowTwo) {
...@@ -59,59 +61,60 @@ public class MoreItemOperation implements Operation { ...@@ -59,59 +61,60 @@ public class MoreItemOperation implements Operation {
if (null != xssfRowThree) { if (null != xssfRowThree) {
cell3 = xssfRowTwo.getCell(config.getColumnPlace()); cell3 = xssfRowTwo.getCell(config.getColumnPlace());
} }
if ("sn".equals(config.getDataAttribute())){ if ("sn".equals(config.getDataAttribute())) {
continue; continue;
} }
if (StringUtils.isBlank(config.getDataAttribute())){ if (StringUtils.isBlank(config.getDataAttribute())) {
continue; continue;
} }
if (config.getDataAttribute().startsWith("clc.")) { if (config.getDataAttribute().startsWith("clc.")) {
String mapKey = config.getDataAttribute().substring(4); String mapKey = config.getDataAttribute().substring(4);
if (CollectionUtils.isNotEmpty(vo.getCollectionDataList())) { if (CollectionUtils.isNotEmpty(vo.getCollectionDataList())) {
cell.setCellValue(vo.getCollectionDataList().get(0).get(mapKey)); //
cell.setCellValue(getValueFillZero(vo.getCollectionDataList().get(0).get(mapKey)));
if (null != cell2 && vo.getCollectionDataList().size() >= 2) { if (null != cell2 && vo.getCollectionDataList().size() >= 2) {
cell2.setCellValue(vo.getCollectionDataList().get(1).get(mapKey)); cell2.setCellValue(getValueFillZero(vo.getCollectionDataList().get(1).get(mapKey)));
} }
if (null != cell3 && vo.getCollectionDataList().size() >= 3) { if (null != cell3 && vo.getCollectionDataList().size() >= 3) {
cell3.setCellValue(vo.getCollectionDataList().get(2).get(mapKey)); cell3.setCellValue(getValueFillZero(vo.getCollectionDataList().get(2).get(mapKey)));
} }
} }
continue; continue;
} }
String value= StringHandleUtils.getFieldValue(config.getDataAttribute(),vo); String value = StringHandleUtils.getFieldValue(config.getDataAttribute(), vo);
cell.setCellValue(value); cell.setCellValue(getValueFillZero(value));
} }
beginRow+=sampleMergerNum; beginRow += sampleMergerNum;
} }
Integer sampleBgMum = template.getSampleBeginRow(); Integer sampleBgMum = template.getSampleBeginRow();
for (OriginalTemplateConfig config:configList) { for (OriginalTemplateConfig config : configList) {
if (null == config.getMergeRowNum()){ if (null == config.getMergeRowNum()) {
config.setMergeRowNum(1); config.setMergeRowNum(1);
} }
String formula = config.getFormula(); String formula = config.getFormula();
if (StringUtils.isBlank(formula)){ if (StringUtils.isBlank(formula)) {
continue; continue;
} }
Integer columnPlace = config.getColumnPlace(); Integer columnPlace = config.getColumnPlace();
if (null == config.getColumnPlace()){ if (null == config.getColumnPlace()) {
continue; continue;
} }
if (null == config.getMergeRowNum()){ if (null == config.getMergeRowNum()) {
continue; continue;
} }
Integer mergeRowNum = config.getMergeRowNum(); Integer mergeRowNum = config.getMergeRowNum();
int formulaNum = template.getSampleBeginRow()+sampleMergerNum*templateSampleNum-1 ; int formulaNum = template.getSampleBeginRow() + sampleMergerNum * templateSampleNum - 1;
for (int i =sampleBgMum ; i <= formulaNum; i+=mergeRowNum) { for (int i = sampleBgMum; i <= formulaNum; i += mergeRowNum) {
XSSFRow row = sheetOne.getRow(i); XSSFRow row = sheetOne.getRow(i);
XSSFCell cell = row.getCell(columnPlace); XSSFCell cell = row.getCell(columnPlace);
cell.setCellFormula(OriginalUtil.initFormula(formula,i)); cell.setCellFormula(OriginalUtil.initFormula(formula, i));
} }
} }
} }
} }
...@@ -17,10 +17,11 @@ import java.util.Map; ...@@ -17,10 +17,11 @@ import java.util.Map;
public class MoreSheetMoreOperation implements Operation { public class MoreSheetMoreOperation implements Operation {
private OriginalTemplate template; private OriginalTemplate template;
private List<EntrustSampleItemVO> voList; private List<EntrustSampleItemVO> voList;
private Entrust entrust ; private Entrust entrust;
private List<OriginalTemplateConfig> configList; private List<OriginalTemplateConfig> configList;
private XSSFWorkbook xssfWorkbook; private XSSFWorkbook xssfWorkbook;
public MoreSheetMoreOperation(OriginalTemplate template, List<EntrustSampleItemVO> voList, Entrust entrust, List<OriginalTemplateConfig> configList, XSSFWorkbook xssfWorkbook) { public MoreSheetMoreOperation(OriginalTemplate template, List<EntrustSampleItemVO> voList, Entrust entrust, List<OriginalTemplateConfig> configList, XSSFWorkbook xssfWorkbook) {
this.template = template; this.template = template;
this.voList = voList; this.voList = voList;
...@@ -31,10 +32,10 @@ public class MoreSheetMoreOperation implements Operation { ...@@ -31,10 +32,10 @@ public class MoreSheetMoreOperation implements Operation {
@Override @Override
public void doMakeOriginal() { public void doMakeOriginal() {
Integer templateSampleNum = template.getTemplateSampleNum(); Integer templateSampleNum = template.getTemplateSampleNum();
Map<String, String> mapReplace = new HashMap<>(); Map<String, String> mapReplace = new HashMap<>();
mapReplace.put("#{client}",entrust.getClient()); mapReplace.put("#{client}", entrust.getClient());
List<List<EntrustSampleItemVO>> relList= ListUtils.partition(voList,templateSampleNum); List<List<EntrustSampleItemVO>> relList = ListUtils.partition(voList, templateSampleNum);
int templateSheetMum = xssfWorkbook.getNumberOfSheets(); int templateSheetMum = xssfWorkbook.getNumberOfSheets();
XSSFSheet sheetMy = xssfWorkbook.getSheetAt(0); XSSFSheet sheetMy = xssfWorkbook.getSheetAt(0);
...@@ -43,46 +44,46 @@ public class MoreSheetMoreOperation implements Operation { ...@@ -43,46 +44,46 @@ public class MoreSheetMoreOperation implements Operation {
List<EntrustSampleItemVO> firstList = null; List<EntrustSampleItemVO> firstList = null;
for (List<EntrustSampleItemVO> expVOList:relList) { for (List<EntrustSampleItemVO> expVOList : relList) {
XSSFSheet sheet=null; XSSFSheet sheet = null;
if (first){ if (first) {
sheet = sheetMy; sheet = sheetMy;
firstList = expVOList; firstList = expVOList;
first = false; first = false;
continue; continue;
}else{ } else {
sheet = xssfWorkbook.cloneSheet(0,sheetMy.getSheetName()+(templateSheetMum)); sheet = xssfWorkbook.cloneSheet(0, sheetMy.getSheetName() + (templateSheetMum));
} }
Map<String,String> mapReplaceMy = new HashMap<>(); Map<String, String> mapReplaceMy = new HashMap<>();
for (int i = 0; i < templateSampleNum; i++) { for (int i = 0; i < templateSampleNum; i++) {
mapReplaceMy.put("#{sampleCode"+i+"}",""); mapReplaceMy.put("#{sampleCode" + i + "}", "");
} }
mapReplaceMy.put("#{client}",entrust.getClient()); mapReplaceMy.put("#{client}", entrust.getClient());
int entitySize = expVOList.size(); int entitySize = expVOList.size();
for (int j = 0; j < entitySize; j++) { for (int j = 0; j < entitySize; j++) {
EntrustSampleItemVO vo = expVOList.get(j); EntrustSampleItemVO vo = expVOList.get(j);
mapReplaceMy.put("#{sampleCode"+j+"}", StringHandleUtils.getString(vo.getSampleCode())); mapReplaceMy.put("#{sampleCode" + j + "}", StringHandleUtils.getString(vo.getSampleCode()));
} }
HSSFWorkbookUtil.replaceModel(mapReplaceMy,xssfWorkbook,sheet); HSSFWorkbookUtil.replaceModel(mapReplaceMy, xssfWorkbook, sheet);
templateSheetMum++; templateSheetMum++;
} }
int firstSize = firstList.size(); int firstSize = firstList.size();
Map<String,String> mapReplaceMy = new HashMap<>(); Map<String, String> mapReplaceMy = new HashMap<>();
for (int i = 0; i < templateSampleNum; i++) { for (int i = 0; i < templateSampleNum; i++) {
mapReplaceMy.put("#{sampleCode"+i+"}",""); mapReplaceMy.put("#{sampleCode" + i + "}", "");
} }
mapReplaceMy.put("#{client}",entrust.getClient()); mapReplaceMy.put("#{client}", entrust.getClient());
for (int j = 0; j < firstSize; j++) { for (int j = 0; j < firstSize; j++) {
EntrustSampleItemVO vo = firstList.get(j); EntrustSampleItemVO vo = firstList.get(j);
mapReplaceMy.put("#{sampleCode"+j+"}",StringHandleUtils.getString(vo.getSampleCode())); mapReplaceMy.put("#{sampleCode" + j + "}", StringHandleUtils.getString(vo.getSampleCode()));
} }
HSSFWorkbookUtil.replaceModel(mapReplaceMy,xssfWorkbook,sheetMy); HSSFWorkbookUtil.replaceModel(mapReplaceMy, xssfWorkbook, sheetMy);
} }
} }
...@@ -15,10 +15,11 @@ import java.util.Map; ...@@ -15,10 +15,11 @@ import java.util.Map;
public class MoreSheetOneOperation implements Operation { public class MoreSheetOneOperation implements Operation {
private OriginalTemplate template; private OriginalTemplate template;
private List<EntrustSampleItemVO> voList; private List<EntrustSampleItemVO> voList;
private Entrust entrust ; private Entrust entrust;
private List<OriginalTemplateConfig> configList; private List<OriginalTemplateConfig> configList;
private XSSFWorkbook xssfWorkbook; private XSSFWorkbook xssfWorkbook;
public MoreSheetOneOperation(OriginalTemplate template, List<EntrustSampleItemVO> voList, Entrust entrust, List<OriginalTemplateConfig> configList, XSSFWorkbook xssfWorkbook) { public MoreSheetOneOperation(OriginalTemplate template, List<EntrustSampleItemVO> voList, Entrust entrust, List<OriginalTemplateConfig> configList, XSSFWorkbook xssfWorkbook) {
this.template = template; this.template = template;
this.voList = voList; this.voList = voList;
...@@ -30,24 +31,22 @@ public class MoreSheetOneOperation implements Operation { ...@@ -30,24 +31,22 @@ public class MoreSheetOneOperation implements Operation {
@Override @Override
public void doMakeOriginal() { public void doMakeOriginal() {
Map<String, String> mapReplace = new HashMap<>(); Map<String, String> mapReplace = new HashMap<>();
mapReplace.put("#{client}",entrust.getClient()); mapReplace.put("#{client}", entrust.getClient());
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0); XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
xssfSheet.setForceFormulaRecalculation(true); xssfSheet.setForceFormulaRecalculation(true);
int index = 0; int index = 0;
EntrustSampleItemVO firstVO = null; EntrustSampleItemVO firstVO = new EntrustSampleItemVO();
int sheetNum = xssfWorkbook.getNumberOfSheets();
int sheetNum = xssfWorkbook.getNumberOfSheets();
for (EntrustSampleItemVO vo:voList) { for (EntrustSampleItemVO vo : voList) {
if (index==0){ if (index == 0) {
index++; index++;
firstVO = vo; firstVO = vo;
continue; continue;
} }
XSSFSheet sheet = xssfWorkbook.cloneSheet(0); xssfWorkbook.cloneSheet(0);
index++; index++;
} }
...@@ -55,19 +54,19 @@ public class MoreSheetOneOperation implements Operation { ...@@ -55,19 +54,19 @@ public class MoreSheetOneOperation implements Operation {
int nextSample = sheetNum; int nextSample = sheetNum;
boolean start = true; boolean start = true;
for (EntrustSampleItemVO vo:voList) { for (EntrustSampleItemVO vo : voList) {
if (start){ if (start) {
start = false; start = false;
continue; continue;
} }
XSSFSheet sheet = xssfWorkbook.getSheetAt(nextSample); XSSFSheet sheet = xssfWorkbook.getSheetAt(nextSample);
xssfWorkbook.setSheetName(nextSample,vo.getSampleCode()); xssfWorkbook.setSheetName(nextSample, vo.getSampleCode());
mapReplace.put("#{sampleCode}",vo.getSampleCode()); mapReplace.put("#{sampleCode}", vo.getSampleCode());
HSSFWorkbookUtil.replaceModel(mapReplace,xssfWorkbook,sheet); HSSFWorkbookUtil.replaceModel(mapReplace, xssfWorkbook, sheet);
nextSample++; nextSample++;
} }
mapReplace.put("#{sampleCode}",firstVO.getSampleCode()); mapReplace.put("#{sampleCode}", firstVO.getSampleCode());
HSSFWorkbookUtil.replaceModel(mapReplace,xssfWorkbook,xssfSheet); HSSFWorkbookUtil.replaceModel(mapReplace, xssfWorkbook, xssfSheet);
} }
} }
...@@ -6,11 +6,25 @@ import org.apache.poi.ss.usermodel.Cell; ...@@ -6,11 +6,25 @@ import org.apache.poi.ss.usermodel.Cell;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.Objects;
public interface Operation { public interface Operation {
void doMakeOriginal(); void doMakeOriginal();
default String getValueFillZero(String value) {
if (StringUtils.isBlank(value)) {
return value;
}
value = value.trim();
// 不为0时,返回不进行处理
if (!Objects.equals(value, "0")) {
return value;
}
// 默认 0 精度为3位有效数字 0.000
return new BigDecimal(value).setScale(3).toPlainString();
}
/** /**
* 对从直读光谱中抓取过来的原铝分析结果,进行修约 * 对从直读光谱中抓取过来的原铝分析结果,进行修约
* *
......
...@@ -56,7 +56,6 @@ public final class OriginalUtil { ...@@ -56,7 +56,6 @@ public final class OriginalUtil {
return formula; return formula;
} }
public final static void doReplace(XSSFWorkbook xssfWorkbook, Entrust entrust) { public final static void doReplace(XSSFWorkbook xssfWorkbook, Entrust entrust) {
Map<String, String> mapReplace = new HashMap<>(); Map<String, String> mapReplace = new HashMap<>();
mapReplace.put("#{client}", entrust.getClient()); mapReplace.put("#{client}", entrust.getClient());
......
...@@ -180,22 +180,22 @@ public class SingleSheetMoreItemOperation implements Operation { ...@@ -180,22 +180,22 @@ public class SingleSheetMoreItemOperation implements Operation {
continue; continue;
} }
// 不需要修约 // 不需要修约
cell.setCellValue(sampleIdMap.get(vo.getId()).get(mapKey)); cell.setCellValue(getValueFillZero(sampleIdMap.get(vo.getId()).get(mapKey)));
if (null != cell2 && vo.getCollectionDataList().size() >= 2) { if (null != cell2 && vo.getCollectionDataList().size() >= 2) {
cell2.setCellValue(vo.getCollectionDataList().get(1).get(mapKey)); cell2.setCellValue(getValueFillZero(vo.getCollectionDataList().get(1).get(mapKey)));
} }
if (null != cell3 && vo.getCollectionDataList().size() >= 3) { if (null != cell3 && vo.getCollectionDataList().size() >= 3) {
cell3.setCellValue(vo.getCollectionDataList().get(2).get(mapKey)); cell3.setCellValue(getValueFillZero(vo.getCollectionDataList().get(2).get(mapKey)));
} }
if (null != cell4 && vo.getCollectionDataList().size() >= 4) { if (null != cell4 && vo.getCollectionDataList().size() >= 4) {
cell4.setCellValue(vo.getCollectionDataList().get(3).get(mapKey)); cell4.setCellValue(getValueFillZero(vo.getCollectionDataList().get(3).get(mapKey)));
} }
} }
continue; continue;
} }
String value = StringHandleUtils.getFieldIfNummReturnBlankValueByFieldName(config.getDataAttribute(), vo); String value = StringHandleUtils.getFieldIfNummReturnBlankValueByFieldName(config.getDataAttribute(), vo);
cell.setCellValue(value); cell.setCellValue(getValueFillZero(value));
} }
beginRow += sampleMergerNum; beginRow += sampleMergerNum;
sn++; sn++;
......
...@@ -138,21 +138,21 @@ public class SingleSheetMoreOperation implements Operation { ...@@ -138,21 +138,21 @@ public class SingleSheetMoreOperation implements Operation {
continue; continue;
} }
// 不需要修约 // 不需要修约
cell.setCellValue(vo.getCollectionDataList().get(0).get(mapKey)); cell.setCellValue(getValueFillZero(vo.getCollectionDataList().get(0).get(mapKey)));
if (null != cell2 && vo.getCollectionDataList().size() >= 2) { if (null != cell2 && vo.getCollectionDataList().size() >= 2) {
cell2.setCellValue(vo.getCollectionDataList().get(1).get(mapKey)); cell2.setCellValue(getValueFillZero(vo.getCollectionDataList().get(1).get(mapKey)));
} }
if (null != cell3 && vo.getCollectionDataList().size() >= 3) { if (null != cell3 && vo.getCollectionDataList().size() >= 3) {
cell3.setCellValue(vo.getCollectionDataList().get(2).get(mapKey)); cell3.setCellValue(getValueFillZero(vo.getCollectionDataList().get(2).get(mapKey)));
} }
if (null != cell4 && vo.getCollectionDataList().size() >= 4) { if (null != cell4 && vo.getCollectionDataList().size() >= 4) {
cell4.setCellValue(vo.getCollectionDataList().get(3).get(mapKey)); cell4.setCellValue(getValueFillZero(vo.getCollectionDataList().get(3).get(mapKey)));
} }
} }
continue;
} else { } else {
cell.setCellValue(StringHandleUtils.getFieldIfNummReturnBlankValueByFieldName(config.getDataAttribute(), vo)); String value = StringHandleUtils.getFieldIfNummReturnBlankValueByFieldName(config.getDataAttribute(), vo);
cell.setCellValue(getValueFillZero(value));
} }
} }
...@@ -231,9 +231,9 @@ public class SingleSheetMoreOperation implements Operation { ...@@ -231,9 +231,9 @@ public class SingleSheetMoreOperation implements Operation {
} }
if (null != config.getDataAttribute() && config.getDataAttribute().startsWith(collectionDataPrefix)) { if (null != config.getDataAttribute() && config.getDataAttribute().startsWith(collectionDataPrefix)) {
XSSFCell cell = row.getCell(config.getColumnPlace()); XSSFCell cell = row.getCell(config.getColumnPlace());
cell.setCellValue(curveDataList.get(index).get(config.getDataAttribute().substring(collectionDataPrefix.length()))); String value = curveDataList.get(index).get(config.getDataAttribute().substring(collectionDataPrefix.length()));
cell.setCellValue(getValueFillZero(value));
} }
} }
index++; index++;
} }
...@@ -248,7 +248,8 @@ public class SingleSheetMoreOperation implements Operation { ...@@ -248,7 +248,8 @@ public class SingleSheetMoreOperation implements Operation {
} }
if (null != config.getDataAttribute() && config.getDataAttribute().startsWith(collectionDataPrefix)) { if (null != config.getDataAttribute() && config.getDataAttribute().startsWith(collectionDataPrefix)) {
XSSFCell cell = row.getCell(config.getColumnPlace()); XSSFCell cell = row.getCell(config.getColumnPlace());
cell.setCellValue(blankDataMap.get(config.getDataAttribute().substring(collectionDataPrefix.length()))); String value = blankDataMap.get(config.getDataAttribute().substring(collectionDataPrefix.length()));
cell.setCellValue(getValueFillZero(value));
} }
} }
} }
......
...@@ -127,7 +127,7 @@ public class SingleSheetMoreTabletOperation implements Operation { ...@@ -127,7 +127,7 @@ public class SingleSheetMoreTabletOperation implements Operation {
rounding(cellS, rowDataS, config.getRoundNum()); rounding(cellS, rowDataS, config.getRoundNum());
} else { } else {
// 不需要修约 // 不需要修约
cellS.setCellValue(rowDataS); cellS.setCellValue(getValueFillZero(rowDataS));
} }
} }
...@@ -139,7 +139,7 @@ public class SingleSheetMoreTabletOperation implements Operation { ...@@ -139,7 +139,7 @@ public class SingleSheetMoreTabletOperation implements Operation {
rounding(cellE, rowDataE, config.getRoundNum()); rounding(cellE, rowDataE, config.getRoundNum());
} else { } else {
// 不需要修约 // 不需要修约
cellE.setCellValue(rowDataE); cellE.setCellValue(getValueFillZero(rowDataE));
} }
} }
} }
...@@ -151,7 +151,8 @@ public class SingleSheetMoreTabletOperation implements Operation { ...@@ -151,7 +151,8 @@ public class SingleSheetMoreTabletOperation implements Operation {
if (CollectionUtils.isEmpty(dataMapList)) { if (CollectionUtils.isEmpty(dataMapList)) {
continue; continue;
} }
cellS.setCellValue(StringHandleUtils.getFieldIfNummReturnBlankValueByFieldName(config.getDataAttribute(), itemVO)); String val = StringHandleUtils.getFieldIfNummReturnBlankValueByFieldName(config.getDataAttribute(), itemVO);
cellS.setCellValue(getValueFillZero(val));
} }
} }
} }
...@@ -177,7 +178,7 @@ public class SingleSheetMoreTabletOperation implements Operation { ...@@ -177,7 +178,7 @@ public class SingleSheetMoreTabletOperation implements Operation {
continue; continue;
} }
String formula = config.getFormula(); String formula = config.getFormula();
cell.setCellFormula(OriginalUtil.initFormula(formula, i)); cell.setCellFormula(getValueFillZero(OriginalUtil.initFormula(formula, i)));
} }
} }
} }
...@@ -230,7 +231,8 @@ public class SingleSheetMoreTabletOperation implements Operation { ...@@ -230,7 +231,8 @@ public class SingleSheetMoreTabletOperation implements Operation {
} }
if (null != config.getDataAttribute() && config.getDataAttribute().startsWith(collectionDataPrefix)) { if (null != config.getDataAttribute() && config.getDataAttribute().startsWith(collectionDataPrefix)) {
XSSFCell cell = row.getCell(config.getColumnPlace()); XSSFCell cell = row.getCell(config.getColumnPlace());
cell.setCellValue(curveDataList.get(index).get(config.getDataAttribute().substring(collectionDataPrefix.length()))); String val = curveDataList.get(index).get(config.getDataAttribute().substring(collectionDataPrefix.length()));
cell.setCellValue(getValueFillZero(val));
} }
} }
...@@ -247,7 +249,8 @@ public class SingleSheetMoreTabletOperation implements Operation { ...@@ -247,7 +249,8 @@ public class SingleSheetMoreTabletOperation implements Operation {
} }
if (null != config.getDataAttribute() && config.getDataAttribute().startsWith(collectionDataPrefix)) { if (null != config.getDataAttribute() && config.getDataAttribute().startsWith(collectionDataPrefix)) {
XSSFCell cell = row.getCell(config.getColumnPlace()); XSSFCell cell = row.getCell(config.getColumnPlace());
cell.setCellValue(blankDataMap.get(config.getDataAttribute().substring(collectionDataPrefix.length()))); String val = blankDataMap.get(config.getDataAttribute().substring(collectionDataPrefix.length()));
cell.setCellValue(getValueFillZero(val));
} }
} }
} }
......
...@@ -11,7 +11,7 @@ import javax.servlet.http.HttpServletResponse; ...@@ -11,7 +11,7 @@ import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
* 服务类 * 服务类
* *
* @author wwd * @author wwd
* @since 2021-02-01 * @since 2021-02-01
...@@ -24,7 +24,7 @@ public interface IEntrustService extends IBaseService<Entrust> { ...@@ -24,7 +24,7 @@ public interface IEntrustService extends IBaseService<Entrust> {
boolean deletePhysicalByIds(List<Long> ids); boolean deletePhysicalByIds(List<Long> ids);
boolean saveEntrustDTO(EntrustDTO dto, Account account); boolean saveEntrustDTO(EntrustDTO dto, boolean isSubmit, Account account);
boolean submitToCheck(Long[] ids, Account account); boolean submitToCheck(Long[] ids, Account account);
...@@ -76,9 +76,9 @@ public interface IEntrustService extends IBaseService<Entrust> { ...@@ -76,9 +76,9 @@ public interface IEntrustService extends IBaseService<Entrust> {
boolean submitToNextNode(Entrust entrust, Account account); boolean submitToNextNode(Entrust entrust, Account account);
boolean rejectToPrevNode(Long id,String reason, Account account); boolean rejectToPrevNode(Long id, String reason, Account account);
boolean rejectToPrevNode(Entrust entrust,String reason, Account account); boolean rejectToPrevNode(Entrust entrust, String reason, Account account);
boolean cloneEntrust(Long[] ids, Account account); boolean cloneEntrust(Long[] ids, Account account);
...@@ -92,12 +92,12 @@ public interface IEntrustService extends IBaseService<Entrust> { ...@@ -92,12 +92,12 @@ public interface IEntrustService extends IBaseService<Entrust> {
boolean approveSubmitApply(Long id, Account account); boolean approveSubmitApply(Long id, Account account);
boolean rejectSubmitApply(Long id,String reason, Account account); boolean rejectSubmitApply(Long id, String reason, Account account);
Boolean exportEntrust(List<Long> ids, HttpServletResponse response); Boolean exportEntrust(List<Long> ids, HttpServletResponse response);
/* 修改检测委托书的打印状态 */ /* 修改检测委托书的打印状态 */
Boolean updatePrintStatus(List<Long> ids,Long userId); Boolean updatePrintStatus(List<Long> ids, Long userId);
Boolean saveOutEntrust(EntrustDTO dto, Account account); Boolean saveOutEntrust(EntrustDTO dto, Account account);
...@@ -118,7 +118,9 @@ public interface IEntrustService extends IBaseService<Entrust> { ...@@ -118,7 +118,9 @@ public interface IEntrustService extends IBaseService<Entrust> {
boolean submitToNextFlow(Long[] ids, Account account); boolean submitToNextFlow(Long[] ids, Account account);
boolean saveOrUpdateToSubmit(EntrustDTO entrustDTO, Account account); boolean saveOrUpdateToSubmit(EntrustDTO entrustDTO, Account account);
Page<EntrustVO> getPageReportProduct(Page<EntrustVO> page, EntrustVO entrust); Page<EntrustVO> getPageReportProduct(Page<EntrustVO> page, EntrustVO entrust);
Boolean confirmRecheck(EntrustDTO entrustDTO, Account account); Boolean confirmRecheck(EntrustDTO entrustDTO, Account account);
} }
...@@ -46,7 +46,6 @@ import com.patzn.cloud.service.lims.hmhj.original.OriginalFactory; ...@@ -46,7 +46,6 @@ import com.patzn.cloud.service.lims.hmhj.original.OriginalFactory;
import com.patzn.cloud.service.lims.hmhj.original.SingleSheetMoreItemOperation; import com.patzn.cloud.service.lims.hmhj.original.SingleSheetMoreItemOperation;
import com.patzn.cloud.service.lims.hmhj.original.SingleSheetMoreTabletOperation; import com.patzn.cloud.service.lims.hmhj.original.SingleSheetMoreTabletOperation;
import com.patzn.cloud.service.lims.hmhj.service.*; import com.patzn.cloud.service.lims.hmhj.service.*;
import okhttp3.*;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFCell;
...@@ -60,7 +59,6 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -60,7 +59,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
...@@ -1133,7 +1131,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI ...@@ -1133,7 +1131,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
logger.error("======================质量判定开始========================"); logger.error("======================质量判定开始========================");
RestAssert.fail(null == ids || ids.length == 0, "样品编号不能为空"); RestAssert.fail(ArrayUtils.isEmpty(ids), "样品编号不能为空");
// == // ==
List<EntrustSampleVO> sampleList = entrustSampleService.getVOListByIds(Arrays.asList(ids)); List<EntrustSampleVO> sampleList = entrustSampleService.getVOListByIds(Arrays.asList(ids));
...@@ -1390,7 +1388,10 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI ...@@ -1390,7 +1388,10 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
break; break;
} }
} }
// 样品牌号MAP
Map<Long, String> sampleBrandMap = new HashMap<>();
if (updateSampleList.size() > 0) { if (updateSampleList.size() > 0) {
sampleBrandMap = updateSampleList.stream().collect(Collectors.toMap(EntrustSample::getId, EntrustSample::getSampleGrading));
entrustSampleService.updateBatchById(updateSampleList); entrustSampleService.updateBatchById(updateSampleList);
logger.error("====更新样品判级:]\r\n"); logger.error("====更新样品判级:]\r\n");
for (EntrustSample s : updateSampleList) { for (EntrustSample s : updateSampleList) {
...@@ -1398,15 +1399,15 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI ...@@ -1398,15 +1399,15 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
} }
} }
// 单端开线程处理 Map<Long, String> finalSampleBrandMap = sampleBrandMap;
executor1.execute(() -> { executor1.execute(() -> {
// 处理正常的报告文件 // 处理正常的报告文件
handleSampleBrand(ids, false); handleSampleBrand(ids, finalSampleBrandMap, false);
// 处理一级编码的报告文件 // 处理一级编码的报告文件
handleSampleBrand(ids, true); handleSampleBrand(ids, finalSampleBrandMap, true);
});
executor1.execute(() -> {
// 针对铝成品和原铝进行发送ERP数据处理 // 针对铝成品和原铝进行发送ERP数据处理
sendTestDataToErp(Arrays.asList(ids)); sendTestDataToErp(Arrays.asList(ids));
}); });
...@@ -2058,28 +2059,140 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI ...@@ -2058,28 +2059,140 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
return baseMapper.updateSampleRetakeInfoByEntrustId(entrustId); return baseMapper.updateSampleRetakeInfoByEntrustId(entrustId);
} }
class TestInterceptor implements Interceptor { protected void handleSampleBrand(Long[] ids, Map<Long, String> brandMap, boolean isOther) {
// 对数据处理
@Override if (ArrayUtils.isEmpty(ids) || MapUtils.isEmpty(brandMap)) {
public Response intercept(Chain chain) throws IOException { return;
Request request = chain.request(); }
String mUrl = "https://www.baidu.com/";
String url = request.url().toString(); List<ReportSampleVO> reportSampleList = entrustSampleService.getReportBrands(ids);
System.out.println("url=" + url);
Response response = null; if (CollectionUtils.isEmpty(reportSampleList)) {
if (url.equals(mUrl)) { return;
String responseString = "{\"message\":\"我是模拟的数据\"}";//模拟的错误的返回值 }
response = new Response.Builder()
.code(400) // 对列表数据的牌号重新赋值
.request(request) reportSampleList.forEach(rs -> {
.protocol(Protocol.HTTP_1_0) rs.setSampleGrading(brandMap.get(rs.getSampleId()));
.body(ResponseBody.create(MediaType.parse("application/json"), responseString.getBytes())) });
.addHeader("content-type", "application/json")
.build(); boolean finalIsOther = isOther;
List<EntrustReport> reportList = new ArrayList<>();
// objectKey data
Map<String, Long> objReportMap = reportSampleList.stream().collect(Collectors.toMap(t -> {
return finalIsOther ? t.getOtherObjectKey() : t.getObjectKey();
}, ReportSampleVO::getReportId, (v1, v2) -> v1));
for (Map.Entry<String, Long> entry : objReportMap.entrySet()) {
EntrustReport entrustReport = new EntrustReport();
String objectKey = entry.getKey();
Long reportId = entry.getValue();
entrustReport.setId(reportId);
Map<String, String> sampleMap = null;
// 根据是否一级编码确定使用得objectKey
if (finalIsOther) {
sampleMap = reportSampleList.stream().filter(t -> t.getOtherObjectKey().equals(objectKey))
.collect(Collectors.toMap(ReportSampleVO::getFirstCode, ReportSampleVO::getSampleGrading));
} else { } else {
response = chain.proceed(request); sampleMap = reportSampleList.stream().filter(t -> Objects.equals(objectKey, t.getObjectKey()))
.collect(Collectors.toMap(t -> {
if (StringUtils.isNotBlank(t.getThirdCode())) {
return t.getThirdCode();
} else if (StringUtils.isNotBlank(t.getSecondCode())) {
return t.getSecondCode();
}
return t.getFirstCode();
}, ReportSampleVO::getSampleGrading));
}
if (StringUtils.isBlank(objectKey)) {
continue;
}
InputStream io = ossClient.download(objectKey);
if (null == io) {
logger.error("文件下载失败,报告文件不存在!");
continue;
}
//结果回调
XSSFWorkbook xssfWorkbook = null;
try {
xssfWorkbook = new XSSFWorkbook(io);
} catch (Exception e) {
logger.error(e.getMessage(), e.getCause());
continue;
}
XSSFSheet sheet = xssfWorkbook.getSheetAt(0);
int rowNum = sheet.getLastRowNum();
// 默认开始行为:5,单元格序号为:-1
int startRow = 5, sampleCodePos = -1, sampleBrandPos = -1;
flag:
for (int i = 1; i < rowNum; i++) {
startRow = i;
XSSFRow xssfRow = sheet.getRow(i);
for (int j = 0; j < xssfRow.getLastCellNum(); j++) {
String title = getCellValue(xssfRow, j);
if ("试样编号".equals(title)) {
sampleCodePos = j;
}
if ("牌号".equals(title)) {
sampleBrandPos = j;
break flag;
}
}
}
// 若循环无牌号,那么跳过本次循环的原始记录
if (-1 == sampleBrandPos) {
continue;
}
for (int i = startRow + 1; i < rowNum; i++) {
XSSFRow xssfRow = sheet.getRow(i);
String sampleCode = getCellValue(xssfRow, sampleCodePos);
if (StringUtils.isBlank(sampleCode)) {
continue;
}
String sampleGrading = sampleMap.get(sampleCode);
if (StringUtils.isNotBlank(sampleGrading)) {
xssfRow.getCell(sampleBrandPos).setCellValue(sampleGrading);
}
}
FileOutputStream os = null;
File file = null;
String generated = "报告记录修改";
try {
file = File.createTempFile(generated, ".xlsx");
os = new FileOutputStream(file);
xssfWorkbook.write(os);
os.flush();
OssFileResult fileResult = ossClient.upload(file);
if (null != fileResult) {
if (finalIsOther) {
entrustReport.setOtherObjectKey(fileResult.getObjectKey());
} else {
entrustReport.setObjectKey(fileResult.getObjectKey());
}
reportList.add(entrustReport);
}
} catch (Exception e) {
logger.error("Exception 报错" + e.getMessage());
e.printStackTrace();
} finally {
IOUtils.closeQuietly(os, io);
FileUtils.deleteFiles(file);
} }
return response; }
if (CollectionUtils.isNotEmpty(reportList)) {
entrustReportService.updateBatchById(reportList);
// Long[] reportIds = reportList.stream().map(EntrustReport::getId).collect(Collectors.toList()).toArray(new Long[reportList.size()]);
// 重新生成pdf文件
// entrustReportService.changeExcelReportToPdf(reportIds);
} }
} }
} }
...@@ -243,9 +243,7 @@ public class EntrustSamplePrepareServiceImpl extends BaseServiceImpl<EntrustSamp ...@@ -243,9 +243,7 @@ public class EntrustSamplePrepareServiceImpl extends BaseServiceImpl<EntrustSamp
statusNotOkList.add(EntrustSamplePrepareStatusEnum.RECEIVE_OK); statusNotOkList.add(EntrustSamplePrepareStatusEnum.RECEIVE_OK);
List<EntrustSamplePrepare> preparesNotOkList = super.list(Condition.create().in("id", sampleIdsList).in("status", statusNotOkList)); List<EntrustSamplePrepare> preparesNotOkList = super.list(Condition.create().in("id", sampleIdsList).in("status", statusNotOkList));
List<Long> notSampleIds = preparesNotOkList.stream().map(i -> { List<Long> notSampleIds = preparesNotOkList.stream().map(EntrustSamplePrepare::getEntrustSampleId).collect(Collectors.toList());
return i.getEntrustSampleId();
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(notSampleIds)) { if (CollectionUtils.isNotEmpty(notSampleIds)) {
notOkSampleIds.addAll(notSampleIds); notOkSampleIds.addAll(notSampleIds);
......
...@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.plugins.Page; ...@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.toolkit.CollectionUtils; import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.patzn.cloud.commons.api.RestAssert; import com.patzn.cloud.commons.api.RestAssert;
import com.patzn.cloud.commons.constant.CommonConstants;
import com.patzn.cloud.commons.controller.Account; import com.patzn.cloud.commons.controller.Account;
import com.patzn.cloud.commons.controller.LoginHelper; import com.patzn.cloud.commons.controller.LoginHelper;
import com.patzn.cloud.commons.exception.PatznException; import com.patzn.cloud.commons.exception.PatznException;
...@@ -101,7 +102,7 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe ...@@ -101,7 +102,7 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
@Override @Override
public Page<EntrustSample> page(Page<EntrustSample> page, EntrustSample entrustSample) { public Page<EntrustSample> page(Page<EntrustSample> page, EntrustSample entrustSample) {
Wrapper wrapper = new EntityWrapper<>(entrustSample); Wrapper wrapper = new EntityWrapper<>(entrustSample);
wrapper.orderDesc(Collections.singleton("ctime")); wrapper.orderAsc(Lists.newArrayList("code", "order_by"));
return this.page(page, wrapper); return this.page(page, wrapper);
} }
...@@ -369,9 +370,9 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe ...@@ -369,9 +370,9 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
PMakeFeVO gtNum = new PMakeFeVO(); PMakeFeVO gtNum = new PMakeFeVO();
PMakeFeVO inNum = new PMakeFeVO(); PMakeFeVO inNum = new PMakeFeVO();
val.setCVal(vo.getCVal() + "").setMnVal(vo.getMnVal() + "").setSiVal(vo.getSiVal() + "").setPVal(vo.getPVal() + "").setSVal(vo.getSVal() + ""); val.setCVal(vo.getCVal()).setMnVal(vo.getMnVal()).setSiVal(vo.getSiVal()).setPVal(vo.getPVal()).setSVal(vo.getSVal());
per.setCVal(vo.getCPer() + "").setMnVal(vo.getMnPer() + "").setSiVal(vo.getSiPer() + "").setPVal(vo.getPPer() + "").setSVal(vo.getSPer() + ""); per.setCVal(vo.getCPer()).setMnVal(vo.getMnPer()).setSiVal(vo.getSiPer()).setPVal(vo.getPPer()).setSVal(vo.getSPer());
ltNum.setCVal(vo.getCLtNum() + "").setMnVal(vo.getMnLtNum() + "").setSiVal(vo.getSiLtNum() + "").setPVal(vo.getPLtNum() + ""); ltNum.setCVal(vo.getCLtNum() + "").setMnVal(vo.getMnLtNum() + "").setSiVal(vo.getSiLtNum() + "").setPVal(vo.getPLtNum() + "").setSVal(CommonConstants.SYMBOL_CENTER_GANG);
inNum.setCVal(vo.getCInNum() + "").setMnVal(vo.getMnInNum() + "").setSiVal(vo.getSiInNum() + "").setPVal(vo.getPInNum() + "").setSVal(vo.getSInNum() + ""); inNum.setCVal(vo.getCInNum() + "").setMnVal(vo.getMnInNum() + "").setSiVal(vo.getSiInNum() + "").setPVal(vo.getPInNum() + "").setSVal(vo.getSInNum() + "");
gtNum.setCVal(vo.getCGtNum() + "").setMnVal(vo.getMnGtNum() + "").setSiVal(vo.getSiGtNum() + "").setPVal(vo.getPGtNum() + "").setSVal(vo.getSGtNum() + ""); gtNum.setCVal(vo.getCGtNum() + "").setMnVal(vo.getMnGtNum() + "").setSiVal(vo.getSiGtNum() + "").setPVal(vo.getPGtNum() + "").setSVal(vo.getSGtNum() + "");
......
...@@ -384,7 +384,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> ...@@ -384,7 +384,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public boolean saveEntrustDTO(EntrustDTO dto, Account account) { public boolean saveEntrustDTO(EntrustDTO dto, boolean isSubmit, Account account) {
RestAssert.fail(StringUtils.isBlank(dto.getClient()), "委托单位不能为空!"); RestAssert.fail(StringUtils.isBlank(dto.getClient()), "委托单位不能为空!");
Entrust entrust = dto.convert(Entrust.class); Entrust entrust = dto.convert(Entrust.class);
List<EntrustSampleDTO> sampleDTOList = dto.getSampleDTOList(); List<EntrustSampleDTO> sampleDTOList = dto.getSampleDTOList();
...@@ -423,12 +423,15 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> ...@@ -423,12 +423,15 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
} }
EntrustSample sample = sampleDTO.convert(EntrustSample.class); EntrustSample sample = sampleDTO.convert(EntrustSample.class);
sample.setEntrustId(entrust.getId()); sample.setEntrustId(entrust.getId());
handleSampleCode(entrust, sample); if (isSubmit) {
if (StringUtils.isBlank(sample.getCode())) {
if(StringUtils.isNotBlank(sample.getCode())){ handleSampleCode(entrust, sample);
RestAssert.fail(entrustSampleService.isRepeatSampleCode(sample),String.format("样品编号【%s】重复!",sample.getCode())); }
if (StringUtils.isNotBlank(sample.getCode())) {
RestAssert.fail(entrustSampleService.isRepeatSampleCode(sample), String.format("样品编号【%s】重复!", sample.getCode()));
}
} }
judgeSampleFields(sample, true); judgeSampleFields(sample, isSubmit);
sample.setId(IdWorker.getId()); sample.setId(IdWorker.getId());
sample.setOrderBy(incNum); sample.setOrderBy(incNum);
saveSampleList.add(sample); saveSampleList.add(sample);
...@@ -475,7 +478,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> ...@@ -475,7 +478,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
public Boolean saveOutEntrust(EntrustDTO dto, Account account) { public Boolean saveOutEntrust(EntrustDTO dto, Account account) {
RestAssert.fail(CollectionUtils.isEmpty(dto.getSampleDTOList()), "外委样品不能为空"); RestAssert.fail(CollectionUtils.isEmpty(dto.getSampleDTOList()), "外委样品不能为空");
dto.getSampleDTOList().forEach(t -> t.setCategory(HmConst.EXTERNAL_INSPECTION_MATERIALS)); dto.getSampleDTOList().forEach(t -> t.setCategory(HmConst.EXTERNAL_INSPECTION_MATERIALS));
return saveEntrustDTO(dto, account); return saveEntrustDTO(dto, false, account);
} }
...@@ -638,6 +641,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> ...@@ -638,6 +641,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
sample.setOrderBy(incNum); sample.setOrderBy(incNum);
incNum += 10; incNum += 10;
if (null != sample.getId()) { if (null != sample.getId()) {
handleSampleCode(entrust, sample);
updateSampleList.add(sample); updateSampleList.add(sample);
} else { } else {
sample.setEntrustId(entrust.getId()); sample.setEntrustId(entrust.getId());
...@@ -646,8 +650,8 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> ...@@ -646,8 +650,8 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
saveSampleList.add(sample); saveSampleList.add(sample);
} }
if(StringUtils.isNotBlank(sample.getCode())){ if (StringUtils.isNotBlank(sample.getCode())) {
RestAssert.fail(entrustSampleService.isRepeatSampleCode(sample),String.format("样品编号【%s】重复!",sample.getCode())); RestAssert.fail(entrustSampleService.isRepeatSampleCode(sample), String.format("样品编号【%s】重复!", sample.getCode()));
} }
judgeSampleFields(sample, true); judgeSampleFields(sample, true);
...@@ -1585,6 +1589,18 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> ...@@ -1585,6 +1589,18 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
List<Long> specialIds = new ArrayList<>(), normalIds = new ArrayList<>(); List<Long> specialIds = new ArrayList<>(), normalIds = new ArrayList<>();
List<Long> sendUserIdList = new ArrayList<>(); List<Long> sendUserIdList = new ArrayList<>();
for (Entrust entrust : entrustList) { for (Entrust entrust : entrustList) {
List<EntrustSample> sampleList = entrustSampleService.getByEntrustId(entrust.getId());
RestAssert.fail(CollectionUtils.isEmpty(sampleList), String.format("委托编号为的【%s】样品为空!", entrust.getCode()));
// 若存在任何一个样品的编号为空,那么需要自动生成其编号
if (sampleList.stream().anyMatch(t -> StringUtils.isBlank(t.getCode()))) {
for (EntrustSample sample : sampleList) {
handleSampleCode(entrust, sample);
if (StringUtils.isNotBlank(sample.getCode())) {
RestAssert.fail(entrustSampleService.isRepeatSampleCode(sample), String.format("样品编号【%s】重复!", sample.getCode()));
}
}
entrustSampleService.updateBatchById(sampleList);
}
if ("是".equals(entrust.getSpecialAsk())) { if ("是".equals(entrust.getSpecialAsk())) {
specialIds.add(entrust.getId()); specialIds.add(entrust.getId());
} else { } else {
...@@ -1627,7 +1643,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> ...@@ -1627,7 +1643,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean saveOrUpdateToSubmit(EntrustDTO entrustDTO, Account account) { public boolean saveOrUpdateToSubmit(EntrustDTO entrustDTO, Account account) {
if (null == entrustDTO.getId()) { if (null == entrustDTO.getId()) {
saveEntrustDTO(entrustDTO, account); saveEntrustDTO(entrustDTO, true, account);
} else { } else {
editEntrust(entrustDTO, account); editEntrust(entrustDTO, account);
} }
......
...@@ -339,13 +339,13 @@ ...@@ -339,13 +339,13 @@
coalesce(sum(ix.gt235_lte240_num),0) "gt235_lte240_num", coalesce(sum(ix.gt235_lte240_num),0) "gt235_lte240_num",
coalesce(sum(ix.gt240_num),0) "gt240_num", coalesce(sum(ix.gt240_num),0) "gt240_num",
coalesce(round(sum(ix.lt216_num) / count(1),2),0.00) "lt216_per", coalesce(round(sum(ix.lt216_num) * 1.00 / count(1),2),0.00) "lt216_per",
coalesce(round(sum(ix.gt215_lte220_num) / count(1),2),0.00) "gt215_lte220_per", coalesce(round(sum(ix.gt215_lte220_num) * 1.00 / count(1),2),0.00) "gt215_lte220_per",
coalesce(round(sum(ix.gt220_lte225_num) / count(1),2),0.00) "gt220_lte225_per", coalesce(round(sum(ix.gt220_lte225_num) * 1.00 / count(1),2),0.00) "gt220_lte225_per",
coalesce(round(sum(ix.gt225_lte230_num) / count(1),2),0.00) "gt225_lte230_per", coalesce(round(sum(ix.gt225_lte230_num) * 1.00 / count(1),2),0.00) "gt225_lte230_per",
coalesce(round(sum(ix.gt230_lte235_num) / count(1),2),0.00) "gt230_lte235_per", coalesce(round(sum(ix.gt230_lte235_num) * 1.00 / count(1),2),0.00) "gt230_lte235_per",
coalesce(round(sum(ix.gt235_lte240_num) / count(1),2),0.00) "gt235_lte240_per", coalesce(round(sum(ix.gt235_lte240_num) * 1.00 / count(1),2),0.00) "gt235_lte240_per",
coalesce(round(sum(ix.gt240_num) / count(1),2),0.00) "gt240_per" coalesce(round(sum(ix.gt240_num) * 1.00 / count(1),2),0.00) "gt240_per"
FROM FROM
entrust_sample s entrust_sample s
...@@ -395,37 +395,32 @@ ...@@ -395,37 +395,32 @@
round(sum(case when ii.name = '磷生铁中P' then ROUND(CAST(ii.test_value AS NUMERIC),5) else 0.00 end) / coalesce(sum(case when ii.name = '磷生铁中P' then 1 else null end),1),2) "p_val", round(sum(case when ii.name = '磷生铁中P' then ROUND(CAST(ii.test_value AS NUMERIC),5) else 0.00 end) / coalesce(sum(case when ii.name = '磷生铁中P' then 1 else null end),1),2) "p_val",
round(sum(case when ii.name = '磷生铁中S' then ROUND(CAST(ii.test_value AS NUMERIC),5) else 0.00 end) / coalesce(sum(case when ii.name = '磷生铁中S' then 1 else null end),1),2) "s_val" round(sum(case when ii.name = '磷生铁中S' then ROUND(CAST(ii.test_value AS NUMERIC),5) else 0.00 end) / coalesce(sum(case when ii.name = '磷生铁中S' then 1 else null end),1),2) "s_val"
FROM FROM
entrust_sample_item i, entrust_sample_item i
entrust_sample_item_index ii JOIN entrust_sample_item_index ii ON ii.entrust_sample_item_id = i.id and ii.deleted = 0
WHERE JOIN entrust_sample s on s.id = i.entrust_sample_id and s.deleted = 0
i.ID = ii.entrust_sample_item_id WHERE i.deleted = 0
AND i.deleted = 0 AND s.name like '%磷生铁%'
AND ii.deleted = 0
AND i.period is not null AND i.period is not null
AND ii.test_value is not null and is_numeric(ii.test_value) AND ii.test_value is not null and is_numeric(ii.test_value)
AND EXISTS ( <if test="null != vo.timeS and null != vo.timeE">
select 1 from entrust_sample s where s.id = i.entrust_sample_id and s.deleted = 0 and date(i.test_time) &gt;= date(#{vo.timeS}) AND date(i.test_time) &lt;= date(#{vo.timeE})
and s.name like '%磷生铁%' </if>
)
<if test="null != vo.timeS and null != vo.timeE">
and to_char(i.test_time, 'YYYY-MM-dd HH24:MI:SS') BETWEEN #{vo.timeS} AND #{vo.timeE}
</if>
GROUP BY i.company_id,i.period,i.entrust_sample_id GROUP BY i.company_id,i.period,i.entrust_sample_id
) PI ) PI
) )
select select
pi.period, pi.period,
round(sum(pi.c_val) / count(1),2) "c_val", round(sum(pi.c_val) * 1.00 / count(1),2) "c_val",
round(sum(pi.si_val) / count(1),2) "si_val", round(sum(pi.si_val) * 1.00 / count(1),2) "si_val",
round(sum(pi.mn_val) / count(1),2) "mn_val", round(sum(pi.mn_val) * 1.00 / count(1),2) "mn_val",
round(sum(pi.p_val) / count(1),2) "p_val", round(sum(pi.p_val) * 1.00 / count(1),2) "p_val",
round(sum(pi.s_val) / count(1),2) "s_val", round(sum(pi.s_val) * 1.00 / count(1),2) "s_val",
round(sum(pi.c_in_num) / count(1),2) "c_per", round(sum(pi.c_in_num) * 1.00 / count(1),2) "c_per",
round(sum(pi.si_in_num) / count(1),2) "si_per", round(sum(pi.si_in_num) * 1.00 / count(1),2) "si_per",
round(sum(pi.mn_in_num) / count(1),2) "mn_per", round(sum(pi.mn_in_num) * 1.00 / count(1),2) "mn_per",
round(sum(pi.p_in_num) / count(1),2) "p_per", round(sum(pi.p_in_num) * 1.00 / count(1),2) "p_per",
round(sum(pi.s_in_num) / count(1),2) "s_per", round(sum(pi.s_in_num) * 1.00 / count(1),2) "s_per",
sum(pi.c_lt_num) "c_lt_num", sum(pi.c_lt_num) "c_lt_num",
sum(pi.si_lt_num) "si_lt_num", sum(pi.si_lt_num) "si_lt_num",
......
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