rev:超期信息导入
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.nl.wms.basedata.st.rest;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -12,7 +13,9 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
@@ -98,10 +101,16 @@ public class StructivtController {
|
||||
|
||||
@PostMapping("/save")
|
||||
@Log("保存")
|
||||
|
||||
public ResponseEntity<Object> save(@RequestBody JSONObject whereJson) {
|
||||
structivtService.save(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/importExcel")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> importExcel(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||
structivtService.importExcel(file, request);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.basedata.st.service.dto.StructivtDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -81,4 +83,6 @@ public interface StructivtService {
|
||||
void download(Map map, HttpServletResponse response, String[] product_area, String[] ivt_flag) throws IOException;
|
||||
|
||||
void save(JSONObject whereJson);
|
||||
|
||||
void importExcel(MultipartFile file, HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
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.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -23,9 +26,12 @@ import org.nl.wms.basedata.st.service.dto.StructivtDto;
|
||||
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.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -329,4 +335,34 @@ public class StructivtServiceImpl implements StructivtService {
|
||||
WQLObject.getWQLObject("st_ivt_structivt").update(jsonObject, "stockrecord_id = '" + whereJson.getString("stockrecord_id") + "'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importExcel(MultipartFile file, HttpServletRequest request) {
|
||||
// 1.获取上传文件输入流
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream = file.getInputStream();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ExcelReader excelReader = ExcelUtil.getReader(inputStream);
|
||||
List<List<Object>> read = excelReader.read(1, excelReader.getRowCount());
|
||||
// 循环获取的数据
|
||||
for (int i = 0; i < read.size(); i++) {
|
||||
List list = read.get(i);
|
||||
String container_name = list.get(0).toString();
|
||||
String remark = list.get(1).toString();
|
||||
|
||||
if (StrUtil.isEmpty(container_name) || StrUtil.isEmpty(remark)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
JSONObject ivt_jo = WQLObject.getWQLObject("st_ivt_structivt").query("pcsn = '" + container_name + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(ivt_jo)) {
|
||||
continue;
|
||||
}
|
||||
ivt_jo.put("remark", remark);
|
||||
WQLObject.getWQLObject("st_ivt_structivt").update(ivt_jo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
116
lms/nladmin-ui/src/views/wms/basedata/st/ivt/UploadDialog.vue
Normal file
116
lms/nladmin-ui/src/views/wms/basedata/st/ivt/UploadDialog.vue
Normal file
@@ -0,0 +1,116 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="导入Excel文件"
|
||||
append-to-body
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="400px"
|
||||
:show-close="true"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<el-upload
|
||||
ref="upload"
|
||||
class="upload-demo"
|
||||
action=""
|
||||
drag
|
||||
:on-exceed="is_one"
|
||||
: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="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudStructivt from '@/views/wms/basedata/st/ivt/structivt'
|
||||
import CRUD, { crud } from '@crud/crud'
|
||||
|
||||
export default {
|
||||
name: 'UploadDialog',
|
||||
mixins: [crud()],
|
||||
components: {},
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
openParam: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
fileList: [],
|
||||
file1: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue, oldValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
},
|
||||
openParam: {
|
||||
handler(newValue, oldValue) {
|
||||
this.opendtlParam = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
},
|
||||
close() {
|
||||
this.$emit('update:dialogShow', false)
|
||||
},
|
||||
is_one() {
|
||||
this.crud.notify('只能上传一个excel文件!', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
},
|
||||
// 文件校验方法
|
||||
beforeAvatarUpload(file) {
|
||||
// 不能导入大小超过2Mb的文件
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
// 文件发生改变就会触发的事件
|
||||
uploadByJsqd(file) {
|
||||
this.file1 = file
|
||||
},
|
||||
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)
|
||||
// excelImport:请求接口 formdata:传递参数
|
||||
crudStructivt.excelImport(formdata).then((res) => {
|
||||
this.crud.notify('导入成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.$emit('tableChanged', '')
|
||||
this.$emit('update:dialogShow', false)
|
||||
})
|
||||
} else {
|
||||
this.crud.notify('文件过大,请上传小于10MB的文件〜', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -155,7 +155,7 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<rrOperation :crud="crud" />
|
||||
<rrOperation :crud="crud"/>
|
||||
</el-form>
|
||||
</div>
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
@@ -170,39 +170,63 @@
|
||||
>
|
||||
导出Excel
|
||||
</el-button>
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="warning"
|
||||
icon="el-icon-arrow-down"
|
||||
size="mini"
|
||||
@click="Import"
|
||||
>
|
||||
超期信息导入
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表格渲染-->
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="struct_code" label="仓位编码" :min-width="flexWidth('struct_code',crud.data,'仓位编码')" />
|
||||
<el-table-column prop="struct_name" label="仓位名称" :min-width="flexWidth('struct_name',crud.data,'仓位名称')" />
|
||||
<el-table-column prop="stor_name" label="仓库" :min-width="flexWidth('stor_name',crud.data,'仓库')" />
|
||||
<el-table-column prop="sect_name" label="库区" :min-width="flexWidth('sect_name',crud.data,'库区')" />
|
||||
<el-table-column prop="material_code" label="物料编码" :min-width="flexWidth('material_code',crud.data,'物料编码')" />
|
||||
<el-table-column prop="material_name" label="物料名称" :min-width="flexWidth('material_name',crud.data,'物料名称')" />
|
||||
<!-- <el-table-column prop="region_name" label="下料区域" min-width="120" show-overflow-tooltip />-->
|
||||
<!-- <el-table-column prop="quality_scode" label="品质类型" min-width="120" show-overflow-tooltip>
|
||||
<template slot-scope="scope">
|
||||
{{ dict.label.ST_QUALITY_SCODE[scope.row.quality_scode] }}
|
||||
</template>
|
||||
</el-table-column>-->
|
||||
<el-table-column prop="package_box_sn" label="木箱码" :min-width="flexWidth('package_box_sn',crud.data,'木箱码')" />
|
||||
<el-table-column prop="quanlity_in_box" label="子卷数" :min-width="flexWidth('quanlity_in_box',crud.data,'子卷数')" />
|
||||
<el-table-column prop="pcsn" label="子卷号" :min-width="flexWidth('pcsn',crud.data,'子卷号')" />
|
||||
<el-table-column prop="sap_pcsn" label="sap批次" :min-width="flexWidth('sap_pcsn',crud.data,'sap批次')" />
|
||||
<el-table-column prop="box_weight" label="毛重" :formatter="rounding2" />
|
||||
<el-table-column prop="canuse_qty" label="可用数" :formatter="rounding" />
|
||||
<el-table-column prop="frozen_qty" label="冻结数" :formatter="rounding" />
|
||||
<el-table-column prop="ivt_qty" label="库存数" :formatter="rounding" />
|
||||
<el-table-column prop="warehousing_qty" label="待入数" :formatter="rounding" />
|
||||
<el-table-column prop="unit_name" label="计量单位" />
|
||||
<el-table-column prop="instorage_time" label="入库时间" min-width="150" />
|
||||
<el-table-column prop="paper_type" label="管件类型" min-width="150" />
|
||||
<el-table-column prop="paper_code" label="管件编码" min-width="150" />
|
||||
<el-table-column prop="paper_name" label="管件描述" min-width="250" />
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%;"
|
||||
@selection-change="crud.selectionChangeHandler"
|
||||
>
|
||||
<el-table-column type="selection" width="55"/>
|
||||
<el-table-column prop="struct_code" label="仓位编码"
|
||||
:min-width="flexWidth('struct_code',crud.data,'仓位编码')"
|
||||
/>
|
||||
<el-table-column prop="struct_name" label="仓位名称"
|
||||
:min-width="flexWidth('struct_name',crud.data,'仓位名称')"
|
||||
/>
|
||||
<el-table-column prop="stor_name" label="仓库" :min-width="flexWidth('stor_name',crud.data,'仓库')"/>
|
||||
<el-table-column prop="sect_name" label="库区" :min-width="flexWidth('sect_name',crud.data,'库区')"/>
|
||||
<el-table-column prop="material_code" label="物料编码"
|
||||
:min-width="flexWidth('material_code',crud.data,'物料编码')"
|
||||
/>
|
||||
<el-table-column prop="material_name" label="物料名称"
|
||||
:min-width="flexWidth('material_name',crud.data,'物料名称')"
|
||||
/>
|
||||
<!-- <el-table-column prop="region_name" label="下料区域" min-width="120" show-overflow-tooltip />-->
|
||||
<!-- <el-table-column prop="quality_scode" label="品质类型" min-width="120" show-overflow-tooltip>
|
||||
<template slot-scope="scope">
|
||||
{{ dict.label.ST_QUALITY_SCODE[scope.row.quality_scode] }}
|
||||
</template>
|
||||
</el-table-column>-->
|
||||
<el-table-column prop="package_box_sn" label="木箱码"
|
||||
:min-width="flexWidth('package_box_sn',crud.data,'木箱码')"
|
||||
/>
|
||||
<el-table-column prop="quanlity_in_box" label="子卷数"
|
||||
:min-width="flexWidth('quanlity_in_box',crud.data,'子卷数')"
|
||||
/>
|
||||
<el-table-column prop="pcsn" label="子卷号" :min-width="flexWidth('pcsn',crud.data,'子卷号')"/>
|
||||
<el-table-column prop="sap_pcsn" label="sap批次" :min-width="flexWidth('sap_pcsn',crud.data,'sap批次')"/>
|
||||
<el-table-column prop="box_weight" label="毛重" :formatter="rounding2"/>
|
||||
<el-table-column prop="canuse_qty" label="可用数" :formatter="rounding"/>
|
||||
<el-table-column prop="frozen_qty" label="冻结数" :formatter="rounding"/>
|
||||
<el-table-column prop="ivt_qty" label="库存数" :formatter="rounding"/>
|
||||
<el-table-column prop="warehousing_qty" label="待入数" :formatter="rounding"/>
|
||||
<el-table-column prop="unit_name" label="计量单位"/>
|
||||
<el-table-column prop="instorage_time" label="入库时间" min-width="150"/>
|
||||
<el-table-column prop="paper_type" label="管件类型" min-width="150"/>
|
||||
<el-table-column prop="paper_code" label="管件编码" min-width="150"/>
|
||||
<el-table-column prop="paper_name" label="管件描述" min-width="250"/>
|
||||
<el-table-column prop="remark" label="超期原因" min-width="250">
|
||||
<template scope="scope">
|
||||
<!-- <el-input v-model="scope.row.remark" style="width: 200px" />-->
|
||||
<!-- <el-input v-model="scope.row.remark" style="width: 200px" />-->
|
||||
<el-select
|
||||
v-model="scope.row.remark"
|
||||
clearable
|
||||
@@ -222,13 +246,16 @@
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="操作" width="120" fixed="right">
|
||||
<template scope="scope">
|
||||
<el-button type="primary" class="filter-item" size="mini" icon="el-icon-edit" @click.native.prevent="save(scope.row)" />
|
||||
<el-button type="primary" class="filter-item" size="mini" icon="el-icon-edit"
|
||||
@click.native.prevent="save(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
<pagination/>
|
||||
</div>
|
||||
<UploadDialog :dialog-show.sync="viewShow" @tableChanged="querytable"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -240,17 +267,37 @@ import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import crudUserStor from '@/views/wms/basedata/st/userStor/userStor'
|
||||
import UploadDialog from '@/views/wms/basedata/st/ivt/UploadDialog'
|
||||
import { download } from '@/api/data'
|
||||
import { downloadFile } from '@/utils'
|
||||
|
||||
const defaultForm = { stockrecord_id: null, cascader: null, struct_id: null, struct_code: null, struct_name: null, workprocedure_id: null, material_id: null, material_code: null, quality_scode: null, pcsn: null, canuse_qty: null, frozen_qty: null, ivt_qty: null, warehousing_qty: null, qty_unit_id: null, instorage_time: null, sale_id: null }
|
||||
const defaultForm = {
|
||||
stockrecord_id: null,
|
||||
cascader: null,
|
||||
struct_id: null,
|
||||
struct_code: null,
|
||||
struct_name: null,
|
||||
workprocedure_id: null,
|
||||
material_id: null,
|
||||
material_code: null,
|
||||
quality_scode: null,
|
||||
pcsn: null,
|
||||
canuse_qty: null,
|
||||
frozen_qty: null,
|
||||
ivt_qty: null,
|
||||
warehousing_qty: null,
|
||||
qty_unit_id: null,
|
||||
instorage_time: null,
|
||||
sale_id: null
|
||||
}
|
||||
export default {
|
||||
name: 'Structivt',
|
||||
dicts: ['ST_QUALITY_SCODE', 'product_area', 'IS_OR_NOT'],
|
||||
components: { pagination, crudOperation, rrOperation, udOperation },
|
||||
components: { pagination, crudOperation, rrOperation, udOperation, UploadDialog },
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({ title: '库存管理', url: 'api/structivt', idField: 'stockrecord_id', sort: 'stockrecord_id,desc',
|
||||
return CRUD({
|
||||
title: '库存管理', url: 'api/structivt', idField: 'stockrecord_id', sort: 'stockrecord_id,desc',
|
||||
optShow: {
|
||||
add: false,
|
||||
edit: false,
|
||||
@@ -258,11 +305,13 @@ export default {
|
||||
download: false,
|
||||
reset: true
|
||||
},
|
||||
crudMethod: { ...crudStructivt }})
|
||||
crudMethod: { ...crudStructivt }
|
||||
})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
sects: [],
|
||||
viewShow: false,
|
||||
ivtStatusList: [
|
||||
{ 'value': 'canuse_qty', 'label': '可用数' },
|
||||
{ 'value': 'warehousing_qty', 'label': '待入数' },
|
||||
@@ -278,10 +327,8 @@ export default {
|
||||
{ 'value': '2', 'label': '生产质量原因' },
|
||||
{ 'value': '3', 'label': '市场原因' }
|
||||
],
|
||||
permission: {
|
||||
},
|
||||
rules: {
|
||||
}
|
||||
permission: {},
|
||||
rules: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@@ -324,6 +371,9 @@ export default {
|
||||
}
|
||||
this.crud.toQuery()
|
||||
},
|
||||
querytable() {
|
||||
this.crud.toQuery()
|
||||
},
|
||||
downdtl() {
|
||||
if (this.currentRow !== null) {
|
||||
crud.downloadLoading = true
|
||||
@@ -335,6 +385,9 @@ export default {
|
||||
})
|
||||
}
|
||||
},
|
||||
Import() {
|
||||
this.viewShow = true
|
||||
},
|
||||
save(row) {
|
||||
crudStructivt.save(row).then(res => {
|
||||
this.crud.notify('操作成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
|
||||
@@ -54,4 +54,12 @@ export function save(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getStruct, getStructById, getUnits, save }
|
||||
export function excelImport(data) {
|
||||
return request({
|
||||
url: 'api/structivt/importExcel',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getStruct, getStructById, getUnits, save, excelImport }
|
||||
|
||||
Reference in New Issue
Block a user