入库导入
parent
3e27fc399a
commit
8d901caf5f
|
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 Zheng Jie
|
* Copyright 2019-2020 Zheng Jie
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.youchain.basicdata.repository;
|
package com.youchain.basicdata.repository;
|
||||||
|
|
||||||
import com.youchain.basicdata.domain.Item;
|
import com.youchain.basicdata.domain.Item;
|
||||||
|
|
@ -24,10 +24,10 @@ import org.springframework.data.jpa.repository.Query;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
* @author houjianlan
|
||||||
* @author houjianlan
|
* @website https://eladmin.vip
|
||||||
* @date 2023-08-16
|
* @date 2023-08-16
|
||||||
**/
|
**/
|
||||||
public interface ItemRepository extends JpaRepository<Item, Long>, JpaSpecificationExecutor<Item> {
|
public interface ItemRepository extends JpaRepository<Item, Long>, JpaSpecificationExecutor<Item> {
|
||||||
@Query(value = "SELECT * FROM base_item i WHERE i.code=?1 and i.enabled=true", nativeQuery = true)
|
@Query(value = "SELECT * FROM base_item i WHERE i.code=?1 and i.enabled=true", nativeQuery = true)
|
||||||
Item findByCode(String code);
|
Item findByCode(String code);
|
||||||
|
|
@ -37,4 +37,7 @@ public interface ItemRepository extends JpaRepository<Item, Long>, JpaSpecificat
|
||||||
|
|
||||||
@Query(value = "SELECT DISTINCT b.* FROM `data_item_key` a INNER JOIN `base_item` b on a.item_id = b.id", nativeQuery = true)
|
@Query(value = "SELECT DISTINCT b.* FROM `data_item_key` a INNER JOIN `base_item` b on a.item_id = b.id", nativeQuery = true)
|
||||||
List<Item> quryOneItemAll();
|
List<Item> quryOneItemAll();
|
||||||
|
|
||||||
|
@Query("from Item i where i.code in (:itemCodes) and i.enabled=true ")
|
||||||
|
List<Item> queryByItemCodes(List<String> itemCodes);
|
||||||
}
|
}
|
||||||
|
|
@ -40,6 +40,7 @@ import com.youchain.businessdata.service.dto.AsnDto;
|
||||||
import com.youchain.config.FileProperties;
|
import com.youchain.config.FileProperties;
|
||||||
import com.youchain.exception.BadRequestException;
|
import com.youchain.exception.BadRequestException;
|
||||||
import com.youchain.exception.handler.ApiError;
|
import com.youchain.exception.handler.ApiError;
|
||||||
|
import com.youchain.exception.handler.ApiResult;
|
||||||
import com.youchain.modules.system.domain.DictDetail;
|
import com.youchain.modules.system.domain.DictDetail;
|
||||||
import com.youchain.modules.system.service.DictDetailService;
|
import com.youchain.modules.system.service.DictDetailService;
|
||||||
import com.youchain.modules.system.service.dto.DictQueryCriteria;
|
import com.youchain.modules.system.service.dto.DictQueryCriteria;
|
||||||
|
|
@ -67,6 +68,9 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
* @website https://eladmin.vip
|
||||||
|
|
@ -237,4 +241,19 @@ public class ImportDataController {
|
||||||
List<Map<String, Object>> readAll = reader.readAll();
|
List<Map<String, Object>> readAll = reader.readAll();
|
||||||
return readAll;
|
return readAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/importAsn")
|
||||||
|
@Log("导入asn")
|
||||||
|
@ApiOperation("导入asn")
|
||||||
|
@AnonymousAccess
|
||||||
|
public ResponseEntity<Object> importAsn(@RequestParam("file") MultipartFile file, @RequestParam("templateType") String templateType) {
|
||||||
|
try {
|
||||||
|
log.info("导入开始");
|
||||||
|
importDataService.importAsn(file, templateType);
|
||||||
|
return new ResponseEntity<>(ApiResult.success(OK.value(), "导入成功", null), HttpStatus.OK);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return new ResponseEntity<>(ApiResult.success(BAD_REQUEST.value(), e.getMessage(), null), HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,4 +55,12 @@ public interface ImportDataService {
|
||||||
void importPickInstruction(List<Map<String, Object>> readAll);
|
void importPickInstruction(List<Map<String, Object>> readAll);
|
||||||
|
|
||||||
void importCountMoveDetail(Long countId,List<Map<String, Object>> readAll);
|
void importCountMoveDetail(Long countId,List<Map<String, Object>> readAll);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 入库导入
|
||||||
|
*
|
||||||
|
* @param file 上传文件
|
||||||
|
*/
|
||||||
|
void importAsn(MultipartFile file, String templateType);
|
||||||
}
|
}
|
||||||
|
|
@ -112,4 +112,8 @@ public interface ItemService {
|
||||||
*/
|
*/
|
||||||
Item existItem(String itemCode);
|
Item existItem(String itemCode);
|
||||||
|
|
||||||
|
List<Item> queryByItemCodes(List<String> itemCodes);
|
||||||
|
|
||||||
|
Map<String, Item> queryByItemCodesToMap(List<String> itemCodes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -17,6 +17,7 @@ package com.youchain.basicdata.service.impl;
|
||||||
|
|
||||||
import cn.hutool.poi.excel.ExcelReader;
|
import cn.hutool.poi.excel.ExcelReader;
|
||||||
import cn.hutool.poi.excel.ExcelUtil;
|
import cn.hutool.poi.excel.ExcelUtil;
|
||||||
|
import cn.idev.excel.FastExcel;
|
||||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||||
import com.youchain.basicdata.domain.*;
|
import com.youchain.basicdata.domain.*;
|
||||||
import com.youchain.basicdata.repository.*;
|
import com.youchain.basicdata.repository.*;
|
||||||
|
|
@ -26,9 +27,8 @@ import com.youchain.basicdata.service.dto.AreaQueryCriteria;
|
||||||
import com.youchain.basicdata.service.mapstruct.AreaMapper;
|
import com.youchain.basicdata.service.mapstruct.AreaMapper;
|
||||||
import com.youchain.basicdata.service.mapstruct.PointMapper;
|
import com.youchain.basicdata.service.mapstruct.PointMapper;
|
||||||
import com.youchain.businessdata.domain.*;
|
import com.youchain.businessdata.domain.*;
|
||||||
import com.youchain.businessdata.repository.CountMoveRepository;
|
import com.youchain.businessdata.inputJson.imports.AsnImportForm;
|
||||||
import com.youchain.businessdata.repository.InventoryRepository;
|
import com.youchain.businessdata.repository.*;
|
||||||
import com.youchain.businessdata.repository.ItemKeyRepository;
|
|
||||||
import com.youchain.businessdata.service.*;
|
import com.youchain.businessdata.service.*;
|
||||||
import com.youchain.config.FileProperties;
|
import com.youchain.config.FileProperties;
|
||||||
import com.youchain.exception.BadRequestException;
|
import com.youchain.exception.BadRequestException;
|
||||||
|
|
@ -37,6 +37,9 @@ import com.youchain.modules.system.repository.DictDetailRepository;
|
||||||
import com.youchain.modules.system.repository.DictRepository;
|
import com.youchain.modules.system.repository.DictRepository;
|
||||||
import com.youchain.utils.*;
|
import com.youchain.utils.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
@ -51,6 +54,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author HJL
|
* @author HJL
|
||||||
|
|
@ -60,6 +64,7 @@ import java.util.*;
|
||||||
**/
|
**/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
public class ImportDataServiceImpl implements ImportDataService {
|
public class ImportDataServiceImpl implements ImportDataService {
|
||||||
private final FileProperties properties;
|
private final FileProperties properties;
|
||||||
private final BigItemRepository bigItemRepository;
|
private final BigItemRepository bigItemRepository;
|
||||||
|
|
@ -67,6 +72,8 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
private final ItemRepository itemRepository;
|
private final ItemRepository itemRepository;
|
||||||
private final DictDetailRepository dictDetailRepository;
|
private final DictDetailRepository dictDetailRepository;
|
||||||
private final PointRepository pointRepository;
|
private final PointRepository pointRepository;
|
||||||
|
private final AsnRepository asnRepository;
|
||||||
|
private final AsnDetailRepository asnDetailRepository;
|
||||||
private final PointService pointService;
|
private final PointService pointService;
|
||||||
private final AreaService areaService;
|
private final AreaService areaService;
|
||||||
private final BomAccountRepository bomAccountRepository;
|
private final BomAccountRepository bomAccountRepository;
|
||||||
|
|
@ -90,56 +97,56 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
private final CountMoveService countMoveService;
|
private final CountMoveService countMoveService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void importBomAccount(int row,Map<String, Object> readAll) {
|
public void importBomAccount(int row, Map<String, Object> readAll) {
|
||||||
String bigItemCode =readAll.get("完成品品番")==null?null:readAll.get("完成品品番").toString();
|
String bigItemCode = readAll.get("完成品品番") == null ? null : readAll.get("完成品品番").toString();
|
||||||
String station_type =readAll.get("工位")==null?null:readAll.get("工位").toString();
|
String station_type = readAll.get("工位") == null ? null : readAll.get("工位").toString();
|
||||||
String itemCode = readAll.get("部品品番")==null?null:readAll.get("部品品番").toString();
|
String itemCode = readAll.get("部品品番") == null ? null : readAll.get("部品品番").toString();
|
||||||
String ac = readAll.get("AC")==null?null:readAll.get("AC").toString();
|
String ac = readAll.get("AC") == null ? null : readAll.get("AC").toString();
|
||||||
String contents = readAll.get("加工内容")==null?null:readAll.get("加工内容").toString();
|
String contents = readAll.get("加工内容") == null ? null : readAll.get("加工内容").toString();
|
||||||
String single = readAll.get("单用")==null?null:readAll.get("单用").toString();
|
String single = readAll.get("单用") == null ? null : readAll.get("单用").toString();
|
||||||
String r_area_name = readAll.get("入库库区")==null?null:readAll.get("入库库区").toString();
|
String r_area_name = readAll.get("入库库区") == null ? null : readAll.get("入库库区").toString();
|
||||||
String c_area_name =readAll.get("出库库区")==null?null:readAll.get("出库库区").toString();
|
String c_area_name = readAll.get("出库库区") == null ? null : readAll.get("出库库区").toString();
|
||||||
String z_point_code =readAll.get("制造库位")==null?null:readAll.get("制造库位").toString();
|
String z_point_code = readAll.get("制造库位") == null ? null : readAll.get("制造库位").toString();
|
||||||
// String c_point_code =readAll.get("暂存库位")==null?null:readAll.get("暂存库位").toString();
|
// String c_point_code =readAll.get("暂存库位")==null?null:readAll.get("暂存库位").toString();
|
||||||
String out_type = readAll.get("出库类型")==null?null:readAll.get("出库类型").toString();
|
String out_type = readAll.get("出库类型") == null ? null : readAll.get("出库类型").toString();
|
||||||
String supplier = readAll.get("供应商")==null?null:readAll.get("供应商").toString();
|
String supplier = readAll.get("供应商") == null ? null : readAll.get("供应商").toString();
|
||||||
String bp_type = readAll.get("部品种类")==null?null:readAll.get("部品种类").toString();
|
String bp_type = readAll.get("部品种类") == null ? null : readAll.get("部品种类").toString();
|
||||||
|
|
||||||
BigItem bigItem = null;
|
BigItem bigItem = null;
|
||||||
if (bigItemCode.length() > 0) {
|
if (bigItemCode.length() > 0) {
|
||||||
bigItem = bigItemRepository.findByCode(bigItemCode);
|
bigItem = bigItemRepository.findByCode(bigItemCode);
|
||||||
if (bigItem == null) {
|
if (bigItem == null) {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, row+"行"+bigItemCode+"完成品品番无效");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, row + "行" + bigItemCode + "完成品品番无效");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, row+"行"+"请输入完成品品番");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, row + "行" + "请输入完成品品番");
|
||||||
}
|
}
|
||||||
Item item = null;
|
Item item = null;
|
||||||
if (itemCode.length() > 0) {
|
if (itemCode.length() > 0) {
|
||||||
item = itemRepository.findByCode(itemCode);
|
item = itemRepository.findByCode(itemCode);
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, row+"行"+itemCode+"部品品番无效");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, row + "行" + itemCode + "部品品番无效");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, row+"行"+"请输入部品品番");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, row + "行" + "请输入部品品番");
|
||||||
}
|
}
|
||||||
Area r_area = null;
|
Area r_area = null;
|
||||||
if (r_area_name.length() > 0) {
|
if (r_area_name.length() > 0) {
|
||||||
r_area = areaRepository.getByName(r_area_name);
|
r_area = areaRepository.getByName(r_area_name);
|
||||||
if (r_area == null) {
|
if (r_area == null) {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, row+"行"+r_area_name+"入库库区无效");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, row + "行" + r_area_name + "入库库区无效");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, row+"行"+"请输入入库库区");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, row + "行" + "请输入入库库区");
|
||||||
}
|
}
|
||||||
Area c_area = null;
|
Area c_area = null;
|
||||||
if (c_area_name.length() > 0) {
|
if (c_area_name.length() > 0) {
|
||||||
c_area = areaRepository.getByName(c_area_name);
|
c_area = areaRepository.getByName(c_area_name);
|
||||||
if (c_area == null) {
|
if (c_area == null) {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, row+"行"+c_area_name+"出库库区无效");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, row + "行" + c_area_name + "出库库区无效");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, row+"行"+"请输入出库库区");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, row + "行" + "请输入出库库区");
|
||||||
}
|
}
|
||||||
// Point c_point = null;
|
// Point c_point = null;
|
||||||
// if (c_point_code!=null&&!c_point_code.equals("")) {
|
// if (c_point_code!=null&&!c_point_code.equals("")) {
|
||||||
|
|
@ -149,7 +156,7 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
Point z_point = null;
|
Point z_point = null;
|
||||||
if (z_point_code!=null&&!z_point_code.equals("")) {
|
if (z_point_code != null && !z_point_code.equals("")) {
|
||||||
z_point = pointRepository.findByCode(z_point_code);
|
z_point = pointRepository.findByCode(z_point_code);
|
||||||
if (z_point == null) {
|
if (z_point == null) {
|
||||||
// z_point = pointService.createPoint(z_point_code, "ZZKW", r_area,c_point);
|
// z_point = pointService.createPoint(z_point_code, "ZZKW", r_area,c_point);
|
||||||
|
|
@ -157,9 +164,9 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, row+"行"+"请输入制造库位");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, row + "行" + "请输入制造库位");
|
||||||
}
|
}
|
||||||
Boolean isNew= Boolean.FALSE;
|
Boolean isNew = Boolean.FALSE;
|
||||||
BomAccount bomAccount = bomAccountRepository.findByOnly(bigItem.getId(), item.getId(), r_area.getId(), z_point.getId());
|
BomAccount bomAccount = bomAccountRepository.findByOnly(bigItem.getId(), item.getId(), r_area.getId(), z_point.getId());
|
||||||
if (bomAccount == null) {
|
if (bomAccount == null) {
|
||||||
bomAccount = new BomAccount();
|
bomAccount = new BomAccount();
|
||||||
|
|
@ -169,7 +176,7 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
bomAccount.setDept(r_area.getDept());
|
bomAccount.setDept(r_area.getDept());
|
||||||
bomAccount.setZPoint(z_point);
|
bomAccount.setZPoint(z_point);
|
||||||
bomAccount.setBp_type(bp_type);
|
bomAccount.setBp_type(bp_type);
|
||||||
isNew=Boolean.TRUE;
|
isNew = Boolean.TRUE;
|
||||||
}
|
}
|
||||||
bomAccount.setStationType(station_type);
|
bomAccount.setStationType(station_type);
|
||||||
bomAccount.setCArea(c_area);
|
bomAccount.setCArea(c_area);
|
||||||
|
|
@ -179,24 +186,24 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
bomAccount.setSingles(Integer.parseInt(single));
|
bomAccount.setSingles(Integer.parseInt(single));
|
||||||
bomAccount.setOutType(out_type);
|
bomAccount.setOutType(out_type);
|
||||||
bomAccount.setSupplier(supplier);
|
bomAccount.setSupplier(supplier);
|
||||||
if(isNew){
|
if (isNew) {
|
||||||
bomAccountService.create(bomAccount);
|
bomAccountService.create(bomAccount);
|
||||||
bomAccountLogService.copyBomAccount(bomAccount.getId(),"import_add");
|
bomAccountLogService.copyBomAccount(bomAccount.getId(), "import_add");
|
||||||
}else{
|
} else {
|
||||||
bomAccountService.update(bomAccount);
|
bomAccountService.update(bomAccount);
|
||||||
bomAccountLogService.copyBomAccount(bomAccount.getId(),"import_update");
|
bomAccountLogService.copyBomAccount(bomAccount.getId(), "import_update");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String importItem(Map<String, Object> readAll) {
|
public String importItem(Map<String, Object> readAll) {
|
||||||
String re = "";
|
String re = "";
|
||||||
String code = readAll.get("品番")==null?null:readAll.get("品番").toString();
|
String code = readAll.get("品番") == null ? null : readAll.get("品番").toString();
|
||||||
String name = 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 specs = readAll.get("规格") == null ? null : readAll.get("规格").toString();
|
||||||
String unit = 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 hz = readAll.get("荷资") == null ? null : readAll.get("荷资").toString();
|
||||||
String srs =readAll.get("收容数")==null?null:readAll.get("收容数").toString();
|
String srs = readAll.get("收容数") == null ? null : readAll.get("收容数").toString();
|
||||||
if (code.length() > 0) {
|
if (code.length() > 0) {
|
||||||
Item item = itemRepository.findByAllCode(code);
|
Item item = itemRepository.findByAllCode(code);
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
|
|
@ -210,14 +217,14 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
item.setName(name);
|
item.setName(name);
|
||||||
item.setExtendStr3(hz);
|
item.setExtendStr3(hz);
|
||||||
item.setExtendD3(Double.parseDouble(srs));
|
item.setExtendD3(Double.parseDouble(srs));
|
||||||
if (unit!=null&&!unit.equals("")) {
|
if (unit != null && !unit.equals("")) {
|
||||||
DictDetail dictDetail = dictDetailRepository.findByDictAndLabel("item_unit", unit);
|
DictDetail dictDetail = dictDetailRepository.findByDictAndLabel("item_unit", unit);
|
||||||
item.setUnit(dictDetail.getValue());
|
item.setUnit(dictDetail.getValue());
|
||||||
}
|
}
|
||||||
item.setSpecs(specs);
|
item.setSpecs(specs);
|
||||||
if (re.equals("a")){
|
if (re.equals("a")) {
|
||||||
itemRepository.save(item);
|
itemRepository.save(item);
|
||||||
}else if (re.equals("b")){
|
} else if (re.equals("b")) {
|
||||||
itemService.update(item);
|
itemService.update(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -227,11 +234,11 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
@Override
|
@Override
|
||||||
public String importBigItem(Map<String, Object> readAll) {
|
public String importBigItem(Map<String, Object> readAll) {
|
||||||
String re = "";
|
String re = "";
|
||||||
String code =readAll.get("完成品品番")==null?null:readAll.get("完成品品番").toString().trim();
|
String code = readAll.get("完成品品番") == null ? null : readAll.get("完成品品番").toString().trim();
|
||||||
String name = readAll.get("完成品型式名")==null?null:readAll.get("完成品型式名").toString().trim();
|
String name = readAll.get("完成品型式名") == null ? null : readAll.get("完成品型式名").toString().trim();
|
||||||
String models =readAll.get("机种")==null?null:readAll.get("机种").toString().trim();
|
String models = readAll.get("机种") == null ? null : readAll.get("机种").toString().trim();
|
||||||
String country =readAll.get("国别")==null?null:readAll.get("国别").toString().trim();
|
String country = readAll.get("国别") == null ? null : readAll.get("国别").toString().trim();
|
||||||
String outboundType =readAll.get("出库类型")==null?null:readAll.get("出库类型").toString().trim();
|
String outboundType = readAll.get("出库类型") == null ? null : readAll.get("出库类型").toString().trim();
|
||||||
if (code.length() > 0) {
|
if (code.length() > 0) {
|
||||||
BigItem bigItem = bigItemRepository.findByCode(code);
|
BigItem bigItem = bigItemRepository.findByCode(code);
|
||||||
if (bigItem == null) {
|
if (bigItem == null) {
|
||||||
|
|
@ -247,9 +254,9 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
bigItem.setCountry(country);
|
bigItem.setCountry(country);
|
||||||
bigItem.setOutboundType(outboundType);
|
bigItem.setOutboundType(outboundType);
|
||||||
bigItem.setEnabled(true);
|
bigItem.setEnabled(true);
|
||||||
if (re.equals("a")){
|
if (re.equals("a")) {
|
||||||
bigItemService.create(bigItem);
|
bigItemService.create(bigItem);
|
||||||
}else if (re.equals("b")){
|
} else if (re.equals("b")) {
|
||||||
bigItemService.update(bigItem);
|
bigItemService.update(bigItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -259,23 +266,23 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
@Override
|
@Override
|
||||||
public String importAsnDetail(Map<String, Object> readAll, Asn asn) {
|
public String importAsnDetail(Map<String, Object> readAll, Asn asn) {
|
||||||
String re = "";
|
String re = "";
|
||||||
String code =readAll.get("品番")==null?null:readAll.get("品番").toString();
|
String code = readAll.get("品番") == null ? null : readAll.get("品番").toString();
|
||||||
String qty = readAll.get("数量")==null?null:readAll.get("数量").toString();
|
String qty = readAll.get("数量") == null ? null : readAll.get("数量").toString();
|
||||||
String zzkw = readAll.get("制造库位")==null?null:readAll.get("制造库位").toString();
|
String zzkw = readAll.get("制造库位") == null ? null : readAll.get("制造库位").toString();
|
||||||
if (code.length() > 0) {
|
if (code.length() > 0) {
|
||||||
Item item = itemRepository.findByCode(code);
|
Item item = itemRepository.findByCode(code);
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
return "部品品番无效";
|
return "部品品番无效";
|
||||||
}
|
}
|
||||||
Point point=pointService.getPoint(zzkw,null,null,null);
|
Point point = pointService.getPoint(zzkw, null, null, null);
|
||||||
if(point==null){
|
if (point == null) {
|
||||||
return "制造库位无效";
|
return "制造库位无效";
|
||||||
}
|
}
|
||||||
List<BomAccount> boms= bomAccountRepository.queryBomUnique(asn.getArea().getId(),item.getId(), point.getId());
|
List<BomAccount> boms = bomAccountRepository.queryBomUnique(asn.getArea().getId(), item.getId(), point.getId());
|
||||||
if(boms.size()<=0){
|
if (boms.size() <= 0) {
|
||||||
return "BOM工位清单不存在";
|
return "BOM工位清单不存在";
|
||||||
}
|
}
|
||||||
AsnDetail asnDetail=new AsnDetail();
|
AsnDetail asnDetail = new AsnDetail();
|
||||||
asnDetail.setAsn(asn);
|
asnDetail.setAsn(asn);
|
||||||
asnDetail.setDept(UserUtils.getDept());
|
asnDetail.setDept(UserUtils.getDept());
|
||||||
asnDetail.setStatus(BizStatus.OPEN);
|
asnDetail.setStatus(BizStatus.OPEN);
|
||||||
|
|
@ -283,7 +290,7 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
asnDetail.setPoint(point);
|
asnDetail.setPoint(point);
|
||||||
asnDetail.setOrderQty(Double.parseDouble(qty));
|
asnDetail.setOrderQty(Double.parseDouble(qty));
|
||||||
asnDetailService.create(asnDetail);
|
asnDetailService.create(asnDetail);
|
||||||
asn.setOrderQuantity(asn.getOrderQuantity()+asnDetail.getOrderQty());
|
asn.setOrderQuantity(asn.getOrderQuantity() + asnDetail.getOrderQty());
|
||||||
asnService.update(asn);
|
asnService.update(asn);
|
||||||
}
|
}
|
||||||
return re;
|
return re;
|
||||||
|
|
@ -301,24 +308,24 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
return "部品品番无效";
|
return "部品品番无效";
|
||||||
}
|
}
|
||||||
Point point=pointService.getPoint(zzkw,null,null,null);
|
Point point = pointService.getPoint(zzkw, null, null, null);
|
||||||
Long zzkwId=null;
|
Long zzkwId = null;
|
||||||
if(point==null){
|
if (point == null) {
|
||||||
if(pickTicket.getArea().getBexb()) {
|
if (pickTicket.getArea().getBexb()) {
|
||||||
return "制造库位无效";
|
return "制造库位无效";
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
zzkwId=point.getId();
|
zzkwId = point.getId();
|
||||||
}
|
}
|
||||||
// List<BomAccount> boms= bomAccountRepository.queryBomUnique(pickTicket.getArea().getId(),item.getId(), point.getId());
|
// List<BomAccount> boms= bomAccountRepository.queryBomUnique(pickTicket.getArea().getId(),item.getId(), point.getId());
|
||||||
// if(boms.size()<=0){
|
// if(boms.size()<=0){
|
||||||
// return "BOM工位清单不存在";
|
// return "BOM工位清单不存在";
|
||||||
// }
|
// }
|
||||||
Double xbQty=inventoryService.getInvQty(item.getId(),pickTicket.getArea().getId(),zzkwId);
|
Double xbQty = inventoryService.getInvQty(item.getId(), pickTicket.getArea().getId(), zzkwId);
|
||||||
if(xbQty.intValue()<Double.parseDouble(qty)){
|
if (xbQty.intValue() < Double.parseDouble(qty)) {
|
||||||
return "库存不足";
|
return "库存不足";
|
||||||
}
|
}
|
||||||
PickDetail pickDetail=new PickDetail();
|
PickDetail pickDetail = new PickDetail();
|
||||||
pickDetail.setPickTicket(pickTicket);
|
pickDetail.setPickTicket(pickTicket);
|
||||||
pickDetail.setDept(UserUtils.getDept());
|
pickDetail.setDept(UserUtils.getDept());
|
||||||
pickDetail.setStatus(BizStatus.OPEN);
|
pickDetail.setStatus(BizStatus.OPEN);
|
||||||
|
|
@ -328,7 +335,7 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
pickDetail.setArea(pickTicket.getArea());
|
pickDetail.setArea(pickTicket.getArea());
|
||||||
pickDetail.setOrderQty(Double.parseDouble(qty));
|
pickDetail.setOrderQty(Double.parseDouble(qty));
|
||||||
pickDetailService.create(pickDetail);
|
pickDetailService.create(pickDetail);
|
||||||
pickTicket.setOrderQuantity(pickTicket.getOrderQuantity()+pickDetail.getOrderQty());
|
pickTicket.setOrderQuantity(pickTicket.getOrderQuantity() + pickDetail.getOrderQty());
|
||||||
pickTicketService.update(pickTicket);
|
pickTicketService.update(pickTicket);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -337,33 +344,33 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void importPickInstruction(List<Map<String, Object>> readAll) {
|
public void importPickInstruction(List<Map<String, Object>> readAll) {
|
||||||
String zsCode=codeUtils.getCode_yyMMdd("ZS",3);
|
String zsCode = codeUtils.getCode_yyMMdd("ZS", 3);
|
||||||
BillType billType = billTypeRepository.findByName(BaseStatus.BT_SGDD);
|
BillType billType = billTypeRepository.findByName(BaseStatus.BT_SGDD);
|
||||||
for (int i = 0; i < readAll.size(); i++) {
|
for (int i = 0; i < readAll.size(); i++) {
|
||||||
Map<String, Object> map=readAll.get(i);
|
Map<String, Object> map = readAll.get(i);
|
||||||
String code =map.get("品番")==null?null:map.get("品番").toString().trim();
|
String code = map.get("品番") == null ? null : map.get("品番").toString().trim();
|
||||||
String qty = map.get("数量")==null?null:map.get("数量").toString().trim();
|
String qty = map.get("数量") == null ? null : map.get("数量").toString().trim();
|
||||||
String areaName =map.get("纳所")==null?null:map.get("纳所").toString().trim();
|
String areaName = map.get("纳所") == null ? null : map.get("纳所").toString().trim();
|
||||||
if (code.length() > 0) {
|
if (code.length() > 0) {
|
||||||
PickInstruction pickInstruction=new PickInstruction();
|
PickInstruction pickInstruction = new PickInstruction();
|
||||||
Item item = itemRepository.findByCode(code);
|
Item item = itemRepository.findByCode(code);
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, i+1+"行"+code+"部品品番无效");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, i + 1 + "行" + code + "部品品番无效");
|
||||||
}
|
}
|
||||||
Area r_area = null;
|
Area r_area = null;
|
||||||
if (areaName.length() > 0) {
|
if (areaName.length() > 0) {
|
||||||
r_area = areaRepository.getByName(areaName);
|
r_area = areaRepository.getByName(areaName);
|
||||||
if (r_area == null) {
|
if (r_area == null) {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, i+1+"行"+areaName+"纳所无效");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, i + 1 + "行" + areaName + "纳所无效");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, i+1+"行"+"请输入纳所");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, i + 1 + "行" + "请输入纳所");
|
||||||
}
|
}
|
||||||
List<BomAccount> boms= bomAccountRepository.getBomList(r_area.getId(),item.getId());
|
List<BomAccount> boms = bomAccountRepository.getBomList(r_area.getId(), item.getId());
|
||||||
if(boms.size()<=0){
|
if (boms.size() <= 0) {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, i+1+"行"+code+"找不到BOM清单");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, i + 1 + "行" + code + "找不到BOM清单");
|
||||||
}
|
}
|
||||||
BomAccount bomAccount=boms.get(0);
|
BomAccount bomAccount = boms.get(0);
|
||||||
pickInstruction.setAllocationNumber(zsCode);
|
pickInstruction.setAllocationNumber(zsCode);
|
||||||
pickInstruction.setOutKType(billType);
|
pickInstruction.setOutKType(billType);
|
||||||
pickInstruction.setItem(item);
|
pickInstruction.setItem(item);
|
||||||
|
|
@ -376,53 +383,215 @@ public class ImportDataServiceImpl implements ImportDataService {
|
||||||
pickInstruction.setZzkwPoint(bomAccount.getZPoint());
|
pickInstruction.setZzkwPoint(bomAccount.getZPoint());
|
||||||
pickInstruction.setAllocationDate(new Timestamp(new Date().getTime()));
|
pickInstruction.setAllocationDate(new Timestamp(new Date().getTime()));
|
||||||
pickInstructionService.create(pickInstruction);
|
pickInstructionService.create(pickInstruction);
|
||||||
}else{
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void importCountMoveDetail(Long countId,List<Map<String, Object>> readAll) {
|
public void importCountMoveDetail(Long countId, List<Map<String, Object>> readAll) {
|
||||||
for (int i = 0; i < readAll.size(); i++) {
|
for (int i = 0; i < readAll.size(); i++) {
|
||||||
Map<String, Object> map=readAll.get(i);
|
Map<String, Object> map = readAll.get(i);
|
||||||
String code =map.get("品番")==null?null:map.get("品番").toString().trim();
|
String code = map.get("品番") == null ? null : map.get("品番").toString().trim();
|
||||||
String src_point_code = map.get("原库位")==null?null:map.get("原库位").toString().trim();
|
String src_point_code = map.get("原库位") == null ? null : map.get("原库位").toString().trim();
|
||||||
String dst_point_code = map.get("目标库位")==null?null:map.get("目标库位").toString().trim();
|
String dst_point_code = map.get("目标库位") == null ? null : map.get("目标库位").toString().trim();
|
||||||
String pc1 = map.get("批次号")==null?null:map.get("批次号").toString().trim();
|
String pc1 = map.get("批次号") == null ? null : map.get("批次号").toString().trim();
|
||||||
if (code.length() > 0) {
|
if (code.length() > 0) {
|
||||||
CountMove countMove=countMoveRepository.getById(countId);
|
CountMove countMove = countMoveRepository.getById(countId);
|
||||||
Item item = itemRepository.findByCode(code);
|
Item item = itemRepository.findByCode(code);
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, i+1+"行"+code+"部品品番无效");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, i + 1 + "行" + code + "部品品番无效");
|
||||||
}
|
}
|
||||||
Point point=pointService.getPoint(src_point_code,null,null,countMove.getSrcArea().getCode());
|
Point point = pointService.getPoint(src_point_code, null, null, countMove.getSrcArea().getCode());
|
||||||
if (point == null) {
|
if (point == null) {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, i+1+"行"+src_point_code+"原库位不存在");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, i + 1 + "行" + src_point_code + "原库位不存在");
|
||||||
}
|
}
|
||||||
List<ItemKey> itemKeyList=itemKeyRepository.queryItemKey(item.getId(),pc1);
|
List<ItemKey> itemKeyList = itemKeyRepository.queryItemKey(item.getId(), pc1);
|
||||||
if (itemKeyList.size() == 0) {
|
if (itemKeyList.size() == 0) {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, i+1+"行"+code+"不存在库存");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, i + 1 + "行" + code + "不存在库存");
|
||||||
}
|
}
|
||||||
ItemKey ik=itemKeyList.get(0);
|
ItemKey ik = itemKeyList.get(0);
|
||||||
List<Inventory> inventoryList=inventoryRepository.queryInventoryPointIk(point.getId(),ik.getId());
|
List<Inventory> inventoryList = inventoryRepository.queryInventoryPointIk(point.getId(), ik.getId());
|
||||||
if (inventoryList.size() == 0) {
|
if (inventoryList.size() == 0) {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, i+1+"行"+code+"不存在库存");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, i + 1 + "行" + code + "不存在库存");
|
||||||
}
|
}
|
||||||
Point dstPoint=null;
|
Point dstPoint = null;
|
||||||
if(dst_point_code==null){
|
if (dst_point_code == null) {
|
||||||
dstPoint=countMove.getDstPoint();
|
dstPoint = countMove.getDstPoint();
|
||||||
}else{
|
} else {
|
||||||
dstPoint=pointService.getPoint(dst_point_code,null,null,countMove.getDstArea().getCode());
|
dstPoint = pointService.getPoint(dst_point_code, null, null, countMove.getDstArea().getCode());
|
||||||
if (point == null) {
|
if (point == null) {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, i+1+"行"+dst_point_code+"目标库位不存在");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, i + 1 + "行" + dst_point_code + "目标库位不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
countMoveService.createCountDetail(countMove,inventoryList.get(0),ik,dstPoint);
|
countMoveService.createCountDetail(countMove, inventoryList.get(0), ik, dstPoint);
|
||||||
}else{
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void importAsn(MultipartFile file, String templateType) {
|
||||||
|
// 验证模板类型
|
||||||
|
if (StringUtils.isEmpty(templateType)) {
|
||||||
|
throw new BadRequestException("模板类型不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证模板类型是否有效
|
||||||
|
if (!isValidTemplateType(templateType)) {
|
||||||
|
throw new BadRequestException("无效的模板类型: " + templateType);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<AsnImportForm> dataList;
|
||||||
|
try {
|
||||||
|
dataList = FastExcel.read(file.getInputStream()).head(AsnImportForm.class)
|
||||||
|
.sheet()
|
||||||
|
.doReadSync();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new BadRequestException("数据格式存在问题,无法读取");
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(dataList)) {
|
||||||
|
throw new BadRequestException("数据为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据模板类型进行不同的处理
|
||||||
|
switch (templateType) {
|
||||||
|
case "template1":
|
||||||
|
template1Import(dataList);
|
||||||
|
break;
|
||||||
|
case "template2":
|
||||||
|
template2Import(dataList);
|
||||||
|
break;
|
||||||
|
case "template3":
|
||||||
|
template3Import(dataList);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new BadRequestException("不支持的模板类型: " + templateType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证模板类型是否有效
|
||||||
|
*/
|
||||||
|
private boolean isValidTemplateType(String templateType) {
|
||||||
|
return "template1".equals(templateType) ||
|
||||||
|
"template2".equals(templateType) ||
|
||||||
|
"template3".equals(templateType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理标准导入
|
||||||
|
*/
|
||||||
|
private void template1Import(List<AsnImportForm> dataList) {
|
||||||
|
// TODO: 实现标准导入逻辑
|
||||||
|
log.info("处理标准导入,数据条数: {}", dataList.size());
|
||||||
|
|
||||||
|
//获取文件中所有的品番
|
||||||
|
List<String> itemCodes = dataList.stream().map(AsnImportForm::getPartNo).collect(Collectors.toList());
|
||||||
|
|
||||||
|
//验证品番
|
||||||
|
Map<String, Item> exitItemMap = validateItem(itemCodes);
|
||||||
|
|
||||||
|
//获取文件中所有的托盘号
|
||||||
|
List<String> codes = dataList.stream().map(AsnImportForm::getCNo).collect(Collectors.toList());
|
||||||
|
|
||||||
|
//验证托盘号
|
||||||
|
validateAsn(codes);
|
||||||
|
|
||||||
|
Map<String, Asn> asnMap = new HashMap<>();
|
||||||
|
List<Asn> insertToAsn=new ArrayList<>();//批量新增ASN
|
||||||
|
List<AsnDetail> insertToAsnDetail=new ArrayList<>();
|
||||||
|
for (AsnImportForm data : dataList) {
|
||||||
|
String relatedBill1 = data.getInvoiceNo();//发票号
|
||||||
|
String propC2 = data.getBoi();//税别
|
||||||
|
String po = data.getPoNo();//订单号
|
||||||
|
String itemCode = data.getPartNo();//品番
|
||||||
|
String remark = data.getDescription();//描述
|
||||||
|
Double orderQty = data.getQty();//数量
|
||||||
|
String code = data.getCNo();//托盘号
|
||||||
|
|
||||||
|
Asn asn = null;
|
||||||
|
if (asnMap.containsKey(code)) {
|
||||||
|
asn=asnMap.get(code);
|
||||||
|
asn.setOrderQuantity(asn.getOrderQuantity() + orderQty);
|
||||||
|
}else{
|
||||||
|
asn = Asn.builder()
|
||||||
|
.relatedBill1(relatedBill1)
|
||||||
|
.code(code)
|
||||||
|
.status(BizStatus.OPEN)
|
||||||
|
.orderDate(new Timestamp(new Date().getTime()))
|
||||||
|
.orderQuantity(orderQty)
|
||||||
|
.build();
|
||||||
|
asnMap.put(code, asn);
|
||||||
|
insertToAsn.add(asn);
|
||||||
|
}
|
||||||
|
|
||||||
|
AsnDetail asnDetail = AsnDetail.builder()
|
||||||
|
.propC2(propC2)
|
||||||
|
.po(po)
|
||||||
|
.item(exitItemMap.get(itemCode))
|
||||||
|
.remark( remark)
|
||||||
|
.orderQty(orderQty)
|
||||||
|
.asn(asn)
|
||||||
|
.build();
|
||||||
|
insertToAsnDetail.add(asnDetail);
|
||||||
|
}
|
||||||
|
if(!insertToAsn.isEmpty()){
|
||||||
|
asnRepository.saveAll(insertToAsn);
|
||||||
|
}
|
||||||
|
if(!insertToAsnDetail.isEmpty()){
|
||||||
|
asnDetailRepository.saveAll(insertToAsnDetail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理大物导入
|
||||||
|
*/
|
||||||
|
private void template2Import(List<AsnImportForm> dataList) {
|
||||||
|
// TODO: 实现大物导入逻辑
|
||||||
|
log.info("处理大物导入,数据条数: {}", dataList.size());
|
||||||
|
// 这里添加大物导入的具体业务逻辑
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理发票箱单导入
|
||||||
|
*/
|
||||||
|
private void template3Import(List<AsnImportForm> dataList) {
|
||||||
|
// TODO: 实现发票箱单导入逻辑
|
||||||
|
log.info("处理发票箱单导入,数据条数: {}", dataList.size());
|
||||||
|
// 这里添加发票箱单导入的具体业务逻辑
|
||||||
|
}
|
||||||
|
|
||||||
|
//验证品番
|
||||||
|
private Map<String, Item> validateItem(List<String> itemCodes) {
|
||||||
|
Map<String, Item> exitItemMap = itemService.queryByItemCodesToMap(itemCodes);
|
||||||
|
if (exitItemMap.isEmpty()) {
|
||||||
|
throw new BadRequestException(itemCodes + "品番不存在或已失效");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> existingItemCodes = new ArrayList<>(exitItemMap.keySet());
|
||||||
|
|
||||||
|
// 获取两个集合的非交集说明品番不存在或失效,直接提示
|
||||||
|
List<String> difference = SmartStringUtil.getDifference(itemCodes, existingItemCodes);
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(difference)) {
|
||||||
|
throw new BadRequestException(difference + "品番不存在或已失效");
|
||||||
|
}
|
||||||
|
return exitItemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
//验证ASN单号
|
||||||
|
private void validateAsn(List<String> codes) {
|
||||||
|
Map<String, Asn> exitAsnMap = asnService.queryByasnCodesToMap(codes);
|
||||||
|
List<String> existingAsnCodes = new ArrayList<>(exitAsnMap.keySet());
|
||||||
|
// 获取两个集合的交集说明ASN重复导入了,直接提示
|
||||||
|
List<String> difference = SmartStringUtil.getIntersection(codes, existingAsnCodes);
|
||||||
|
if (CollectionUtils.isNotEmpty(difference)) {
|
||||||
|
throw new BadRequestException(difference + "托盘号已导入,请勿重复导入");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package com.youchain.basicdata.service.impl;
|
package com.youchain.basicdata.service.impl;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import com.youchain.basicdata.domain.Item;
|
import com.youchain.basicdata.domain.Item;
|
||||||
import com.youchain.basicdata.domain.Point;
|
import com.youchain.basicdata.domain.Point;
|
||||||
import com.youchain.basicdata.service.dto.ItemSmallDto;
|
import com.youchain.basicdata.service.dto.ItemSmallDto;
|
||||||
|
|
@ -25,25 +26,25 @@ import com.youchain.basicdata.service.ItemService;
|
||||||
import com.youchain.basicdata.service.dto.ItemDto;
|
import com.youchain.basicdata.service.dto.ItemDto;
|
||||||
import com.youchain.basicdata.service.dto.ItemQueryCriteria;
|
import com.youchain.basicdata.service.dto.ItemQueryCriteria;
|
||||||
import com.youchain.basicdata.service.mapstruct.ItemMapper;
|
import com.youchain.basicdata.service.mapstruct.ItemMapper;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import org.springframework.data.domain.Example;
|
import org.springframework.data.domain.Example;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author houjianlan
|
||||||
* @website https://eladmin.vip
|
* @website https://eladmin.vip
|
||||||
* @description 服务实现
|
* @description 服务实现
|
||||||
* @author houjianlan
|
|
||||||
* @date 2023-08-07
|
* @date 2023-08-07
|
||||||
**/
|
**/
|
||||||
@Service
|
@Service
|
||||||
|
|
@ -55,21 +56,21 @@ public class ItemServiceImpl implements ItemService {
|
||||||
private final EntityManager entityMapper;
|
private final EntityManager entityMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String,Object> queryAll(ItemQueryCriteria criteria, Pageable pageable){
|
public Map<String, Object> queryAll(ItemQueryCriteria criteria, Pageable pageable) {
|
||||||
Page<Item> page = itemRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
Page<Item> page = itemRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||||
return PageUtil.toPage(page.map(itemMapper::toDto));
|
return PageUtil.toPage(page.map(itemMapper::toDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemDto> queryAll(ItemQueryCriteria criteria){
|
public List<ItemDto> queryAll(ItemQueryCriteria criteria) {
|
||||||
return itemMapper.toDto(itemRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
return itemMapper.toDto(itemRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ItemDto findById(Long id) {
|
public ItemDto findById(Long id) {
|
||||||
Item item = itemRepository.findById(id).orElseGet(Item::new);
|
Item item = itemRepository.findById(id).orElseGet(Item::new);
|
||||||
ValidationUtil.isNull(item.getId(),"Item","id",id);
|
ValidationUtil.isNull(item.getId(), "Item", "id", id);
|
||||||
return itemMapper.toDto(item);
|
return itemMapper.toDto(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,16 +80,17 @@ public class ItemServiceImpl implements ItemService {
|
||||||
Item item = itemRepository.findById(id).orElseGet(Item::new);
|
Item item = itemRepository.findById(id).orElseGet(Item::new);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public ItemDto findByCode(String itemCode) {
|
public ItemDto findByCode(String itemCode) {
|
||||||
Item itemExample = new Item();
|
Item itemExample = new Item();
|
||||||
itemExample.setCode(itemCode);
|
itemExample.setCode(itemCode);
|
||||||
Example<Item> example = Example.of(itemExample);
|
Example<Item> example = Example.of(itemExample);
|
||||||
List<Item> its=itemRepository.findAll(example);
|
List<Item> its = itemRepository.findAll(example);
|
||||||
if(its.size()>0){
|
if (its.size() > 0) {
|
||||||
return itemMapper.toDto(its.get(0));
|
return itemMapper.toDto(its.get(0));
|
||||||
}else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +105,7 @@ public class ItemServiceImpl implements ItemService {
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(Item resources) {
|
public void update(Item resources) {
|
||||||
Item item = itemRepository.findById(resources.getId()).orElseGet(Item::new);
|
Item item = itemRepository.findById(resources.getId()).orElseGet(Item::new);
|
||||||
ValidationUtil.isNull( item.getId(),"Item","id",resources.getId());
|
ValidationUtil.isNull(item.getId(), "Item", "id", resources.getId());
|
||||||
item.copy(resources);
|
item.copy(resources);
|
||||||
itemRepository.save(item);
|
itemRepository.save(item);
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +119,7 @@ public class ItemServiceImpl implements ItemService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void download(List<ItemDto> all, HttpServletResponse response) throws Exception {
|
public void download(List<ItemDto> all, HttpServletResponse response) throws Exception {
|
||||||
List<Map<String, Object>> list= ExcelDownUtils.CreateMap(all,"Item");
|
List<Map<String, Object>> list = ExcelDownUtils.CreateMap(all, "Item");
|
||||||
FileUtil.downloadExcel(list, response);
|
FileUtil.downloadExcel(list, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,14 +130,35 @@ public class ItemServiceImpl implements ItemService {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item existItem(String itemCode){
|
public Item existItem(String itemCode) {
|
||||||
String hql="select it from Item it where it.code='"+itemCode+"'";
|
String hql = "select it from Item it where it.code='" + itemCode + "'";
|
||||||
Query query=entityMapper.createQuery(hql);
|
Query query = entityMapper.createQuery(hql);
|
||||||
List<Item> its=query.getResultList();
|
List<Item> its = query.getResultList();
|
||||||
if(its.size()>0){
|
if (its.size() > 0) {
|
||||||
return its.get(0);
|
return its.get(0);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Item> queryByItemCodes(List<String> itemCodes) {
|
||||||
|
if (CollectionUtils.isEmpty(itemCodes)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
//去重
|
||||||
|
itemCodes = itemCodes.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||||
|
return itemRepository.queryByItemCodes(itemCodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Item> queryByItemCodesToMap(List<String> itemCodes) {
|
||||||
|
List<Item> items = queryByItemCodes(itemCodes);
|
||||||
|
//封装成map
|
||||||
|
Map<String, Item> itemMap = Maps.newHashMap();
|
||||||
|
for (Item item : items) {
|
||||||
|
itemMap.put(item.getCode(), item);
|
||||||
|
}
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -19,10 +19,14 @@ import com.youchain.base.BaseEntity;
|
||||||
import com.youchain.basicdata.domain.Area;
|
import com.youchain.basicdata.domain.Area;
|
||||||
import com.youchain.basicdata.domain.BillType;
|
import com.youchain.basicdata.domain.BillType;
|
||||||
import com.youchain.modules.system.domain.Dept;
|
import com.youchain.modules.system.domain.Dept;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
|
@ -36,6 +40,9 @@ import java.io.Serializable;
|
||||||
**/
|
**/
|
||||||
@Entity
|
@Entity
|
||||||
@Data
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
@Table(name="data_asn")
|
@Table(name="data_asn")
|
||||||
public class Asn extends BaseEntity implements Serializable {
|
public class Asn extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,13 @@ import com.youchain.basicdata.domain.Point;
|
||||||
import com.youchain.basicdata.domain.Stock;
|
import com.youchain.basicdata.domain.Stock;
|
||||||
import com.youchain.basicdata.domain.StockType;
|
import com.youchain.basicdata.domain.StockType;
|
||||||
import com.youchain.modules.system.domain.Dept;
|
import com.youchain.modules.system.domain.Dept;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
|
@ -39,6 +42,9 @@ import java.io.Serializable;
|
||||||
**/
|
**/
|
||||||
@Entity
|
@Entity
|
||||||
@Data
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
@Table(name = "data_asn_detail")
|
@Table(name = "data_asn_detail")
|
||||||
public class AsnDetail extends BaseEntity implements Serializable {
|
public class AsnDetail extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.youchain.businessdata.inputJson.imports;
|
||||||
|
|
||||||
|
import cn.idev.excel.annotation.ExcelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AsnImportForm {
|
||||||
|
@ExcelProperty("INVOICE NO.")
|
||||||
|
private String invoiceNo;
|
||||||
|
|
||||||
|
@ExcelProperty("BOI")
|
||||||
|
private String boi;
|
||||||
|
|
||||||
|
@ExcelProperty("PO&LN NO.")
|
||||||
|
private String poNo;
|
||||||
|
|
||||||
|
@ExcelProperty("PART NO.")
|
||||||
|
private String partNo;
|
||||||
|
|
||||||
|
@ExcelProperty("DESCRIPTION")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@ExcelProperty("Q'TY")
|
||||||
|
private Double qty;
|
||||||
|
|
||||||
|
@ExcelProperty("C/NO.")
|
||||||
|
private String cNo;
|
||||||
|
}
|
||||||
|
|
@ -39,4 +39,6 @@ public interface AsnRepository extends JpaRepository<Asn, Long>, JpaSpecificatio
|
||||||
@Query(value = "SELECT * FROM `data_asn` asn ORDER BY asn.create_time DESC LIMIT 0,1", nativeQuery = true)
|
@Query(value = "SELECT * FROM `data_asn` asn ORDER BY asn.create_time DESC LIMIT 0,1", nativeQuery = true)
|
||||||
Asn queryMaxCode();
|
Asn queryMaxCode();
|
||||||
|
|
||||||
|
@Query("from Asn asn where asn.code in (:asnCodes) ")
|
||||||
|
List<Asn> queryByAsnCodes(List<String> asnCodes);
|
||||||
}
|
}
|
||||||
|
|
@ -22,6 +22,7 @@ import com.youchain.businessdata.domain.Asn;
|
||||||
import com.youchain.businessdata.repository.AsnRepository;
|
import com.youchain.businessdata.repository.AsnRepository;
|
||||||
import com.youchain.businessdata.service.AsnService;
|
import com.youchain.businessdata.service.AsnService;
|
||||||
import com.youchain.businessdata.service.dto.AsnQueryCriteria;
|
import com.youchain.businessdata.service.dto.AsnQueryCriteria;
|
||||||
|
import com.youchain.exception.handler.ApiResult;
|
||||||
import com.youchain.utils.CodeUtils;
|
import com.youchain.utils.CodeUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
@ -32,6 +33,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
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 io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|
@ -39,6 +41,9 @@ import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JiangKun
|
* @author JiangKun
|
||||||
* @website https://eladmin.vip
|
* @website https://eladmin.vip
|
||||||
|
|
@ -69,7 +74,7 @@ public class AsnController {
|
||||||
@ApiOperation("查询最大单号")
|
@ApiOperation("查询最大单号")
|
||||||
@AnonymousAccess
|
@AnonymousAccess
|
||||||
public ResponseEntity<Object> maxNo(@RequestParam("code") String code) {
|
public ResponseEntity<Object> maxNo(@RequestParam("code") String code) {
|
||||||
return new ResponseEntity<>(codeUtils.getCode_yyMMdd(code,3), HttpStatus.OK);
|
return new ResponseEntity<>(codeUtils.getCode_yyMMdd(code, 3), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -82,7 +87,6 @@ public class AsnController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/getIdByAsn")
|
@GetMapping("/getIdByAsn")
|
||||||
@Log("查询asn")
|
@Log("查询asn")
|
||||||
@ApiOperation("查询asn")
|
@ApiOperation("查询asn")
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,13 @@
|
||||||
*/
|
*/
|
||||||
package com.youchain.businessdata.service;
|
package com.youchain.businessdata.service;
|
||||||
|
|
||||||
|
import com.youchain.basicdata.domain.Item;
|
||||||
import com.youchain.businessdata.domain.Asn;
|
import com.youchain.businessdata.domain.Asn;
|
||||||
import com.youchain.businessdata.service.dto.AsnDto;
|
import com.youchain.businessdata.service.dto.AsnDto;
|
||||||
import com.youchain.businessdata.service.dto.AsnQueryCriteria;
|
import com.youchain.businessdata.service.dto.AsnQueryCriteria;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -82,4 +85,8 @@ public interface AsnService {
|
||||||
* @throws Exception /
|
* @throws Exception /
|
||||||
*/
|
*/
|
||||||
void download(List<AsnDto> all, HttpServletResponse response) throws Exception, Exception;
|
void download(List<AsnDto> all, HttpServletResponse response) throws Exception, Exception;
|
||||||
|
|
||||||
|
List<Asn> queryByAsnCodes(List<String> asnCodes);
|
||||||
|
|
||||||
|
Map<String, Asn> queryByasnCodesToMap(List<String> asnCodes);
|
||||||
}
|
}
|
||||||
|
|
@ -15,10 +15,15 @@
|
||||||
*/
|
*/
|
||||||
package com.youchain.businessdata.service.impl;
|
package com.youchain.businessdata.service.impl;
|
||||||
|
|
||||||
|
import cn.idev.excel.FastExcel;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.youchain.basicdata.domain.Item;
|
||||||
import com.youchain.businessdata.domain.Asn;
|
import com.youchain.businessdata.domain.Asn;
|
||||||
import com.youchain.businessdata.domain.AsnDetail;
|
import com.youchain.businessdata.domain.AsnDetail;
|
||||||
|
import com.youchain.businessdata.inputJson.imports.AsnImportForm;
|
||||||
import com.youchain.businessdata.repository.AsnDetailRepository;
|
import com.youchain.businessdata.repository.AsnDetailRepository;
|
||||||
import com.youchain.businessdata.service.AsnDetailService;
|
import com.youchain.businessdata.service.AsnDetailService;
|
||||||
|
import com.youchain.exception.BadRequestException;
|
||||||
import com.youchain.utils.*;
|
import com.youchain.utils.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import com.youchain.businessdata.repository.AsnRepository;
|
import com.youchain.businessdata.repository.AsnRepository;
|
||||||
|
|
@ -27,16 +32,20 @@ import com.youchain.businessdata.service.dto.AsnDto;
|
||||||
import com.youchain.businessdata.service.dto.AsnQueryCriteria;
|
import com.youchain.businessdata.service.dto.AsnQueryCriteria;
|
||||||
import com.youchain.businessdata.service.mapstruct.AsnMapper;
|
import com.youchain.businessdata.service.mapstruct.AsnMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -147,4 +156,27 @@ public class AsnServiceImpl implements AsnService {
|
||||||
}
|
}
|
||||||
FileUtil.downloadExcel(list, response);
|
FileUtil.downloadExcel(list, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Asn> queryByAsnCodes(List<String> asnCodes) {
|
||||||
|
if (CollectionUtils.isEmpty(asnCodes)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
//去重
|
||||||
|
asnCodes = asnCodes.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||||
|
return asnRepository.queryByAsnCodes(asnCodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Asn> queryByasnCodesToMap(List<String> asnCodes) {
|
||||||
|
List<Asn> asnList = queryByAsnCodes(asnCodes);
|
||||||
|
//封装成map
|
||||||
|
Map<String, Asn> asnMap = Maps.newHashMap();
|
||||||
|
for (Asn asn : asnList) {
|
||||||
|
asnMap.put(asn.getCode(), asn);
|
||||||
|
}
|
||||||
|
return asnMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.youchain.utils;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class SmartStringUtil {
|
||||||
|
/**
|
||||||
|
* 获取两个列表的相同的元素
|
||||||
|
*
|
||||||
|
* @param list1 第一个列表
|
||||||
|
* @param list2 第二个列表
|
||||||
|
* @return 相同元素
|
||||||
|
*/
|
||||||
|
public static List<String> getIntersection(List<String> list1, List<String> list2) {
|
||||||
|
return list1.stream()
|
||||||
|
.filter(list2::contains)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 找到 list1 中存在但 list2 中不存在的元素
|
||||||
|
*
|
||||||
|
* @param list1 第一个列表
|
||||||
|
* @param list2 第二个列表
|
||||||
|
* @return 不同
|
||||||
|
*/
|
||||||
|
public static List<String> getDifference(List<String> list1, List<String> list2) {
|
||||||
|
Set<String> existingLocationCodesSet = new HashSet<>(list2);
|
||||||
|
return list1.stream()
|
||||||
|
.filter(code -> !existingLocationCodesSet.contains(code))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue