Merge remote-tracking branch 'origin/dev0310' into release-OCR

release
zhenghaiyang@ele-cloud.com 2 years ago
commit aa01a218cd
  1. 1
      dxhy-common/src/main/java/com/dxhy/common/constant/ConfigureConstant.java
  2. 43
      dxhy-erp/src/main/java/com/dxhy/erp/controller/InterfaceController.java
  3. 3
      dxhy-erp/src/main/java/com/dxhy/erp/dao/AreaDao.java
  4. 13
      dxhy-erp/src/main/java/com/dxhy/erp/dao/BaseReceiptOutDao.java
  5. 21
      dxhy-erp/src/main/java/com/dxhy/erp/dao/BaseTDxRecordInvoiceDao.java
  6. 2
      dxhy-erp/src/main/java/com/dxhy/erp/dao/OrgUserInfoDao.java
  7. 45
      dxhy-erp/src/main/java/com/dxhy/erp/entity/BaseInvoiceEditVO.java
  8. 468
      dxhy-erp/src/main/java/com/dxhy/erp/entity/BaseTDxRecordInvoice.java
  9. 93
      dxhy-erp/src/main/java/com/dxhy/erp/entity/BaseTDxRecordInvoiceOut.java
  10. 2
      dxhy-erp/src/main/java/com/dxhy/erp/model/IsInput.java
  11. 25
      dxhy-erp/src/main/java/com/dxhy/erp/service/BaseIReceiptInvoiceService.java
  12. 14
      dxhy-erp/src/main/java/com/dxhy/erp/service/IReceiptOutService.java
  13. 45
      dxhy-erp/src/main/java/com/dxhy/erp/service/impl/BaseIReceiptInvoiceServiceImpl.java
  14. 5
      dxhy-erp/src/main/java/com/dxhy/erp/service/impl/InvoiceAuthServiceImpl.java
  15. 245
      dxhy-erp/src/main/java/com/dxhy/erp/service/impl/ReceiptOutServiceImpl.java
  16. 8
      dxhy-erp/src/main/resources/mapper/AreaDao.xml
  17. 34
      dxhy-erp/src/main/resources/mapper/OrgUserInfoDao.xml

@ -36,6 +36,7 @@ public class ConfigureConstant {
public static final int INT_0 = 0; public static final int INT_0 = 0;
public static final int INT_2 = 2; public static final int INT_2 = 2;
public static final String POTOKEN="6_ca323ed526e74edea7e023c0733a9bef";
} }

