|
|
|
@ -38,24 +38,24 @@ import java.util.*; |
|
|
|
|
@Slf4j |
|
|
|
|
@Service |
|
|
|
|
public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String LOGGER_MSG = "(购方信息业务实现类)"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BuyerMapper buyerMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BaseService baseService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private VerifyBuyerManageInfoService verifyBuyerManageInfoService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private BaseServiceConfig baseServiceConfig; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private OpenApiService openApiService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public PageUtils queryBuyerList(Map<String, Object> paramMap, List<String> shList) { |
|
|
|
|
int pageSize = Integer.parseInt(String.valueOf(paramMap.get(ConfigureConstant.STRING_PAGE_SIZE))); |
|
|
|
@ -66,11 +66,11 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
PageInfo<BuyerEntity> pageInfo = new PageInfo<>(list); |
|
|
|
|
PageUtils page = new PageUtils(pageInfo.getList(), (int) pageInfo.getTotal(), pageInfo.getPageSize(), |
|
|
|
|
pageInfo.getPageNum()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("{}返回值{} ", LOGGER_MSG, page); |
|
|
|
|
return page; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 接口提供根据名称模糊查询 |
|
|
|
|
* |
|
|
|
@ -92,7 +92,7 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R removeBuyerbyId(List<Map> ids) { |
|
|
|
|
R r = new R(); |
|
|
|
@ -110,10 +110,10 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
} |
|
|
|
|
return r; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R importBuyerByExcel(List<BuyerEntity> buyerEntityList) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long t2 = System.currentTimeMillis(); |
|
|
|
|
List<Map<String, Object>> list = new ArrayList<>(); |
|
|
|
|
List<Map<String, String>> checkResultMapList = new ArrayList<>(); |
|
|
|
@ -128,7 +128,7 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
if (StringUtils.isBlank(buyerEntity.getBuyerCode())) { |
|
|
|
|
buyerEntity.setBuyerCode(baseService.getGenerateShotKey()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String key = buyerEntity.getXhfNsrsbh() + buyerEntity.getXhfMc() + buyerEntity.getTaxpayerCode() + buyerEntity.getPurchaseName(); |
|
|
|
|
if (repeatMap.get(key) != null) { |
|
|
|
|
Map<String, String> checkResultMap1 = new HashMap<>(2); |
|
|
|
@ -139,18 +139,18 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
} else { |
|
|
|
|
repeatMap.put(key, buyerEntity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> shList = new ArrayList<>(); |
|
|
|
|
shList.add(buyerEntity.getXhfNsrsbh()); |
|
|
|
|
Map<String, String> param = new HashMap<>(5); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GmfxxtbReqBO gmfxxtbReqBo = transGmfxxtbReqBo(buyerEntity); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String, String>> checkResultMap = verifyBuyerManageInfoService.checkSyncBuyerRequestParam(gmfxxtbReqBo, preStr); |
|
|
|
|
if (ObjectUtil.isNotEmpty(checkResultMap)) { |
|
|
|
|
checkResultMapList.addAll(checkResultMap); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(buyerEntity.getTaxpayerCode())) { |
|
|
|
|
param.put("taxpayerCode", buyerEntity.getTaxpayerCode()); |
|
|
|
|
int i = buyerMapper.selectBuyerByName(param, shList); |
|
|
|
@ -171,7 +171,7 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
checkResultMapList.add(checkResultMap1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(checkResultMapList)) { |
|
|
|
|
for (Map<String, String> stringStringMap : checkResultMapList) { |
|
|
|
@ -180,7 +180,7 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
} |
|
|
|
|
long t3 = System.currentTimeMillis(); |
|
|
|
|
log.debug("{}校验耗时:{}", LOGGER_MSG, (t3 - t2)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//导入成功的条数
|
|
|
|
|
int importSuccessCount = 0; |
|
|
|
|
Map<String, Object> resultMap = new HashMap<>(10); |
|
|
|
@ -197,7 +197,7 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
if (StringUtils.isBlank(buyerEntity.getBuyerCode())) { |
|
|
|
|
buyerEntity.setBuyerCode(baseService.getGenerateShotKey()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (buyerEntityList.size() < ConfigureConstant.BATCH_INSERT) { |
|
|
|
|
buyerMapper.insertBuyerByList(buyerEntityList); |
|
|
|
@ -219,11 +219,11 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
resultMap.put("list", list); |
|
|
|
|
} |
|
|
|
|
log.info("{}数据库插入耗时:{}", LOGGER_MSG, (System.currentTimeMillis() - t3)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result.put(OrderManagementConstant.DATA, resultMap).put("count", importSuccessCount) |
|
|
|
|
.put("importResult", "导入数据共" + buyerEntityList.size() + "条,成功" + importSuccessCount + "条"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public BuyerEntity queryBuyerByPurchaseName(String purchaseName, String xhfNsrsbh) { |
|
|
|
|
List<String> shList = new ArrayList<>(); |
|
|
|
@ -237,8 +237,8 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public BuyerEntity queryBuyerInfoByxhfNsrsbhAndBuyerCode(String xhfNsrsbh, String buyerCode) { |
|
|
|
|
log.info("{}根据销方税号:{}和自编ID查询购方信息{}", LOGGER_MSG, xhfNsrsbh, buyerCode); |
|
|
|
@ -254,7 +254,7 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R syncBuyer(BuyerEntity buyerEntity, String operationType) { |
|
|
|
|
OrderInfoContentEnum orderInfoContentEnum = OrderInfoContentEnum.BUYER_MESSAGE_SYNC_SUCCESS; |
|
|
|
@ -287,6 +287,18 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
orderInfoContentEnum = OrderInfoContentEnum.BUYER_MESSAGE_SYNC_DELETE; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case "3": |
|
|
|
|
// 先查后更新,针对山能MDM可能回重复推送的问题,先查,如果存在则更新,不存在则udpate
|
|
|
|
|
if (Objects.nonNull(buyerEntityOld)) { |
|
|
|
|
// 存在则更新
|
|
|
|
|
buyerEntity.setId(buyerEntityOld.getId()); |
|
|
|
|
buyerMapper.updateBuyer(buyerEntity, shList); |
|
|
|
|
} else if (Objects.isNull(buyerEntityOld)) { |
|
|
|
|
// 不存在则插入
|
|
|
|
|
buyerEntity.setId(baseService.getGenerateShotKey()); |
|
|
|
|
buyerMapper.insertBuyer(buyerEntity); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
log.error("不存在的类型"); |
|
|
|
|
break; |
|
|
|
@ -298,34 +310,34 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
log.info("{}同步购买方信息:{}", LOGGER_MSG, orderInfoContentEnum.getMessage()); |
|
|
|
|
return R.setCodeAndMsg(orderInfoContentEnum, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R saveOrUpdateBuyerInfo(BuyerEntity buyerEntity) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据入参进行判断是新增还是修改 |
|
|
|
|
*/ |
|
|
|
|
List<String> shList = new ArrayList<>(); |
|
|
|
|
shList.add(buyerEntity.getXhfNsrsbh()); |
|
|
|
|
R r = new R(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ConfigureConstant.STRING_1.equals(buyerEntity.getIsEdit()) && StringUtils.isBlank(buyerEntity.getId())) { |
|
|
|
|
BuyerEntity existBuyer = isExistBuyer(buyerEntity); |
|
|
|
|
if (ObjectUtil.isNotNull(existBuyer)) { |
|
|
|
|
buyerEntity.setId(existBuyer.getId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(buyerEntity.getId())) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buyerEntity.setModifyTime(new Date()); |
|
|
|
|
int i = buyerMapper.updateBuyer(buyerEntity, shList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i <= 0) { |
|
|
|
|
r.put("message", "修改失败").put(OrderManagementConstant.CODE, ConfigureConstant.STRING_9999); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
BuyerEntity buyerEntity1 = new BuyerEntity(); |
|
|
|
|
buyerEntity1.setBuyerCode(buyerEntity.getBuyerCode()); |
|
|
|
@ -333,18 +345,18 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
buyerEntity1.setPurchaseName(buyerEntity.getPurchaseName()); |
|
|
|
|
List<BuyerEntity> queryBuyerEntity = buyerMapper.selectBuyerByBuyerEntity(buyerEntity1, shList); |
|
|
|
|
if (queryBuyerEntity != null && queryBuyerEntity.size() > 0) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buyerEntity.setModifyTime(new Date()); |
|
|
|
|
buyerEntity.setBuyerCode(queryBuyerEntity.get(0).getBuyerCode()); |
|
|
|
|
buyerEntity.setId(queryBuyerEntity.get(0).getId()); |
|
|
|
|
//更新客户信息
|
|
|
|
|
int i = buyerMapper.updateBuyer(buyerEntity, shList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i <= 0) { |
|
|
|
|
r.put("message", "修改失败").put(OrderManagementConstant.CODE, ConfigureConstant.STRING_9999); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
//新增购方信息
|
|
|
|
|
if (StringUtils.isBlank(buyerEntity.getBuyerCode())) { |
|
|
|
@ -353,34 +365,34 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
String uuid = baseService.getGenerateShotKey(); |
|
|
|
|
log.info("{}添加开始执行开始执行 uuid = {}", LOGGER_MSG, uuid); |
|
|
|
|
buyerEntity.setId(uuid); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int i = buyerMapper.insertBuyer(buyerEntity); |
|
|
|
|
if (i <= 0) { |
|
|
|
|
r.put("message", "添加失败").put(OrderManagementConstant.CODE, ConfigureConstant.STRING_9999); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return R.ok().put(OrderManagementConstant.MESSAGE, "保存成功!"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
@Override |
|
|
|
|
public R saveBuyerInfoList(List<BuyerEntity> buyerList, String userId) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//业务挪到provider
|
|
|
|
|
if (ObjectUtil.isEmpty(buyerList)) { |
|
|
|
|
return R.error(OrderInfoContentEnum.GENERATE_READY_ORDER_DATA_ERROR); |
|
|
|
|
} |
|
|
|
|
List<R> errorList = new ArrayList<>(); |
|
|
|
|
//数据校验
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (BuyerEntity buyerEntity : buyerList) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buyerEntity.setGhfQylx(OrderInfoEnum.GHF_QYLX_01.getKey()); |
|
|
|
|
if (StringUtils.isEmpty(buyerEntity.getTaxpayerCode())) { |
|
|
|
|
buyerEntity.setGhfQylx(OrderInfoEnum.GHF_QYLX_03.getKey()); |
|
|
|
@ -389,7 +401,7 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
buyerEntity.setBuyerCode(baseService.getGenerateShotKey()); |
|
|
|
|
} |
|
|
|
|
GmfxxtbReqBO gmfxxtbReqBo = transGmfxxtbReqBo(buyerEntity); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String, String>> checkResultMap = verifyBuyerManageInfoService.checkSyncBuyerRequestParam(gmfxxtbReqBo, ""); |
|
|
|
|
if (ObjectUtil.isNotEmpty(checkResultMap)) { |
|
|
|
|
StringBuilder errorMsg = new StringBuilder(); |
|
|
|
@ -399,16 +411,16 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
} |
|
|
|
|
return R.error(errorMsg.toString()).put("errorList", errorList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean isEdit = ConfigureConstant.STRING_1.equals(buyerEntity.getIsEdit()); |
|
|
|
|
if (!isEdit) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//税号非空校验
|
|
|
|
|
if (StringUtils.isBlank(buyerEntity.getXhfNsrsbh())) { |
|
|
|
|
return R.error(OrderInfoContentEnum.GENERATE_READY_ORDER_DATA_ERROR); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//是否重复校验
|
|
|
|
|
/** |
|
|
|
|
* 如果id不为空说明是编辑过来的数据,优先使用id进行查询,查询结果如果和入参一样,则代表更新操作,不进行拦截 |
|
|
|
@ -419,7 +431,7 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
*/ |
|
|
|
|
BuyerEntity existBuyer = isExistBuyer(buyerEntity); |
|
|
|
|
if (ObjectUtil.isNotNull(existBuyer)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(existBuyer.getTaxpayerCode()) || StringUtils.isNotBlank(existBuyer.getPurchaseName())) { |
|
|
|
|
if (StringUtils.isBlank(existBuyer.getTaxpayerCode())) { |
|
|
|
|
existBuyer.setTaxpayerCode(""); |
|
|
|
@ -444,11 +456,11 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
buyerEntity.setId(existBuyer.getId()); |
|
|
|
|
errorList.add(R.error().put("xhfNsrsbh", buyerEntity.getXhfNsrsbh()).put("xhfMc", buyerEntity.getXhfMc()) |
|
|
|
|
.put("ghfMc", buyerEntity.getPurchaseName()).put("ghfNsrsbh", buyerEntity.getTaxpayerCode())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
buyerEntity.setId(existBuyer.getId()); |
|
|
|
@ -456,20 +468,20 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
.put("ghfMc", buyerEntity.getPurchaseName()).put("ghfNsrsbh", buyerEntity.getTaxpayerCode())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(errorList)) { |
|
|
|
|
return R.error().put("errorList", errorList).put(OrderManagementConstant.CODE, "9095").put(OrderManagementConstant.MESSAGE, "购方名称和税号重复").put(OrderManagementConstant.DATA, buyerList); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//数据补全入库
|
|
|
|
|
for (BuyerEntity buyerEntity : buyerList) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buyerEntity.setPurchaseName(StringUtil.replaceStr(buyerEntity.getPurchaseName(), true)); |
|
|
|
|
buyerEntity.setModifyUserId(userId); |
|
|
|
|
buyerEntity.setCreateUserId(userId); |
|
|
|
@ -477,7 +489,7 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
} |
|
|
|
|
return R.ok(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 销方下购方信息是否存在 |
|
|
|
|
* |
|
|
|
@ -485,7 +497,7 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private BuyerEntity isExistBuyer(BuyerEntity buyerEntity) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BuyerEntity queryBuyerEntity = new BuyerEntity(); |
|
|
|
|
if (StringUtils.isNotBlank(buyerEntity.getId())) { |
|
|
|
|
queryBuyerEntity.setId(buyerEntity.getId()); |
|
|
|
@ -493,7 +505,7 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
queryBuyerEntity.setTaxpayerCode(buyerEntity.getTaxpayerCode()); |
|
|
|
|
queryBuyerEntity.setPurchaseName(buyerEntity.getPurchaseName()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> shList = new ArrayList<>(); |
|
|
|
|
shList.add(buyerEntity.getXhfNsrsbh()); |
|
|
|
|
List<BuyerEntity> result = buyerMapper.selectBuyerByBuyerEntity(queryBuyerEntity, shList); |
|
|
|
@ -501,10 +513,10 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
log.debug("{}购方名称和税号信息已存在,数据为:{}", LOGGER_MSG, JsonUtils.getInstance().toJsonString(result)); |
|
|
|
|
return result.get(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 封装错误信息 |
|
|
|
|
* |
|
|
|
@ -518,7 +530,7 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
map.put(OrderManagementConstant.MESSAGE, msg); |
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 购买方信息转换, |
|
|
|
|
* |
|
|
|
@ -541,44 +553,46 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
gmfxxtbReq.setGMFYX(buyerEntity.getEmail()); |
|
|
|
|
gmfxxtbReq.setGMFSJH(buyerEntity.getSjh()); |
|
|
|
|
gmfxxtbReq.setBZ(buyerEntity.getRemarks()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return gmfxxtbReq; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 自动获取购方企业信息 |
|
|
|
|
* |
|
|
|
|
* @param ghfMc |
|
|
|
|
* @param shList |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public List<BuyerEntity> autoQueryBuyerInfoList(String ghfMc, List<String> shList, List<String> entList) { |
|
|
|
|
log.info("{}自动查询购方信息,请求纳税人识别号:{},数据权限列表:{},请求购方名称为:{}",LOGGER_MSG, shList,entList,ghfMc); |
|
|
|
|
List<BuyerEntity> dataList = queryBuyerByName(ghfMc, shList,entList); |
|
|
|
|
log.info("{}自动查询购方信息,请求纳税人识别号:{},数据权限列表:{},请求购方名称为:{}", LOGGER_MSG, shList, entList, ghfMc); |
|
|
|
|
List<BuyerEntity> dataList = queryBuyerByName(ghfMc, shList, entList); |
|
|
|
|
log.info("{}本地调用购方发票列表结果{}", LOGGER_MSG, JsonUtils.getInstance().toJsonString(dataList)); |
|
|
|
|
if (ObjectUtil.isEmpty(dataList) && ConfigureConstant.STRING_Y.equals(baseServiceConfig.configUseBigDataProcessBuyer())) { |
|
|
|
|
log.info("{}本地调用购方发票列表数据为空,开始调用大数据接口", LOGGER_MSG); |
|
|
|
|
dataList = queryEnterpriseInfoList(ghfMc); |
|
|
|
|
log.info("{}本地调用大数据接口 结果{}", LOGGER_MSG, JsonUtils.getInstance().toJsonString(dataList)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return dataList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 自动获取购方企业信息 |
|
|
|
|
* |
|
|
|
|
* @param ghfMc |
|
|
|
|
* @param shList |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public BuyerEntity autoQueryBuyerInfo(String ghfMc, List<String> shList, List<String> entList) { |
|
|
|
|
BuyerEntity buyerEntity = new BuyerEntity(); |
|
|
|
|
log.info("{}自动查询购方信息,请求纳税人识别号:{},请求购方名称为:{}",LOGGER_MSG, shList,ghfMc); |
|
|
|
|
List<BuyerEntity> dataList = queryBuyerByName(ghfMc, shList,entList); |
|
|
|
|
log.info("{}自动查询购方信息,请求纳税人识别号:{},请求购方名称为:{}", LOGGER_MSG, shList, ghfMc); |
|
|
|
|
List<BuyerEntity> dataList = queryBuyerByName(ghfMc, shList, entList); |
|
|
|
|
log.info("{}本地调用购方发票列表结果{}", LOGGER_MSG, JsonUtils.getInstance().toJsonString(dataList)); |
|
|
|
|
if(ObjectUtil.isNotEmpty(dataList)){ |
|
|
|
|
if (ObjectUtil.isNotEmpty(dataList)) { |
|
|
|
|
buyerEntity = dataList.get(0); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
//如果返回数据为空或者返回数据不为空,但是购方地址或购方银行为空时
|
|
|
|
|
boolean usePlatform = false; |
|
|
|
|
if (ObjectUtil.isEmpty(dataList)) { |
|
|
|
@ -594,40 +608,41 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
log.info("{}本地调用大数据接口 结果{}", LOGGER_MSG, JsonUtils.getInstance().toJsonString(buyerEntity)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return buyerEntity; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 调用大象云平台企业模糊查询 |
|
|
|
|
* |
|
|
|
|
* @param purchaseName |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<BuyerEntity> queryEnterpriseInfoList(String purchaseName) { |
|
|
|
|
List<BuyerEntity> buyerEntityList = new ArrayList<>(); |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断使用新版还是旧版,
|
|
|
|
|
String useOpenApiNew = baseServiceConfig.getUseOpenApiNew(); |
|
|
|
|
if(StringUtils.isNotBlank(useOpenApiNew) && ConfigureConstant.STRING_Y.equals(useOpenApiNew)) { |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(useOpenApiNew) && ConfigureConstant.STRING_Y.equals(useOpenApiNew)) { |
|
|
|
|
|
|
|
|
|
OpenApiGfxxCxReq openApiGfxxCxReq = new OpenApiGfxxCxReq(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openApiGfxxCxReq.setNsrmc(purchaseName); |
|
|
|
|
|
|
|
|
|
log.info("{}调用开放平台企业模糊查询接口content内容:{}",LOGGER_MSG, JsonUtils.getInstance().toJsonString(openApiGfxxCxReq)); |
|
|
|
|
|
|
|
|
|
Map<String, Object> response = openApiService.openApiGfxxCx(baseServiceConfig.configFuzzyQuery(),JsonUtils.getInstance().toJsonString(openApiGfxxCxReq)); |
|
|
|
|
|
|
|
|
|
log.info("{}调用开放平台企业模糊查询接口content内容:{}", LOGGER_MSG, JsonUtils.getInstance().toJsonString(openApiGfxxCxReq)); |
|
|
|
|
|
|
|
|
|
Map<String, Object> response = openApiService.openApiGfxxCx(baseServiceConfig.configFuzzyQuery(), JsonUtils.getInstance().toJsonString(openApiGfxxCxReq)); |
|
|
|
|
log.info("{}调用开放平台企业模糊查询结果:{} ", LOGGER_MSG, JsonUtils.getInstance().toJsonString(response)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(response) && ConfigureConstant.STRING_0000.equals(String.valueOf(response.get(OrderManagementConstant.CODE)))) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<OpenApiGfxxCxData> buyerList = JsonUtils.getInstance().parseObject(String.valueOf(response.get(OrderManagementConstant.DATA)), OpenApiFzyyQueryRsp.class).getData(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(buyerList) && buyerList.size() > ConfigureConstant.INT_10) { |
|
|
|
|
buyerList = buyerList.subList(ConfigureConstant.INT_0, ConfigureConstant.INT_10); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (OpenApiGfxxCxData openApiGfxxCxData : buyerList) { |
|
|
|
|
BuyerEntity buyerEntity = new BuyerEntity(); |
|
|
|
|
buyerEntity.setPurchaseName(openApiGfxxCxData.getNsrmc()); |
|
|
|
@ -637,9 +652,9 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
buyerEntityList.add(buyerEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
Map<String, String> headMap = new HashMap<>(2); |
|
|
|
|
Map<String, String> requestMap = new HashMap<>(2); |
|
|
|
|
requestMap.put("ptcode", baseServiceConfig.configBigDataPtCode()); |
|
|
|
@ -648,14 +663,14 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
headMap.put("Authorization", baseServiceConfig.configBigDataAuthId()); |
|
|
|
|
log.debug("{}调用大象云平台企业模糊查询请求信息为:{}", LOGGER_MSG, JsonUtils.getInstance().toJsonString(requestMap)); |
|
|
|
|
String result = HttpUtils.doPostWithHeader(baseServiceConfig.configBigDataQueryEnterprise(), JsonUtils.getInstance().toJsonString(requestMap), headMap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("{}调用大象云平台企业模糊查询 {} ", LOGGER_MSG, JsonUtils.getInstance().toJsonString(result)); |
|
|
|
|
if (ObjectUtil.isNotEmpty(result)) { |
|
|
|
|
List<String> buyerList = JSON.parseArray(result, String.class); |
|
|
|
|
if (ObjectUtil.isNotEmpty(buyerList) && buyerList.size() > ConfigureConstant.INT_10) { |
|
|
|
|
buyerList = buyerList.subList(ConfigureConstant.INT_0, ConfigureConstant.INT_10); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String buyer : buyerList) { |
|
|
|
|
JSONObject jsonObject = JSON.parseObject(buyer); |
|
|
|
|
BuyerEntity buyerEntity = new BuyerEntity(); |
|
|
|
@ -667,38 +682,39 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("{}调用大象平台企业模糊查询异常:{}", LOGGER_MSG, e); |
|
|
|
|
} |
|
|
|
|
return buyerEntityList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 调用大象云平台企业精确查询 |
|
|
|
|
* |
|
|
|
|
* @param purchaseName |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private BuyerEntity queryEnterpriseInfo(String purchaseName) { |
|
|
|
|
BuyerEntity buyerEntity = new BuyerEntity(); |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String useOpenApiNew = baseServiceConfig.getUseOpenApiNew(); |
|
|
|
|
if(StringUtils.isNotBlank(useOpenApiNew) && ConfigureConstant.STRING_Y.equals(useOpenApiNew)){ |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(useOpenApiNew) && ConfigureConstant.STRING_Y.equals(useOpenApiNew)) { |
|
|
|
|
|
|
|
|
|
OpenApiGfxxCxReq openApiGfxxCxReq = new OpenApiGfxxCxReq(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openApiGfxxCxReq.setNsrmc(purchaseName); |
|
|
|
|
|
|
|
|
|
log.info("{}调用开放平台企业精确查询接口content内容:{}",LOGGER_MSG, JsonUtils.getInstance().toJsonString(openApiGfxxCxReq)); |
|
|
|
|
|
|
|
|
|
Map<String, Object> response = openApiService.openApiGfxxCx(baseServiceConfig.configExactQuery(),JsonUtils.getInstance().toJsonString(openApiGfxxCxReq)); |
|
|
|
|
|
|
|
|
|
log.info("{}调用开放平台企业精确查询接口content内容:{}", LOGGER_MSG, JsonUtils.getInstance().toJsonString(openApiGfxxCxReq)); |
|
|
|
|
|
|
|
|
|
Map<String, Object> response = openApiService.openApiGfxxCx(baseServiceConfig.configExactQuery(), JsonUtils.getInstance().toJsonString(openApiGfxxCxReq)); |
|
|
|
|
log.info("{}调用开放平台企业精确查询结果:{} ", LOGGER_MSG, JsonUtils.getInstance().toJsonString(response)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(response) && ConfigureConstant.STRING_0000.equals(String.valueOf(response.get(OrderManagementConstant.CODE)))) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OpenApiGfxxCxData openApiGfxxCxData = JsonUtils.getInstance().parseObject(String.valueOf(response.get(OrderManagementConstant.DATA)), OpenApiExactQueryRsp.class).getData(); |
|
|
|
|
if(ObjectUtil.isNotNull(openApiGfxxCxData)){ |
|
|
|
|
if (ObjectUtil.isNotNull(openApiGfxxCxData)) { |
|
|
|
|
buyerEntity.setPurchaseName(openApiGfxxCxData.getNsrmc()); |
|
|
|
|
buyerEntity.setTaxpayerCode(openApiGfxxCxData.getNsrsbh()); |
|
|
|
|
buyerEntity.setAddress(openApiGfxxCxData.getZcdwdz()); |
|
|
|
@ -707,9 +723,9 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
buyerEntity.setBankNumber(openApiGfxxCxData.getKhzh()); |
|
|
|
|
buyerEntity.setGhfQylx(OrderInfoEnum.GHF_QYLX_01.getKey()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
Map<String, String> headMap = new HashMap<>(2); |
|
|
|
|
Map<String, String> requestMap = new HashMap<>(2); |
|
|
|
|
requestMap.put("ptcode", baseServiceConfig.configBigDataPtCode()); |
|
|
|
@ -718,11 +734,11 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
headMap.put("Authorization", baseServiceConfig.configBigDataAuthId()); |
|
|
|
|
log.debug("{}调用大象云平台企业精确查询请求信息为:{}", LOGGER_MSG, JsonUtils.getInstance().toJsonString(requestMap)); |
|
|
|
|
String result = HttpUtils.doPostWithHeader(baseServiceConfig.configBigDataExactQueryEnterprise(), JsonUtils.getInstance().toJsonString(requestMap), headMap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("{}调用大象云平台企业精确查询结果:{} ", LOGGER_MSG, JsonUtils.getInstance().toJsonString(result)); |
|
|
|
|
if (ObjectUtil.isNotEmpty(result)) { |
|
|
|
|
JSONObject jsonObject = JSON.parseObject(result); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buyerEntity.setPurchaseName(jsonObject.get("nsrmc") + ""); |
|
|
|
|
buyerEntity.setTaxpayerCode(jsonObject.get(ConfigureConstant.REQUEST_PARAM_NSRSBH) + ""); |
|
|
|
|
buyerEntity.setAddress(jsonObject.get("zcdz") + ""); |
|
|
|
@ -732,8 +748,8 @@ public class BuyerServiceImpl implements BuyerService { |
|
|
|
|
buyerEntity.setGhfQylx(OrderInfoEnum.GHF_QYLX_01.getKey()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("{}调用大象平台企业精确查询异常:{}", LOGGER_MSG, e); |
|
|
|
|
} |
|
|
|
|