|
|
|
@ -33,7 +33,6 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.math.RoundingMode; |
|
|
|
|
import java.text.ParseException; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.*; |
|
|
|
@ -107,7 +106,6 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private GatherService gatherService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查验发票 |
|
|
|
|
*/ |
|
|
|
@ -203,10 +201,10 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
List<BaseTDxRecordInvoiceDetail> baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper); |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ); |
|
|
|
|
|
|
|
|
|
if (baseTDxRecordInvoiceDetail != null && baseTDxRecordInvoiceDetail.size() == 0) { |
|
|
|
|
if(baseTDxRecordInvoiceDetail != null && baseTDxRecordInvoiceDetail.size() == 0){ |
|
|
|
|
//先删除原有主数据,再查验更新主数据和明细数据
|
|
|
|
|
int delete = baseTDxRecordInvoiceDao.delete(recordWrapper); |
|
|
|
|
if (delete > 0) { |
|
|
|
|
if(delete > 0) { |
|
|
|
|
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap); |
|
|
|
|
|
|
|
|
|
if (!checkInvoiceResult.containsKey("code")) { |
|
|
|
@ -261,13 +259,14 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap); |
|
|
|
|
log.info("查验结果为:{}", checkInvoiceResult); |
|
|
|
|
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap); |
|
|
|
|
log.info("查验结果为:{}", checkInvoiceResult); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error("查验失败,errormsg:{}", e.getMessage()); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("查验失败," + e.getMessage()))); |
|
|
|
|
log.error("查验失败,errormsg:{}",e.getMessage()); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("查验失败,"+e.getMessage()))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!checkInvoiceResult.containsKey("code")) { |
|
|
|
|
|
|
|
|
|
if (checkInvoiceResult.containsKey("cyjg") && !"0001".equals(checkInvoiceResult.getString("cyjg"))) { |
|
|
|
@ -290,7 +289,6 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
//其他类发票,直接入库
|
|
|
|
|
log.info("其他类发票,不做查验,直接入库"); |
|
|
|
@ -456,7 +454,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
for (int i = 0; i < detailList.size(); i++) { |
|
|
|
|
String taxRateDetail = ""; |
|
|
|
|
JSONObject detail = (JSONObject) detailList.get(i); |
|
|
|
|
if (StringUtils.isNotEmpty(detail.getString("goodsName")) && detail.getString("goodsName").contains("详见销货清单")) { |
|
|
|
|
if(StringUtils.isNotEmpty(detail.getString("goodsName")) && detail.getString("goodsName").contains("详见销货清单")){ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
Map<String, String> snDetailMap = new HashMap<String, String>(); |
|
|
|
@ -506,33 +504,24 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
int index = taxRateDetail.indexOf("%"); |
|
|
|
|
if (index > 0) { |
|
|
|
|
taxRateDetail = taxRateDetail.substring(0, taxRateDetail.length() - 1); |
|
|
|
|
Float num = Float.parseFloat(taxRateDetail); |
|
|
|
|
if (num > 9) { |
|
|
|
|
taxRateDetail = "0." + taxRateDetail; |
|
|
|
|
} else { |
|
|
|
|
if (!taxRateDetail.startsWith("0")) { |
|
|
|
|
taxRateDetail = "0.0" + taxRateDetail; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Float num = Float.parseFloat(taxRateDetail); |
|
|
|
|
if (num > 9) { |
|
|
|
|
taxRateDetail = "0." + taxRateDetail; |
|
|
|
|
} else { |
|
|
|
|
if (!taxRateDetail.startsWith("0")) { |
|
|
|
|
taxRateDetail = "0.0" + taxRateDetail; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// Float num = Float.parseFloat(taxRateDetail);
|
|
|
|
|
// if (num > 9) {
|
|
|
|
|
// taxRateDetail = "0." + taxRateDetail;
|
|
|
|
|
// } else {
|
|
|
|
|
// if (!taxRateDetail.startsWith("0")) {
|
|
|
|
|
// taxRateDetail = "0.0" + taxRateDetail;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("报错的原因为:{}", e); |
|
|
|
|
taxRateDetail = "0.00"; |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
log.error("报错的原因为:{}",e); |
|
|
|
|
taxRateDetail = "0"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ("11".equals(invoiceType)) { |
|
|
|
|
taxRateDetail = "0.000"; |
|
|
|
|
taxRateDetail = "0"; |
|
|
|
|
} |
|
|
|
|
log.info("明细-发票税率为:{}", taxRateDetail); |
|
|
|
|
snDetailMap.put("taxRate", taxRateDetail); |
|
|
|
@ -687,11 +676,11 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
log.error("同步SAP失败,报错信息为:{}", exception); |
|
|
|
|
exception.printStackTrace(); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.CONNECT_TIMEOUT))); |
|
|
|
|
} catch (NullPointerException exception) { |
|
|
|
|
} catch(NullPointerException exception){ |
|
|
|
|
log.error("同步SAP失败,报错信息为:{}", exception); |
|
|
|
|
exception.printStackTrace(); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.NULL_POINTER_TIMEOUT))); |
|
|
|
|
} catch (Exception exception) { |
|
|
|
|
} catch(Exception exception){ |
|
|
|
|
log.error("同步SAP失败,报错信息为:{}", exception); |
|
|
|
|
exception.printStackTrace(); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT))); |
|
|
|
@ -798,7 +787,6 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
info.setZGFZH(snInvoice.getPurchaserBank()); |
|
|
|
|
info.setZBZ(snInvoice.getRemarks()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SNInvoiceDetail> invoiceLineList = snInvoice.getInvoiceLineList(); |
|
|
|
|
List<SAPInvoiceDetail> sapInvoiceDetailList = new ArrayList<>(); |
|
|
|
|
//查询明细
|
|
|
|
@ -830,36 +818,26 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
sapInvoiceDetail.setZJK(snInvoiceDetail.getAmount()); |
|
|
|
|
sapInvoiceDetail.setZHH(snInvoiceDetail.getRowNo()); |
|
|
|
|
//将类似于0.03数据格式转化为3.00
|
|
|
|
|
if (snInvoiceDetail.getTaxRate() != null && !"".equals(snInvoiceDetail.getTaxRate())) { |
|
|
|
|
if (snInvoiceDetail.getTaxRate() != null && snInvoiceDetail.getTaxRate() != "") { |
|
|
|
|
sapInvoiceDetail.setZTAX(snInvoiceDetail.getTaxRate()); |
|
|
|
|
if ("0".equals(snInvoiceDetail.getTaxRate())) { |
|
|
|
|
sapInvoiceDetail.setZTAX("0.00"); |
|
|
|
|
sapInvoiceDetail.setZSM(sapInvoiceDetail.getZTAX()); |
|
|
|
|
// sapInvoiceDetail.setZSM(sapInvoiceDetail.getZTAX());
|
|
|
|
|
} |
|
|
|
|
if (snInvoiceDetail.getTaxRate().contains(".")) { |
|
|
|
|
String getTaxRate = snInvoiceDetail.getTaxRate(); |
|
|
|
|
// if (snInvoiceDetail.getTaxRate().length() > 4) {
|
|
|
|
|
// getTaxRate = getTaxRate.substring(0, 4);
|
|
|
|
|
// }
|
|
|
|
|
if (snInvoiceDetail.getTaxRate().length() > 4) { |
|
|
|
|
getTaxRate = getTaxRate.substring(0, 4); |
|
|
|
|
} |
|
|
|
|
BigDecimal tax = new BigDecimal(getTaxRate); |
|
|
|
|
sapInvoiceDetail.setZSM(getZSM(tax.toString())); |
|
|
|
|
BigDecimal tax1 = tax.multiply(new BigDecimal("100")); |
|
|
|
|
sapInvoiceDetail.setZTAX(tax1.toString()); |
|
|
|
|
if (tax1.compareTo(new BigDecimal("100")) > 0) { |
|
|
|
|
sapInvoiceDetail.setZTAX(snInvoiceDetail.getTaxRate()); |
|
|
|
|
} else if (tax1.scale() > 2) { |
|
|
|
|
BigDecimal substring = tax1.setScale(2, RoundingMode.FLOOR); |
|
|
|
|
sapInvoiceDetail.setZTAX(substring.toPlainString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (snInvoiceDetail.getTaxRate().contains("%") && !snInvoiceDetail.getTaxRate().contains(".")) { |
|
|
|
|
String replace = snInvoiceDetail.getTaxRate().replace("%", ".00"); |
|
|
|
|
String replaceZsm = snInvoiceDetail.getTaxRate().replace("%", ""); |
|
|
|
|
sapInvoiceDetail.setZSM(getZSM(replaceZsm)); |
|
|
|
|
sapInvoiceDetail.setZTAX(replace); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
// if (invoiceLineList.size() == 1 && snInvoice.getTaxRate() == null) {
|
|
|
|
|
// info.setZTAX(sapInvoiceDetail.getZTAX());
|
|
|
|
@ -885,16 +863,15 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
sapInvoiceDetail.setZSL(snInvoiceDetail.getQuantity()); |
|
|
|
|
|
|
|
|
|
// String zsmTax = snInvoiceDetail.getTaxRate();
|
|
|
|
|
// if (zsmTax != null && zsmTax != "" && zsmTax.length() > 4) {
|
|
|
|
|
// zsmTax = zsmTax.substring(0, 4);
|
|
|
|
|
// }
|
|
|
|
|
// if (zsmTax != null && zsmTax.contains("%") && !zsmTax.contains(".")) {
|
|
|
|
|
// zsmTax = (new BigDecimal(zsmTax.replace("%", ""))).divide(new BigDecimal("100")).toString();
|
|
|
|
|
// }
|
|
|
|
|
//// sapInvoiceDetail.setZSM(getZSM(snInvoiceDetail.getTaxRate()));
|
|
|
|
|
// sapInvoiceDetail.setZSM(getZSM(zsmTax));
|
|
|
|
|
String zsmTax = snInvoiceDetail.getTaxRate(); |
|
|
|
|
if (zsmTax != null && zsmTax != "" && zsmTax.length() > 4) { |
|
|
|
|
zsmTax = zsmTax.substring(0, 4); |
|
|
|
|
} |
|
|
|
|
if (zsmTax != null && zsmTax.contains("%") && !zsmTax.contains(".")) { |
|
|
|
|
zsmTax = (new BigDecimal(zsmTax.replace("%", ""))).divide(new BigDecimal("100")).toString(); |
|
|
|
|
} |
|
|
|
|
// sapInvoiceDetail.setZSM(getZSM(snInvoiceDetail.getTaxRate()));
|
|
|
|
|
sapInvoiceDetail.setZSM(getZSM(zsmTax)); |
|
|
|
|
sapInvoiceDetail.setZGGXH(snInvoiceDetail.getSpecificationModel()); |
|
|
|
|
if (snInvoice.getInvoiceCode() != null) { |
|
|
|
|
sapInvoiceDetail.setZTID(snInvoice.getInvoiceCode() + snInvoice.getInvoiceNumber() + snFplx); |
|
|
|
@ -912,7 +889,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
if (taxRate != null && !taxRate.contains("%")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(taxRate); |
|
|
|
|
BigDecimal multiply = bigDecimal.multiply(new BigDecimal("100")); |
|
|
|
|
info.setZTAX(multiply.toPlainString()); |
|
|
|
|
info.setZTAX(multiply.toString()); |
|
|
|
|
info.setZSM(getZSM(taxRate)); |
|
|
|
|
} |
|
|
|
|
if (taxRate != null && taxRate.contains("%")) { |
|
|
|
@ -925,19 +902,20 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
info.setZSM(getZSM(divide.toString())); |
|
|
|
|
} |
|
|
|
|
if (taxRate != null && taxRate.contains(".") && !taxRate.contains("%")) { |
|
|
|
|
|
|
|
|
|
BigDecimal tax = new BigDecimal(taxRate); |
|
|
|
|
info.setZSM(getZSM(tax.toPlainString())); |
|
|
|
|
BigDecimal tax1 = tax.multiply(new BigDecimal("100")); |
|
|
|
|
info.setZTAX(tax1.setScale(2, RoundingMode.FLOOR).toPlainString()); |
|
|
|
|
|
|
|
|
|
if (taxRate.length() > 4) { |
|
|
|
|
taxRate = taxRate.substring(0, 4); |
|
|
|
|
BigDecimal tax = new BigDecimal(taxRate); |
|
|
|
|
info.setZSM(getZSM(tax.toString())); |
|
|
|
|
BigDecimal tax1 = tax.multiply(new BigDecimal("100")); |
|
|
|
|
info.setZTAX(tax1.toString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (taxRate != null && "0".equals(taxRate)) { |
|
|
|
|
info.setZTAX("0.00"); |
|
|
|
|
info.setZSM(getZSM(info.getZTAX())); |
|
|
|
|
} |
|
|
|
|
if (invoiceLineList == null || invoiceLineList.size() == 0) { |
|
|
|
|
if (info.getZTAX() == null || "".equals(info.getZTAX())) { |
|
|
|
|
if (info.getZTAX() == null || info.getZTAX() == "") { |
|
|
|
|
info.setZTAX("0.00"); |
|
|
|
|
info.setZSM(getZSM(info.getZTAX())); |
|
|
|
|
} |
|
|
|
@ -1024,12 +1002,12 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|| "08".equals(snInvoice.getInvoiceType()) || "10".equals(snInvoice.getInvoiceType()) || "11".equals(snInvoice.getInvoiceType()) || "14".equals(snInvoice.getInvoiceType()) |
|
|
|
|
|| "15".equals(snInvoice.getInvoiceType()) || "31".equals(snInvoice.getInvoiceType()) || "32".equals(snInvoice.getInvoiceType())) { |
|
|
|
|
//可查验发票,
|
|
|
|
|
log.info("发票类型为:{}", snInvoice.getInvoiceType()); |
|
|
|
|
log.info("发票类型为:{}",snInvoice.getInvoiceType()); |
|
|
|
|
//0608 区块链发票 并且 checkStatus = 3 的时候 提交sap状态为3(刘振和谈楚才提出需求)
|
|
|
|
|
if ("10".equals(snInvoice.getInvoiceType()) && "3".equals(snInvoice.getCheckStatus())) { |
|
|
|
|
if("10".equals(snInvoice.getInvoiceType()) && "3".equals(snInvoice.getCheckStatus())){ |
|
|
|
|
log.info("区块链发票 传输状态checkStatus = 3"); |
|
|
|
|
info.setZCYZT("3"); |
|
|
|
|
} else { |
|
|
|
|
}else { |
|
|
|
|
info.setZCYZT("1"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
@ -1200,9 +1178,6 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
case "1.5": |
|
|
|
|
sm = "JA"; |
|
|
|
|
break; |
|
|
|
|
case "0.015": |
|
|
|
|
sm = "JA"; |
|
|
|
|
break; |
|
|
|
|
case "1": |
|
|
|
|
sm = "J9"; |
|
|
|
|
break; |
|
|
|
@ -1276,17 +1251,4 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
} |
|
|
|
|
return ZCYJG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查验发票 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/refresh") |
|
|
|
|
@ResponseBody |
|
|
|
|
@SysLog("发票查验") |
|
|
|
|
public String refreshDetailData(@RequestBody Map<String, Object> pramsMap) throws Exception { |
|
|
|
|
log.info("接口请求的参数为:{}", pramsMap); |
|
|
|
|
String result = snPushCheckRecordService.getRecords(pramsMap); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|