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 index e7258719..2b1209ab 100755 --- 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 @@ -9,6 +9,7 @@ public class Voucher { private String pk_glorgbook; private String pk_prepared; private String pk_vouchertype; + private String pk_voucher; public List<VoucherDetails> getDetails() { return details; @@ -57,4 +58,12 @@ public class Voucher { public void setPk_vouchertype(String pk_vouchertype) { this.pk_vouchertype = pk_vouchertype; } + + public String getPk_voucher() { + return pk_voucher; + } + + public void setPk_voucher(String pk_voucher) { + this.pk_voucher = pk_voucher; + } } \ No newline at end of file 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 index be1b6e75..ba6b05a3 100644 --- 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 @@ -1,5 +1,6 @@ package com.hzya.frame.u8c.ax.service.impl; +import cn.hutool.http.HttpRequest; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; @@ -51,7 +52,10 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement 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 pzApiCode = "8000160014";//凭证新增 + private final String pzApiCodexz = "8000160014";//凭证新增 + private final String pzApiCodexg = "8000160031";//凭证修改 + private final String pzApiCodesc = "8000160033";//凭证删除 + private final String pzApiCodezf = "8000160032";//凭证作废 private final String ryApiCodexz = "8000160029";//人员对照新增 private final String ryApiCodexg = "8000160029";//人员对照修改 @@ -104,6 +108,9 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement if(jsonObject == null ){ return BaseResult.getFailureMessageEntity("数据为空,请先传递数据"); } + if(!checkStr(jsonObject.getString("voucherType"))){ + return BaseResult.getFailureMessageEntity("voucherType为空"); + } if(!checkStr(jsonObject.getString("usercode"))){ return BaseResult.getFailureMessageEntity("usercode为空"); } @@ -119,37 +126,80 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement 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为空"); - } + String bodys = jsonObject.getString("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()); - //} + switch (jsonObject.getString("voucherType")){ + case "add"://新增 + VoucherRoot entity1 = getData("data", jsonObject, VoucherRoot.class); + if(entity1 == null || entity1.getVoucher() == null || entity1.getVoucher().size() == 0){ + return BaseResult.getFailureMessageEntity("data为空"); + } + for (int i = 0; i < entity1.getVoucher().size(); i++) { + Voucher voucher = entity1.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()); + //} + } + } } } } } } - } + bodys = JSON.toJSONString(entity1); + break; + case "update"://修改 + VoucherRoot entity = getData("data", jsonObject, VoucherRoot.class); + if(entity == null || entity.getVoucher() == null || entity.getVoucher().size() == 0){ + return BaseResult.getFailureMessageEntity("data为空"); + } + 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()); + //} + } + } + } + } + } + } + } + bodys = JSON.toJSONString(entity); + break; + case "delete"://删除 + break; + case "cancellation"://作废 + break; + default: + break; } - HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); // HttpClient CloseableHttpClient closeableHttpClient = httpClientBuilder.disableCookieManagement().build(); @@ -165,9 +215,23 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement post.setHeader("publicKey", publicKey); post.setHeader("secretKey", secretKey); post.setHeader("appId", appId); - post.setHeader("apiCode", pzApiCode); + switch (jsonObject.getString("voucherType")){ + case "add"://新增 + post.setHeader("apiCode", pzApiCodexz); + break; + case "update"://修改 + post.setHeader("apiCode", pzApiCodexg); + break; + case "delete"://删除 + post.setHeader("apiCode", pzApiCodesc); + break; + case "cancellation"://作废 + post.setHeader("apiCode", pzApiCodezf); + break; + default: + break; + } StringBuilder body = new StringBuilder(); - String bodys = JSON.toJSONString(entity); try { if (bodys != null && !"".equals(bodys)) { ByteArrayEntity byteArrayEntity = new ByteArrayEntity(bodys.getBytes("UTF-8")); @@ -182,8 +246,6 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement logger.info("返回结果:" + body); JsonResultEntity resultEntity = JSON.parseObject(body.toString(),JsonResultEntity.class); return resultEntity; - //return resultEntity.getAttribute(); - } catch (Exception e) { logger.error("请求错误:" + e.getMessage()); body.append(e.getMessage());