add:新增配粉开单检测结果导入功能
This commit is contained in:
Binary file not shown.
@@ -6,6 +6,8 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
@@ -40,6 +42,7 @@ import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@@ -96,6 +99,18 @@ public class FormulaController {
|
||||
return new ResponseEntity<>(formulaService.getView(whereJson),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("导入配粉检测结果")
|
||||
@ApiOperation("导入配粉检测结果")
|
||||
@PostMapping("/importDetection")
|
||||
public ResponseEntity<Object> importDetection(@RequestParam MultipartFile file) {
|
||||
if (file ==null || file.getSize()<100 ){
|
||||
throw new BadRequestException("文件内容不允许为空");
|
||||
}
|
||||
formulaService.importDetection(file);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@Log("打印工艺指令卡")
|
||||
@ApiOperation("打印工艺指令卡")
|
||||
@PostMapping("/pointCard")
|
||||
|
||||
@@ -4,6 +4,7 @@ package org.nl.wms.pf.service;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
@@ -72,4 +73,10 @@ public interface FormulaService {
|
||||
* @param whereJson /
|
||||
*/
|
||||
void printCard(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 导入配方检测结果:球墨时间,hcp值
|
||||
* @param file
|
||||
*/
|
||||
void importDetection(MultipartFile file);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
@@ -24,6 +26,7 @@ import org.nl.exception.BadRequestException;
|
||||
import org.nl.modules.security.service.dto.JwtUserDto;
|
||||
import org.nl.modules.system.service.impl.ParamServiceImpl;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.system.util.MapOf;
|
||||
import org.nl.utils.SecurityUtils;
|
||||
import org.nl.utils.SpringContextHolder;
|
||||
import org.nl.wms.basedata.master.constant.MaterOptTypeEnum;
|
||||
@@ -38,6 +41,7 @@ import org.nl.wql.util.WqlUtil;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -53,7 +57,9 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -1134,4 +1140,40 @@ public class FormulaServiceImpl implements FormulaService {
|
||||
|
||||
return wcchange;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入格式:formula_code,ball_time,hcp_stand,hcp_detec
|
||||
* @param file
|
||||
*/
|
||||
@Override
|
||||
public void importDetection(MultipartFile file) {
|
||||
WQLObject table = WQLObject.getWQLObject("PDM_BI_Formula");
|
||||
try {
|
||||
ExcelReader excelReader = ExcelUtil.getReader(file.getInputStream(), 0);
|
||||
// 从第1行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
|
||||
List<List<Object>> read = excelReader.read(0, excelReader.getRowCount());
|
||||
if (read.size()<1){
|
||||
return;
|
||||
}
|
||||
Map<String, List<Object>> collect = read.stream().collect(HashMap::new, (k, v) -> k.put(String.valueOf(v.get(0)), v), HashMap::putAll);
|
||||
Stream<String> stream = read.stream().map(row -> String.valueOf(row.get(0)));
|
||||
JSONArray formulaList = table.query("formula_code in ('" + stream.collect(Collectors.joining("','")) + "') and status = '20'").getResultJSONArray(0);
|
||||
for (Object item : formulaList) {
|
||||
JSONObject formula = (JSONObject) item;
|
||||
String formula_code = formula.getString("formula_code");
|
||||
List<Object> detectionValue = collect.get(formula_code);
|
||||
if (detectionValue!=null && detectionValue.size() == 4){
|
||||
table.update(MapOf.of(
|
||||
"ball_time",detectionValue.get(1),
|
||||
"hcp_standard",detectionValue.get(2),
|
||||
"hcp_detection",detectionValue.get(3)),"formula_code = '"+formula_code+"'");
|
||||
}
|
||||
|
||||
}
|
||||
}catch (Exception ex){
|
||||
log.error("导入配方异常"+ex.getMessage());
|
||||
throw new BadRequestException(ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user