ariesy 优化代码

release
yefei 2 years ago
parent d82d04cf8a
commit c651922318
  1. 39
      dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java
  2. 8
      dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java

@ -107,6 +107,7 @@ public class SDNYMainProcessController extends AbstractController {
@Resource
private GatherService gatherService;
/**
* 查验发票
*/
@ -117,7 +118,7 @@ public class SDNYMainProcessController extends AbstractController {
log.info("传入的参数为:{}", pramsMap);
String userid = "101833";
String dbName = "business";
JSONObject checkInvoiceResult = null;
JSONObject checkInvoiceResult = new JSONObject();
//挡板开关
if ("1".equals(isPresure)) {
@ -202,10 +203,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")) {
@ -264,10 +265,9 @@ public class SDNYMainProcessController extends AbstractController {
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,6 +290,7 @@ public class SDNYMainProcessController extends AbstractController {
return ResponseEntity.ok(JSONObject.toJSONString(data));
}
} else {
//其他类发票,直接入库
log.info("其他类发票,不做查验,直接入库");
@ -455,7 +456,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>();
@ -497,7 +498,7 @@ public class SDNYMainProcessController extends AbstractController {
taxRateDetail = "0";
snDetailMap.put("taxRate", taxRateDetail);
} else {
if (detail.get("taxRate") != null && StringUtils.isNoneBlank(detail.get("taxRate").toString())) {
if (StringUtils.isNoneBlank(detail.get("taxRate").toString())) {
try {
taxRateDetail = detail.get("taxRate").toString();
if (!"0".equals(taxRateDetail)) {
@ -525,8 +526,8 @@ public class SDNYMainProcessController extends AbstractController {
}
}
}
}catch (Exception e){
log.error("报错的原因为:{}",e);
} catch (Exception e) {
log.error("报错的原因为:{}", e);
taxRateDetail = "0.00";
}
@ -686,11 +687,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)));
@ -846,7 +847,7 @@ public class SDNYMainProcessController extends AbstractController {
sapInvoiceDetail.setZTAX(tax1.toString());
if (tax1.compareTo(new BigDecimal("100")) > 0) {
sapInvoiceDetail.setZTAX(snInvoiceDetail.getTaxRate());
}else if (tax1.scale() > 2){
} else if (tax1.scale() > 2) {
BigDecimal substring = tax1.setScale(2, RoundingMode.FLOOR);
sapInvoiceDetail.setZTAX(substring.toPlainString());
}
@ -854,7 +855,7 @@ public class SDNYMainProcessController extends AbstractController {
}
if (snInvoiceDetail.getTaxRate().contains("%") && !snInvoiceDetail.getTaxRate().contains(".")) {
String replace = snInvoiceDetail.getTaxRate().replace("%", ".00");
String replaceZsm = snInvoiceDetail.getTaxRate().replace("%","");
String replaceZsm = snInvoiceDetail.getTaxRate().replace("%", "");
sapInvoiceDetail.setZSM(getZSM(replaceZsm));
sapInvoiceDetail.setZTAX(replace);
}
@ -928,7 +929,7 @@ public class SDNYMainProcessController extends AbstractController {
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());
info.setZTAX(tax1.setScale(2, RoundingMode.FLOOR).toPlainString());
}
if (taxRate != null && "0".equals(taxRate)) {
@ -1023,12 +1024,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 {
@ -1283,7 +1284,7 @@ public class SDNYMainProcessController extends AbstractController {
@ResponseBody
@SysLog("发票查验")
public String refreshDetailData(@RequestBody Map<String, Object> pramsMap) throws Exception {
log.info("接口请求的参数为:{}",pramsMap);
log.info("接口请求的参数为:{}", pramsMap);
String result = snPushCheckRecordService.getRecords(pramsMap);
return result;
}

@ -512,20 +512,18 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
jsonObject.put("tonnage", invoiceData.get("dw"));
jsonObject.put("limitPeople", invoiceData.get("xcrs"));
String taxRate = "";
if (invoiceData.get("sl") == null || StringUtils.isBlank(invoiceData.get("sl").toString()) ||
"免税".equals(invoiceData.get("sl").toString()) || "不征税".equals(invoiceData.get("sl").toString()) || "***".equals(invoiceData.get("sl").toString())) {
if (StringUtils.isNotEmpty(invoiceData.get("sl").toString()) || "免税".equals(invoiceData.get("sl").toString()) || "不征税".equals(invoiceData.get("sl").toString()) || "***".equals(invoiceData.get("sl").toString())) {
taxRate = "0";
jsonObject.put("taxRate", taxRate);
} else {
if (invoiceData.get("sl") != null && StringUtils.isNoneBlank(invoiceData.get("sl").toString())) {
if (StringUtils.isNoneBlank(invoiceData.get("sl").toString())) {
taxRate = invoiceData.get("sl").toString();
if (!"0".equals(taxRate)) {
taxRate = "0." + taxRate;
taxRate = taxRate.substring(0, taxRate.length() - 1);
}
if ("11".equals(invoiceType)) {
taxRate = "0.000";
taxRate = "0";
}
log.info("明细-发票税率为:{}", taxRate);
jsonObject.put("taxRate", taxRate);

Loading…
Cancel
Save