|
|
|
@ -9,8 +9,11 @@ import com.dxhy.order.baseservice.module.buyer.model.BuyerEntity; |
|
|
|
|
import com.dxhy.order.baseservice.module.commodity.dao.CommodityMapper; |
|
|
|
|
import com.dxhy.order.baseservice.module.commodity.model.CommodityCodeEntity; |
|
|
|
|
import com.dxhy.order.baseservice.module.taxclass.dao.GroupTaxClassCodeMapper; |
|
|
|
|
import com.dxhy.order.baseservice.module.taxclass.dao.TaxClassCodeMapper; |
|
|
|
|
import com.dxhy.order.baseservice.module.taxclass.model.TaxClassCodeEntity; |
|
|
|
|
import com.dxhy.order.baseservice.module.thirdservice.user.dto.AddUserRequestDto; |
|
|
|
|
import com.dxhy.order.baseservice.module.thirdservice.user.service.UserInfoService; |
|
|
|
|
import com.dxhy.order.consumer.dao.GroupCommodityCodeMapper; |
|
|
|
|
import com.dxhy.order.consumer.modules.taxcodematch.dao.SdenergyTaxCodeMatchDao; |
|
|
|
|
import com.dxhy.order.consumer.modules.taxcodematch.entity.SdenergyTaxCodeMatch; |
|
|
|
|
import com.dxhy.order.consumer.openapi.protocol.AjaxResult; |
|
|
|
@ -21,6 +24,7 @@ import com.dxhy.order.utils.HttpUtils; |
|
|
|
|
import com.dxhy.order.utils.JsonUtils; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@ -58,6 +62,12 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract { |
|
|
|
|
@Autowired |
|
|
|
|
private SdenergyTaxCodeMatchDao sdenergyTaxCodeMatchDao; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private GroupCommodityCodeMapper groupCommodityCodeMapper; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private TaxClassCodeMapper taxClassCodeMapper; |
|
|
|
|
|
|
|
|
|
// ===========物料相关开始===========
|
|
|
|
|
// 物料主动查询接口
|
|
|
|
|
@Value("${mdm.groupTaxCode.url}") |
|
|
|
@ -240,6 +250,10 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract { |
|
|
|
|
|
|
|
|
|
commodityCodeEntity.setCommodityId(baseService.getGenerateShotKey()); |
|
|
|
|
commodityCodeEntity.setXhfNsrsbh("-1"); |
|
|
|
|
|
|
|
|
|
// 进行物料匹配
|
|
|
|
|
matchCommodityCode(commodityCodeEntity); |
|
|
|
|
|
|
|
|
|
if (commodityMapper.insertCommodityOnDuplicateKey(commodityCodeEntity) > 0) { |
|
|
|
|
commodityCodeEntity.setSuccess(true); |
|
|
|
|
} else { |
|
|
|
@ -267,6 +281,41 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract { |
|
|
|
|
return AjaxResult.success("success", resp); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据规则进行物料匹配 |
|
|
|
|
* |
|
|
|
|
* @param commodityCodeEntity |
|
|
|
|
*/ |
|
|
|
|
private void matchCommodityCode(CommodityCodeEntity commodityCodeEntity) { |
|
|
|
|
// 1.接收到MDM的商品信息后优先使用推送的“物料名称”去所有子公司库中匹配税编,若存在多个同名税编,默认使用第一个作为集团库的税编;
|
|
|
|
|
String xmmc = commodityCodeEntity.getXmmc(); |
|
|
|
|
CommodityCodeEntity codeEntityForMatch = groupCommodityCodeMapper.queryCommodityCodeByXmmcInChildCompany(xmmc); |
|
|
|
|
if (codeEntityForMatch != null) { |
|
|
|
|
// 查找原codeEntity
|
|
|
|
|
CommodityCodeEntity parentCodeEntity = groupCommodityCodeMapper.queryCommodityCodeByZxbmAndXhfNsrsbh(codeEntityForMatch.getZxbm(), "-1"); |
|
|
|
|
BeanUtils.copyProperties(codeEntityForMatch, commodityCodeEntity); |
|
|
|
|
if (parentCodeEntity != null) { |
|
|
|
|
commodityCodeEntity.setCommodityId(parentCodeEntity.getCommodityId()); // 要把原commodityId维护回去
|
|
|
|
|
} |
|
|
|
|
commodityCodeEntity.setXhfNsrsbh("-1"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// 2. 若根据物料名称未匹配到子公司库的税编时,根据物料编码匹配“物料分类编码”库中的税编;
|
|
|
|
|
SdenergyTaxCodeMatch taxCodeMatch = sdenergyTaxCodeMatchDao.queryByWlflbm(commodityCodeEntity.getWlflbm()); |
|
|
|
|
if (taxCodeMatch != null) { |
|
|
|
|
// 如果匹配到了物料分类编码,去查一下税收分类编码找到对应的简称等信息
|
|
|
|
|
TaxClassCodeEntity taxClassCodeEntity = taxClassCodeMapper.selectTaxClassCodeBySpbm(taxCodeMatch.getSsflbm()); |
|
|
|
|
commodityCodeEntity.setSpsm(taxClassCodeEntity.getSm()); |
|
|
|
|
commodityCodeEntity.setSpjm(taxClassCodeEntity.getSpjc()); |
|
|
|
|
commodityCodeEntity.setSl(taxClassCodeEntity.getZzssl()); |
|
|
|
|
if(!StringUtils.isBlank(taxClassCodeEntity.getYhzcmc())){ |
|
|
|
|
commodityCodeEntity.setYhzcbs("1"); |
|
|
|
|
} |
|
|
|
|
commodityCodeEntity.setSpbm(taxClassCodeEntity.getSpbm()); |
|
|
|
|
commodityCodeEntity.setSsflMc(taxCodeMatch.getSsflmc()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 同步人员库 |
|
|
|
|