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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,4 +56,11 @@ export function print(data) {
|
||||
data
|
||||
})
|
||||
}
|
||||
export default { audit, cancel, getform, submit, getView, pointCard, preview, print }
|
||||
export function excelImport(data) {
|
||||
return request({
|
||||
url: 'api/formula/importDetection',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
export default { audit, cancel, getform, submit, getView, pointCard, preview, print, excelImport }
|
||||
|
||||
@@ -138,6 +138,31 @@
|
||||
style="width: 210px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="hcp标准值">
|
||||
<label slot="label">hcp标准值:</label>
|
||||
<el-input-number
|
||||
v-model="form.hcp_standard"
|
||||
:controls="false"
|
||||
:precision="2"
|
||||
:min="1"
|
||||
:max="9999"
|
||||
disabled
|
||||
style="width: 210px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="hcp检测值">
|
||||
<label slot="label">hcp检测值:</label>
|
||||
<el-input-number
|
||||
v-model="form.ball_time"
|
||||
:controls="false"
|
||||
:precision="2"
|
||||
:min="1"
|
||||
:max="9999"
|
||||
disabled
|
||||
style="width: 210px"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="产品系列" prop="product_series_id">
|
||||
<el-select
|
||||
v-model="form.product_series_id"
|
||||
|
||||
@@ -153,6 +153,16 @@
|
||||
>
|
||||
查看记录卡
|
||||
</el-button>
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="success"
|
||||
icon="el-icon-position"
|
||||
size="mini"
|
||||
@click="saveDetection()"
|
||||
>
|
||||
导入检测结果
|
||||
</el-button>
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
@@ -190,6 +200,9 @@
|
||||
<el-table-column prop="pcsn" min-width="130" label="批次" />
|
||||
<el-table-column prop="detail_count" min-width="100" label="明细数" />
|
||||
<el-table-column prop="masterbucket_qty" min-width="100" label="重量" :formatter="crud.formatNum3" />
|
||||
<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="审核时间" />
|
||||
@@ -242,6 +255,40 @@
|
||||
<el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<el-dialog
|
||||
title="导入检测Excel文件"
|
||||
append-to-body
|
||||
:visible.sync="dialogUpload2"
|
||||
destroy-on-close
|
||||
width="400px"
|
||||
:show-close="true"
|
||||
@close="upclose"
|
||||
>
|
||||
<el-upload
|
||||
ref="upload"
|
||||
class="upload-demo"
|
||||
action=""
|
||||
drag
|
||||
:limit="1"
|
||||
:auto-upload="false"
|
||||
:multiple="false"
|
||||
:show-file-list="true"
|
||||
:on-change="uploadByJsqd"
|
||||
:file-list="fileList"
|
||||
accept=".xlsx,.xls"
|
||||
>
|
||||
<i class="el-icon-upload" />
|
||||
<div class="el-upload__text">
|
||||
将文件拖到此处,或
|
||||
<em>点击上传</em>
|
||||
</div>
|
||||
<div slot="tip" class="el-upload__tip">只能上传Excel文件,且不超过10MB</div>
|
||||
</el-upload>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogUpload2 = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<PicDialog ref="child" :dialog-show.sync="PicDialog" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -285,6 +332,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
dialogUpload: false,
|
||||
dialogUpload2: false,
|
||||
PicDialog: false,
|
||||
formula_id: null,
|
||||
headers: { 'Authorization': getToken() },
|
||||
@@ -303,7 +351,9 @@ export default {
|
||||
currentRow: null,
|
||||
query_flag: true,
|
||||
checkrows: [],
|
||||
XLList: []
|
||||
XLList: [],
|
||||
fileList: [],
|
||||
file1: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -368,6 +418,45 @@ export default {
|
||||
this.handleCurrentChange()
|
||||
}
|
||||
},
|
||||
// 文件发生改变就会触发的事件
|
||||
uploadByJsqd(file) {
|
||||
this.file1 = file
|
||||
},
|
||||
// 文件校验方法
|
||||
beforeAvatarUpload(file) {
|
||||
// 不能导入大小超过2Mb的文件
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
submit() {
|
||||
if (this.beforeAvatarUpload(this.file1)) {
|
||||
this.fileList.name = this.file1.name
|
||||
this.fileList.url = ''
|
||||
var formdata = new FormData()
|
||||
formdata.append('file', this.file1.raw)
|
||||
formula.excelImport(formdata).then((res) => {
|
||||
this.crud.notify('导入成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.dialogUpload2 = false
|
||||
this.fileList = []
|
||||
this.file1 = ''
|
||||
this.crud.toQuery()
|
||||
}).catch(err => {
|
||||
this.dialogUpload2 = false
|
||||
this.fileList = []
|
||||
this.file1 = ''
|
||||
})
|
||||
this.dialogUpload2 = false
|
||||
this.fileList = []
|
||||
this.file1 = ''
|
||||
} else {
|
||||
this.crud.notify('文件过大,请上传小于10MB的文件〜', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
this.dialogUpload = false
|
||||
this.fileList = []
|
||||
this.file1 = ''
|
||||
}
|
||||
},
|
||||
stateFormat(row) {
|
||||
return this.dict.label.formula_status[row.status]
|
||||
},
|
||||
@@ -485,6 +574,14 @@ export default {
|
||||
this.formula_id = data.formula_id
|
||||
this.dialogUpload = true
|
||||
},
|
||||
saveDetection() {
|
||||
this.dialogUpload2 = true
|
||||
},
|
||||
upclose() {
|
||||
this.dialogUpload2 = false
|
||||
this.fileList = []
|
||||
this.file1 = ''
|
||||
},
|
||||
beforeUpload(file) {
|
||||
let isLt2M = true
|
||||
isLt2M = file.size / 1024 / 1024 < 50
|
||||
|
||||
Reference in New Issue
Block a user