|
|
|
@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import cn.hutool.core.util.RandomUtil; |
|
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.dxhy.base.file.common.ExcelReadContext; |
|
|
|
|
import com.dxhy.base.file.handle.ExcelExportHandle; |
|
|
|
|
import com.dxhy.order.baseservice.config.BaseServiceConfig; |
|
|
|
@ -20,11 +21,16 @@ import com.dxhy.order.baseservice.module.thirdservice.simsback.service.SimsBackS |
|
|
|
|
import com.dxhy.order.baseservice.module.thirdservice.user.model.DeptEntity; |
|
|
|
|
import com.dxhy.order.baseservice.module.thirdservice.user.service.UserInfoService; |
|
|
|
|
import com.dxhy.order.constant.*; |
|
|
|
|
import com.dxhy.order.exception.OrderReceiveException; |
|
|
|
|
import com.dxhy.order.invoice.config.InvoiceConfig; |
|
|
|
|
import com.dxhy.order.invoice.module.invoice.dao.*; |
|
|
|
|
import com.dxhy.order.invoice.module.invoice.model.FileDownLoad; |
|
|
|
|
import com.dxhy.order.invoice.module.invoice.model.GsClient; |
|
|
|
|
import com.dxhy.order.invoice.module.invoice.model.bo.QueryCountInvoiceBO; |
|
|
|
|
import com.dxhy.order.invoice.module.invoice.model.excel.*; |
|
|
|
|
import com.dxhy.order.invoice.module.invoice.model.po.IsInput; |
|
|
|
|
import com.dxhy.order.invoice.module.invoice.model.po.PoCommonRequestParam; |
|
|
|
|
import com.dxhy.order.invoice.module.invoice.model.po.PoCommonResponseParam; |
|
|
|
|
import com.dxhy.order.invoice.module.invoice.model.vo.*; |
|
|
|
|
import com.dxhy.order.invoice.module.invoice.service.EmailService; |
|
|
|
|
import com.dxhy.order.invoice.module.invoice.service.HistoryDataPdfService; |
|
|
|
@ -38,6 +44,10 @@ import com.dxhy.order.invoice.utils.HttpInvoiceRequestUtilQd; |
|
|
|
|
import com.dxhy.order.invoice.utils.PDFExportUtil; |
|
|
|
|
import com.dxhy.order.invoice.utils.generateinvoice.PdfProducer; |
|
|
|
|
import com.dxhy.order.model.*; |
|
|
|
|
import com.dxhy.order.model.page.OrderInvoiceInfoVo; |
|
|
|
|
import com.dxhy.order.model.page.RedInvoiceCheckReqPo; |
|
|
|
|
import com.dxhy.order.model.page.RedInvoiceRespPo; |
|
|
|
|
import com.dxhy.order.model.page.RedInvoiceStageReqPo; |
|
|
|
|
import com.dxhy.order.model.qd.QdFileDownloadRequest; |
|
|
|
|
import com.dxhy.order.model.qd.QdFileDownloadResponse; |
|
|
|
|
import com.dxhy.order.model.queue.CommonTsMqData; |
|
|
|
@ -49,12 +59,17 @@ import com.dxhy.order.model.sk.pdf.InvoicePdf; |
|
|
|
|
import com.dxhy.order.utils.*; |
|
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
|
import com.google.common.collect.Maps; |
|
|
|
|
import lombok.SneakyThrows; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.apache.ibatis.annotations.Param; |
|
|
|
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook; |
|
|
|
|
import org.joda.time.DateTime; |
|
|
|
|
import org.joda.time.Duration; |
|
|
|
|
import org.redisson.api.RLock; |
|
|
|
|
import org.redisson.api.RedissonClient; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
|
@ -65,6 +80,7 @@ import java.io.File; |
|
|
|
|
import java.io.FileInputStream; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.OutputStream; |
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
|
import java.util.concurrent.Executor; |
|
|
|
@ -95,6 +111,9 @@ public class OrderInvoiceInfoServiceImpl implements OrderInvoiceInfoService { |
|
|
|
|
private OrderInfoJdcMapper orderInfoJdcMapper; |
|
|
|
|
@Resource |
|
|
|
|
private OrderInfoEscMapper orderInfoEscMapper; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private GsClientFindMapper gsClientFindMapper; |
|
|
|
|
@Resource |
|
|
|
|
private HistoryDataPdfService historyDataPdfService; |
|
|
|
|
@Resource |
|
|
|
@ -129,6 +148,9 @@ public class OrderInvoiceInfoServiceImpl implements OrderInvoiceInfoService { |
|
|
|
|
@Qualifier("asyncExecutor") |
|
|
|
|
private Executor voucherTaskExecutor; |
|
|
|
|
|
|
|
|
|
private static final String KEY_PREFIX = "order:red:"; |
|
|
|
|
private static final String KEY_RED_SYJE = "order:red:syje"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 作用: |
|
|
|
@ -1493,5 +1515,287 @@ public class OrderInvoiceInfoServiceImpl implements OrderInvoiceInfoService { |
|
|
|
|
return orderInvoiceInfoMapper.countInoviceInfo(orderInfoIds); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R checkRedInvoice(RedInvoiceCheckReqPo redInvoiceReqPo) throws OrderReceiveException{ |
|
|
|
|
//根据报账单查询蓝字数据
|
|
|
|
|
RedInvoiceRespPo orderInvoiceData = this.getOrderInvoiceData(redInvoiceReqPo); |
|
|
|
|
List<OrderInvoiceInfoVo> orderInvoiceInfos = orderInvoiceData.getOrderInvoiceInfos(); |
|
|
|
|
|
|
|
|
|
//查询报账单是否存在
|
|
|
|
|
if(orderInvoiceInfos.size() == 0){ |
|
|
|
|
return R.error("根据报账单号未查询到订单");//改为常量
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//todo 根据蓝字报账单调用SAP接口查询SAP状态,是否允许冲红 明慧开发
|
|
|
|
|
//查询公司client
|
|
|
|
|
List<GsClient> gsClients = gsClientFindMapper.selectByGsdm(orderInvoiceData.getGsdm()); |
|
|
|
|
if (ObjectUtils.isEmpty(gsClients)){ |
|
|
|
|
return R.error("未查询到公司client"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
boolean bzhStatus = getBzhStatus(orderInvoiceData.getRedBzdh(), gsClients.get(0).getClient()); |
|
|
|
|
|
|
|
|
|
if (bzhStatus) { |
|
|
|
|
return R.error("蓝字报账单状态不允许冲红"); |
|
|
|
|
} |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
log.error("{}获取蓝字报账单状态异常", LOGGER_MSG,e); |
|
|
|
|
return R.error("未查询到订单"); |
|
|
|
|
} |
|
|
|
|
List<OrderItemInfo> redItemInfoList = orderInvoiceData.getRedItemInfoList(); |
|
|
|
|
if(CollectionUtil.isNotEmpty(redItemInfoList)){ |
|
|
|
|
boolean b = redItemInfoList.stream().allMatch(redItemInfo -> StringUtils.isNotBlank(redItemInfo.getSpbm()) && ConfigureConstant.STRING_0.equals(redItemInfo.getZnfm())); |
|
|
|
|
if(!b){ |
|
|
|
|
return R.error("负数订单存在智能赋码及局端税编的明细行");//改为常量
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//根据orderinfoId,查询红字订单信息
|
|
|
|
|
OrderInfo orderInfo = orderInfoMapper.selectOrderInfoByOrderId(redInvoiceReqPo.getOrderInfoId(), Arrays.asList(redInvoiceReqPo.getXhfNsrsbh())); |
|
|
|
|
if(orderInfo == null){ |
|
|
|
|
return R.error("当前红冲订单查询为空"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String xhfXx = (StringUtils.isNotBlank(orderInfo.getXhfNsrsbh()) ? orderInfo.getXhfNsrsbh() : "") |
|
|
|
|
+ (StringUtils.isNotBlank(orderInfo.getXhfMc()) ? orderInfo.getXhfMc() : ""); |
|
|
|
|
String lzXhfXx = (StringUtils.isNotBlank(orderInvoiceInfos.get(0).getXhfNsrsbh()) ? orderInvoiceInfos.get(0).getXhfNsrsbh() : "") |
|
|
|
|
+ (StringUtils.isNotBlank(orderInvoiceInfos.get(0).getXhfMc()) ? orderInvoiceInfos.get(0).getXhfMc() : ""); |
|
|
|
|
String ghfXx = (StringUtils.isNotBlank(orderInfo.getGhfNsrsbh()) ? orderInfo.getGhfNsrsbh() : "") |
|
|
|
|
+ (StringUtils.isNotBlank(orderInfo.getGhfMc()) ? orderInfo.getGhfMc() : ""); |
|
|
|
|
String lzGhfXx = (StringUtils.isNotBlank(orderInvoiceInfos.get(0).getGhfNsrsbh()) ? orderInvoiceInfos.get(0).getGhfNsrsbh() : "") |
|
|
|
|
+ (StringUtils.isNotBlank(orderInvoiceInfos.get(0).getGhfMc()) ? orderInvoiceInfos.get(0).getGhfMc() : ""); |
|
|
|
|
|
|
|
|
|
//购销方是否一致
|
|
|
|
|
if(!xhfXx.equals(lzXhfXx) ){ |
|
|
|
|
return R.error("负数订单的销方信息与对应蓝字报账单号不一致");//改为常量
|
|
|
|
|
} |
|
|
|
|
if(!ghfXx.equals(lzGhfXx)){ |
|
|
|
|
return R.error("负数订单的购方信息与对应蓝字报账单号不一致");//改为常量
|
|
|
|
|
} |
|
|
|
|
//校验发票种类是否一致
|
|
|
|
|
if(!orderInfo.getFpzlDm().equals(orderInvoiceInfos.get(0).getFpzlDm())){ |
|
|
|
|
return R.error("负数订单的发票种类与对应蓝字报账单号不一致");//改为常量
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//比较金额(发票剩余金额、如果是专票的话需要加上红字申请的金额、如果是数电票的话需要调用接口查询红字查询)
|
|
|
|
|
BigDecimal sykchbhsje = new BigDecimal("0.00"); |
|
|
|
|
BigDecimal sykchse = new BigDecimal("0.00"); |
|
|
|
|
for (OrderInvoiceInfoVo orderInvoiceInfo : orderInvoiceInfos) { |
|
|
|
|
if(StringUtils.isNotBlank(orderInvoiceInfo.getSykchbhsje()) && StringUtils.isNotBlank(orderInvoiceInfo.getSykchje()) |
|
|
|
|
&& StringUtils.isNotBlank(orderInvoiceInfo.getSykchse()) && new BigDecimal(orderInvoiceInfo.getSykchse()).compareTo(BigDecimal.ZERO) > ConfigureConstant.INT_0){ |
|
|
|
|
sykchbhsje = sykchbhsje.add(new BigDecimal(orderInvoiceInfo.getSykchbhsje())); |
|
|
|
|
sykchse = sykchse.add(new BigDecimal(orderInvoiceInfo.getSykchse())); |
|
|
|
|
} else { |
|
|
|
|
List<OrderInfo> orderInfos = orderInfoMapper.selectOrderInfoByYfpdmhm(orderInvoiceInfo.getFpdm(), orderInvoiceInfo.getFphm(), Arrays.asList(redInvoiceReqPo.getXhfNsrsbh())); |
|
|
|
|
if(CollectionUtil.isNotEmpty(orderInfos)){ |
|
|
|
|
BigDecimal chbhsje = orderInfos.stream().map(order -> new BigDecimal(order.getHjbhsje())).reduce(BigDecimal.ZERO, BigDecimal::add).abs(); |
|
|
|
|
BigDecimal chse = orderInfos.stream().map(order -> new BigDecimal(order.getHjse())).reduce(BigDecimal.ZERO, BigDecimal::add).abs(); |
|
|
|
|
sykchbhsje = sykchbhsje.add(new BigDecimal(orderInvoiceInfo.getHjbhsje()).subtract(chbhsje)); |
|
|
|
|
sykchse = sykchse.add(new BigDecimal(orderInvoiceInfo.getKpse()).subtract(chse)); |
|
|
|
|
} else { |
|
|
|
|
sykchbhsje = sykchbhsje.add(new BigDecimal(orderInvoiceInfo.getHjbhsje())); |
|
|
|
|
sykchse = sykchse.add(new BigDecimal(orderInvoiceInfo.getKpse())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(sykchbhsje.compareTo(BigDecimal.ZERO) > ConfigureConstant.INT_0 && sykchse.compareTo(BigDecimal.ZERO) > ConfigureConstant.INT_0){ |
|
|
|
|
BigDecimal hzddHjbhsje = new BigDecimal(orderInfo.getHjbhsje()).abs(); |
|
|
|
|
BigDecimal hzddHjse = new BigDecimal(orderInfo.getHjse()).abs(); |
|
|
|
|
if (hzddHjbhsje.subtract(sykchbhsje).compareTo(BigDecimal.ZERO) <= ConfigureConstant.INT_0 |
|
|
|
|
&& hzddHjse.subtract(sykchse).compareTo(BigDecimal.ZERO) <= ConfigureConstant.INT_0){ |
|
|
|
|
return R.ok().put(OrderManagementConstant.DATA,orderInvoiceData); |
|
|
|
|
} else { |
|
|
|
|
return R.error("蓝字剩余可冲红不含税金额小于负数订单不含税金额或税额");//改为常量
|
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
return R.error("蓝字剩余可冲红不含税金额或者税额小于0");//改为常量
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据报账单查询蓝字数据 |
|
|
|
|
* 根据请求流水号查询红字明细 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public RedInvoiceRespPo getOrderInvoiceData(RedInvoiceCheckReqPo redInvoiceReqPo) { |
|
|
|
|
RedInvoiceRespPo redInvoiceRespPo = new RedInvoiceRespPo(); |
|
|
|
|
List<OrderInvoiceInfoVo> orderInvoiceInfoVos = orderInvoiceInfoMapper.selectInvoiceInfoByBzdh(redInvoiceReqPo.getLzbzdh(), Arrays.asList(redInvoiceReqPo.getXhfNsrsbh())); |
|
|
|
|
List<OrderItemInfo> orderItemInfos = orderItemInfoMapper.selectOrderItemInfoByOrderId(redInvoiceReqPo.getOrderInfoId(), Arrays.asList(redInvoiceReqPo.getXhfNsrsbh())); |
|
|
|
|
// OrderInvoiceInfo invoiceInfo = new OrderInvoiceInfo();
|
|
|
|
|
// invoiceInfo.setOrderInfoId(redInvoiceReqPo.getOrderInfoId());
|
|
|
|
|
OrderInfo orderInfo = orderInfoMapper.selectOrderInfoByOrderId(redInvoiceReqPo.getOrderInfoId(), Arrays.asList(redInvoiceReqPo.getXhfNsrsbh())); |
|
|
|
|
OrderProcessInfo orderProcessInfo = orderInfoMapper.selectProcessByFpqqlsh(orderInfo.getFpqqlsh(), Arrays.asList(redInvoiceReqPo.getXhfNsrsbh())); |
|
|
|
|
//是否允许勾选,发票状态
|
|
|
|
|
orderInvoiceInfoVos.stream().map(t->{ |
|
|
|
|
Boolean selected = true; |
|
|
|
|
t.setDdzt("开具成功");//枚举
|
|
|
|
|
if(OrderInfoEnum.ORDER_STATUS_0.getKey().equals(t.getDdzt()) |
|
|
|
|
||OrderInfoEnum.ORDER_STATUS_1.getKey().equals(t.getDdzt()) |
|
|
|
|
||OrderInfoEnum.ORDER_STATUS_2.getKey().equals(t.getDdzt()) |
|
|
|
|
||OrderInfoEnum.ORDER_STATUS_3.getKey().equals(t.getDdzt()) |
|
|
|
|
){ |
|
|
|
|
t.setDdzt("未开具");//枚举
|
|
|
|
|
selected = false; |
|
|
|
|
} |
|
|
|
|
if(OrderInfoEnum.ORDER_STATUS_4.getKey().equals(t.getDdzt())){ |
|
|
|
|
t.setDdzt("开具中");//枚举
|
|
|
|
|
selected = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(OrderInfoEnum.ORDER_STATUS_5.getKey().equals(t.getDdzt()) && |
|
|
|
|
(ConfigureConstant.STRING_1.equals(t.getZfBz()) |
|
|
|
|
|| ConfigureConstant.STRING_2.equals(t.getZfBz())) |
|
|
|
|
){ |
|
|
|
|
t.setDdzt("已作废");//枚举
|
|
|
|
|
selected = false; |
|
|
|
|
} |
|
|
|
|
if(OrderInfoEnum.ORDER_STATUS_5.getKey().equals(t.getDdzt()) && |
|
|
|
|
(ConfigureConstant.STRING_1.equals(t.getChBz()) |
|
|
|
|
|| ConfigureConstant.STRING_2.equals(t.getChBz()) |
|
|
|
|
|| ConfigureConstant.STRING_3.equals(t.getChBz())) |
|
|
|
|
){ |
|
|
|
|
t.setDdzt("已冲红");//枚举
|
|
|
|
|
selected = false; |
|
|
|
|
} |
|
|
|
|
//
|
|
|
|
|
if(OrderInfoEnum.ORDER_STATUS_5.getKey().equals(t.getDdzt()) && |
|
|
|
|
(ConfigureConstant.STRING_4.equals(t.getChBz()) |
|
|
|
|
|| ConfigureConstant.STRING_5.equals(t.getChBz()) |
|
|
|
|
|| ConfigureConstant.STRING_6.equals(t.getChBz())) |
|
|
|
|
){ |
|
|
|
|
t.setDdzt("部分冲红");//枚举
|
|
|
|
|
} |
|
|
|
|
t.setSelected(selected); |
|
|
|
|
|
|
|
|
|
return t; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
redInvoiceRespPo.setOrderInvoiceInfos(orderInvoiceInfoVos); |
|
|
|
|
redInvoiceRespPo.setRedItemInfoList(orderItemInfos); |
|
|
|
|
//明细合并
|
|
|
|
|
if(StringUtils.isNotBlank(redInvoiceReqPo.getSfhb()) && ConfigureConstant.STRING_1.equals(redInvoiceReqPo.getSfhb())){ |
|
|
|
|
Map<String, OrderItemInfo> comparisonMap = Maps.newHashMap(); |
|
|
|
|
for (OrderItemInfo orderItemInfo : orderItemInfos) { |
|
|
|
|
String comparisonKey = orderItemInfo.getZxbm()+orderItemInfo.getXmmc(); |
|
|
|
|
OrderItemInfo itemInfo = comparisonMap.get(comparisonKey); |
|
|
|
|
if(itemInfo == null){ |
|
|
|
|
comparisonMap.put(comparisonKey,orderItemInfo); |
|
|
|
|
}else { |
|
|
|
|
String xmje = new BigDecimal(itemInfo.getXmje()).abs().add(new BigDecimal(orderItemInfo.getXmje()).abs()).toPlainString(); |
|
|
|
|
String se = new BigDecimal(itemInfo.getSe()).abs().add(new BigDecimal(orderItemInfo.getSe()).abs()).toPlainString(); |
|
|
|
|
orderItemInfo.setXmje(xmje); |
|
|
|
|
orderItemInfo.setSe(se); |
|
|
|
|
String redSyjeKey = KEY_RED_SYJE + orderItemInfo.getId(); |
|
|
|
|
String value = redisService.get(redSyjeKey); |
|
|
|
|
if(StringUtils.isNotBlank(value)){ |
|
|
|
|
orderItemInfo.setSykchje(value); |
|
|
|
|
} else { |
|
|
|
|
orderItemInfo.setSykchje(xmje); |
|
|
|
|
} |
|
|
|
|
comparisonMap.put(comparisonKey,orderItemInfo); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
List<OrderItemInfo> itemInfos = comparisonMap.entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toList()); |
|
|
|
|
redInvoiceRespPo.setRedItemInfoList(itemInfos); |
|
|
|
|
} |
|
|
|
|
redInvoiceRespPo.setRedFpqqlsh(orderInfo.getFpqqlsh()); |
|
|
|
|
redInvoiceRespPo.setRedBzdh(orderProcessInfo.getBzdh()); |
|
|
|
|
redInvoiceRespPo.setGsdm(orderProcessInfo.getGsdm()); |
|
|
|
|
return redInvoiceRespPo; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private RedissonClient redisson; |
|
|
|
|
|
|
|
|
|
@SneakyThrows |
|
|
|
|
@Override |
|
|
|
|
public R stageRedInvoiceData(RedInvoiceStageReqPo redInvoiceSaveReqPo){ |
|
|
|
|
//存储redis map结构,map外层key是红字fpqqlsh,内层是发票号码+发票代码,将整体发票报文存储在value里
|
|
|
|
|
OrderInvoiceInfo blueInvoiceInfo = redInvoiceSaveReqPo.getBlueInvoiceInfo(); |
|
|
|
|
String key = KEY_PREFIX + redInvoiceSaveReqPo.getFpqqlsh(); |
|
|
|
|
String innerKey = StringUtils.isBlank(blueInvoiceInfo.getFpdm())?"":blueInvoiceInfo.getFpdm() + blueInvoiceInfo.getFphm(); |
|
|
|
|
//组装发票报文
|
|
|
|
|
//金额、数量、税额跟跟换为负数,折扣行要与被折扣行合并
|
|
|
|
|
//校验重复提交数据覆盖问题
|
|
|
|
|
RLock lock = redisson.getLock(redInvoiceSaveReqPo.getFpqqlsh()); |
|
|
|
|
// boolean redRedisLock = redisService.setNx(redInvoiceSaveReqPo.getFpqqlsh(), key, RedisConstant.REDIS_EXPIRE_TIME_2HOUR);
|
|
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
|
try { |
|
|
|
|
if(!lock.isLocked()){ |
|
|
|
|
lock.lock(); |
|
|
|
|
Map<String, String> paramMap = redisService.pullAllHashMap(key); |
|
|
|
|
if(paramMap != null){ |
|
|
|
|
String value = redisService.pullHashMap(key, innerKey); |
|
|
|
|
if(StringUtils.isNotBlank(value)){ |
|
|
|
|
redisService.delHashMap(key,innerKey); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
redisService.putHashMap(key,innerKey, JSONObject.toJSONString(redInvoiceSaveReqPo)); |
|
|
|
|
Map<String, String> hashMap = Maps.newHashMap(); |
|
|
|
|
if(paramMap != null){ |
|
|
|
|
BigDecimal blueMxje = new BigDecimal("0.00"); |
|
|
|
|
BigDecimal redMxje = new BigDecimal("0.00"); |
|
|
|
|
List<OrderItemInfo> redItemList = null; |
|
|
|
|
for (Map.Entry<String, String> stringEntry : paramMap.entrySet()) { |
|
|
|
|
String entryValue = stringEntry.getValue(); |
|
|
|
|
RedInvoiceStageReqPo invoiceStageReqPo = JSONObject.parseObject(entryValue, RedInvoiceStageReqPo.class); |
|
|
|
|
List<OrderItemInfo> blueItemList = invoiceStageReqPo.getBlueItemList(); |
|
|
|
|
blueMxje = blueMxje.add(blueItemList.stream().map(blueItem -> new BigDecimal(blueItem.getXmje())).reduce(BigDecimal.ZERO, BigDecimal::add)); |
|
|
|
|
redItemList = invoiceStageReqPo.getRedItemList(); |
|
|
|
|
} |
|
|
|
|
if(redItemList != null){ |
|
|
|
|
redMxje = redItemList.stream().map(redItem -> new BigDecimal(redItem.getXmje())).reduce(BigDecimal.ZERO, BigDecimal::add).abs(); |
|
|
|
|
String syfpje = redMxje.subtract(blueMxje).toPlainString(); |
|
|
|
|
String redSyjeKey = KEY_RED_SYJE + redItemList.get(0).getId(); |
|
|
|
|
redisService.set(redSyjeKey,syfpje); |
|
|
|
|
hashMap.put(redItemList.get(0).getId(),syfpje); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
lock.unlock(); |
|
|
|
|
return R.ok().put(OrderManagementConstant.DATA,hashMap); |
|
|
|
|
} else { |
|
|
|
|
Thread.sleep(2000); |
|
|
|
|
log.info("获取redis锁请等待,三次之后还是获取锁失败则返回。。。"); |
|
|
|
|
} |
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
lock.unlock(); |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return R.ok(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean getBzhStatus(String bzdh,String clint){ |
|
|
|
|
//拼凑报文
|
|
|
|
|
IsInput isInput = new IsInput(); |
|
|
|
|
isInput.setSYSID(OrderInfoEnum.SYS_SIGN_FP.getKey()); |
|
|
|
|
isInput.setIFYWID(OrderInfoEnum.INTERFACE_BUSINESS_ID_BZDSTATUS.getKey()); |
|
|
|
|
isInput.setBSKEY(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
|
isInput.setZORG(""); |
|
|
|
|
isInput.setZFILED5(clint); |
|
|
|
|
Map<String,String> data = new HashMap<>(); |
|
|
|
|
data.put("ZBZDH",bzdh); |
|
|
|
|
isInput.setZDATA(JsonUtils.getInstance().toJsonString(data)); |
|
|
|
|
PoCommonRequestParam poCommonRequestParam = new PoCommonRequestParam(); |
|
|
|
|
poCommonRequestParam.setIS_INPUT(isInput); |
|
|
|
|
String param = JsonUtils.getInstance().toJsonString(poCommonRequestParam); |
|
|
|
|
log.info("{}获取报账单号状态入参:{}",LOGGER_MSG,param); |
|
|
|
|
String result = HttpUtils.sendPo(baseServiceConfig.getPoUrl(), param,baseServiceConfig.getPoUserName(),baseServiceConfig.getPoPassword()); |
|
|
|
|
log.info("{}获取报账单号状态出参:{}",LOGGER_MSG,result); |
|
|
|
|
PoCommonResponseParam poCommonResponseParam = JSONObject.parseObject(result, PoCommonResponseParam.class); |
|
|
|
|
String zdata = poCommonResponseParam.getES_OUTPUT().getZDATA(); |
|
|
|
|
JSONObject response = JSONObject.parseObject(zdata); |
|
|
|
|
String bzdzt = response.getString("BZDZT"); |
|
|
|
|
//校验状态
|
|
|
|
|
String bzdStatus = baseServiceConfig.getBzdStatus(); |
|
|
|
|
String[] split = bzdStatus.split(","); |
|
|
|
|
if (StringUtils.isNotBlank(bzdh)||Arrays.asList(split).contains(bzdzt)){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|