澳星凭证

This commit is contained in:
lvleigang 2024-04-25 08:41:38 +08:00
parent d6ea257070
commit d63d2ca28b
11 changed files with 565 additions and 0 deletions

View File

@ -0,0 +1,18 @@
package com.hzya.frame.u8c.ax.dao;
import com.hzya.frame.u8c.ax.entity.ArchivesEntity;
import com.hzya.frame.basedao.dao.IBaseDao;
import java.util.List;
/**
* (bd_corp: table)表数据库访问层
*
* @author makejava
* @since 2023-09-06 14:47:17
*/
public interface IAxDao extends IBaseDao<ArchivesEntity, String> {
List<ArchivesEntity> queryArchivesData(ArchivesEntity archivesEntity);
}

View File

@ -0,0 +1,26 @@
package com.hzya.frame.u8c.ax.dao.impl;
import com.hzya.frame.sysnew.user.entity.SysUserEntity;
import com.hzya.frame.u8c.ax.dao.IAxDao;
import com.hzya.frame.u8c.ax.entity.ArchivesEntity;
import org.springframework.stereotype.Repository;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import java.util.List;
/**
* (BdCorp)表数据库访问层
*
* @author makejava
* @since 2023-09-06 14:47:17
*/
@Repository("axDaoImpl")
public class AxDaoImpl extends MybatisGenericDao<ArchivesEntity, String> implements IAxDao {
@Override
public List<ArchivesEntity> queryArchivesData(ArchivesEntity entity) {
List<ArchivesEntity> o = super.query(getSqlIdPrifx() + "queryArchivesData", entity);
return o;
}
}

View File

@ -0,0 +1,41 @@
package com.hzya.frame.u8c.ax.entity;
import com.hzya.frame.web.entity.BaseEntity;
/**
* (BdCorp)实体类
*
* @author makejava
* @since 2023-09-06 14:47:18
*/
public class ArchivesEntity extends BaseEntity {
private String archivesType;//类型
private String leftCode;//左编码
private String rightCode;//右编码
public String getArchivesType() {
return archivesType;
}
public void setArchivesType(String archivesType) {
this.archivesType = archivesType;
}
public String getLeftCode() {
return leftCode;
}
public void setLeftCode(String leftCode) {
this.leftCode = leftCode;
}
public String getRightCode() {
return rightCode;
}
public void setRightCode(String rightCode) {
this.rightCode = rightCode;
}
}

View File

@ -0,0 +1,35 @@
<?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">
<mapper namespace="com.hzya.frame.u8c.ax.dao.impl.AxDaoImpl">
<resultMap id="get-ArchivesEntity-result" type="com.hzya.frame.u8c.ax.entity.ArchivesEntity" >
<result property="leftCode" column="left_code" jdbcType="VARCHAR"/>
<result property="rightCode" column="right_code" jdbcType="VARCHAR"/>
</resultMap>
<select id="queryArchivesData" resultMap="get-ArchivesEntity-result"
parameterType="com.hzya.frame.sysnew.user.entity.SysUserEntity">
select
right_code
from
<choose>
<when test="archivesType == '1'"> sys_personnel_control </when>
<when test="archivesType == '2'"> sys_org_control </when>
<when test="archivesType == '6'"> sys_stock_control </when>
<when test="archivesType == '73'"> sys_merchant_control </when>
<when test="archivesType == 'D01'"> sys_taxrate_control </when>
<when test="archivesType == 'jobass'"> sys_project_control </when>
<when test="archivesType == '93'"> sys_bank_control </when>
<when test="archivesType == '96'"> sys_bankaccount_control </when>
<when test="archivesType == '22'"> sys_assets_control </when>
</choose>
<trim prefix="where" prefixOverrides="and">
<if test="leftCode != null and leftCode != ''">and left_code = #{leftCode}</if>
and sts='Y'
</trim>
</select>
</mapper>

View File

@ -0,0 +1,24 @@
package com.hzya.frame.u8c.ax.entity;
public class Ass {
private String checktypecode;
private String checkvaluecode;
public String getChecktypecode() {
return checktypecode;
}
public void setChecktypecode(String checktypecode) {
this.checktypecode = checktypecode;
}
public String getCheckvaluecode() {
return checkvaluecode;
}
public void setCheckvaluecode(String checkvaluecode) {
this.checkvaluecode = checkvaluecode;
}
}

View File

@ -0,0 +1,23 @@
package com.hzya.frame.u8c.ax.entity;
public class Cashflow {
private String money;
private String pk_cashflow;
public String getMoney() {
return money;
}
public void setMoney(String money) {
this.money = money;
}
public String getPk_cashflow() {
return pk_cashflow;
}
public void setPk_cashflow(String pk_cashflow) {
this.pk_cashflow = pk_cashflow;
}
}

View File

