Compare commits
2 Commits
b5c15d34b0
...
bc7f065b1b
| Author | SHA1 | Date |
|---|---|---|
|
|
bc7f065b1b | |
|
|
41c37c007c |
|
|
@ -19,10 +19,7 @@ import cn.hutool.poi.excel.ExcelReader;
|
|||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import com.youchain.annotation.AnonymousAccess;
|
||||
import com.youchain.annotation.Log;
|
||||
import com.youchain.basicdata.service.ImportAsnService;
|
||||
import com.youchain.basicdata.service.ImportBomAccountService;
|
||||
import com.youchain.basicdata.service.ImportDataService;
|
||||
import com.youchain.basicdata.service.ImportPointService;
|
||||
import com.youchain.basicdata.service.*;
|
||||
import com.youchain.businessdata.domain.Asn;
|
||||
import com.youchain.businessdata.domain.PickDetail;
|
||||
import com.youchain.businessdata.domain.PickTicket;
|
||||
|
|
@ -73,6 +70,7 @@ public class ImportDataController {
|
|||
private final ImportAsnService importAsnService;
|
||||
private final ImportBomAccountService importBomAccountService;
|
||||
private final ImportPointService importPointService;
|
||||
private final ImportItemService importItemService;
|
||||
|
||||
@Log("导入完成品品番")
|
||||
@ApiOperation("导入完成品品番")
|
||||
|
|
@ -102,23 +100,11 @@ public class ImportDataController {
|
|||
@Transactional
|
||||
@AnonymousAccess
|
||||
public ResponseEntity<Object> importItem(@RequestParam("file") MultipartFile multipartFile) {
|
||||
List<Map<String, Object>> readAll = getMaps(multipartFile);
|
||||
int a = 0;//新增
|
||||
int b = 0;//修改
|
||||
for (int i = 0; i < readAll.size(); i++) {
|
||||
Map<String, Object> map = readAll.get(i);
|
||||
String code = (String) map.get("品番");
|
||||
if (code == null || code.equals("")) {
|
||||
break;
|
||||
}
|
||||
String re = importDataService.importItem(map);
|
||||
if (re.equals("a")) {
|
||||
a = a + 1;
|
||||
} else if (re.equals("b")) {
|
||||
b = b + 1;
|
||||
}
|
||||
}
|
||||
return new ResponseEntity("导入成功:执行" + (a + b) + "行 新增" + a + "行,修改" + b + "行", OK);
|
||||
log.info("开始导入");
|
||||
long start = System.currentTimeMillis();
|
||||
importItemService.importData(multipartFile);
|
||||
log.info("导入结束,耗时:{}ms", (System.currentTimeMillis() - start));
|
||||
return new ResponseEntity<>(ApiResult.success(OK.value(), "导入成功", null), OK);
|
||||
}
|
||||
|
||||
@Log("导入其他入库")
|
||||
|
|
@ -266,4 +252,5 @@ public class ImportDataController {
|
|||
log.info("导入结束,耗时:{}ms", (System.currentTimeMillis() - start));
|
||||
return new ResponseEntity<>(ApiResult.success(OK.value(), "导入成功", null), OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -89,68 +89,6 @@ public class PointController {
|
|||
public void exportPoint(HttpServletResponse response, PointQueryCriteria criteria) throws Exception {
|
||||
pointService.download(pointService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@Log("导入点位")
|
||||
@PostMapping(value = "/import_point")
|
||||
@ApiOperation("导入点位")
|
||||
@AnonymousAccess
|
||||
public ResponseEntity<Object> importPoint(@RequestParam("file") MultipartFile multipartFile) {
|
||||
FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
|
||||
String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
|
||||
String type = FileUtil.getFileType(suffix);
|
||||
|
||||
File file = FileUtil.upload(multipartFile, properties.getPath().getPath() + type + File.separator);
|
||||
|
||||
Dept dept = UserUtils.getDept();
|
||||
//编码、描述、库区、存储类型
|
||||
ExcelReader reader = ExcelUtil.getReader(file);
|
||||
int i = 0;
|
||||
List<Map<String, Object>> readAll = reader.readAll();
|
||||
for (i = 1; i < readAll.size(); i++) {
|
||||
String code = readAll.get(i).get("编码").toString().trim();
|
||||
String types = readAll.get(i).get("存储类型").toString().trim();
|
||||
String areaCode = readAll.get(i).get("库区").toString().trim();
|
||||
String itemCode = readAll.get(i).get("品番编码") == null ? "" : readAll.get(i).get("品番编码").toString().trim();
|
||||
String beatCode = readAll.get(i).get("纳所") == null ? "" : readAll.get(i).get("纳所").toString().trim();
|
||||
String ccTYPE = readAll.get(i).get("标签类型") == null ? "" : readAll.get(i).get("标签类型").toString().trim();
|
||||
Area area = areaService.findByCode(areaCode);
|
||||
if (area == null) {
|
||||
throw new BadRequestException(areaCode+"库区不存在");
|
||||
}
|
||||
Point point = pointService.getPoint(code, null, null, null);
|
||||
Boolean isNew=Boolean.FALSE;
|
||||
if (point == null) {
|
||||
point = new Point();
|
||||
point.setCode(code);
|
||||
point.setDept(dept);
|
||||
point.setEnabled(true);
|
||||
point.setStatus(BaseStatus.FREE);
|
||||
point.setName(code);
|
||||
isNew=Boolean.TRUE;
|
||||
}
|
||||
String lx = "";
|
||||
if (types.equals("材管库位")) {
|
||||
lx = BaseStatus.CH;
|
||||
} else if (types.equals("制造库位")) {
|
||||
lx = BaseStatus.ZZKW;
|
||||
}else if (types.equals("缓存库位")) {
|
||||
lx = BaseStatus.HCKW;
|
||||
}
|
||||
point.setType(lx);
|
||||
point.setArea(area);
|
||||
point.setDescription(ccTYPE);
|
||||
point.setItemCode(itemCode);
|
||||
point.setBeatCode(beatCode);
|
||||
if(isNew){
|
||||
pointService.create(point);
|
||||
}else {
|
||||
pointService.update(point);
|
||||
}
|
||||
}
|
||||
return new ResponseEntity("导入成功", HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询point")
|
||||
@ApiOperation("查询point")
|
||||
|
|
@ -159,8 +97,6 @@ public class PointController {
|
|||
return new ResponseEntity<>(pointService.queryAll(criteria, pageable), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/getPoints")
|
||||
@Log("加载point下拉框")
|
||||
@ApiOperation("加载point下拉框")
|
||||
|
|
|
|||
|
|
@ -40,12 +40,6 @@ public interface ImportDataService {
|
|||
*/
|
||||
void importBomAccount(int row,Map<String,Object> readAll);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param stringObjectMap
|
||||
* @return
|
||||
*/
|
||||
String importItem(Map<String, Object> stringObjectMap);
|
||||
|
||||
String importBigItem(Map<String, Object> stringObjectMap);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
package com.youchain.basicdata.service;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
public interface ImportItemService {
|
||||
/**
|
||||
* 批量导入
|
||||
* @param file 文件
|
||||
*/
|
||||
void importData(MultipartFile file);
|
||||
}
|
||||
|
|
@ -175,42 +175,6 @@ public class ImportDataServiceImpl implements ImportDataService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String importItem(Map<String, Object> readAll) {
|
||||
String re = "";
|
||||
String code = readAll.get("品番") == null ? null : readAll.get("品番").toString();
|
||||
String name = readAll.get("品名") == null ? null : readAll.get("品名").toString();
|
||||
String specs = readAll.get("规格") == null ? null : readAll.get("规格").toString();
|
||||
String unit = readAll.get("单位") == null ? null : readAll.get("单位").toString();
|
||||
String hz = readAll.get("荷资") == null ? null : readAll.get("荷资").toString();
|
||||
String srs = readAll.get("收容数") == null ? null : readAll.get("收容数").toString();
|
||||
if (code.length() > 0) {
|
||||
Item item = itemRepository.findByAllCode(code);
|
||||
if (item == null) {
|
||||
re = "a";
|
||||
item = new Item();
|
||||
item.setDept(UserUtils.getDept());
|
||||
item.setCode(code);
|
||||
} else {
|
||||
re = "b";
|
||||
}
|
||||
item.setName(name);
|
||||
item.setExtendStr3(hz);
|
||||
item.setExtendD3(Double.parseDouble(srs));
|
||||
if (unit != null && !unit.equals("")) {
|
||||
DictDetail dictDetail = dictDetailRepository.findByDictAndLabel("item_unit", unit);
|
||||
item.setUnit(dictDetail.getValue());
|
||||
}
|
||||
item.setSpecs(specs);
|
||||
if (re.equals("a")) {
|
||||
itemRepository.save(item);
|
||||
} else if (re.equals("b")) {
|
||||
itemService.update(item);
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String importBigItem(Map<String, Object> readAll) {
|
||||
String re = "";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,111 @@
|
|||
package com.youchain.basicdata.service.impl;
|
||||
|
||||
import com.youchain.basicdata.domain.Area;
|
||||
import com.youchain.basicdata.domain.Item;
|
||||
import com.youchain.basicdata.domain.Point;
|
||||
import com.youchain.basicdata.repository.ItemRepository;
|
||||
import com.youchain.basicdata.repository.PointRepository;
|
||||
import com.youchain.basicdata.service.*;
|
||||
import com.youchain.businessdata.inputJson.imports.ItemImport;
|
||||
import com.youchain.businessdata.inputJson.imports.PointImport;
|
||||
import com.youchain.exception.BadRequestException;
|
||||
import com.youchain.utils.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ImportItemServiceImpl implements ImportItemService {
|
||||
|
||||
private final ItemRepository itemRepository;
|
||||
|
||||
private final ItemService itemService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importData(MultipartFile file) {
|
||||
|
||||
// 验证模板类型是否正确
|
||||
isValidTemplateType(file);
|
||||
|
||||
// 根据模板类型进行不同的处理
|
||||
baseImportTemplate(file);
|
||||
}
|
||||
|
||||
// 处理标准模板
|
||||
@Transactional
|
||||
public void baseImportTemplate(MultipartFile file) {
|
||||
// 读取sheet数据
|
||||
List<ItemImport> dataList = FastExcelUtil.readExcelData(file, ItemImport.class, 0, 1);
|
||||
|
||||
//批量导入
|
||||
importItemData(dataList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理批量导入
|
||||
*/
|
||||
private void importItemData(List<ItemImport> dataList) {
|
||||
// TODO: 实现批量导入逻辑
|
||||
log.info("处理批量导入,数据条数: {}", dataList.size());
|
||||
|
||||
//获取文件中所有的库位编码
|
||||
List<String> itemcodes = dataList.stream().map(ItemImport::getCode).collect(Collectors.toList());
|
||||
itemcodes = itemcodes.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
Map<String, Item> exitPointMap = validateItem(itemcodes);
|
||||
|
||||
for (ItemImport data : dataList) {
|
||||
Item item = exitPointMap.get(data.getCode());
|
||||
if (item == null) {
|
||||
item=new Item();
|
||||
item.setCode(data.getCode());
|
||||
item.setDept(UserUtils.getDept());
|
||||
item.setCreateBy(SecurityUtils.getCurrentUsername());
|
||||
item.setCreateTime(new Timestamp(new Date().getTime()));
|
||||
item.setEnabled(Boolean.TRUE);
|
||||
}
|
||||
item.setName(data.getName());
|
||||
item.setSrs(data.getSrs());
|
||||
item.setAc(data.getAc());
|
||||
item.setContents(data.getContents());
|
||||
item.setXz(data.getXz());
|
||||
item.setExtendD3(data.getSrs()+0d);
|
||||
itemRepository.save(item);
|
||||
}
|
||||
}
|
||||
|
||||
//验证库位
|
||||
private Map<String, Item> validateItem(List<String> codes) {
|
||||
Map<String, Item> existMap = itemService.queryByItemCodesToMap(codes);
|
||||
return existMap;
|
||||
}
|
||||
|
||||
|
||||
//验证模板是否使用正确
|
||||
private void isValidTemplateType(MultipartFile file) {
|
||||
// 根据模板类型进行不同的处理
|
||||
List<String> requiredColumns = Arrays.asList(
|
||||
"品番",
|
||||
"品名",
|
||||
"A/C",
|
||||
"加工内容",
|
||||
"箱种",
|
||||
"收容数"
|
||||
);
|
||||
List<String> headers = FastExcelUtil.readHeadContent(file, requiredColumns, 0, 0);
|
||||
if (!SmartStringUtil.containsAllIgnoreCase(requiredColumns, headers)) {
|
||||
throw new BadRequestException("标准导入模板不正确,请确认模板信息");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.youchain.businessdata.inputJson.imports;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
||||
/**
|
||||
* @description: 基础导入
|
||||
* @author: youzhi.gao
|
||||
* @date: 2020-04-01 15:01
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ItemImport {
|
||||
@ExcelProperty("品番")
|
||||
private String code;
|
||||
|
||||
@ExcelProperty("品名")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("A/C")
|
||||
private String ac;
|
||||
|
||||
@ExcelProperty("加工内容")
|
||||
private String contents;
|
||||
|
||||
@ExcelProperty("箱种")
|
||||
private String xz;
|
||||
|
||||
@ExcelProperty("收容数")
|
||||
private int srs=0;
|
||||
|
||||
}
|
||||
|
|
@ -285,7 +285,12 @@ public class AsnDetailController {
|
|||
if(seq==2) {//收货上架
|
||||
XppRecord xppRecord = xppRecordService.saveXppRecord(ewm, point.getArea(), BillParmType.XPP_1001);
|
||||
AsnDetail asnDetail = xppRecordService.addAsnDetail(xppRecord);
|
||||
asnDetail.setPropC2("课税");
|
||||
String nrcs=xppRecord.getRelaCode();
|
||||
if(nrcs.equals("00209")||nrcs.equals("00609")||nrcs.equals("00683")||nrcs.equals("00809")){
|
||||
asnDetail.setPropC2(BaseStatus.BS);
|
||||
}else {
|
||||
asnDetail.setPropC2(BaseStatus.KS);
|
||||
}
|
||||
asnDetailRepository.save(asnDetail);
|
||||
asnDetailService.putawayInv(asnDetail.getId(), area.getId(), point.getId(), xppRecord.getNrs(), xppRecord.getEwm());
|
||||
}else if(seq==3){//制造投料
|
||||
|
|
@ -309,6 +314,12 @@ public class AsnDetailController {
|
|||
if(type.equals(BillParmType.XPP_1001)){//收货上架
|
||||
XppRecord xppRecord = xppRecordService.saveXppRecord(rk.get("ewm").toString(),point.getArea(),type);
|
||||
AsnDetail asnDetail = xppRecordService.addAsnDetail(xppRecord);
|
||||
String nrcs=xppRecord.getRelaCode();
|
||||
if(nrcs.equals("00209")||nrcs.equals("00609")||nrcs.equals("00683")||nrcs.equals("00809")){
|
||||
asnDetail.setPropC2(BaseStatus.BS);
|
||||
}else {
|
||||
asnDetail.setPropC2(BaseStatus.KS);
|
||||
}
|
||||
asnDetailService.putawayInv(asnDetail.getId(),point.getArea().getId(),pointId,xppRecord.getNrs(),xppRecord.getEwm());
|
||||
}else if(type.equals(BillParmType.XPP_2001)){//制造投料上架
|
||||
//查找线边库存是否存在,插入
|
||||
|
|
|
|||
|
|
@ -62,6 +62,11 @@ public class XppRecordViewDto implements Serializable {
|
|||
*/
|
||||
private String contents;
|
||||
|
||||
/**
|
||||
* 税别
|
||||
*/
|
||||
private String bonded;
|
||||
|
||||
/**
|
||||
* 纳入数
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -240,15 +240,16 @@ public class AsnDetailServiceImpl implements AsnDetailService {
|
|||
@Override
|
||||
public void putawayInv(@RequestBody Long asnDetailId, Long areaId, Long pointId, double recQty, String ewm) {
|
||||
AsnDetail d = asnDetailRepository.getById(asnDetailId);
|
||||
String propC2=null;
|
||||
String propC2=d.getPropC2();
|
||||
if(d.getPropC2()!=null){
|
||||
if(d.getPropC2().indexOf("EXP")>=0){
|
||||
propC2=BaseStatus.BS;
|
||||
}else if(d.getPropC2().indexOf("DOM")>=0){
|
||||
propC2=BaseStatus.KS;
|
||||
}
|
||||
}else{
|
||||
propC2="课税";
|
||||
}
|
||||
if(propC2==null||propC2.equals("")){
|
||||
propC2=BaseStatus.KS;
|
||||
}
|
||||
Area area =null;
|
||||
Point point = null;
|
||||
|
|
|
|||
|
|
@ -189,7 +189,6 @@ public class XppRecordServiceImpl implements XppRecordService {
|
|||
String sb=null;
|
||||
if(ewm.length()==85){//85为国产
|
||||
fzh=ewm.substring(i, i += 3);
|
||||
sb="课税";
|
||||
}
|
||||
//纳入场所包含0055不接收
|
||||
if(nrcs.indexOf("0055")==0){
|
||||
|
|
@ -301,7 +300,7 @@ public class XppRecordServiceImpl implements XppRecordService {
|
|||
|
||||
public Query getQuery(XppRecordQueryCriteria criteria,String type){
|
||||
String midSql=" xpp.`id`, dictd.label rela_supplier,it.code item_code,it.name item_name,xpp.`status`, xpp.`nrs`, xpp.`ddbh`, xpp.`fzh`, " +
|
||||
"xpp.`nr_date` ,xpp.`cjr`, xpp.`cj_date`,ik.prop_c1,it.extend_d3 srs,point.code inv_point_code, xpp.`ac`,xpp.contents, ott.bill_code bh_code,xpp.`bhr`, xpp.`fhr`, xpp.jsr, xpp.`zztlr`, xpp.`hctlr`," +
|
||||
"xpp.`nr_date` ,xpp.`cjr`, xpp.`cj_date`,ik.prop_c1,it.extend_d3 srs,point.code inv_point_code, xpp.`ac`,xpp.contents, ik.prop_c2 bonded,ott.bill_code bh_code,xpp.`bhr`, xpp.`fhr`, xpp.jsr, xpp.`zztlr`, xpp.`hctlr`," +
|
||||
"xpp.`bh_date`, xpp.`fh_date`, xpp.js_date,jskw.`code` jskw, xpp.`zztl_date`,zzkw.code zzkw, xpp.`tf_ly` tf_ly, xpp.`ly_data` ly_data, xpp.`hy_data` hy_data,xpp.be_fz," +
|
||||
"xpp.`area_code`,xpp.`ewm`, xpp.`description`,xpp.ly_code,xpp.receipt_code,xpp.count_code ";
|
||||
if(type.equals(BizStatus.QUERY_TOTAL)){
|
||||
|
|
|
|||
Loading…
Reference in New Issue