Commit b0cab846 by lijingjing

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

原始记录生成优化;
样品编号在提交时生成;
parent eb5f1604
......@@ -10,6 +10,14 @@ public class HttpConst {
public static final String ACCEPT_ENCODING = "identity";
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=";
}
......@@ -280,7 +280,7 @@ public class EntrustController extends ServiceController {
public RestResult<Boolean> addEntrust(@RequestBody EntrustDTO dto) {
dto.setStatus(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 {
@ApiOperation("确认生成复检委托")
@RequestMapping(value = "/confirm_recheck", method = {RequestMethod.POST, RequestMethod.GET})
public RestResult<Boolean> confirmRecheck(@RequestBody EntrustDTO entrustDTO) {
return success(entrustService.confirmRecheck(entrustDTO,getAccount()));
return success(entrustService.confirmRecheck(entrustDTO, getAccount()));
}
}
package com.patzn.cloud.service.lims.hmhj.original;
import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.patzn.cloud.service.hmhj.entity.Entrust;
import com.patzn.cloud.service.hmhj.entity.OriginalTemplate;
......@@ -16,10 +17,11 @@ import java.util.List;
public class MoreItemOperation implements Operation {
private OriginalTemplate template;
private List<EntrustSampleVO> voList;
private Entrust entrust ;
private List<EntrustSampleVO> voList;
private Entrust entrust;
private List<OriginalTemplateConfig> configList;
private XSSFWorkbook xssfWorkbook;
public MoreItemOperation(OriginalTemplate template, List<EntrustSampleVO> voList, Entrust entrust, List<OriginalTemplateConfig> configList, XSSFWorkbook xssfWorkbook) {
this.template = template;
this.voList = voList;
......@@ -30,15 +32,15 @@ public class MoreItemOperation implements Operation {
@Override
public void doMakeOriginal() {
OriginalUtil.doReplace(xssfWorkbook,entrust);
OriginalUtil.doReplace(xssfWorkbook, entrust);
XSSFSheet sheetOne = xssfWorkbook.getSheetAt(0);
String sheetName = sheetOne.getSheetName();
System.out.println(sheetName);
sheetOne.setForceFormulaRecalculation(true);
Integer beginRow = template.getSampleBeginRow();
Integer beginRow = template.getSampleBeginRow();
int sampleMergerNum = template.getSampleMergerNum();
int templateSampleNum = template.getTemplateSampleNum();
for (EntrustSampleVO vo:voList) {
for (EntrustSampleVO vo : voList) {
XSSFRow xssfRow = sheetOne.getRow(beginRow);
XSSFRow xssfRowTwo = null;
XSSFRow xssfRowThree = null;
......@@ -49,8 +51,8 @@ public class MoreItemOperation implements Operation {
xssfRowTwo = sheetOne.getRow(beginRow + 1);
xssfRowThree = sheetOne.getRow(beginRow + 2);
}
for (OriginalTemplateConfig config:configList) {
XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
for (OriginalTemplateConfig config : configList) {
XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
XSSFCell cell2 = null;
XSSFCell cell3 = null;
if (null != xssfRowTwo) {
......@@ -59,59 +61,60 @@ public class MoreItemOperation implements Operation {
if (null != xssfRowThree) {
cell3 = xssfRowTwo.getCell(config.getColumnPlace());
}
if ("sn".equals(config.getDataAttribute())){
if ("sn".equals(config.getDataAttribute())) {
continue;
}
if (StringUtils.isBlank(config.getDataAttribute())){
if (StringUtils.isBlank(config.getDataAttribute())) {
continue;
}
if (config.getDataAttribute().startsWith("clc.")) {
String mapKey = config.getDataAttribute().substring(4);
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) {
cell2.setCellValue(vo.getCollectionDataList().get(1).get(mapKey));
cell2.setCellValue(getValueFillZero(vo.getCollectionDataList().get(1).get(mapKey)));
}
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;
}
String value= StringHandleUtils.getFieldValue(config.getDataAttribute(),vo);
cell.setCellValue(value);
String value = StringHandleUtils.getFieldValue(config.getDataAttribute(), vo);
cell.setCellValue(getValueFillZero(value));
}
beginRow+=sampleMergerNum;
beginRow += sampleMergerNum;
}
Integer sampleBgMum = template.getSampleBeginRow();
for (OriginalTemplateConfig config:configList) {
if (null == config.getMergeRowNum()){
config.setMergeRowNum(1);
}
for (OriginalTemplateConfig config : configList) {
if (null == config.getMergeRowNum()) {
config.setMergeRowNum(1);
}
String formula = config.getFormula();
if (StringUtils.isBlank(formula)){
continue;
}
String formula = config.getFormula();
if (StringUtils.isBlank(formula)) {
continue;
}
Integer columnPlace = config.getColumnPlace();
if (null == config.getColumnPlace()){
continue;
}
if (null == config.getMergeRowNum()){
continue;
}
Integer columnPlace = config.getColumnPlace();
if (null == config.getColumnPlace()) {
continue;
}
if (null == config.getMergeRowNum()) {
continue;
}
Integer mergeRowNum = config.getMergeRowNum();
int formulaNum = template.getSampleBeginRow()+sampleMergerNum*templateSampleNum-1 ;
Integer mergeRowNum = config.getMergeRowNum();
int formulaNum = template.getSampleBeginRow() + sampleMergerNum * templateSampleNum - 1;
for (int i =sampleBgMum ; i <= formulaNum; i+=mergeRowNum) {
XSSFRow row = sheetOne.getRow(i);
XSSFCell cell = row.getCell(columnPlace);
cell.setCellFormula(OriginalUtil.initFormula(formula,i));
}
for (int i = sampleBgMum; i <= formulaNum; i += mergeRowNum) {
XSSFRow row = sheetOne.getRow(i);
XSSFCell cell = row.getCell(columnPlace);
cell.setCellFormula(OriginalUtil.initFormula(formula, i));
}
}
}
}
......@@ -17,10 +17,11 @@ import java.util.Map;
public class MoreSheetMoreOperation implements Operation {
private OriginalTemplate template;
private List<EntrustSampleItemVO> voList;
private Entrust entrust ;
private List<EntrustSampleItemVO> voList;
private Entrust entrust;
private List<OriginalTemplateConfig> configList;
private XSSFWorkbook xssfWorkbook;
public MoreSheetMoreOperation(OriginalTemplate template, List<EntrustSampleItemVO> voList, Entrust entrust, List<OriginalTemplateConfig> configList, XSSFWorkbook xssfWorkbook) {
this.template = template;
this.voList = voList;
......@@ -31,10 +32,10 @@ public class MoreSheetMoreOperation implements Operation {
@Override
public void doMakeOriginal() {
Integer templateSampleNum = template.getTemplateSampleNum();
Integer templateSampleNum = template.getTemplateSampleNum();
Map<String, String> mapReplace = new HashMap<>();
mapReplace.put("#{client}",entrust.getClient());
List<List<EntrustSampleItemVO>> relList= ListUtils.partition(voList,templateSampleNum);
mapReplace.put("#{client}", entrust.getClient());
List<List<EntrustSampleItemVO>> relList = ListUtils.partition(voList, templateSampleNum);
int templateSheetMum = xssfWorkbook.getNumberOfSheets();
XSSFSheet sheetMy = xssfWorkbook.getSheetAt(0);
......@@ -43,46 +44,46 @@ public class MoreSheetMoreOperation implements Operation {
List<EntrustSampleItemVO> firstList = null;
for (List<EntrustSampleItemVO> expVOList:relList) {
XSSFSheet sheet=null;
if (first){
sheet = sheetMy;
for (List<EntrustSampleItemVO> expVOList : relList) {
XSSFSheet sheet = null;
if (first) {
sheet = sheetMy;
firstList = expVOList;
first = false;
continue;
}else{
sheet = xssfWorkbook.cloneSheet(0,sheetMy.getSheetName()+(templateSheetMum));
} else {
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++) {
mapReplaceMy.put("#{sampleCode"+i+"}","");
mapReplaceMy.put("#{sampleCode" + i + "}", "");
}
mapReplaceMy.put("#{client}",entrust.getClient());
mapReplaceMy.put("#{client}", entrust.getClient());
int entitySize = expVOList.size();
for (int j = 0; j < entitySize; j++) {
EntrustSampleItemVO vo = expVOList.get(j);
mapReplaceMy.put("#{sampleCode"+j+"}", StringHandleUtils.getString(vo.getSampleCode()));
EntrustSampleItemVO vo = expVOList.get(j);
mapReplaceMy.put("#{sampleCode" + j + "}", StringHandleUtils.getString(vo.getSampleCode()));
}
HSSFWorkbookUtil.replaceModel(mapReplaceMy,xssfWorkbook,sheet);
HSSFWorkbookUtil.replaceModel(mapReplaceMy, xssfWorkbook, sheet);
templateSheetMum++;
}
int firstSize = firstList.size();
Map<String,String> mapReplaceMy = new HashMap<>();
Map<String, String> mapReplaceMy = new HashMap<>();
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++) {
EntrustSampleItemVO vo = firstList.get(j);
mapReplaceMy.put("#{sampleCode"+j+"}",StringHandleUtils.getString(vo.getSampleCode()));
EntrustSampleItemVO vo = firstList.get(j);
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;
public class MoreSheetOneOperation implements Operation {
private OriginalTemplate template;
private List<EntrustSampleItemVO> voList;
private Entrust entrust ;
private List<EntrustSampleItemVO> voList;
private Entrust entrust;
private List<OriginalTemplateConfig> configList;
private XSSFWorkbook xssfWorkbook;
public MoreSheetOneOperation(OriginalTemplate template, List<EntrustSampleItemVO> voList, Entrust entrust, List<OriginalTemplateConfig> configList, XSSFWorkbook xssfWorkbook) {
this.template = template;
this.voList = voList;
......@@ -30,24 +31,22 @@ public class MoreSheetOneOperation implements Operation {
@Override
public void doMakeOriginal() {
Map<String, String> mapReplace = new HashMap<>();
mapReplace.put("#{client}",entrust.getClient());
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
mapReplace.put("#{client}", entrust.getClient());
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
xssfSheet.setForceFormulaRecalculation(true);
int index = 0;
EntrustSampleItemVO firstVO = null;
int sheetNum = xssfWorkbook.getNumberOfSheets();
EntrustSampleItemVO firstVO = new EntrustSampleItemVO();
int sheetNum = xssfWorkbook.getNumberOfSheets();
for (EntrustSampleItemVO vo:voList) {
if (index==0){
for (EntrustSampleItemVO vo : voList) {
if (index == 0) {
index++;
firstVO = vo;
continue;
}
XSSFSheet sheet = xssfWorkbook.cloneSheet(0);
xssfWorkbook.cloneSheet(0);
index++;
}
......@@ -55,19 +54,19 @@ public class MoreSheetOneOperation implements Operation {
int nextSample = sheetNum;
boolean start = true;
for (EntrustSampleItemVO vo:voList) {
if (start){
for (EntrustSampleItemVO vo : voList) {
if (start) {
start = false;
continue;
}
XSSFSheet sheet = xssfWorkbook.getSheetAt(nextSample);
xssfWorkbook.setSheetName(nextSample,vo.getSampleCode());
mapReplace.put("#{sampleCode}",vo.getSampleCode());
HSSFWorkbookUtil.replaceModel(mapReplace,xssfWorkbook,sheet);
XSSFSheet sheet = xssfWorkbook.getSheetAt(nextSample);
xssfWorkbook.setSheetName(nextSample, vo.getSampleCode());
mapReplace.put("#{sampleCode}", vo.getSampleCode());
HSSFWorkbookUtil.replaceModel(mapReplace, xssfWorkbook, sheet);
nextSample++;
}
mapReplace.put("#{sampleCode}",firstVO.getSampleCode());
HSSFWorkbookUtil.replaceModel(mapReplace,xssfWorkbook,xssfSheet);
mapReplace.put("#{sampleCode}", firstVO.getSampleCode());
HSSFWorkbookUtil.replaceModel(mapReplace, xssfWorkbook, xssfSheet);
}
}
......@@ -6,11 +6,25 @@ import org.apache.poi.ss.usermodel.Cell;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Objects;
public interface Operation {
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 {
return formula;
}
public final static void doReplace(XSSFWorkbook xssfWorkbook, Entrust entrust) {
Map<String, String> mapReplace = new HashMap<>();
mapReplace.put("#{client}", entrust.getClient());
......
......@@ -180,22 +180,22 @@ public class SingleSheetMoreItemOperation implements Operation {
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) {
cell2.setCellValue(vo.getCollectionDataList().get(1).get(mapKey));
cell2.setCellValue(getValueFillZero(vo.getCollectionDataList().get(1).get(mapKey)));
}
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) {
cell4.setCellValue(vo.getCollectionDataList().get(3).get(mapKey));
cell4.setCellValue(getValueFillZero(vo.getCollectionDataList().get(3).get(mapKey)));
}
}
continue;
}
String value = StringHandleUtils.getFieldIfNummReturnBlankValueByFieldName(config.getDataAttribute(), vo);
cell.setCellValue(value);
cell.setCellValue(getValueFillZero(value));
}
beginRow += sampleMergerNum;
sn++;
......
......@@ -138,21 +138,21 @@ public class SingleSheetMoreOperation implements Operation {
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) {
cell2.setCellValue(vo.getCollectionDataList().get(1).get(mapKey));
cell2.setCellValue(getValueFillZero(vo.getCollectionDataList().get(1).get(mapKey)));
}
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) {
cell4.setCellValue(vo.getCollectionDataList().get(3).get(mapKey));
cell4.setCellValue(getValueFillZero(vo.getCollectionDataList().get(3).get(mapKey)));
}
}
continue;
} 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 {
}
if (null != config.getDataAttribute() && config.getDataAttribute().startsWith(collectionDataPrefix)) {
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++;
}
......@@ -248,7 +248,8 @@ public class SingleSheetMoreOperation implements Operation {
}
if (null != config.getDataAttribute() && config.getDataAttribute().startsWith(collectionDataPrefix)) {
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 {
rounding(cellS, rowDataS, config.getRoundNum());
} else {
// 不需要修约
cellS.setCellValue(rowDataS);
cellS.setCellValue(getValueFillZero(rowDataS));
}
}
......@@ -139,7 +139,7 @@ public class SingleSheetMoreTabletOperation implements Operation {
rounding(cellE, rowDataE, config.getRoundNum());
} else {
// 不需要修约
cellE.setCellValue(rowDataE);
cellE.setCellValue(getValueFillZero(rowDataE));
}
}
}
......@@ -151,7 +151,8 @@ public class SingleSheetMoreTabletOperation implements Operation {
if (CollectionUtils.isEmpty(dataMapList)) {
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 {
continue;
}
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 {
}
if (null != config.getDataAttribute() && config.getDataAttribute().startsWith(collectionDataPrefix)) {
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 {
}
if (null != config.getDataAttribute() && config.getDataAttribute().startsWith(collectionDataPrefix)) {
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;
import java.util.List;
/**
* 服务类
* 服务类
*
* @author wwd
* @since 2021-02-01
......@@ -24,7 +24,7 @@ public interface IEntrustService extends IBaseService<Entrust> {
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);
......@@ -76,9 +76,9 @@ public interface IEntrustService extends IBaseService<Entrust> {
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);
......@@ -92,12 +92,12 @@ public interface IEntrustService extends IBaseService<Entrust> {
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 updatePrintStatus(List<Long> ids,Long userId);
Boolean updatePrintStatus(List<Long> ids, Long userId);
Boolean saveOutEntrust(EntrustDTO dto, Account account);
......@@ -118,7 +118,9 @@ public interface IEntrustService extends IBaseService<Entrust> {
boolean submitToNextFlow(Long[] ids, Account account);
boolean saveOrUpdateToSubmit(EntrustDTO entrustDTO, Account account);
Page<EntrustVO> getPageReportProduct(Page<EntrustVO> page, EntrustVO entrust);
Boolean confirmRecheck(EntrustDTO entrustDTO, Account account);
}
......@@ -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.SingleSheetMoreTabletOperation;
import com.patzn.cloud.service.lims.hmhj.service.*;
import okhttp3.*;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFCell;
......@@ -60,7 +59,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.*;
......@@ -1133,7 +1131,7 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
logger.error("======================质量判定开始========================");
RestAssert.fail(null == ids || ids.length == 0, "样品编号不能为空");
RestAssert.fail(ArrayUtils.isEmpty(ids), "样品编号不能为空");
// ==
List<EntrustSampleVO> sampleList = entrustSampleService.getVOListByIds(Arrays.asList(ids));
......@@ -1390,7 +1388,10 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
break;
}
}
// 样品牌号MAP
Map<Long, String> sampleBrandMap = new HashMap<>();
if (updateSampleList.size() > 0) {
sampleBrandMap = updateSampleList.stream().collect(Collectors.toMap(EntrustSample::getId, EntrustSample::getSampleGrading));
entrustSampleService.updateBatchById(updateSampleList);
logger.error("====更新样品判级:]\r\n");
for (EntrustSample s : updateSampleList) {
......@@ -1398,15 +1399,15 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
}
}
// 单端开线程处理
Map<Long, String> finalSampleBrandMap = sampleBrandMap;
executor1.execute(() -> {
// 处理正常的报告文件
handleSampleBrand(ids, false);
handleSampleBrand(ids, finalSampleBrandMap, false);
// 处理一级编码的报告文件
handleSampleBrand(ids, true);
});
handleSampleBrand(ids, finalSampleBrandMap, true);
executor1.execute(() -> {
// 针对铝成品和原铝进行发送ERP数据处理
sendTestDataToErp(Arrays.asList(ids));
});
......@@ -2058,28 +2059,140 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
return baseMapper.updateSampleRetakeInfoByEntrustId(entrustId);
}
class TestInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
String mUrl = "https://www.baidu.com/";
String url = request.url().toString();
System.out.println("url=" + url);
Response response = null;
if (url.equals(mUrl)) {
String responseString = "{\"message\":\"我是模拟的数据\"}";//模拟的错误的返回值
response = new Response.Builder()
.code(400)
.request(request)
.protocol(Protocol.HTTP_1_0)
.body(ResponseBody.create(MediaType.parse("application/json"), responseString.getBytes()))
.addHeader("content-type", "application/json")
.build();
protected void handleSampleBrand(Long[] ids, Map<Long, String> brandMap, boolean isOther) {
// 对数据处理
if (ArrayUtils.isEmpty(ids) || MapUtils.isEmpty(brandMap)) {
return;
}
List<ReportSampleVO> reportSampleList = entrustSampleService.getReportBrands(ids);
if (CollectionUtils.isEmpty(reportSampleList)) {
return;
}
// 对列表数据的牌号重新赋值
reportSampleList.forEach(rs -> {
rs.setSampleGrading(brandMap.get(rs.getSampleId()));
});
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 {
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
statusNotOkList.add(EntrustSamplePrepareStatusEnum.RECEIVE_OK);
List<EntrustSamplePrepare> preparesNotOkList = super.list(Condition.create().in("id", sampleIdsList).in("status", statusNotOkList));
List<Long> notSampleIds = preparesNotOkList.stream().map(i -> {
return i.getEntrustSampleId();
}).collect(Collectors.toList());
List<Long> notSampleIds = preparesNotOkList.stream().map(EntrustSamplePrepare::getEntrustSampleId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(notSampleIds)) {
notOkSampleIds.addAll(notSampleIds);
......
......@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.google.common.collect.Lists;
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.LoginHelper;
import com.patzn.cloud.commons.exception.PatznException;
......@@ -101,7 +102,7 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
@Override
public Page<EntrustSample> page(Page<EntrustSample> page, EntrustSample entrustSample) {
Wrapper wrapper = new EntityWrapper<>(entrustSample);
wrapper.orderDesc(Collections.singleton("ctime"));
wrapper.orderAsc(Lists.newArrayList("code", "order_by"));
return this.page(page, wrapper);
}
......@@ -369,9 +370,9 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
PMakeFeVO gtNum = new PMakeFeVO();
PMakeFeVO inNum = new PMakeFeVO();
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() + "");
ltNum.setCVal(vo.getCLtNum() + "").setMnVal(vo.getMnLtNum() + "").setSiVal(vo.getSiLtNum() + "").setPVal(vo.getPLtNum() + "");
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());
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() + "");
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>
@Transactional(rollbackFor = Exception.class)
@Override
public boolean saveEntrustDTO(EntrustDTO dto, Account account) {
public boolean saveEntrustDTO(EntrustDTO dto, boolean isSubmit, Account account) {
RestAssert.fail(StringUtils.isBlank(dto.getClient()), "委托单位不能为空!");
Entrust entrust = dto.convert(Entrust.class);
List<EntrustSampleDTO> sampleDTOList = dto.getSampleDTOList();
......@@ -423,12 +423,15 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
}
EntrustSample sample = sampleDTO.convert(EntrustSample.class);
sample.setEntrustId(entrust.getId());
handleSampleCode(entrust, sample);
if(StringUtils.isNotBlank(sample.getCode())){
RestAssert.fail(entrustSampleService.isRepeatSampleCode(sample),String.format("样品编号【%s】重复!",sample.getCode()));
if (isSubmit) {
if (StringUtils.isBlank(sample.getCode())) {
handleSampleCode(entrust, sample);
}
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.setOrderBy(incNum);
saveSampleList.add(sample);
......@@ -475,7 +478,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
public Boolean saveOutEntrust(EntrustDTO dto, Account account) {
RestAssert.fail(CollectionUtils.isEmpty(dto.getSampleDTOList()), "外委样品不能为空");
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>
sample.setOrderBy(incNum);
incNum += 10;
if (null != sample.getId()) {
handleSampleCode(entrust, sample);
updateSampleList.add(sample);
} else {
sample.setEntrustId(entrust.getId());
......@@ -646,8 +650,8 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
saveSampleList.add(sample);
}
if(StringUtils.isNotBlank(sample.getCode())){
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);
......@@ -1585,6 +1589,18 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
List<Long> specialIds = new ArrayList<>(), normalIds = new ArrayList<>();
List<Long> sendUserIdList = new ArrayList<>();
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())) {
specialIds.add(entrust.getId());
} else {
......@@ -1627,7 +1643,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
@Transactional(rollbackFor = Exception.class)
public boolean saveOrUpdateToSubmit(EntrustDTO entrustDTO, Account account) {
if (null == entrustDTO.getId()) {
saveEntrustDTO(entrustDTO, account);
saveEntrustDTO(entrustDTO, true, account);
} else {
editEntrust(entrustDTO, account);
}
......
......@@ -339,13 +339,13 @@
coalesce(sum(ix.gt235_lte240_num),0) "gt235_lte240_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.gt215_lte220_num) / 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.gt225_lte230_num) / 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.gt235_lte240_num) / 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.lt216_num) * 1.00 / count(1),2),0.00) "lt216_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) * 1.00 / count(1),2),0.00) "gt220_lte225_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) * 1.00 / count(1),2),0.00) "gt230_lte235_per",
coalesce(round(sum(ix.gt235_lte240_num) * 1.00 / count(1),2),0.00) "gt235_lte240_per",
coalesce(round(sum(ix.gt240_num) * 1.00 / count(1),2),0.00) "gt240_per"
FROM
entrust_sample s
......@@ -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 = '磷生铁中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
entrust_sample_item i,
entrust_sample_item_index ii
WHERE
i.ID = ii.entrust_sample_item_id
AND i.deleted = 0
AND ii.deleted = 0
entrust_sample_item i
JOIN entrust_sample_item_index ii ON ii.entrust_sample_item_id = i.id and ii.deleted = 0
JOIN entrust_sample s on s.id = i.entrust_sample_id and s.deleted = 0
WHERE i.deleted = 0
AND s.name like '%磷生铁%'
AND i.period is not null
AND ii.test_value is not null and is_numeric(ii.test_value)
AND EXISTS (
select 1 from entrust_sample s where s.id = i.entrust_sample_id and s.deleted = 0
and s.name like '%磷生铁%'
)
<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>
<if test="null != vo.timeS and null != vo.timeE">
and date(i.test_time) &gt;= date(#{vo.timeS}) AND date(i.test_time) &lt;= date(#{vo.timeE})
</if>
GROUP BY i.company_id,i.period,i.entrust_sample_id
) PI
)
select
pi.period,
round(sum(pi.c_val) / count(1),2) "c_val",
round(sum(pi.si_val) / count(1),2) "si_val",
round(sum(pi.mn_val) / count(1),2) "mn_val",
round(sum(pi.p_val) / count(1),2) "p_val",
round(sum(pi.s_val) / count(1),2) "s_val",
round(sum(pi.c_in_num) / count(1),2) "c_per",
round(sum(pi.si_in_num) / count(1),2) "si_per",
round(sum(pi.mn_in_num) / count(1),2) "mn_per",
round(sum(pi.p_in_num) / count(1),2) "p_per",
round(sum(pi.s_in_num) / count(1),2) "s_per",
round(sum(pi.c_val) * 1.00 / count(1),2) "c_val",
round(sum(pi.si_val) * 1.00 / count(1),2) "si_val",
round(sum(pi.mn_val) * 1.00 / count(1),2) "mn_val",
round(sum(pi.p_val) * 1.00 / count(1),2) "p_val",
round(sum(pi.s_val) * 1.00 / count(1),2) "s_val",
round(sum(pi.c_in_num) * 1.00 / count(1),2) "c_per",
round(sum(pi.si_in_num) * 1.00 / count(1),2) "si_per",
round(sum(pi.mn_in_num) * 1.00 / count(1),2) "mn_per",
round(sum(pi.p_in_num) * 1.00 / count(1),2) "p_per",
round(sum(pi.s_in_num) * 1.00 / count(1),2) "s_per",
sum(pi.c_lt_num) "c_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