add:物料信息导入
This commit is contained in:
@@ -14,7 +14,9 @@ import org.springframework.http.HttpStatus;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -73,4 +75,11 @@ public class MdBaseMaterialController {
|
|||||||
wmsToMesService.synchronizeMaterialInfo();
|
wmsToMesService.synchronizeMaterialInfo();
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/excelImport")
|
||||||
|
@Log("excel导入")
|
||||||
|
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
|
||||||
|
wmsToMesService.excelImport(file, request);
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import org.nl.wms.database.brick.service.dao.MdBaseBrickInfo;
|
|||||||
import org.nl.wms.ext.mes.service.dto.*;
|
import org.nl.wms.ext.mes.service.dto.*;
|
||||||
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
|
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
|
||||||
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
|
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -193,4 +195,6 @@ public interface WmsToMesService {
|
|||||||
* @param entity
|
* @param entity
|
||||||
*/
|
*/
|
||||||
void addScrap(ScrapDto entity);
|
void addScrap(ScrapDto entity);
|
||||||
|
|
||||||
|
void excelImport(MultipartFile file, HttpServletRequest request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,18 @@ package org.nl.wms.ext.mes.service.impl;
|
|||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
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.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.common.domain.query.PageQuery;
|
import org.nl.common.domain.query.PageQuery;
|
||||||
import org.nl.common.exception.BadRequestException;
|
import org.nl.common.exception.BadRequestException;
|
||||||
|
import org.nl.common.utils.SecurityUtils;
|
||||||
import org.nl.system.service.notice.ISysNoticeService;
|
import org.nl.system.service.notice.ISysNoticeService;
|
||||||
import org.nl.wms.database.brick.service.dao.MdBaseBrickInfo;
|
import org.nl.wms.database.brick.service.dao.MdBaseBrickInfo;
|
||||||
import org.nl.wms.database.material.service.IMdBaseMaterialService;
|
import org.nl.wms.database.material.service.IMdBaseMaterialService;
|
||||||
@@ -31,7 +36,11 @@ import org.slf4j.MDC;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -510,6 +519,28 @@ public class WmsToMesServiceImpl implements WmsToMesService {
|
|||||||
mesRequestMapper.reportSemiProductGXPF(semiProductGXPFDo);
|
mesRequestMapper.reportSemiProductGXPF(semiProductGXPFDo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void excelImport(MultipartFile file, HttpServletRequest request) {
|
||||||
|
if (file.isEmpty()) {
|
||||||
|
throw new BadRequestException("文件为空,请添加数据后重新导入");
|
||||||
|
}
|
||||||
|
// 1.获取上传文件输入流
|
||||||
|
InputStream inputStream = null;
|
||||||
|
try {
|
||||||
|
inputStream = file.getInputStream();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// 调用用 hutool 方法读取数据 默认调用第一个sheet
|
||||||
|
ExcelReader excelReader = ExcelUtil.getReader(inputStream);
|
||||||
|
// 从第二行开始获取数据 excelReader.read的结果是一个2纬的list,外层是行,内层是行对应的所有列
|
||||||
|
List<List<Object>> read = excelReader.read(1, excelReader.getRowCount());
|
||||||
|
// 循环获取的数据
|
||||||
|
for (int i = 0; i < read.size(); i++) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换
|
* 转换
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -48,15 +48,25 @@
|
|||||||
</div>
|
</div>
|
||||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||||
<crudOperation :permission="permission" >
|
<crudOperation :permission="permission" >
|
||||||
|
<!-- <el-button-->
|
||||||
|
<!-- slot="right"-->
|
||||||
|
<!-- class="filter-item"-->
|
||||||
|
<!-- type="success"-->
|
||||||
|
<!-- icon="el-icon-position"-->
|
||||||
|
<!-- size="mini"-->
|
||||||
|
<!-- @click="synchronize()"-->
|
||||||
|
<!-- >-->
|
||||||
|
<!-- 同步-->
|
||||||
|
<!-- </el-button>-->
|
||||||
<el-button
|
<el-button
|
||||||
slot="right"
|
slot="right"
|
||||||
class="filter-item"
|
class="filter-item"
|
||||||
type="success"
|
type="warning"
|
||||||
icon="el-icon-position"
|
icon="el-icon-upload2"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="synchronize()"
|
@click="uploadShow = true"
|
||||||
>
|
>
|
||||||
同步
|
导入
|
||||||
</el-button>
|
</el-button>
|
||||||
</crudOperation>
|
</crudOperation>
|
||||||
<!--表单组件-->
|
<!--表单组件-->
|
||||||
@@ -202,6 +212,7 @@
|
|||||||
<!--分页组件-->
|
<!--分页组件-->
|
||||||
<pagination />
|
<pagination />
|
||||||
</div>
|
</div>
|
||||||
|
<UploadDialog :dialog-show.sync="uploadShow" @tableChanged3="tableChanged3" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -214,6 +225,8 @@ import rrOperation from '@crud/RR.operation'
|
|||||||
import crudOperation from '@crud/CRUD.operation'
|
import crudOperation from '@crud/CRUD.operation'
|
||||||
import udOperation from '@crud/UD.operation'
|
import udOperation from '@crud/UD.operation'
|
||||||
import pagination from '@crud/Pagination'
|
import pagination from '@crud/Pagination'
|
||||||
|
import UploadDialog from './UploadDialog'
|
||||||
|
|
||||||
|
|
||||||
const defaultForm = {
|
const defaultForm = {
|
||||||
material_id: null,
|
material_id: null,
|
||||||
@@ -240,7 +253,7 @@ const defaultForm = {
|
|||||||
export default {
|
export default {
|
||||||
name: 'MdBaseMaterial',
|
name: 'MdBaseMaterial',
|
||||||
dicts: ['vehicle_type'],
|
dicts: ['vehicle_type'],
|
||||||
components: { pagination, crudOperation, rrOperation, udOperation, Treeselect },
|
components: { pagination, crudOperation, rrOperation, udOperation, Treeselect, UploadDialog },
|
||||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||||
cruds() {
|
cruds() {
|
||||||
return CRUD({
|
return CRUD({
|
||||||
@@ -258,6 +271,7 @@ export default {
|
|||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
},
|
},
|
||||||
|
uploadShow: false,
|
||||||
fullscreenLoading: false,
|
fullscreenLoading: false,
|
||||||
workShopList: []
|
workShopList: []
|
||||||
}
|
}
|
||||||
@@ -284,6 +298,9 @@ export default {
|
|||||||
this.workShopList = res
|
this.workShopList = res
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
tableChanged3() {
|
||||||
|
this.crud.toQuery()
|
||||||
|
},
|
||||||
// 获取子节点数据
|
// 获取子节点数据
|
||||||
loadChildNodes({ action, parentNode, callback }) {
|
loadChildNodes({ action, parentNode, callback }) {
|
||||||
// if (action === LOAD_CHILDREN_OPTIONS) {
|
// if (action === LOAD_CHILDREN_OPTIONS) {
|
||||||
|
|||||||
@@ -32,4 +32,12 @@ export function synchronize(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default { add, edit, del, synchronize }
|
export function excelImport(data) {
|
||||||
|
return request({
|
||||||
|
url: 'api/mdBaseMaterial/excelImport',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default { add, edit, del, synchronize, excelImport }
|
||||||
|
|||||||
Reference in New Issue
Block a user