|
@@ -21,6 +21,7 @@ import com.fjhx.common.utils.Assert;
|
|
|
import com.fjhx.customer.entity.customer.po.Customer;
|
|
|
import com.fjhx.customer.service.customer.CustomerService;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
|
+import com.fjhx.item.entity.product.IssueImportExcelBo;
|
|
|
import com.fjhx.item.entity.product.dto.ProductInfoDto;
|
|
|
import com.fjhx.item.entity.product.dto.ProductInfoSelectDto;
|
|
|
import com.fjhx.item.entity.product.po.ProductClassify;
|
|
@@ -1071,20 +1072,73 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
*/
|
|
|
@Override
|
|
|
@DSTransactional
|
|
|
- public void editByCodes(ProductInfoDto dto){
|
|
|
- Assert.notEmpty(dto.getSalesStatus(),"销售状态不能为空");
|
|
|
- Assert.notEmpty(dto.getProductCodes(),"产品编号不能为空");
|
|
|
+ public void editByCodes(ProductInfoDto dto) {
|
|
|
+ Assert.notEmpty(dto.getSalesStatus(), "销售状态不能为空");
|
|
|
+ Assert.notEmpty(dto.getProductCodes(), "产品编号不能为空");
|
|
|
String[] productCodes = dto.getProductCodes()
|
|
|
.replace("\r\n", "\n")
|
|
|
.replace("\n\r", "\n")
|
|
|
.replace("\r", "\n").split("\n");
|
|
|
|
|
|
- this.update(q->q.set(ProductInfo::getVictoriatouristJson,"{}")
|
|
|
+ this.update(q -> q.set(ProductInfo::getVictoriatouristJson, "{}")
|
|
|
.isNull(ProductInfo::getVictoriatouristJson)
|
|
|
- .or().eq(ProductInfo::getVictoriatouristJson,"")
|
|
|
+ .or().eq(ProductInfo::getVictoriatouristJson, "")
|
|
|
);
|
|
|
|
|
|
- baseMapper.editByCodes(dto.getSalesStatus(),SecurityUtils.getUserId(),IWrapper.<ProductInfo>getWrapper().in(ProductInfo::getCustomCode,productCodes));
|
|
|
+ baseMapper.editByCodes(dto.getSalesStatus(), SecurityUtils.getUserId(), IWrapper.<ProductInfo>getWrapper().in(ProductInfo::getCustomCode, productCodes));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据产品编码获取产品信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<IssueImportExcelBo> issueImportExcel(MultipartFile file) {
|
|
|
+ List<IssueImportExcelBo> excelBoList = ExcelUtil.read(file, IssueImportExcelBo.class);
|
|
|
+ if (ObjectUtil.isEmpty(excelBoList)) {
|
|
|
+ return excelBoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (IssueImportExcelBo issueImportExcelBo : excelBoList) {
|
|
|
+ if (ObjectUtil.isEmpty(issueImportExcelBo.getProductCustomCode())){
|
|
|
+ throw new ServiceException("物品编码不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //相同产品合并
|
|
|
+ Map<String, IssueImportExcelBo> collect = excelBoList.stream().collect(Collectors.groupingBy(IssueImportExcelBo::getProductCustomCode,
|
|
|
+ Collectors.collectingAndThen(Collectors.toList(), value -> {
|
|
|
+ BigDecimal count = value.stream().map(IssueImportExcelBo::getCount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+
|
|
|
+ IssueImportExcelBo issueImportExcelBo = value.get(0);
|
|
|
+ issueImportExcelBo.setCount(count);
|
|
|
+ return issueImportExcelBo;
|
|
|
+ }))
|
|
|
+ );
|
|
|
+ excelBoList = collect.values().stream().collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<String> productCodes = excelBoList.stream().distinct().map(IssueImportExcelBo::getProductCustomCode).collect(Collectors.toList());
|
|
|
+ if (ObjectUtil.isNotEmpty(productCodes)) {
|
|
|
+ List<String> notArr = new ArrayList<>();
|
|
|
+ //赋值产品信息
|
|
|
+ Map<String, ProductInfo> productInfoMap = this.mapKEntity(ProductInfo::getCustomCode, q -> q.in(ProductInfo::getCustomCode, productCodes));
|
|
|
+ for (IssueImportExcelBo subscribeDetailExcelBo : excelBoList) {
|
|
|
+ ProductInfo productInfo = productInfoMap.get(subscribeDetailExcelBo.getProductCustomCode());
|
|
|
+ if (ObjectUtil.isEmpty(productInfo)) {
|
|
|
+ notArr.add(subscribeDetailExcelBo.getProductCustomCode());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ subscribeDetailExcelBo.setBussinessId(productInfo.getId());
|
|
|
+ subscribeDetailExcelBo.setProductId(productInfo.getId());
|
|
|
+ subscribeDetailExcelBo.setProductDefinition(productInfo.getDefinition());
|
|
|
+ subscribeDetailExcelBo.setProductName(productInfo.getName());
|
|
|
+ subscribeDetailExcelBo.setProductSpec(productInfo.getSpec());
|
|
|
+ subscribeDetailExcelBo.setProductUnit(productInfo.getUnit());
|
|
|
+ }
|
|
|
+ if (notArr.size() != 0) {
|
|
|
+ throw new ServiceException("以下产品不存在:" + notArr.stream().collect(Collectors.joining(",")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return excelBoList;
|
|
|
}
|
|
|
|
|
|
}
|