@ -0,0 +1,60 @@
package com.hzya.frame.u8c.ax.entity;
import java.util.List;
public class Voucher {
private List<VoucherDetails> details;
private String no;
private String pk_corp;
private String pk_glorgbook;
private String pk_prepared;
private String pk_vouchertype;
public List<VoucherDetails> getDetails() {
return details;
}
public void setDetails(List<VoucherDetails> details) {
this.details = details;
}
public String getNo() {
return no;
}
public void setNo(String no) {
this.no = no;
}
public String getPk_corp() {
return pk_corp;
}
public void setPk_corp(String pk_corp) {
this.pk_corp = pk_corp;
}
public String getPk_glorgbook() {
return pk_glorgbook;
}
public void setPk_glorgbook(String pk_glorgbook) {
this.pk_glorgbook = pk_glorgbook;
}
public String getPk_prepared() {
return pk_prepared;
}
public void setPk_prepared(String pk_prepared) {
this.pk_prepared = pk_prepared;
}
public String getPk_vouchertype() {
return pk_vouchertype;
}
public void setPk_vouchertype(String pk_vouchertype) {
this.pk_vouchertype = pk_vouchertype;
}
}

View File

@ -0,0 +1,87 @@
package com.hzya.frame.u8c.ax.entity;
import java.util.List;
public class VoucherDetails {
private List<Ass> ass;
private List<Cashflow> cashflow;
private String creditamount;
private String debitamount;
private String explanation;
private String localcreditamount;
private String localdebitamount;
private String pk_accsubj;
private String pk_currtype;
public List<Ass> getAss() {
return ass;
}
public void setAss(List<Ass> ass) {
this.ass = ass;
}
public List<Cashflow> getCashflow() {
return cashflow;
}
public void setCashflow(List<Cashflow> cashflow) {
this.cashflow = cashflow;
}
public String getCreditamount() {
return creditamount;
}
public void setCreditamount(String creditamount) {
this.creditamount = creditamount;
}
public String getDebitamount() {
return debitamount;
}
public void setDebitamount(String debitamount) {
this.debitamount = debitamount;
}
public String getExplanation() {
return explanation;
}
public void setExplanation(String explanation) {
this.explanation = explanation;
}
public String getLocalcreditamount() {
return localcreditamount;
}
public void setLocalcreditamount(String localcreditamount) {
this.localcreditamount = localcreditamount;
}
public String getLocaldebitamount() {
return localdebitamount;
}
public void setLocaldebitamount(String localdebitamount) {
this.localdebitamount = localdebitamount;
}
public String getPk_accsubj() {
return pk_accsubj;
}
public void setPk_accsubj(String pk_accsubj) {
this.pk_accsubj = pk_accsubj;
}
public String getPk_currtype() {
return pk_currtype;
}
public void setPk_currtype(String pk_currtype) {
this.pk_currtype = pk_currtype;
}
}

View File

@ -0,0 +1,14 @@
package com.hzya.frame.u8c.ax.entity;
import java.util.List;
public class VoucherRoot {
private List<Voucher> voucher;
public List<Voucher> getVoucher() {
return voucher;
}
public void setVoucher(List<Voucher> voucher) {
this.voucher = voucher;
}
}

View File

