|
|
|
@ -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<CommodityCodeEntity> result = groupCommodityMapper.queryGroupCommodityCodeList(query); |
|
|
|
|
result = result.stream().map(i -> { |
|
|
|
|
PageInfo<CommodityCodeEntity> pageInfo = new PageInfo<>(result); |
|
|
|
|
List<CommodityCodeEntity> temp = pageInfo.getList().stream().map(i -> { |
|
|
|
|
if (StringUtils.isNotEmpty(i.getSl())) { |
|
|
|
|
i.setSl(CommonUtils.formatSl(i.getSl())); |
|
|
|
|
} |
|
|
|
|
return i; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
PageInfo<CommodityCodeEntity> 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<String> 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(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|