diff --git a/service/src/main/java/com/hzya/frame/u8c/ax/dao/IAxDao.java b/service/src/main/java/com/hzya/frame/u8c/ax/dao/IAxDao.java new file mode 100644 index 00000000..adac1e3e --- /dev/null +++ b/service/src/main/java/com/hzya/frame/u8c/ax/dao/IAxDao.java @@ -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); +} + diff --git a/service/src/main/java/com/hzya/frame/u8c/ax/dao/impl/AxDaoImpl.java b/service/src/main/java/com/hzya/frame/u8c/ax/dao/impl/AxDaoImpl.java new file mode 100644 index 00000000..c44ddb72 --- /dev/null +++ b/service/src/main/java/com/hzya/frame/u8c/ax/dao/impl/AxDaoImpl.java @@ -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; + } +} + diff --git a/service/src/main/java/com/hzya/frame/u8c/ax/entity/ArchivesEntity.java b/service/src/main/java/com/hzya/frame/u8c/ax/entity/ArchivesEntity.java new file mode 100644 index 00000000..51955803 --- /dev/null +++ b/service/src/main/java/com/hzya/frame/u8c/ax/entity/ArchivesEntity.java @@ -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; + } +} + diff --git a/service/src/main/java/com/hzya/frame/u8c/ax/entity/ArchivesEntity.xml b/service/src/main/java/com/hzya/frame/u8c/ax/entity/ArchivesEntity.xml new file mode 100644 index 00000000..163240b0 --- /dev/null +++ b/service/src/main/java/com/hzya/frame/u8c/ax/entity/ArchivesEntity.xml @@ -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> + diff --git a/service/src/main/java/com/hzya/frame/u8c/ax/entity/Ass.java b/service/src/main/java/com/hzya/frame/u8c/ax/entity/Ass.java new file mode 100755 index 00000000..032b7b26 --- /dev/null +++ b/service/src/main/java/com/hzya/frame/u8c/ax/entity/Ass.java @@ -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; + } +} \ No newline at end of file diff --git a/service/src/main/java/com/hzya/frame/u8c/ax/entity/Cashflow.java b/service/src/main/java/com/hzya/frame/u8c/ax/entity/Cashflow.java new file mode 100755 index 00000000..b6edbd75 --- /dev/null +++ b/service/src/main/java/com/hzya/frame/u8c/ax/entity/Cashflow.java @@ -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; + } +} \ No newline at end of file diff --git a/service/src/main/java/com/hzya/frame/u8c/ax/entity/Voucher.java b/service/src/main/java/com/hzya/frame/u8c/ax/entity/Voucher.java new file mode 100755 index 00000000..e7258719 --- /dev/null +++ b/service/src/main/java/com/hzya/frame/u8c/ax/entity/Voucher.java @@ -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; + } +} \ No newline at end of file diff --git a/service/src/main/java/com/hzya/frame/u8c/ax/entity/VoucherDetails.java b/service/src/main/java/com/hzya/frame/u8c/ax/entity/VoucherDetails.java new file mode 100755 index 00000000..ef8798d6 --- /dev/null +++ b/service/src/main/java/com/hzya/frame/u8c/ax/entity/VoucherDetails.java @@ -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; + } +} \ No newline at end of file diff --git a/service/src/main/java/com/hzya/frame/u8c/ax/entity/VoucherRoot.java b/service/src/main/java/com/hzya/frame/u8c/ax/entity/VoucherRoot.java new file mode 100755 index 00000000..2d50436e --- /dev/null +++ b/service/src/main/java/com/hzya/frame/u8c/ax/entity/VoucherRoot.java @@ -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; + } +} \ No newline at end of file diff --git a/service/src/main/java/com/hzya/frame/u8c/ax/service/IAxService.java b/service/src/main/java/com/hzya/frame/u8c/ax/service/IAxService.java new file mode 100644 index 00000000..29b71543 --- /dev/null +++ b/service/src/main/java/com/hzya/frame/u8c/ax/service/IAxService.java @@ -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); +} diff --git a/service/src/main/java/com/hzya/frame/u8c/ax/service/impl/AxServiceImpl.java b/service/src/main/java/com/hzya/frame/u8c/ax/service/impl/AxServiceImpl.java new file mode 100644 index 00000000..53dbd27e --- /dev/null +++ b/service/src/main/java/com/hzya/frame/u8c/ax/service/impl/AxServiceImpl.java @@ -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; + } +}