@ -25,7 +25,9 @@ import com.dxhy.common.utils.Base64Encoding;
import com.dxhy.common.utils.GzipUtils; import com.dxhy.common.utils.GzipUtils;
import com.dxhy.common.utils.R; import com.dxhy.common.utils.R;
import com.dxhy.common.utils.TripleDesUtil; import com.dxhy.common.utils.TripleDesUtil;
import com.dxhy.common.vo.UserInfo;
import com.dxhy.erp.dao.SysDeptDao; import com.dxhy.erp.dao.SysDeptDao;
import com.dxhy.erp.entity.BaseInvoiceEditVO;
import com.dxhy.erp.entity.SalesInvoicePushInfos; import com.dxhy.erp.entity.SalesInvoicePushInfos;
import com.dxhy.erp.entity.SysDeptEntity; import com.dxhy.erp.entity.SysDeptEntity;
import com.dxhy.erp.entity.TDxInvoiceReimburse; import com.dxhy.erp.entity.TDxInvoiceReimburse;
@ -104,6 +106,8 @@ public class InterfaceController extends AbstractController {
private DeclareService declareService; private DeclareService declareService;
@Value("${erp.checkIp}") @Value("${erp.checkIp}")
private boolean checkIp; private boolean checkIp;
@Resource
private IReceiptOutService iReceiptOutService;
/** /**
* *
@ -1128,6 +1132,24 @@ public class InterfaceController extends AbstractController {
} }
return returnResult; return returnResult;
} }
@RequestMapping(path = "/po",method={RequestMethod.POST,RequestMethod.GET})
public String po(@RequestBody String param,HttpServletRequest request){
log.info("po接口调用开始,传参{}",JsonUtils.getInstance().toJsonString(request));
String token = request.getHeader("token");
if(org.apache.commons.lang3.StringUtils.isBlank(token) && !ConfigureConstant.POTOKEN.equals(token)){
return "非法请求,请停止访问!";
}
String resultString = "";
ErpInvoiceData requestParam = JsonUtils.getInstance().parseObject(param, ErpInvoiceData.class);
//同步 凭证号 判断自动认证接口开发
if("FI005".equals(requestParam.getIS_INPUT().getIFYWID())){
resultString = receiveErpInvoiceMessage(requestParam);
}else if("FI110".equals(requestParam.getIS_INPUT().getIFYWID())){
resultString = transferOut(requestParam);
}
return resultString;
}
@PostMapping("receiveErpInvoiceMessage") @PostMapping("receiveErpInvoiceMessage")
public String receiveErpInvoiceMessage(@RequestBody ErpInvoiceData erpInvoiceData){ public String receiveErpInvoiceMessage(@RequestBody ErpInvoiceData erpInvoiceData){
@ -1143,10 +1165,27 @@ public class InterfaceController extends AbstractController {
esOutPutResp.setZTYPE("E"); esOutPutResp.setZTYPE("E");
esOutPutResp.setZMESSAGE("程序内部错误"); esOutPutResp.setZMESSAGE("程序内部错误");
return JsonUtils.getInstance().toJsonString(esOutPutResp); return JsonUtils.getInstance().toJsonString(esOutPutResp);
} }
}
public String transferOut(ErpInvoiceData erpInvoiceData){
String zdata = erpInvoiceData.getIS_INPUT().getZDATA();
Map<String,String> map=JsonUtils.getInstance().parseObject(zdata,Map.class);
String invoiceCode = map.get("invoiceCode");
String invoiceNo = map.get("invoiceNo");
String outTaxAmount = map.get("outTaxAmount");
String outReason = map.get("outReason");
String outTaxPeriod = map.get("outTaxPeriod");
String uuid = invoiceCode+invoiceNo;
BaseInvoiceEditVO baseInvoiceEditVO = new BaseInvoiceEditVO();
baseInvoiceEditVO.setPrimaryKey(uuid);
baseInvoiceEditVO.setOutReason(outReason);
baseInvoiceEditVO.setOutTax(outTaxAmount);
baseInvoiceEditVO.setOutStatus("1");
baseInvoiceEditVO.setOutTaxPeriod(outTaxPeriod);
UserInfo userInfo = new UserInfo();
String transfer = iReceiptOutService.transfer(erpInvoiceData,baseInvoiceEditVO, userInfo);
return transfer;
} }
} }

@ -1,6 +1,7 @@
package com.dxhy.erp.dao; package com.dxhy.erp.dao;
import com.dxhy.erp.entity.sdny.area.Area; import com.dxhy.erp.entity.sdny.area.Area;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -13,7 +14,7 @@ import java.util.List;
* @author 大象慧云shanQing * @author 大象慧云shanQing
* @since 2017-10-23 16:31:10 * @since 2017-10-23 16:31:10
*/ */
@Repository @Mapper
public interface AreaDao { public interface AreaDao {
/** /**

@ -0,0 +1,13 @@
package com.dxhy.erp.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dxhy.erp.entity.BaseTDxRecordInvoiceOut;
import org.apache.ibatis.annotations.Mapper;
/**
* @author peipei.li
* @date 2019-04-23
*
*/
@Mapper
public interface BaseReceiptOutDao extends BaseMapper<BaseTDxRecordInvoiceOut> {}

@ -0,0 +1,21 @@
package com.dxhy.erp.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dxhy.erp.entity.BaseTDxRecordInvoice;
import org.apache.ibatis.annotations.Mapper;
/**
*
*
* 底账表dao
*
* @author peipei.li
* @date 2019-04-23
*/
@SuppressWarnings("AlibabaClassNamingShouldBeCamel")
@Mapper
public interface BaseTDxRecordInvoiceDao extends BaseMapper<BaseTDxRecordInvoice> {
}

@ -2,6 +2,7 @@ package com.dxhy.erp.dao;
import com.dxhy.erp.entity.sdny.BxwxEnterpriseUserEntity; import com.dxhy.erp.entity.sdny.BxwxEnterpriseUserEntity;
import com.dxhy.erp.entity.sdny.OrgUserInfo; import com.dxhy.erp.entity.sdny.OrgUserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -13,6 +14,7 @@ import java.util.Optional;
* @author guoker * @author guoker
* @date 2020-12-29 * @date 2020-12-29
*/ */
@Mapper
public interface OrgUserInfoDao { public interface OrgUserInfoDao {
/** /**

@ -0,0 +1,45 @@
package com.dxhy.erp.entity;
import lombok.Data;
/**
* @author peipei.li
* @date 2019-04-25 进项税转出确认条件vo
*/
@Data
public class BaseInvoiceEditVO {
/**
* 主键多个以英文逗号分隔结尾不加逗号
*/
private String primaryKey;
/**
* 转出选项1=全部转出 2=部分转出
*/
private String outStatus;
/**
* 转出金额
*/
private String outAmount;
/**
* 转出税额
*/
private String outTax;
/**
* 转出原因
*/
private String outReason;
/**
* 备注
*/
private String outRemark;
/**
* 属期
*/
private String outTaxPeriod;
}

@ -0,0 +1,468 @@
package com.dxhy.erp.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
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_record_invoice")
public class BaseTDxRecordInvoice implements Serializable {
private static final long serialVersionUID = 6086166653761632484L;
/**
* id
*/
private Long id;
/**
* 发票类型 01-增值税专用发票 03-机动车销售统一发票 04-增值税普通发票 10-电子发票 11-卷票 14-通行费发票
*/
private String invoiceType;
/**
* 发票代码
*/
private String invoiceCode;
/**
* 发票号码
*/
private String invoiceNo;
/**
* 开票日期
*/
private Date invoiceDate;
/**
* 购方税号
*/
private String gfTaxNo;
/**
* 购方名称
*/
private String gfName;
/**
* 购方地址电话
*/
private String gfAddressAndPhone;
/**
* 购方开户行及账号
*/
private String gfBankAndNo;
/**
* 销方税号
*/
private String xfTaxNo;
/**
* 销方名称
*/
private String xfName;
/**
* 销方地址及电话
*/
private String xfAddressAndPhone;
/**
* 销方开户行及账号
*/
private String xfBankAndNo;
/**
* 金额
*/
private BigDecimal invoiceAmount;
/**
* 税额
*/
private BigDecimal taxAmount;
/**
* 价格合计
*/
private BigDecimal totalAmount;
/**
* 备注
*/
private String remark;
/**
* 发票状态 0-正常 1-失控 2-作废 3-红冲 4-异常
*/
private String invoiceStatus;
/**
* 发票状态修改时间
*/
private Date statusUpdateDate;
/**
* 发票状态最后修改时间
*/
private Date lastUpdateDate;
/**
* 认证时间
*/
private Date rzhDate;
/**
* 签收时间
*/
private Date qsDate;
/**
* 最晚认证归属期 yyyymm
*/
private String rzhBelongDateLate;
/**
* 实际认证归属期 yyyymm
*/
private String rzhBelongDate;
/**
* 认证确认时间
*/
private Date confirmDate;
/**
* 认证方式 1-勾选认证 2-扫描认证
*/
private String rzhType;
/**
* 是否认证 0-未认证 1-已认证
*/
private String rzhYesorno;
/**
* 提交认证操作人账号
*/
private String gxUserAccount;
/**
* 提交认证操作人
*/
private String gxUserName;
/**
* 底账来源 0-采集 1-查验
*/
private String sourceSystem;
/**
* 是否有效 1-有效 0-无效
*/
private String valid;
/**
* 发票代码+发票号码 唯一索引 防重复
*/
private String uuid;
/**
* 采集时间
*/
private Date createDate;
/**
* 勾选时间
*/
private Date gxDate;
/**
* 认证结果回传信息
*/
private String rzhBackMsg;
/**
* 当前税款所属期
*/
private String dqskssq;
/**
* 当前税款所属期勾选截止日
*/
private String gxjzr;
/**
* 当前税款所属期可勾选发票开票日期范围起
*/
private String gxfwq;
/**
* 当前税款所属期可勾选发票开票日期范围止
*/
private String gxfwz;
/**
* 是否已勾选
*/
private String sfygx;
/**
* 是否存入明细 0 无明细 1 有明细
*/
private String detailYesorno;
/**
* 勾选方式(0-手工勾选 1-扫码勾选 2-导入勾选 3- 智能勾选 4-手工认证 5-扫码认证 6-导入认证)
*/
private String gxType;
/**
* 认证处理状态 0-未认证 1-已勾选未确认2已确认 3 已发送认证 4 认证成功 5 认证失败
*/
private String authStatus;
/**
* 发送认证时间
*/
private Date sendDate;
/**
* 认证类型(1-抵扣 2-退税 3-代理退税 4-不抵扣 5逾期 发票已认证已勾选有该标签
*/
private String rzlx;
/**
* 是否代办退税(0 1)
*/
private String sfdbts;
/**
* 签收方式0-扫码签收 1-扫描仪签收 2-app签收 3-导入签收 4-手工签收5-pdf上传签收
*/
private String qsType;
/**
* 签收结果0-未签收 1-已签收
*/
private String qsStatus;
/**
* 校验码
*/
private String checkCode;
/**
* 通行费标志(y-可抵扣通行费n-不可抵扣通行费)
*/
private String txfbz;
/**
* 零税率标志 (:非零税率1:税率栏位显示免税2:税率栏位显示不征收3:零税率
*/
private String lslbz;
/**
* 转出状态 0-未转出 1-全部转出 2-部分转出
*/
private String outStatus;
/**
* 转出金额
*/
@TableField(fill = FieldFill.UPDATE)
private BigDecimal outInvoiceAmout;
/**
* 转出税额
*/
@TableField(fill = FieldFill.UPDATE)
private BigDecimal outTaxAmount;
/**
* 转出原因1-免税项目用 2-集体福利个人消费3-非正常损失4-简易计税方法征税项目用5-免抵退税办法不得抵扣的进项税额6-纳税检查调减进项税额7-红字专用发票通知单注明的进项税额8-上期留抵税额抵减欠税
*/
@TableField(fill = FieldFill.UPDATE)
private String outReason;
/**
* 转出备注
*/
@TableField(fill = FieldFill.UPDATE)
private String outRemark;
/**
* 转出日期
*/
@TableField(fill = FieldFill.UPDATE)
private Date outDate;
/**
* 转出人
*/
@TableField(fill = FieldFill.UPDATE)
private String outBy;
/**
* 转出税款所属期
*/
@TableField(fill = FieldFill.UPDATE)
private String outBelongDate;
/**
* 确认人
*/
private String confirmUser;
/**
* 机器编号 collate utf32_general_ci
*/
private String machinecode;
/**
* 部门id
*/
private String deptId;
/**
* 部门名称
*/
private String deptName;
/**
* 结算单号
*/
private String settlementNo;
/**
* 是否结算0未结算1已结算
*/
private String settlementStatus;
/**
* 结算单来源
*/
private String settleSource;
/**
* 付款状态0-付款成功 1-付款失败 collate utf8_bin
*/
private String paymentStatus;
/**
* 付款日期
*/
private String paymentDate;
/**
* 凭证号
*/
private String voucherNumber;
/**
* 付款金额
*/
private String paymentSum;
/**
* 签收人
*/
private String qsName;
/**
* 逾期申请结果
*/
private String yqsqMsg;
/**
* 逾期申请标志 0-未申请 1--已申请 默认为空
*/
private String yqsqStatus;
/**
* 逾期申请属期
*/
private String yqCurrentPeriod;
/**
* 管理状态 0正常1异常
*/
private String glzt;
/**
* 信息来源 0扫描认证 1系统推送 2出口转内销
*/
private String xxly;
/**
* 抵扣税额
*/
private BigDecimal dkTaxAmount;
/**
* 逾期可勾选标志 0默认值1可勾选逾期
*/
private String yqkgxbz;
/**
* 异常类型 0发票状态异常1申报用途变更抵扣变代办退税2管理状态异常发票状态为正常时为空
*/
private String yclx;
/**
* 逾期审核状态 0--未审核 1--已审核 默认为空
*/
private String yqshzt;
/**
* 撤销认证处理状态0未撤销1撤销申请2发送撤销4撤销成功5撤销失败
*/
private String cxrzStatus;
/**
* 撤销认证操作时间
*/
private Date cxrzDate;
/**
* 撤销认证属期
*/
private String cxrzCurrentPeriod;
/**
* 不认证处理状态0未申请1申请2发送申请4申请成功5申请失败
*/
private String bdkStatus;
/**
* 撤销不认证处理0未申请1申请2发送申请4申请成功5申请失败
*/
private String cxbdkStatus;
/**
* 逾期申请日期
*/
private Date yqsqDate;
/**
* 集团编码
*/
private String company;
private String exportMark;
/**
* 打款状态
*/
private String inAccountStatus;
private String invoiceSource;
}

@ -0,0 +1,93 @@
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 lipeipei 2019-04-24
*/
@SuppressWarnings("AlibabaClassNamingShouldBeCamel")
@Data
@TableName("t_dx_record_invoice_out")
public class BaseTDxRecordInvoiceOut implements Serializable {
private static final long serialVersionUID = -1633227564761160276L;
/**
* id
*/
private Long id;
/**
* 发票代码
*/
private String invoiceCode;
/**
* 发票号码
*/
private String invoiceNo;
/**
* 发票代码+发票号码
*/
private String uuid;
/**
* 转出状态 1-全部转出 2-部分转出
*/
private String outStatus;
/**
* 转出金额
*/
private BigDecimal outInvoiceAmout;
/**
* 转出税额
*/
private BigDecimal outTaxAmount;
/**
* 转出原因1-免税项目用 2-集体福利个人消费3-非正常损失4-简易计税方法征税项目用5-免抵退税办法不得抵扣的进项税额6-纳税检查调减进项税额7-红字专用发票通知单注明的进项税额8-上期留抵税额抵减欠税
*/
private String outReason;
/**
* 转出备注
*/
private String outRemark;
/**
* 转出日期
*/
private Date outDate;
/**
* 转出人
*/
private String outBy;
/**
* 转出税款所属期
*/
private String outBelongDate;
/**
* 是否取消0-未取消 1-已取消
*/
private String isCancel;
/**
* 集团编码
*/
private String company;
public BaseTDxRecordInvoiceOut() {}
}

@ -32,7 +32,7 @@ public class IsInput {
@JsonProperty(value = "ZFILED5") @JsonProperty(value = "ZFILED5")
private String ZFILED5; private String ZFILED5;
@JsonProperty(value = "ZDATA") @JsonProperty(value = "ZDATA")
private List<ZDATA> ZDATA; private String ZDATA;
} }

@ -0,0 +1,25 @@
package com.dxhy.erp.service;
import com.dxhy.erp.entity.BaseTDxRecordInvoice;
import java.util.List;
/**
* @author peipei.li
* @date 2019-04-23 进项税模块底账表单表相关操作
*/
@SuppressWarnings("AlibabaClassNamingShouldBeCamel")
public interface BaseIReceiptInvoiceService {
List<BaseTDxRecordInvoice> selectByUuids(String[] uuids);
/**
* 进项税转出批量 update 抵账表数据
*
* @param condEntity
* 请求参数
*/
void updateBatch(List<BaseTDxRecordInvoice> condEntity);
}

@ -0,0 +1,14 @@
package com.dxhy.erp.service;
import com.dxhy.common.vo.UserInfo;
import com.dxhy.erp.entity.BaseInvoiceEditVO;
import com.dxhy.erp.model.ErpInvoiceData;
/**
* @Author wangzhikun
* @Date 2022/12/24 2022/12/24
*/
public interface IReceiptOutService {
String transfer(ErpInvoiceData erpInvoiceData, BaseInvoiceEditVO baseInvoiceEditVO, UserInfo userInfo);
}

@ -0,0 +1,45 @@
package com.dxhy.erp.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.dxhy.common.service.impl.MpBaseServiceImpl;
import com.dxhy.erp.dao.BaseTDxRecordInvoiceDao;
import com.dxhy.erp.entity.BaseTDxRecordInvoice;
import com.dxhy.erp.service.BaseIReceiptInvoiceService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author wangzhikun
* @Date 2022/12/24 2022/12/24
*/
/**
* @author peipei.li
* @date 2019-04-23 进项税模块底账表单表相关操作
*/
@SuppressWarnings("AlibabaUndefineMagicConstant")
@Service("baseIReceiptInvoiceService")
public class BaseIReceiptInvoiceServiceImpl extends MpBaseServiceImpl<BaseTDxRecordInvoiceDao, BaseTDxRecordInvoice> implements BaseIReceiptInvoiceService {
@Override
public List<BaseTDxRecordInvoice> selectByUuids(String[] uuids) {
QueryWrapper<BaseTDxRecordInvoice> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().in(BaseTDxRecordInvoice::getUuid, uuids);
return super.list(queryWrapper);
}
@Override
public void updateBatch(List<BaseTDxRecordInvoice> condList) {
for (BaseTDxRecordInvoice entity : condList) {
LambdaUpdateWrapper<BaseTDxRecordInvoice> updateWrapper =
new UpdateWrapper<BaseTDxRecordInvoice>().lambda();
updateWrapper.eq(BaseTDxRecordInvoice::getId, entity.getId());
super.update(entity, updateWrapper);
}
super.succResult(new JSONObject());
}
}

@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.dxhy.common.enums.FplxEnum; import com.dxhy.common.enums.FplxEnum;
import com.dxhy.erp.model.*; import com.dxhy.erp.model.*;
import com.dxhy.erp.utils.JsonUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -326,8 +327,8 @@ public class InvoiceAuthServiceImpl extends MpBaseServiceImpl<RecordInvoiceDao,
es.setZTYPE("S"); es.setZTYPE("S");
ZDATARESP zdataresp = new ZDATARESP(); ZDATARESP zdataresp = new ZDATARESP();
StringBuilder promsg = new StringBuilder(); StringBuilder promsg = new StringBuilder();
String zdata2 = isInput.getZDATA();
List<ZDATA> zdata = isInput.getZDATA(); List<ZDATA> zdata = JSON.parseArray(zdata2, ZDATA.class);
AuthDateReq authDateReq=new AuthDateReq(); AuthDateReq authDateReq=new AuthDateReq();
authDateReq.setBatchNo(isInput.getSAPKEY()); authDateReq.setBatchNo(isInput.getSAPKEY());
authDateReq.setApplyRzlx("1"); authDateReq.setApplyRzlx("1");

@ -0,0 +1,245 @@
package com.dxhy.erp.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dxhy.common.constant.DbConstant;
import com.dxhy.common.datasource.config.DynamicContextHolder;
import com.dxhy.common.enums.JxszcCancelEnum;
import com.dxhy.common.enums.JxszcZtEnum;
import com.dxhy.common.service.impl.MpBaseServiceImpl;
import com.dxhy.common.utils.DateUtils;
import com.dxhy.common.utils.RRException;
import com.dxhy.common.vo.UserInfo;
import com.dxhy.erp.dao.BaseReceiptOutDao;
import com.dxhy.erp.entity.BaseInvoiceEditVO;
import com.dxhy.erp.entity.BaseTDxRecordInvoice;
import com.dxhy.erp.entity.BaseTDxRecordInvoiceOut;
import com.dxhy.erp.model.ErpInvoiceData;
import com.dxhy.erp.model.EsOutPutResp;
import com.dxhy.erp.service.BaseIReceiptInvoiceService;
import com.dxhy.erp.service.IReceiptOutService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Author wangzhikun
* @Date 2022/12/24 2022/12/24
*/
@Service
@Slf4j
public class ReceiptOutServiceImpl extends MpBaseServiceImpl<BaseReceiptOutDao, BaseTDxRecordInvoiceOut>
implements IReceiptOutService {
@Resource
BaseIReceiptInvoiceService baseIReceiptInvoiceService;
@Override
public String transfer(ErpInvoiceData erpInvoiceData, BaseInvoiceEditVO condVO, UserInfo userInfo) {
EsOutPutResp es = new EsOutPutResp();
es.setSAPKEY(erpInvoiceData.getIS_INPUT().getSAPKEY());
DynamicContextHolder.push("business"+DbConstant.BUSINESS_READ);
String idStr = condVO.getPrimaryKey();
String[] ids = idStr.split(",");
// first:查询出底账表相关数据
List<BaseTDxRecordInvoice> invoices = baseIReceiptInvoiceService.selectByUuids(ids);
// second:根据uuids查询出转出明细并转为map,key=uuid ,value=转出明细
List<BaseTDxRecordInvoiceOut> outs = listByUuids(ids);
Map<String, BaseTDxRecordInvoiceOut> outMap =
outs.stream().collect(Collectors.toMap(BaseTDxRecordInvoiceOut::getUuid, tri -> tri));
// third:设置底账表中的 进项税转出 部分相关字段
List<BaseTDxRecordInvoice> condList = setPartInvoiceByType(invoices, condVO, userInfo);
List<BaseTDxRecordInvoiceOut> outList = new ArrayList<>();
// fourth:对比流水明细,区分底账表list中需要update或者insert的数据
invoices.forEach(invoice -> {
BaseTDxRecordInvoiceOut e = new BaseTDxRecordInvoiceOut();
if (outMap.containsKey(invoice.getUuid())) {
e = outMap.get(invoice.getUuid());
}
// 从构建的底账数据中(进项税转出相关字段),更新需要变更的流水字段
e.setCompany(userInfo.getCompany());
createInvoiceOut(condVO, userInfo, invoice, e);
outList.add(e);
});
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
excuteTransferWrite(condList, outList);
return "success";
}
/**
* 根据uuids查询进项税转出明细
*
* @param uuids
* 请求参数
* @return 返回结果
*/
private List<BaseTDxRecordInvoiceOut> listByUuids(String[] uuids) {
QueryWrapper<BaseTDxRecordInvoiceOut> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().in(BaseTDxRecordInvoiceOut::getUuid, uuids);
return super.list(queryWrapper);
}
/**
* 根据转出类型 set 抵账表中进项税转出相关字段 (部分转出 or 全部转出)
*
* @param invoices
* 请求参数
* @param condVO
* 请求参数
* @param userInfo
* 请求参数
* @return 返回结果
*/
private List<BaseTDxRecordInvoice> setPartInvoiceByType(List<BaseTDxRecordInvoice> invoices,
BaseInvoiceEditVO condVO, UserInfo userInfo) {
List<BaseTDxRecordInvoice> condList = new ArrayList<>();
for (BaseTDxRecordInvoice record : invoices) {
record.setOutBelongDate(condVO.getOutTaxPeriod());
BaseTDxRecordInvoice condRecord = new BaseTDxRecordInvoice();
condRecord.setId(record.getId());
// 转出状态
condRecord.setOutStatus(condVO.getOutStatus());
// 转出原因
condRecord.setOutReason(condVO.getOutReason());
// 备注
condRecord.setOutRemark(condVO.getOutRemark());
// 转出日期
condRecord.setOutDate(DateUtils.getNow());
// 转出人
condRecord.setOutBy(userInfo.getUsername());
//转出金额取价税合计
condRecord.setOutInvoiceAmout(record.getTotalAmount());
// 税款所属期
condRecord.setOutBelongDate(condVO.getOutTaxPeriod());
/*全部转出 */
if (JxszcZtEnum.QBZC.getZcztDm().equals(condVO.getOutStatus())) {
// 转出金额
condRecord.setOutInvoiceAmout(record.getInvoiceAmount());
// 转出税额
condRecord.setOutTaxAmount(record.getDkTaxAmount());
}
/*部分转出 */
if (JxszcZtEnum.BFZC.getZcztDm().equals(condVO.getOutStatus())) {
// 转出金额累加
BigDecimal oldOutAmount =
record.getOutInvoiceAmout() == null ? new BigDecimal(0) : record.getOutInvoiceAmout();
BigDecimal newOutAmount = oldOutAmount.add(new BigDecimal(condVO.getOutAmount()));
// -1=小于; 0=等于; 1=大于;
int compareOut = newOutAmount.compareTo(record.getInvoiceAmount());
if (compareOut > 0) {
throw new RRException("累计转出金额不能大于发票金额");
}
// 转出金额
condRecord.setOutInvoiceAmout(newOutAmount);
// 转出税额累加
BigDecimal oldOutTax = record.getOutTaxAmount() == null ? new BigDecimal(0) : record.getOutTaxAmount();
BigDecimal newOutTax = oldOutTax.add(new BigDecimal(condVO.getOutTax()));
int compareTax = newOutTax.compareTo(record.getDkTaxAmount());
if (compareTax > 0) {
throw new RRException("累计转出税额不能大于发票税额");
}
// 转出税额
condRecord.setOutTaxAmount(newOutTax);
if (compareOut == 0 && compareTax == 0) {
// 金额税额已经全部转完,设为 全部转出
condRecord.setOutStatus(JxszcZtEnum.QBZC.getZcztDm());
}
}
condList.add(condRecord);
}
return condList;
}
/**
* 构建进项税转出明细
*
* @param condVO
* 请求参数
* @param userInfo
* 请求参数
* @param invoice
* 请求参数
* @param record
* 请求参数
*/
private void createInvoiceOut(BaseInvoiceEditVO condVO, UserInfo userInfo, BaseTDxRecordInvoice invoice,
BaseTDxRecordInvoiceOut record) {
// uuid
record.setUuid(invoice.getUuid());
// 发票号码
record.setInvoiceNo(invoice.getInvoiceNo());
// 发票代码
record.setInvoiceCode(invoice.getInvoiceCode());
record.setOutBelongDate(invoice.getOutBelongDate());
// 转出状态
record.setOutStatus(condVO.getOutStatus());
/* 全部转出 */
if (JxszcZtEnum.QBZC.getZcztDm().equals(condVO.getOutStatus())) {
// 转出金额
record.setOutInvoiceAmout(invoice.getInvoiceAmount());
// 转出税额
record.setOutTaxAmount(invoice.getDkTaxAmount());
}
/* 部分转出 */
if (JxszcZtEnum.BFZC.getZcztDm().equals(condVO.getOutStatus())) {
// 转出金额累加
BigDecimal oldOutAmount =
record.getOutInvoiceAmout() == null ? new BigDecimal(0) : record.getOutInvoiceAmout();
BigDecimal newOutAmount = oldOutAmount.add(new BigDecimal(condVO.getOutAmount()));
// -1=小于; 0=等于; 1=大于;
int compareOut = newOutAmount.compareTo(invoice.getInvoiceAmount());
if (compareOut > 0) {
throw new RRException("累计转出金额不能大于发票金额");
}
// 转出金额
record.setOutInvoiceAmout(newOutAmount);
// 转出税额累加
BigDecimal oldOutTax = record.getOutTaxAmount() == null ? new BigDecimal(0) : record.getOutTaxAmount();
BigDecimal newOutTax = oldOutTax.add(new BigDecimal(condVO.getOutTax()));
int compareTax = newOutTax.compareTo(invoice.getDkTaxAmount());
if (compareTax > 0) {
throw new RRException("累计转出税额不能大于发票税额");
}
// 转出税额
record.setOutTaxAmount(newOutTax);
// 金额税额全部转完,设置状态为 全部转出
if (compareOut == 0 && compareTax == 0) {
record.setOutStatus(JxszcZtEnum.QBZC.getZcztDm());
}
}
// 转出日期
record.setOutDate(DateUtils.getNow());
// 转出原因
record.setOutReason(condVO.getOutReason());
// 备注
record.setOutRemark(condVO.getOutRemark());
// 转出人
record.setOutBy(userInfo.getUsername());
// 是否取消,默认未取消
record.setIsCancel(JxszcCancelEnum.WQX.getQxztDm());
}
@Transactional(rollbackFor = Exception.class)
public void excuteTransferWrite(List<BaseTDxRecordInvoice> condList, List<BaseTDxRecordInvoiceOut> outList) {
// 流水表批量insert or update
saveOrUpdateBatch(outList);
// 抵账表批量update
baseIReceiptInvoiceService.updateBatch(condList);
}
}

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.dxhy.bxsdk.business.dao.AreaDao"> <mapper namespace="com.dxhy.erp.dao.AreaDao">
<resultMap id="areaResultMap" type="com.dxhy.bxsdk.api.domain.area.Area"> <resultMap id="areaResultMap" type="com.dxhy.erp.entity.sdny.area.Area">
<id column="ID" property="id" jdbcType="BIGINT"/> <id column="ID" property="id" jdbcType="BIGINT"/>
<result column="PID" property="pid" jdbcType="BIGINT"/> <result column="PID" property="pid" jdbcType="BIGINT"/>
<result column="AREA_NAME" property="areaName" jdbcType="VARCHAR"/> <result column="AREA_NAME" property="areaName" jdbcType="VARCHAR"/>
@ -11,7 +11,7 @@
</resultMap> </resultMap>
<!-- 新增区域信息 --> <!-- 新增区域信息 -->
<insert id="addArea" parameterType="com.dxhy.bxsdk.api.domain.area.Area"> <insert id="addArea" parameterType="com.dxhy.erp.entity.sdny.area.Area">
INSERT INTO INSERT INTO
sys_area (PID, AREA_NAME) sys_area (PID, AREA_NAME)
VALUES VALUES
@ -19,7 +19,7 @@
</insert> </insert>
<!-- 更新区域名称字段 --> <!-- 更新区域名称字段 -->
<update id="updateArea" parameterType="com.dxhy.bxsdk.api.domain.area.Area"> <update id="updateArea" parameterType="com.dxhy.erp.entity.sdny.area.Area">
UPDATE UPDATE
sys_area sys_area
SET SET

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.dxhy.bxsdk.business.dao.OrgUserInfoDao"> <mapper namespace="com.dxhy.erp.dao.OrgUserInfoDao">
<!-- 新增员工信息 --> <!-- 新增员工信息 -->
<insert id="addUserInfoList" parameterType="com.dxhy.bxsdk.api.domain.simple.OrgUserInfo"> <insert id="addUserInfoList" parameterType="com.dxhy.erp.entity.sdny.OrgUserInfo">
INSERT INTO INSERT INTO
org_user_info org_user_info
(user_id, user_name, identity_number, create_time, enterprise_id, tax_no, is_white_list, phone, email, password, enterprise_code_list) (user_id, user_name, identity_number, create_time, enterprise_id, tax_no, is_white_list, phone, email, password, enterprise_code_list)
@ -15,7 +15,7 @@
</insert> </insert>
<!-- 查询员工信息列表 --> <!-- 查询员工信息列表 -->
<select id="getUserInfoList" resultType="com.dxhy.bxsdk.api.domain.simple.OrgUserInfo" > <select id="getUserInfoList" resultType="com.dxhy.erp.entity.sdny.OrgUserInfo" >
SELECT * FROM SELECT * FROM
org_user_info org_user_info
WHERE WHERE
@ -51,7 +51,7 @@
</select> </select>
<!-- 删除员工信息 --> <!-- 删除员工信息 -->
<delete id="deleteUserInfo" parameterType="com.dxhy.bxsdk.api.domain.simple.OrgUserInfo"> <delete id="deleteUserInfo" parameterType="com.dxhy.erp.entity.sdny.OrgUserInfo">
DELETE FROM DELETE FROM
org_user_info org_user_info
WHERE WHERE
@ -59,7 +59,7 @@
</delete> </delete>
<!-- 更新员工信息(可批量) --> <!-- 更新员工信息(可批量) -->
<delete id="updateUserInfo" parameterType="com.dxhy.bxsdk.api.domain.simple.OrgUserInfo"> <delete id="updateUserInfo" parameterType="com.dxhy.erp.entity.sdny.OrgUserInfo">
<foreach collection="orgUserInfoList" item="item" index="index" open="" close="" separator=";"> <foreach collection="orgUserInfoList" item="item" index="index" open="" close="" separator=";">
UPDATE UPDATE
org_user_info org_user_info
@ -99,7 +99,7 @@
</foreach> </foreach>
</delete> </delete>
<select id="getUserIdentityNumber" resultType="com.dxhy.bxsdk.api.domain.simple.OrgUserInfo" > <select id="getUserIdentityNumber" resultType="com.dxhy.erp.entity.sdny.OrgUserInfo" >
SELECT * FROM SELECT * FROM
org_user_info org_user_info
WHERE WHERE
@ -127,7 +127,7 @@
user_name = #{userName} user_name = #{userName}
</select> </select>
<select id="getUserIdentityNumberAndEnterpriseId" resultType="com.dxhy.bxsdk.api.domain.simple.OrgUserInfo" > <select id="getUserIdentityNumberAndEnterpriseId" resultType="com.dxhy.erp.entity.sdny.OrgUserInfo" >
SELECT * FROM SELECT * FROM
org_user_info org_user_info
WHERE WHERE
@ -160,7 +160,7 @@
identity_number identity_number
</select> </select>
<select id="selectCount" parameterType="com.dxhy.bxsdk.api.domain.simple.OrgUserInfo" <select id="selectCount" parameterType="com.dxhy.erp.entity.sdny.OrgUserInfo"
resultType="int"> resultType="int">
select count(*) from select count(*) from
org_user_info org_user_info
@ -192,7 +192,7 @@
</if> </if>
</select> </select>
<select id="selectWhiteByParam" resultType="com.dxhy.bxsdk.api.domain.simple.OrgUserInfo"> <select id="selectWhiteByParam" resultType="com.dxhy.erp.entity.sdny.OrgUserInfo">
SELECT * FROM SELECT * FROM
org_user_info org_user_info
WHERE WHERE
@ -227,7 +227,7 @@
</if> </if>
</select> </select>
<update id="updateWhiteUserById" parameterType="com.dxhy.bxsdk.api.domain.simple.OrgUserInfo"> <update id="updateWhiteUserById" parameterType="com.dxhy.erp.entity.sdny.OrgUserInfo">
update org_user_info update org_user_info
set is_white_list = "Y", set is_white_list = "Y",
enterprise_code_list = #{enterpriseCodeList,jdbcType=VARCHAR}, enterprise_code_list = #{enterpriseCodeList,jdbcType=VARCHAR},
@ -252,7 +252,7 @@
</update> </update>
<!-- 查询所有员工信息列表 --> <!-- 查询所有员工信息列表 -->
<select id="getAllUserInfoList" resultType="com.dxhy.bxsdk.api.domain.simple.OrgUserInfo" > <select id="getAllUserInfoList" resultType="com.dxhy.erp.entity.sdny.OrgUserInfo" >
SELECT * FROM SELECT * FROM
org_user_info org_user_info
</select> </select>
@ -268,7 +268,7 @@
</update> </update>
<update id="batchUpdateEnterpriseUserListById" parameterType="com.dxhy.bxsdk.api.domain.wechat.BxwxEnterpriseUserEntity"> <update id="batchUpdateEnterpriseUserListById" parameterType="com.dxhy.erp.entity.sdny.BxwxEnterpriseUserEntity">
<foreach item="item" index="index" collection="list" separator=";"> <foreach item="item" index="index" collection="list" separator=";">
UPDATE org_user_info UPDATE org_user_info
<set> <set>
@ -283,7 +283,7 @@
</update> </update>
<!-- 新增员工信息 --> <!-- 新增员工信息 -->
<insert id="saveUserInfo" parameterType="com.dxhy.bxsdk.api.domain.simple.OrgUserInfo"> <insert id="saveUserInfo" parameterType="com.dxhy.erp.entity.sdny.OrgUserInfo">
INSERT INTO INSERT INTO
org_user_info org_user_info
(user_id, (user_id,
@ -310,7 +310,7 @@
</insert> </insert>
<!-- 更新员工信息(可批量) --> <!-- 更新员工信息(可批量) -->
<update id="updateUserInfoSingle" parameterType="com.dxhy.bxsdk.api.domain.simple.OrgUserInfo"> <update id="updateUserInfoSingle" parameterType="com.dxhy.erp.entity.sdny.OrgUserInfo">
UPDATE UPDATE
org_user_info org_user_info
<set> <set>
@ -346,7 +346,7 @@
user_id = #{userId} user_id = #{userId}
</update> </update>
<select id="getUserInfoListByIsWhile" resultType="com.dxhy.bxsdk.api.domain.simple.OrgUserInfo" > <select id="getUserInfoListByIsWhile" resultType="com.dxhy.erp.entity.sdny.OrgUserInfo" >
SELECT * FROM SELECT * FROM
org_user_info org_user_info
WHERE WHERE
@ -363,7 +363,7 @@
order by create_time desc order by create_time desc
</select> </select>
<select id="queryUserListByUserName" resultType="com.dxhy.bxsdk.api.domain.simple.OrgUserInfo" > <select id="queryUserListByUserName" resultType="com.dxhy.erp.entity.sdny.OrgUserInfo" >
SELECT * FROM SELECT * FROM
org_user_info org_user_info
WHERE WHERE
@ -372,7 +372,7 @@
user_name = #{userName} user_name = #{userName}
</select> </select>
<select id="findByCondition" resultType="com.dxhy.bxsdk.api.domain.simple.OrgUserInfo"> <select id="findByCondition" resultType="com.dxhy.erp.entity.sdny.OrgUserInfo">
select * from org_user_info where user_id = #{userId} select * from org_user_info where user_id = #{userId}
</select> </select>
</mapper> </mapper>
Loading…
Cancel
Save