add:配方同步hcp球磨时间
This commit is contained in:
@@ -2,33 +2,19 @@
|
||||
package org.nl.wms.pf.rest;
|
||||
|
||||
|
||||
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;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import oracle.ucp.proxy.annotation.Post;
|
||||
import org.nl.annotation.Log;
|
||||
import org.nl.domain.LocalStorage;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.service.LocalStorageService;
|
||||
import org.nl.utils.SecurityUtils;
|
||||
import org.nl.wms.basedata.master.constant.MaterOptTypeEnum;
|
||||
import org.nl.wms.basedata.master.service.ClassstandardService;
|
||||
import org.nl.wms.basedata.master.service.MaterialbaseService;
|
||||
import org.nl.wms.pf.service.FormulaService;
|
||||
import org.nl.wms.pf.service.InitformulaService;
|
||||
import org.nl.wms.test.service.dto.DataDto;
|
||||
import org.nl.wql.core.bean.WQLObject;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -36,13 +22,8 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
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
|
||||
@@ -102,11 +83,8 @@ public class FormulaController {
|
||||
@Log("导入配粉检测结果")
|
||||
@ApiOperation("导入配粉检测结果")
|
||||
@PostMapping("/importDetection")
|
||||
public ResponseEntity<Object> importDetection(@RequestParam MultipartFile file) {
|
||||
if (file ==null || file.getSize()<100 ){
|
||||
throw new BadRequestException("文件内容不允许为空");
|
||||
}
|
||||
formulaService.importDetection(file);
|
||||
public ResponseEntity<Object> importDetection(@RequestBody JSONArray whereJson) {
|
||||
formulaService.importDetection(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ 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;
|
||||
@@ -76,7 +75,7 @@ public interface FormulaService {
|
||||
|
||||
/**
|
||||
* 导入配方检测结果:球墨时间,hcp值
|
||||
* @param file
|
||||
* @param whereJson
|
||||
*/
|
||||
void importDetection(MultipartFile file);
|
||||
void importDetection(JSONArray whereJson);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
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;
|
||||
@@ -33,7 +32,6 @@ import org.nl.wms.basedata.master.constant.MaterOptTypeEnum;
|
||||
import org.nl.wms.basedata.master.service.ClassstandardService;
|
||||
import org.nl.wms.basedata.master.service.MaterialbaseService;
|
||||
import org.nl.wms.pf.service.FormulaService;
|
||||
import org.nl.wms.pf.service.InitformulaService;
|
||||
import org.nl.wms.test.service.dto.DataDto;
|
||||
import org.nl.wql.WQL;
|
||||
import org.nl.wql.core.bean.WQLObject;
|
||||
@@ -41,7 +39,6 @@ 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;
|
||||
@@ -57,7 +54,6 @@ 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;
|
||||
|
||||
@@ -1143,37 +1139,29 @@ public class FormulaServiceImpl implements FormulaService {
|
||||
|
||||
/**
|
||||
* 导入格式: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;
|
||||
public void importDetection(JSONArray formuals) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (formuals !=null && formuals.size()>0){
|
||||
for (Object formual : formuals) {
|
||||
Map item = (Map) formual;
|
||||
list.add(String.valueOf(item.get("formula_id")));
|
||||
}
|
||||
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+"'");
|
||||
JSONArray ja = WQL.getWO("QL_ERP")
|
||||
.setDbname("dataSource1")
|
||||
.addParam("flag", "8")
|
||||
.addParam("formula_id", "('"+list.stream().collect(Collectors.joining("','"))+"')")
|
||||
.process().getResultJSONArray(0);
|
||||
if (ja.size()>0){
|
||||
for (Object o : ja) {
|
||||
JSONObject item = (JSONObject) o;
|
||||
WQLObject.getWQLObject("PDM_BI_Formula").update(MapOf.of(
|
||||
"ball_time",item.get("qmsj"),
|
||||
"hcp_standard",item.get("hcp_bz_Avg"),
|
||||
"hcp_detection",item.get("hcp_sc_avg")),"formula_id = '"+item.get("FORMULA_ID")+"'");
|
||||
}
|
||||
|
||||
}
|
||||
}catch (Exception ex){
|
||||
log.error("导入配方异常"+ex.getMessage());
|
||||
throw new BadRequestException(ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#################################################
|
||||
输入.flag TYPEAS s_string
|
||||
输入.ext_id TYPEAS s_string
|
||||
输入.formula_id TYPEAS f_string
|
||||
输入.material_id TYPEAS s_string
|
||||
输入.source_name TYPEAS s_string
|
||||
输入.hide TYPEAS s_string
|
||||
@@ -190,5 +191,20 @@
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "8"
|
||||
QUERY
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
YCL_QMSJ
|
||||
where 1=1
|
||||
OPTION 输入.formula_id <> ""
|
||||
FORMULA_ID in 输入.formula_id
|
||||
ENDOPTION
|
||||
limit 100
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -157,11 +157,12 @@
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="success"
|
||||
:disabled="Export_flag"
|
||||
icon="el-icon-position"
|
||||
size="mini"
|
||||
@click="saveDetection()"
|
||||
>
|
||||
导入检测结果
|
||||
同步检测结果
|
||||
</el-button>
|
||||
<el-button
|
||||
slot="right"
|
||||
@@ -193,6 +194,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="workorder_code" width="130" label="工令号" />
|
||||
<el-table-column prop="status" :formatter="stateFormat" min-width="80" label="状态" />
|
||||
<el-table-column prop="remark2" min-width="200" label="备注"/>
|
||||
<el-table-column prop="bucket_type" :formatter="bucket_typeFormat" min-width="80" label="桶类型" />
|
||||
<el-table-column prop="material_code" min-width="130" label="物料编码" />
|
||||
@@ -203,7 +205,6 @@
|
||||
<el-table-column prop="ball_time" min-width="100" label="球磨时间" />
|
||||
<el-table-column prop="hcp_standard" min-width="100" label="hcp标准值" />
|
||||
<el-table-column prop="hcp_detection" min-width="100" label="hcp检测值" />
|
||||
<el-table-column prop="status" :formatter="stateFormat" min-width="80" label="状态" />
|
||||
<el-table-column prop="is_audit" :formatter="stateFormat2" min-width="80" label="是否审核" />
|
||||
<el-table-column prop="audit_time" min-width="140" label="审核时间" />
|
||||
<el-table-column prop="audit_name" min-width="80" label="审核人" />
|
||||
@@ -442,10 +443,6 @@ export default {
|
||||
this.fileList = []
|
||||
this.file1 = ''
|
||||
this.crud.toQuery()
|
||||
}).catch(err => {
|
||||
this.dialogUpload2 = false
|
||||
this.fileList = []
|
||||
this.file1 = ''
|
||||
})
|
||||
this.dialogUpload2 = false
|
||||
this.fileList = []
|
||||
@@ -556,7 +553,6 @@ export default {
|
||||
}
|
||||
const data = _selectData[0]
|
||||
download('/api/formula/preview', { 'formula_id': data.formula_id }).then(result => {
|
||||
debugger
|
||||
const name = data.material_code + data.pcsn
|
||||
downloadFile(result, name, 'xlsx')
|
||||
crud.downloadLoading = false
|
||||
@@ -575,7 +571,20 @@ export default {
|
||||
this.dialogUpload = true
|
||||
},
|
||||
saveDetection() {
|
||||
this.dialogUpload2 = true
|
||||
const _selectData = this.$refs.table.selection
|
||||
if (_selectData.length === 0 ) {
|
||||
this.crud.notify('请选择一条记录', CRUD.NOTIFICATION_TYPE.INFO)
|
||||
return false
|
||||
}
|
||||
const data = _selectData[0]
|
||||
this.formula_id = data.formula_id
|
||||
formula.excelImport(_selectData).then((res) => {
|
||||
this.crud.notify('同步成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.dialogUpload2 = false
|
||||
this.fileList = []
|
||||
this.file1 = ''
|
||||
this.crud.toQuery()
|
||||
})
|
||||
},
|
||||
upclose() {
|
||||
this.dialogUpload2 = false
|
||||
|
||||
Reference in New Issue
Block a user