diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java b/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java index 909b5a74..a87688ba 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java @@ -95,7 +95,7 @@ public class SDNYMainProcessController extends AbstractController { } } - String uuid = (StringUtils.isBlank(pramsMap.get("invoiceCode"))?"":pramsMap.get("invoiceCode"))+ pramsMap.get("invoiceNo"); + String uuid = (StringUtils.isBlank(pramsMap.get("invoiceCode")) ? "" : pramsMap.get("invoiceCode")) + pramsMap.get("invoiceNo"); String notes = invoiceQueryService.checkingInvoiceInfo("business", uuid, getUserInfo()); if (notes != null) { return ResponseEntity.ok(R.error(notes)); @@ -113,15 +113,15 @@ public class SDNYMainProcessController extends AbstractController { || SNFplxEnum.QDPP.getSnFplxDm().equals(pramsMap.get("invoiceType")) ) { - pramsMap.put("invoiceType",fplxdm); + pramsMap.put("invoiceType", fplxdm); //查验发票数据 checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap); - if(!checkInvoiceResult.containsKey("code")){ + if (!checkInvoiceResult.containsKey("code")) { return ResponseEntity.ok(R.ok().put("data", checkInvoiceResult)); } - }else{ + } else { //价税分离 // snPushCheckRecordService.valoremTaxCount(); } @@ -142,37 +142,44 @@ public class SDNYMainProcessController extends AbstractController { List gfshAll = UserInfoUtil.getGfshAll(getUserInfo().getOrg()); - - //String notes = invoiceQueryService.checkingInvoiceInfo(dbName, uuid, getUserInfo()); + String gfsh = ""; + if (gfshAll.size() > 0) { + gfsh = gfshAll.get(0); + } //入票池 + try { + snPushCheckRecordService.pushInvoiceToRecordInvoice(snRequestObject, gfsh, company); + //推送到SAP + List invoiceInfoList = snRequestObject.getInvoiceInfoList(); - //推送到SAP - List invoiceInfoList = snRequestObject.getInvoiceInfoList(); - - String imageId = snRequestObject.getImageId(); + String imageId = snRequestObject.getImageId(); - for(SNInvoice invoice : invoiceInfoList) { - SNSAPObject object = convertToSapOnject(invoice,imageId); - JSONObject sapObj = (JSONObject) JSONObject.toJSON(object); + for (SNInvoice invoice : invoiceInfoList) { + SNSAPObject object = convertToSapOnject(invoice, imageId); + JSONObject sapObj = (JSONObject) JSONObject.toJSON(object); - String result = ""; - try { - //将信息推送到影像系统 - result = snPushCheckRecordService.pushCheckResultToSAP(sapObj); + String result = ""; + try { + //将信息推送到影像系统 + result = snPushCheckRecordService.pushCheckResultToSAP(sapObj); - return ResponseEntity.ok(R.ok().put("data", result)); - } catch (Exception e) { - e.printStackTrace(); - log.error("", e); - return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT)); + return ResponseEntity.ok(R.ok().put("data", result)); + } catch (Exception e) { + e.printStackTrace(); + log.error("", e); + return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT)); + } } + return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT)); + } catch (Exception e) { + e.printStackTrace(); } return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT)); } - private SNSAPObject convertToSapOnject(SNInvoice snInvoice,String imageId) { + private SNSAPObject convertToSapOnject(SNInvoice snInvoice, String imageId) { Date date = new Date(); @@ -226,7 +233,7 @@ public class SDNYMainProcessController extends AbstractController { info.setZBZ(snInvoice.getRemarks()); List invoiceLineList = snInvoice.getInvoiceLineList(); List sapInvoiceDetailList = new ArrayList<>(); - if(invoiceLineList != null && invoiceLineList.size() > 0){ + if (invoiceLineList != null && invoiceLineList.size() > 0) { SNInvoiceDetail snInvoiceDetail = invoiceLineList.get(0); String taxRate = snInvoiceDetail.getTaxRate(); info.setZSM(taxRate); diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/dao/BaseTDxTaxCurrentDao.java b/dxhy-erp/src/main/java/com/dxhy/erp/dao/BaseTDxTaxCurrentDao.java new file mode 100644 index 00000000..872b2e72 --- /dev/null +++ b/dxhy-erp/src/main/java/com/dxhy/erp/dao/BaseTDxTaxCurrentDao.java @@ -0,0 +1,20 @@ +package com.dxhy.erp.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.dxhy.erp.entity.BaseTDxTaxCurrent; +import org.apache.ibatis.annotations.Mapper; + +/** + * + * + * 企业税务信息表dao + * + * + * @author peipei.li + * @date 2019-04-23 + */ +@SuppressWarnings("AlibabaClassNamingShouldBeCamel") +@Mapper +public interface BaseTDxTaxCurrentDao extends BaseMapper { + +} diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/entity/BaseTDxTaxCurrent.java b/dxhy-erp/src/main/java/com/dxhy/erp/entity/BaseTDxTaxCurrent.java new file mode 100644 index 00000000..2de155d4 --- /dev/null +++ b/dxhy-erp/src/main/java/com/dxhy/erp/entity/BaseTDxTaxCurrent.java @@ -0,0 +1,106 @@ +package com.dxhy.erp.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * + * + * 企业税务信息表 + * + * @author peipei.li + * @date 2019-04-23 + */ +@SuppressWarnings("AlibabaClassNamingShouldBeCamel") +@Data +@TableName("t_dx_tax_current") +public class BaseTDxTaxCurrent implements Serializable { + + private static final long serialVersionUID = -6721685467254429845L; + + /** + * id + */ + private Long id; + + /** + * 税号 + */ + private String taxno; + + /** + * 企业名称 + */ + private String taxname; + + /** + * 当前税款所属期 + */ + private String currentTaxPeriod; + + /** + * 当前税款所属期可勾选发票的起始开票日期 + */ + private String selectStartDate; + + /** + * 当前税款所属期可勾选发票的截止开票日期 + */ + private String selectEndDate; + + /** + * 当前税款所属期可勾选发票操作截止日期 + */ + private String operationEndDate; + + /** + * 企业旧税号 + */ + private String oldTaxNo; + + /** + * 申报周期,值为3-季度/1-月 + */ + private String declarePeriod; + + /** + * 信用等级,值为a/b/c/d或者空 + */ + private String creditRating; + + /** + * update_time + */ + private Date updateTime; + + /** + * create_time + */ + private Date createTime; + + /** + * 锁定状态:0否;1是 + */ + private String latchStatus; + + /** + * 抵扣限额 + */ + private BigDecimal limitDkse; + + private String bussiPwd; + + private String newBussiPwd; + + private String companyType; + private String oilType; + private String taxpayerType; + private String syncTime; + private String indexInfo; + private String periodIndexInfo; + private String monthIndexInfo; +} diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java b/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java index fa18222e..ab562ad2 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java @@ -11,17 +11,22 @@ import com.dxhy.common.datasource.config.DynamicContextHolder; import com.dxhy.common.util.InvoiceUtil; import com.dxhy.common.vo.UserInfo; import com.dxhy.erp.dao.AreaDao; +import com.dxhy.erp.dao.BaseTDxRecordInvoiceDao; +import com.dxhy.erp.dao.BaseTDxTaxCurrentDao; import com.dxhy.erp.dao.OrgUserInfoDao; import com.dxhy.erp.entity.BaseTDxRecordInvoice; +import com.dxhy.erp.entity.BaseTDxTaxCurrent; import com.dxhy.erp.entity.kfpt.ApiCheckInvoiceSingleRequest; import com.dxhy.erp.entity.kfpt.ApiRequest; import com.dxhy.erp.entity.kfpt.ApiResponse; import com.dxhy.erp.entity.kfpt.TokenResponse; import com.dxhy.erp.entity.sdny.InvoiceDetail; import com.dxhy.erp.entity.sdny.InvoiceInfo; +import com.dxhy.erp.entity.sdny.SNInvoice; import com.dxhy.erp.entity.sdny.SNRequestObject; import com.dxhy.erp.entity.sdny.area.Area; import com.dxhy.erp.utils.*; +import com.dxhy.erp.utils.Base64; import com.google.gson.JsonArray; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -32,10 +37,8 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.text.ParseException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; /** * 与山东能源交互数据主类 @@ -78,6 +81,12 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { @Autowired private OrgUserInfoDao orgUserInfoDao; + @Resource + private BaseTDxTaxCurrentDao baseTDxTaxCurrentDao; + + @Resource + private BaseTDxRecordInvoiceDao baseTDxRecordInvoiceDao; + public String pushCheckResultToSAP(JSONObject result) throws Exception { result.put("systemSign", ""); result.put("roleIds", ""); @@ -90,41 +99,55 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { return post; } - public String pushInvoiceToRecordInvoice(SNRequestObject snRequestObject) throws Exception { - - -// QueryWrapper currentWrapper = new QueryWrapper<>(); -// currentWrapper.eq("taxno", gfsbh); -// DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ); -// BaseTDxTaxCurrent current = baseTDxTaxCurrentDao.selectOne(currentWrapper); -// -// -// BaseTDxRecordInvoice recordInvoice = new BaseTDxRecordInvoice(); -// recordInvoice.setUuid(fpdm + fphm); -// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); -// try { -// recordInvoice.setInvoiceDate(sdf.parse(kprq)); -// } catch (ParseException e) { -// e.printStackTrace(); -// } -// recordInvoice.setInvoiceCode(fpdm); -// recordInvoice.setInvoiceNo(fphm); -// recordInvoice.setInvoiceAmount(new BigDecimal(je)); -// recordInvoice.setTaxAmount(new BigDecimal(se)); -// recordInvoice.setXfTaxNo(xfsh); -// recordInvoice.setGfTaxNo(gfsbh); -// recordInvoice.setGfName(gfmc); -// recordInvoice.setRzlx("5"); -// recordInvoice.setYqsqStatus("1"); -// recordInvoice.setYqCurrentPeriod(current.getCurrentTaxPeriod()); -// recordInvoice.setCreateDate(new Date()); -// recordInvoice.setYqsqDate(new Date()); -// recordInvoice.setSourceSystem("2"); -// recordInvoice.setInvoiceStatus("0"); -// recordInvoice.setInvoiceType(invoiceType); -// recordInvoice.setCompany((String)pramsMap.get("company")); -// baseTDxRecordInvoiceDao.insert(recordInvoice); - + public String pushInvoiceToRecordInvoice(SNRequestObject snRequestObject,String taxNo,String company) throws Exception { + QueryWrapper currentWrapper = new QueryWrapper<>(); + currentWrapper.eq("taxno", taxNo); + DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ); + BaseTDxTaxCurrent current = baseTDxTaxCurrentDao.selectOne(currentWrapper); + + List invoiceInfoList = snRequestObject.getInvoiceInfoList(); + + if(invoiceInfoList != null && invoiceInfoList.size() > 0) { + + for(SNInvoice snInvoice : invoiceInfoList) { + + String fpdm = snInvoice.getInvoiceCode(); + String fphm = snInvoice.getInvoiceNumber(); + String kprq = snInvoice.getBillingDate(); + String je = snInvoice.getTotalAmount(); + String xfsh = snInvoice.getSalesTaxNo(); + String se = snInvoice.getAmountTax(); + String gfsbh = snInvoice.getPurchaserTaxNo(); + String gfmc = snInvoice.getPurchaserName(); + String invoiceType = snInvoice.getInvoiceType(); + + BaseTDxRecordInvoice recordInvoice = new BaseTDxRecordInvoice(); + recordInvoice.setUuid(fpdm + fphm); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + try { + recordInvoice.setInvoiceDate(sdf.parse(kprq)); + } catch (ParseException e) { + e.printStackTrace(); + } + recordInvoice.setInvoiceCode(fpdm); + recordInvoice.setInvoiceNo(fphm); + recordInvoice.setInvoiceAmount(new BigDecimal(je)); + recordInvoice.setTaxAmount(new BigDecimal(se)); + recordInvoice.setXfTaxNo(xfsh); + recordInvoice.setGfTaxNo(gfsbh); + recordInvoice.setGfName(gfmc); + recordInvoice.setRzlx("5"); + recordInvoice.setYqsqStatus("1"); + recordInvoice.setYqCurrentPeriod(current.getCurrentTaxPeriod()); + recordInvoice.setCreateDate(new Date()); + recordInvoice.setYqsqDate(new Date()); + recordInvoice.setSourceSystem("2"); + recordInvoice.setInvoiceStatus("0"); + recordInvoice.setInvoiceType(invoiceType); + recordInvoice.setCompany(company); + baseTDxRecordInvoiceDao.insert(recordInvoice); + } + } return ""; }