diff --git a/order-management-consumer/pom.xml b/order-management-consumer/pom.xml index 2d3e186a..264ad7f1 100644 --- a/order-management-consumer/pom.xml +++ b/order-management-consumer/pom.xml @@ -509,6 +509,12 @@ spring-boot-starter-mail + + dxhy-ofd-reader + com.dxhy.jxpt + 1.0.19 + + order-api diff --git a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/service/impl/GroupCommodityCodeServiceImpl.java b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/service/impl/GroupCommodityCodeServiceImpl.java index 25c52daa..13062839 100644 --- a/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/service/impl/GroupCommodityCodeServiceImpl.java +++ b/order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/service/impl/GroupCommodityCodeServiceImpl.java @@ -19,9 +19,12 @@ import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import javax.annotation.Resource; import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -49,7 +52,7 @@ public class GroupCommodityCodeServiceImpl implements IGroupCommodityCodeService * 查询集团物料库 * * @param queryGroupCommodityDTO - * @param shList + * @param queryGroupCommodityDTO * @return */ @Override @@ -63,13 +66,14 @@ public class GroupCommodityCodeServiceImpl implements IGroupCommodityCodeService query.setZxbm(queryGroupCommodityDTO.getZxbm()); query.setXmmc(queryGroupCommodityDTO.getXmmc()); List result = groupCommodityMapper.queryGroupCommodityCodeList(query); - result = result.stream().map(i -> { + PageInfo pageInfo = new PageInfo<>(result); + List temp = pageInfo.getList().stream().map(i -> { if (StringUtils.isNotEmpty(i.getSl())) { i.setSl(CommonUtils.formatSl(i.getSl())); } return i; }).collect(Collectors.toList()); - PageInfo pageInfo = new PageInfo<>(result); + pageInfo.setList(temp); return new PageUtils(pageInfo.getList(), (int) pageInfo.getTotal(), pageInfo.getPageSize(), pageInfo.getPageNum()); } @@ -80,6 +84,7 @@ public class GroupCommodityCodeServiceImpl implements IGroupCommodityCodeService * @return */ @Override + @Transactional public R quoteGroupCommodityCode(QuoteGroupCommodityDTO quoteGroupCommodityDTO) { // 判断销方税号是否合法,因为某些情况下可能会传递list过来 if (StringUtils.isBlank(quoteGroupCommodityDTO.getXhfNsrsbh())) { @@ -90,33 +95,45 @@ public class GroupCommodityCodeServiceImpl implements IGroupCommodityCodeService return R.error(ConfigureConstant.STRING_0000, "销方税号非法"); } - CommodityCodeEntity commodityCodeEntity = groupCommodityMapper.queryCommodityCodeByZxbmAndXhfNsrsbh(quoteGroupCommodityDTO.getZxbm(), quoteGroupCommodityDTO.getXhfNsrsbh()); - // 根据文档4.2.1.2 (6) 若物料编码重复时,引用后不对子公司物料进行更新 - if (commodityCodeEntity != null) { - return R.ok(); - } + List zxbmList = Arrays.asList(StringUtils.split(quoteGroupCommodityDTO.getZxbm(), ",")); + for (int i = 0; i < zxbmList.size(); i++) { + String zxbm = zxbmList.get(i); + if (StringUtils.isBlank(zxbm)) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("第" + (i + 1) + "条数据,物料编码不能为空"); + } - commodityCodeEntity = groupCommodityMapper.queryCommodityCodeByZxbmAndXhfNsrsbh(quoteGroupCommodityDTO.getZxbm(), "-1"); - if (commodityCodeEntity == null) { - return R.error("引用失败,集团物料不存在"); - } + CommodityCodeEntity commodityCodeEntity = groupCommodityMapper.queryCommodityCodeByZxbmAndXhfNsrsbh(zxbm, quoteGroupCommodityDTO.getXhfNsrsbh()); + // 根据文档4.2.1.2 (6) 若物料编码重复时,引用后不对子公司物料进行更新 + if (commodityCodeEntity != null) { + continue; + } - CommodityCodeEntity newCommodityCodeEntity = new CommodityCodeEntity(); - try { - BeanUtils.copyProperties(newCommodityCodeEntity, commodityCodeEntity); - } catch (IllegalAccessException e) { - log.error("{}引用物料异常", LOGGER_MSG, e); - } catch (InvocationTargetException e) { - log.error("{}引用物料异常", LOGGER_MSG, e); - } - newCommodityCodeEntity.setId(baseService.getGenerateShotKey()); - newCommodityCodeEntity.setXhfNsrsbh(quoteGroupCommodityDTO.getXhfNsrsbh()); - if (groupCommodityMapper.insertCommodityCode(newCommodityCodeEntity) > 0) { - return R.ok(); - } else { - return R.error("引用失败"); + commodityCodeEntity = groupCommodityMapper.queryCommodityCodeByZxbmAndXhfNsrsbh(zxbm, "-1"); + if (commodityCodeEntity == null) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("第" + (i + 1) + "条数据,集团物料不存在"); + } + + CommodityCodeEntity newCommodityCodeEntity = new CommodityCodeEntity(); + try { + BeanUtils.copyProperties(newCommodityCodeEntity, commodityCodeEntity); + } catch (IllegalAccessException e) { + log.error("{}引用物料异常", LOGGER_MSG, e); + } catch (InvocationTargetException e) { + log.error("{}引用物料异常", LOGGER_MSG, e); + } + + newCommodityCodeEntity.setId(baseService.getGenerateShotKey()); + newCommodityCodeEntity.setXhfNsrsbh(quoteGroupCommodityDTO.getXhfNsrsbh()); + if (groupCommodityMapper.insertCommodityCode(newCommodityCodeEntity) <= 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("第" + (i + 1) + "条数据,引用失败"); + } } + + return R.ok(); } /**