@ -0,0 +1,41 @@
package com.hzya.frame.u8c.ax.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.u8c.ax.entity.ArchivesEntity;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.web.entity.JsonResultEntity;
public interface IAxService extends IBaseService<ArchivesEntity, String>{
/**
* @Author lvleigang
* @Description 凭证新增
* @Date 3:42 下午 2024/4/24
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
JsonResultEntity thirdInterfaceVoucherInsert(JSONObject object);
/**
* @Author lvleigang
* @Description 档案新增
* @Date 3:42 下午 2024/4/24
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
JsonResultEntity thirdInterfaceArchivesInsert(JSONObject object);
/**
* @Author lvleigang
* @Description 档案修改
* @Date 3:42 下午 2024/4/24
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
JsonResultEntity thirdInterfaceArchivesUpdate(JSONObject object);
/**
* @Author lvleigang
* @Description 档案删除
* @Date 3:42 下午 2024/4/24
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
JsonResultEntity thirdInterfaceArchivesDelete(JSONObject object);
}

View File

@ -0,0 +1,196 @@
package com.hzya.frame.u8c.ax.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.sysnew.user.entity.SysUserEntity;
import com.hzya.frame.u8c.ax.dao.IAxDao;
import com.hzya.frame.u8c.ax.entity.ArchivesEntity;
import com.hzya.frame.u8c.ax.entity.Ass;
import com.hzya.frame.u8c.ax.entity.Voucher;
import com.hzya.frame.u8c.ax.entity.VoucherDetails;
import com.hzya.frame.u8c.ax.entity.VoucherRoot;
import com.hzya.frame.u8c.ax.service.IAxService;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.hzya.frame.basedao.service.impl.BaseService;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
/**
* (BdCorp)表服务实现类
*
* @author makejava
* @since 2023-09-06 14:47:18
*/
@Service("axServiceImpl")
public class AxServiceImpl extends BaseService<ArchivesEntity, String> implements IAxService {
private IAxDao axDao;
@Autowired
public void setAxDao(IAxDao dao) {
this.axDao = dao;
this.dao = dao;
}
private final String voucherUrl = "http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface";
private final String publicKey = "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj";
private final String secretKey = "fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=";
private final String appId = "800016";
private final String apiCode = "8000160014";
private final Object lock = new Object();
/**
* @Author lvleigang
* @Description 凭证新增
* @Date 3:42 下午 2024/4/24
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
@Override
public JsonResultEntity thirdInterfaceVoucherInsert(JSONObject object) {
JSONObject jsonObject = object.getJSONObject("jsonStr");
if(jsonObject == null ){
return BaseResult.getFailureMessageEntity("数据为空,请先传递数据");
}
if(!checkStr(jsonObject.getString("usercode"))){
return BaseResult.getFailureMessageEntity("usercode为空");
}
if(!checkStr(jsonObject.getString("password"))){
return BaseResult.getFailureMessageEntity("password为空");
}
if(!checkStr(jsonObject.getString("trantype"))){
return BaseResult.getFailureMessageEntity("trantype为空");
}
if(!checkStr(jsonObject.getString("system"))){
return BaseResult.getFailureMessageEntity("system为空");
}
if(!checkStr(jsonObject.getString("data"))){
return BaseResult.getFailureMessageEntity("data为空");
}
VoucherRoot entity = getData("data", jsonObject, VoucherRoot.class);
if(entity == null || entity.getVoucher() == null || entity.getVoucher().size() == 0){
return BaseResult.getFailureMessageEntity("data为空");
}
List<String> fzhs = Arrays.asList(new String[]{"1", "2", "6", "73", "D01" , "jobass" , "93" , "96", "22"});
for (int i = 0; i < entity.getVoucher().size(); i++) {
Voucher voucher = entity.getVoucher().get(i);
if(voucher.getDetails() != null && voucher.getDetails().size() > 0){
for (int a = 0; a < voucher.getDetails().size(); a++) {
VoucherDetails voucherDetails = voucher.getDetails().get(a);
if(voucherDetails.getAss() != null && voucherDetails.getAss().size() > 0){
for (int b = 0; b < voucherDetails.getAss().size(); b++) {
Ass ass = voucherDetails.getAss().get(b);
if(ass.getChecktypecode() != null && !"".equals(ass.getChecktypecode())){
//存在需要转换的
if(fzhs.contains(ass.getChecktypecode())){
ArchivesEntity archivesEntity = new ArchivesEntity();
archivesEntity.setArchivesType(ass.getChecktypecode());
archivesEntity.setLeftCode(ass.getCheckvaluecode());
//List<ArchivesEntity> archivesEntities = axDao.queryArchivesData(archivesEntity);
//if(archivesEntities != null && archivesEntities.size() > 0){
// ass.setCheckvaluecode(archivesEntities.get(0).getRightCode());
//}
}
}
}
}
}
}
}
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
// HttpClient
CloseableHttpClient closeableHttpClient = httpClientBuilder.disableCookieManagement().build();
HttpPost post = new HttpPost(voucherUrl);
CloseableHttpResponse response = null;
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60000).build();
post.setConfig(requestConfig);//设置请求参数超时时间
post.setHeader("usercode", jsonObject.getString("usercode"));
post.setHeader("password", jsonObject.getString("password"));
post.setHeader("trantype", jsonObject.getString("trantype"));
post.setHeader("system", jsonObject.getString("system"));
post.setHeader("publicKey", publicKey);
post.setHeader("secretKey", secretKey);
post.setHeader("appId", appId);
post.setHeader("apiCode", apiCode);
StringBuilder body = new StringBuilder();
String bodys = JSON.toJSONString(entity);
try {
if (bodys != null && !"".equals(bodys)) {
ByteArrayEntity byteArrayEntity = new ByteArrayEntity(bodys.getBytes("UTF-8"));
byteArrayEntity.setContentType("application/json");
post.setEntity(byteArrayEntity);
}
response = closeableHttpClient.execute(post);
HttpEntity httpEntity = response.getEntity();
synchronized (lock) {
body.append(EntityUtils.toString(httpEntity));
}
logger.info("返回结果:" + body);
JsonResultEntity resultEntity = JSON.parseObject(body.toString(),JsonResultEntity.class);
return resultEntity;
} catch (Exception e) {
logger.error("请求错误:" + e.getMessage());
body.append(e.getMessage());
return BaseResult.getFailureMessageEntity("转发失败",body);
}finally {
try {
// 关闭响应对象
if (response != null) {
response.close();
}
// 关闭响应对象
if (closeableHttpClient != null) {
closeableHttpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* @Author lvleigang
* @Description 档案新增
* @Date 3:42 下午 2024/4/24
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
@Override
public JsonResultEntity thirdInterfaceArchivesInsert(JSONObject object) {
return null;
}
/**
* @Author lvleigang
* @Description 档案修改
* @Date 3:42 下午 2024/4/24
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
@Override
public JsonResultEntity thirdInterfaceArchivesUpdate(JSONObject object) {
return null;
}
/**
* @Author lvleigang
* @Description 档案删除
* @Date 3:42 下午 2024/4/24
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
@Override
public JsonResultEntity thirdInterfaceArchivesDelete(JSONObject object) {
return null;
}
}