|
|
|
@ -12,7 +12,6 @@ import com.dxhy.common.exception.BaseException; |
|
|
|
|
import com.dxhy.common.util.InvoiceUtil; |
|
|
|
|
import com.dxhy.common.utils.Base64Encoding; |
|
|
|
|
import com.dxhy.common.utils.R; |
|
|
|
|
import com.dxhy.erp.dao.*; |
|
|
|
|
import com.dxhy.erp.entity.*; |
|
|
|
|
import com.dxhy.erp.entity.sdny.*; |
|
|
|
|
import com.dxhy.erp.model.InvoiceDetailInfo; |
|
|
|
@ -21,11 +20,14 @@ import com.dxhy.erp.utils.Base64; |
|
|
|
|
import com.dxhy.erp.utils.HmacSHA1Util; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.redisson.api.RLock; |
|
|
|
|
import org.redisson.api.RedissonClient; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
|
import org.springframework.util.Base64Utils; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
@ -86,6 +88,9 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
@Autowired |
|
|
|
|
private ImageSubmitService imageSubmitService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private RedissonClient redisson; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查验发票 |
|
|
|
|
*/ |
|
|
|
@ -489,142 +494,154 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
@SysLog("发票查验") |
|
|
|
|
public ResponseEntity<String> singleInvoiceCheck(@RequestBody Map<String, String> pramsMap) throws Exception { |
|
|
|
|
log.info("传入的参数为:{}", pramsMap); |
|
|
|
|
String dbName = "business"; |
|
|
|
|
JSONObject checkInvoiceResult = null; |
|
|
|
|
|
|
|
|
|
InvoiceUtil iu = new InvoiceUtil(pramsMap.get("invoiceCode")); |
|
|
|
|
String fplxdm = iu.getFplxdm(); |
|
|
|
|
if (fplxdm != null || "10107".equals(pramsMap.get("invoiceType")) || "10108".equals(pramsMap.get("invoiceType")) || pramsMap.get("invoiceCode").startsWith("50000")) { |
|
|
|
|
//查验类发票,执行查验操作后入库
|
|
|
|
|
log.info("查验类发票,执行查验操作后入库"); |
|
|
|
|
//权限校验
|
|
|
|
|
if (StringUtils.isBlank(pramsMap.get("invoiceNumber"))) { |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("发票号码不能为空!"))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pramsMap.put("invoiceNo", pramsMap.get("invoiceNumber")); |
|
|
|
|
String param = JSONObject.toJSONString(pramsMap); |
|
|
|
|
//加分布式锁
|
|
|
|
|
String lockKey = Base64Utils.encodeToString(param.getBytes()); |
|
|
|
|
boolean isLock = false; |
|
|
|
|
RLock lock = redisson.getLock(lockKey); |
|
|
|
|
try { |
|
|
|
|
isLock = lock.tryLock(); |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(pramsMap.get("billingDate"))) { |
|
|
|
|
String billingDate = pramsMap.get("billingDate").replaceAll("-", ""); |
|
|
|
|
iu.setKprq(pramsMap.get("billingDate")); |
|
|
|
|
pramsMap.put("invoiceDate", billingDate); |
|
|
|
|
pramsMap.put("billingDate", billingDate); |
|
|
|
|
if (!isLock) { |
|
|
|
|
log.info("当前已有线程获取到锁"); |
|
|
|
|
} else { |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("开票日期不能为空!"))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(pramsMap.get("invoiceType"))) { |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("发票类型不能为空!"))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (SNFplxEnum.ZP.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.JDC.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.DZZP.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.ESC.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.QDZP.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.QDPP.getSnFplxDm().equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
if (StringUtils.isBlank(pramsMap.get("totalAmount"))) { |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("金额不能为空!"))); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (StringUtils.isBlank(pramsMap.get("checkCode"))) { |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("校验码不能为空!"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String dbName = "business"; |
|
|
|
|
JSONObject checkInvoiceResult = null; |
|
|
|
|
|
|
|
|
|
InvoiceUtil iu = new InvoiceUtil(pramsMap.get("invoiceCode")); |
|
|
|
|
String fplxdm = iu.getFplxdm(); |
|
|
|
|
if (fplxdm != null || "10107".equals(pramsMap.get("invoiceType")) || "10108".equals(pramsMap.get("invoiceType")) || pramsMap.get("invoiceCode").startsWith("50000")) { |
|
|
|
|
//查验类发票,执行查验操作后入库
|
|
|
|
|
log.info("查验类发票,执行查验操作后入库"); |
|
|
|
|
//权限校验
|
|
|
|
|
if (StringUtils.isBlank(pramsMap.get("invoiceNumber"))) { |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("发票号码不能为空!"))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ("10107".equals(pramsMap.get("invoiceType")) || "10108".equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
pramsMap.put("invoiceType", "21"); |
|
|
|
|
} |
|
|
|
|
pramsMap.put("invoiceNo", pramsMap.get("invoiceNumber")); |
|
|
|
|
|
|
|
|
|
log.info("发票类型为:{}", pramsMap.get("invoiceType")); |
|
|
|
|
if (StringUtils.isNotBlank(pramsMap.get("billingDate"))) { |
|
|
|
|
String billingDate = pramsMap.get("billingDate").replaceAll("-", ""); |
|
|
|
|
iu.setKprq(pramsMap.get("billingDate")); |
|
|
|
|
pramsMap.put("invoiceDate", billingDate); |
|
|
|
|
pramsMap.put("billingDate", billingDate); |
|
|
|
|
} else { |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("开票日期不能为空!"))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String uuid = (StringUtils.isBlank(pramsMap.get("invoiceCode")) ? "" : pramsMap.get("invoiceCode")) + pramsMap.get("invoiceNo"); |
|
|
|
|
log.info("uuid={}", uuid); |
|
|
|
|
String notes = invoiceQueryService.checkingInvoiceInfo("business", uuid, getUserInfo()); |
|
|
|
|
if (notes != null) { |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(notes))); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.isBlank(pramsMap.get("invoiceType"))) { |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("发票类型不能为空!"))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//非通行费类发票 先判断底账库中是否已存在
|
|
|
|
|
if (!"32000".equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
//查询底账库是否有对应发票,有则直接返回
|
|
|
|
|
QueryWrapper<BaseTDxRecordInvoice> recordWrapper = new QueryWrapper<>(); |
|
|
|
|
recordWrapper.eq("uuid", uuid); |
|
|
|
|
BaseTDxRecordInvoice checkInvoiceByUuid = snPushCheckRecordService.selectRecordByWrapper(recordWrapper); |
|
|
|
|
if (checkInvoiceByUuid != null) { |
|
|
|
|
log.info("进项票池已存在发票.直接返回票池信息"); |
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
if (SNFplxEnum.ZP.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.JDC.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.DZZP.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.ESC.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.QDZP.getSnFplxDm().equals(pramsMap.get("invoiceType")) |
|
|
|
|
|| SNFplxEnum.QDPP.getSnFplxDm().equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
if (StringUtils.isBlank(pramsMap.get("totalAmount"))) { |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("金额不能为空!"))); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (StringUtils.isBlank(pramsMap.get("checkCode"))) { |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("校验码不能为空!"))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//如果购方名称为空,则查验之后补充购销方相关信息
|
|
|
|
|
String gfName = checkInvoiceByUuid.getGfName(); |
|
|
|
|
String gfAddressAndPhone = checkInvoiceByUuid.getGfAddressAndPhone(); |
|
|
|
|
if(StringUtils.isEmpty(gfName) || StringUtils.isEmpty(gfAddressAndPhone)){ |
|
|
|
|
log.info("购方名称为空,查验补充信息"); |
|
|
|
|
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap, null); |
|
|
|
|
if ("10107".equals(pramsMap.get("invoiceType")) || "10108".equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
pramsMap.put("invoiceType", "21"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!checkInvoiceResult.containsKey("code")) { |
|
|
|
|
if (!checkInvoiceResult.containsKey("cyjg")) { |
|
|
|
|
snPushCheckRecordService.updateInvoice(dbName, checkInvoiceResult, recordWrapper); |
|
|
|
|
} else if (checkInvoiceResult.containsKey("cyjg") && !"0001".equals(checkInvoiceResult.getString("cyjg"))) { |
|
|
|
|
data = errorInfo(checkInvoiceResult, data); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
log.info("发票类型为:{}", pramsMap.get("invoiceType")); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
checkInvoiceByUuid = snPushCheckRecordService.selectRecordByWrapper(recordWrapper); |
|
|
|
|
String uuid = (StringUtils.isBlank(pramsMap.get("invoiceCode")) ? "" : pramsMap.get("invoiceCode")) + pramsMap.get("invoiceNo"); |
|
|
|
|
log.info("uuid={}", uuid); |
|
|
|
|
String notes = invoiceQueryService.checkingInvoiceInfo("business", uuid, getUserInfo()); |
|
|
|
|
if (notes != null) { |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(notes))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String invoiceNo = checkInvoiceByUuid.getInvoiceNo(); |
|
|
|
|
QueryWrapper<BaseTDxRecordInvoiceDetail> detailWrapper = new QueryWrapper<>(); |
|
|
|
|
detailWrapper.eq("uuid", uuid); |
|
|
|
|
//非通行费类发票 先判断底账库中是否已存在
|
|
|
|
|
if (!"32000".equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
//查询底账库是否有对应发票,有则直接返回
|
|
|
|
|
QueryWrapper<BaseTDxRecordInvoice> recordWrapper = new QueryWrapper<>(); |
|
|
|
|
recordWrapper.eq("uuid", uuid); |
|
|
|
|
BaseTDxRecordInvoice checkInvoiceByUuid = snPushCheckRecordService.selectRecordByWrapper(recordWrapper); |
|
|
|
|
if (checkInvoiceByUuid != null) { |
|
|
|
|
log.info("进项票池已存在发票.直接返回票池信息"); |
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
|
|
|
|
|
//如果购方名称为空,则查验之后补充购销方相关信息
|
|
|
|
|
String gfName = checkInvoiceByUuid.getGfName(); |
|
|
|
|
String gfAddressAndPhone = checkInvoiceByUuid.getGfAddressAndPhone(); |
|
|
|
|
if (StringUtils.isEmpty(gfName) || StringUtils.isEmpty(gfAddressAndPhone)) { |
|
|
|
|
log.info("购方名称为空,查验补充信息"); |
|
|
|
|
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap, null); |
|
|
|
|
|
|
|
|
|
if (!checkInvoiceResult.containsKey("code")) { |
|
|
|
|
if (!checkInvoiceResult.containsKey("cyjg")) { |
|
|
|
|
snPushCheckRecordService.updateInvoice(dbName, checkInvoiceResult, recordWrapper); |
|
|
|
|
} else if (checkInvoiceResult.containsKey("cyjg") && !"0001".equals(checkInvoiceResult.getString("cyjg"))) { |
|
|
|
|
data = errorInfo(checkInvoiceResult, data); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
|
|
|
|
|
List<BaseTDxRecordInvoiceDetail> baseTDxRecordInvoiceDetail = null; |
|
|
|
|
List<TDxVehicleSaleInvoice> vehicleList = null; |
|
|
|
|
if ("10104".equals(pramsMap.get("invoiceType")) || "10105".equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
vehicleList = snPushCheckRecordService.vihicleList(uuid); |
|
|
|
|
} else { |
|
|
|
|
baseTDxRecordInvoiceDetail = snPushCheckRecordService.selectRecordDetailListByWrapper(detailWrapper); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
checkInvoiceByUuid = snPushCheckRecordService.selectRecordByWrapper(recordWrapper); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ((baseTDxRecordInvoiceDetail == null || baseTDxRecordInvoiceDetail.size() == 0) && (vehicleList == null || vehicleList.size() == 0)) { |
|
|
|
|
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap, null); |
|
|
|
|
String invoiceNo = checkInvoiceByUuid.getInvoiceNo(); |
|
|
|
|
QueryWrapper<BaseTDxRecordInvoiceDetail> detailWrapper = new QueryWrapper<>(); |
|
|
|
|
detailWrapper.eq("uuid", uuid); |
|
|
|
|
|
|
|
|
|
if (!checkInvoiceResult.containsKey("code")) { |
|
|
|
|
if (!checkInvoiceResult.containsKey("cyjg")) { |
|
|
|
|
//先删除原有主数据,再查验更新主数据和明细数据
|
|
|
|
|
snPushCheckRecordService.updateInvoice(dbName, checkInvoiceResult, recordWrapper); |
|
|
|
|
List<BaseTDxRecordInvoiceDetail> baseTDxRecordInvoiceDetail = null; |
|
|
|
|
List<TDxVehicleSaleInvoice> vehicleList = null; |
|
|
|
|
if ("10104".equals(pramsMap.get("invoiceType")) || "10105".equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
vehicleList = snPushCheckRecordService.vihicleList(uuid); |
|
|
|
|
} else { |
|
|
|
|
baseTDxRecordInvoiceDetail = snPushCheckRecordService.selectRecordDetailListByWrapper(detailWrapper); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ("10104".equals(pramsMap.get("invoiceType")) || "10105".equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
vehicleList = snPushCheckRecordService.vihicleList(uuid); |
|
|
|
|
} else { |
|
|
|
|
baseTDxRecordInvoiceDetail = snPushCheckRecordService.selectRecordDetailListByWrapper(detailWrapper); |
|
|
|
|
if ((baseTDxRecordInvoiceDetail == null || baseTDxRecordInvoiceDetail.size() == 0) && (vehicleList == null || vehicleList.size() == 0)) { |
|
|
|
|
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap, null); |
|
|
|
|
|
|
|
|
|
if (!checkInvoiceResult.containsKey("code")) { |
|
|
|
|
if (!checkInvoiceResult.containsKey("cyjg")) { |
|
|
|
|
//先删除原有主数据,再查验更新主数据和明细数据
|
|
|
|
|
snPushCheckRecordService.updateInvoice(dbName, checkInvoiceResult, recordWrapper); |
|
|
|
|
|
|
|
|
|
if ("10104".equals(pramsMap.get("invoiceType")) || "10105".equals(pramsMap.get("invoiceType"))) { |
|
|
|
|
vehicleList = snPushCheckRecordService.vihicleList(uuid); |
|
|
|
|
} else { |
|
|
|
|
baseTDxRecordInvoiceDetail = snPushCheckRecordService.selectRecordDetailListByWrapper(detailWrapper); |
|
|
|
|
} |
|
|
|
|
} else if (checkInvoiceResult.containsKey("cyjg") && !"0001".equals(checkInvoiceResult.getString("cyjg"))) { |
|
|
|
|
data = errorInfo(checkInvoiceResult, data); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (checkInvoiceResult.containsKey("cyjg") && !"0001".equals(checkInvoiceResult.getString("cyjg"))) { |
|
|
|
|
data = errorInfo(checkInvoiceResult, data); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
JSONObject checkInvoice = (JSONObject) JSONObject.toJSON(checkInvoiceByUuid); |
|
|
|
|
JSONArray checkInvoiceDetail = (JSONArray) JSONObject.toJSON(baseTDxRecordInvoiceDetail); |
|
|
|
|
JSONObject vehicleDetail = new JSONObject(); |
|
|
|
|
if(vehicleList != null && vehicleList.size() > 0) { |
|
|
|
|
vehicleDetail = (JSONObject) JSONObject.toJSON(vehicleList.get(0)); |
|
|
|
|
} |
|
|
|
|
JSONObject checkInvoice = (JSONObject) JSONObject.toJSON(checkInvoiceByUuid); |
|
|
|
|
JSONArray checkInvoiceDetail = (JSONArray) JSONObject.toJSON(baseTDxRecordInvoiceDetail); |
|
|
|
|
JSONObject vehicleDetail = new JSONObject(); |
|
|
|
|
if (vehicleList != null && vehicleList.size() > 0) { |
|
|
|
|
vehicleDetail = (JSONObject) JSONObject.toJSON(vehicleList.get(0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
convertToResult(checkInvoice, checkInvoiceDetail, vehicleDetail); |
|
|
|
|
convertToResult(checkInvoice, checkInvoiceDetail, vehicleDetail); |
|
|
|
|
|
|
|
|
|
data.put("data", checkInvoice); |
|
|
|
|
//查验结果保存
|
|
|
|
|
//saveCheckLog(pramsMap, checkInvoice);
|
|
|
|
|
data.put("data", checkInvoice); |
|
|
|
|
//查验结果保存
|
|
|
|
|
//saveCheckLog(pramsMap, checkInvoice);
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} else { |
|
|
|
|
TdxSaleRecordInvoice tdxSaleRecordInvoice = snPushCheckRecordService.selectSaleByUuid(uuid); |
|
|
|
|
log.info("tdxSaleRecordInvoice={}", tdxSaleRecordInvoice); |
|
|
|
|
if (tdxSaleRecordInvoice != null) { |
|
|
|
|
log.info("销项票池已存在发票.直接返回票池信息"); |
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} else { |
|
|
|
|
TdxSaleRecordInvoice tdxSaleRecordInvoice = snPushCheckRecordService.selectSaleByUuid(uuid); |
|
|
|
|
log.info("tdxSaleRecordInvoice={}", tdxSaleRecordInvoice); |
|
|
|
|
if (tdxSaleRecordInvoice != null) { |
|
|
|
|
log.info("销项票池已存在发票.直接返回票池信息"); |
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
|
|
|
|
|
String invoiceNo = tdxSaleRecordInvoice.getInvoiceNo(); |
|
|
|
|
QueryWrapper<RecordInvoiceSaleDetailModel> saleDetailWrapper = new QueryWrapper<>(); |
|
|
|
@ -656,51 +673,51 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
} |
|
|
|
|
convertToResult(checkInvoice, saleDetail); |
|
|
|
|
|
|
|
|
|
data.put("data", checkInvoice); |
|
|
|
|
//查验结果保存
|
|
|
|
|
// saveCheckLog(pramsMap,checkInvoice);
|
|
|
|
|
data.put("data", checkInvoice); |
|
|
|
|
//查验结果保存
|
|
|
|
|
// saveCheckLog(pramsMap,checkInvoice);
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap, "1"); |
|
|
|
|
log.info("查验结果为:{}", checkInvoiceResult); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error("查验失败,errormsg:{}", e.getMessage()); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("查验失败," + e.getMessage()))); |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap, "1"); |
|
|
|
|
log.info("查验结果为:{}", checkInvoiceResult); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error("查验失败,errormsg:{}", e.getMessage()); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("查验失败," + e.getMessage()))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!checkInvoiceResult.containsKey("code")) { |
|
|
|
|
if (!checkInvoiceResult.containsKey("code")) { |
|
|
|
|
|
|
|
|
|
if (checkInvoiceResult.containsKey("cyjg") && !"0001".equals(checkInvoiceResult.getString("cyjg"))) { |
|
|
|
|
R data = new R(); |
|
|
|
|
data = errorInfo(checkInvoiceResult, data); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} |
|
|
|
|
if (checkInvoiceResult.containsKey("cyjg") && !"0001".equals(checkInvoiceResult.getString("cyjg"))) { |
|
|
|
|
R data = new R(); |
|
|
|
|
data = errorInfo(checkInvoiceResult, data); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
data.put("message", "success"); |
|
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
data.put("message", "success"); |
|
|
|
|
|
|
|
|
|
if (!checkInvoiceResult.containsKey("cyjg")) { |
|
|
|
|
checkInvoiceResult.put("invoiceNo", checkInvoiceResult.getString("invoiceNumber")); |
|
|
|
|
log.info("返回给影像系统的结果为:{}", checkInvoiceResult); |
|
|
|
|
signSaveInvoiceInfoService.saveQueryInvoiceResult(checkInvoiceResult, "", "1", dbName); |
|
|
|
|
} |
|
|
|
|
if (!checkInvoiceResult.containsKey("cyjg")) { |
|
|
|
|
checkInvoiceResult.put("invoiceNo", checkInvoiceResult.getString("invoiceNumber")); |
|
|
|
|
log.info("返回给影像系统的结果为:{}", checkInvoiceResult); |
|
|
|
|
signSaveInvoiceInfoService.saveQueryInvoiceResult(checkInvoiceResult, "", "1", dbName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Object o = checkInvoiceResult.get("invoiceLineList"); |
|
|
|
|
JSONArray jsonArray = JSONObject.parseArray(JSONObject.toJSONString(o)); |
|
|
|
|
for (Object object : jsonArray) { |
|
|
|
|
Map map = JSONObject.parseObject(JSONObject.toJSONString(object), Map.class); |
|
|
|
|
String taxRate = (String) map.get("taxRate"); |
|
|
|
|
if ("0".equals(taxRate) || "*".equals(taxRate) || "**".equals(taxRate) || "***".equals(taxRate) || "不征税".equals(taxRate) || "免税".equals(taxRate)) { |
|
|
|
|
map.put("taxRate", "0.00"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
data.put("data", checkInvoiceResult); |
|
|
|
|
Object o = checkInvoiceResult.get("invoiceLineList"); |
|
|
|
|
JSONArray jsonArray = JSONObject.parseArray(JSONObject.toJSONString(o)); |
|
|
|
|
for (Object object : jsonArray) { |
|
|
|
|
Map map = JSONObject.parseObject(JSONObject.toJSONString(object), Map.class); |
|
|
|
|
String taxRate = (String) map.get("taxRate"); |
|
|
|
|
if ("0".equals(taxRate) || "*".equals(taxRate) || "**".equals(taxRate) || "***".equals(taxRate) || "不征税".equals(taxRate) || "免税".equals(taxRate)) { |
|
|
|
|
map.put("taxRate", "0.00"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
data.put("data", checkInvoiceResult); |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} |
|
|
|
@ -711,19 +728,31 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
log.info("其他类发票,不做查验,直接入库"); |
|
|
|
|
data.put("message", "success"); |
|
|
|
|
|
|
|
|
|
checkInvoiceResult.put("invoiceNo", checkInvoiceResult.getString("invoiceNumber")); |
|
|
|
|
checkInvoiceResult.put("message", "入库成功"); |
|
|
|
|
log.info("返回给影像系统的结果为:{}", checkInvoiceResult); |
|
|
|
|
checkInvoiceResult.put("invoiceNo", checkInvoiceResult.getString("invoiceNumber")); |
|
|
|
|
checkInvoiceResult.put("message", "入库成功"); |
|
|
|
|
log.info("返回给影像系统的结果为:{}", checkInvoiceResult); |
|
|
|
|
|
|
|
|
|
data.put("data", checkInvoiceResult); |
|
|
|
|
} else { |
|
|
|
|
data.put("message", "error 其他类发票不支持查验"); |
|
|
|
|
} |
|
|
|
|
data.put("data", checkInvoiceResult); |
|
|
|
|
} else { |
|
|
|
|
data.put("message", "error 其他类发票不支持查验"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error().put("data", checkInvoiceResult))); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error().put("data", checkInvoiceResult))); |
|
|
|
|
} |
|
|
|
|
}catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error().put("data", ""))); |
|
|
|
|
} |
|
|
|
|
finally { |
|
|
|
|
//关锁
|
|
|
|
|
if (isLock) { |
|
|
|
|
lock.unlock(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error().put("data", "请求正在处理,不要重复提交"))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Async |
|
|
|
|