澳星修改

This commit is contained in:
lvleigang 2024-08-09 13:37:29 +08:00
parent 9e619c8425
commit a1b46b6dd5
1 changed files with 785 additions and 748 deletions
service/src/main/java/com/hzya/frame/u8c/ax/service/impl

View File

@ -1,6 +1,7 @@
package com.hzya.frame.u8c.ax.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.u8c.ax.dao.IAxDao;
@ -33,11 +34,13 @@ import java.util.List;
@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;
}
@Value("${zt.url}")
private String voucherUrl;
private final String publicKey = "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj";
@ -87,62 +90,62 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
private final Object lock = new Object();
/**
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
* @Author lvleigang
* @Description 凭证新增
* @Date 3:42 下午 2024/4/24
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
@Override
public Object thirdInterfaceVoucherInsert(JSONObject object) {
JSONObject jsonObject = object.getJSONObject("jsonStr");
if(jsonObject == null ){
if (jsonObject == null) {
return BaseResult.getFailureMessageEntity("数据为空,请先传递数据");
}
if(!checkStr(jsonObject.getString("voucherType"))){
if (!checkStr(jsonObject.getString("voucherType"))) {
return BaseResult.getFailureMessageEntity("voucherType为空");
}
if(!checkStr(jsonObject.getString("usercode"))){
if (!checkStr(jsonObject.getString("usercode"))) {
return BaseResult.getFailureMessageEntity("usercode为空");
}
if(!checkStr(jsonObject.getString("password"))){
if (!checkStr(jsonObject.getString("password"))) {
return BaseResult.getFailureMessageEntity("password为空");
}
if(!checkStr(jsonObject.getString("trantype"))){
if (!checkStr(jsonObject.getString("trantype"))) {
return BaseResult.getFailureMessageEntity("trantype为空");
}
if(!checkStr(jsonObject.getString("system"))){
if (!checkStr(jsonObject.getString("system"))) {
return BaseResult.getFailureMessageEntity("system为空");
}
if(!checkStr(jsonObject.getString("data"))){
if (!checkStr(jsonObject.getString("data"))) {
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"});
switch (jsonObject.getString("voucherType")){
List<String> fzhs = Arrays.asList(new String[]{"1", "2", "6", "73", "D01", "jobass", "93", "96", "22"});
switch (jsonObject.getString("voucherType")) {
case "add"://新增
VoucherRoot entity1 = getData("data", jsonObject, VoucherRoot.class);
if(entity1 == null || entity1.getVoucher() == null || entity1.getVoucher().size() == 0){
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){
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){
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 (ass.getChecktypecode() != null && !"".equals(ass.getChecktypecode())) {
//存在需要转换的
if(fzhs.contains(ass.getChecktypecode())){
if (fzhs.contains(ass.getChecktypecode())) {
ArchivesEntity archivesEntity = new ArchivesEntity();
archivesEntity.setArchivesType(ass.getChecktypecode());
archivesEntity.setLeftCode(ass.getCheckvaluecode());
archivesEntity.setLeftOrg(voucher.getPk_corp());
List<ArchivesEntity> archivesEntities = axDao.queryArchivesData(archivesEntity);
if(archivesEntities != null && archivesEntities.size() > 0){
if (archivesEntities != null && archivesEntities.size() > 0) {
ass.setCheckvaluecode(archivesEntities.get(0).getRightCode());
}
}
@ -156,26 +159,26 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
break;
case "update"://修改
VoucherRoot entity = getData("data", jsonObject, VoucherRoot.class);
if(entity == null || entity.getVoucher() == null || entity.getVoucher().size() == 0){
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){
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){
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 (ass.getChecktypecode() != null && !"".equals(ass.getChecktypecode())) {
//存在需要转换的
if(fzhs.contains(ass.getChecktypecode())){
if (fzhs.contains(ass.getChecktypecode())) {
ArchivesEntity archivesEntity = new ArchivesEntity();
archivesEntity.setArchivesType(ass.getChecktypecode());
archivesEntity.setLeftCode(ass.getCheckvaluecode());
archivesEntity.setLeftOrg(voucher.getPk_corp());
List<ArchivesEntity> archivesEntities = axDao.queryArchivesData(archivesEntity);
if(archivesEntities != null && archivesEntities.size() > 0){
if (archivesEntities != null && archivesEntities.size() > 0) {
ass.setCheckvaluecode(archivesEntities.get(0).getRightCode());
}
}
@ -210,7 +213,7 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
post.setHeader("secretKey", secretKey);
post.setHeader("appId", appId);
post.setHeader("needStackTrace", jsonObject.getString("needStackTrace"));
switch (jsonObject.getString("voucherType")){
switch (jsonObject.getString("voucherType")) {
case "add"://新增
post.setHeader("apiCode", pzApiCodexz);
break;
@ -239,13 +242,13 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
body.append(EntityUtils.toString(httpEntity));
}
logger.info("返回结果:" + body);
JsonResultEntity resultEntity = JSON.parseObject(body.toString(),JsonResultEntity.class);
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 {
return BaseResult.getFailureMessageEntity("转发失败", body);
} finally {
try {
// 关闭响应对象
if (response != null) {
@ -260,39 +263,40 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
}
}
}
/**
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
* @Author lvleigang
* @Description 档案新增
* @Date 3:42 下午 2024/4/24
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
@Override
public Object thirdInterfaceArchivesInsert(JSONObject object) {
JSONObject jsonObject = object.getJSONObject("jsonStr");
if(jsonObject == null ){
if (jsonObject == null) {
return BaseResult.getFailureMessageEntity("数据为空,请先传递数据");
}
if(!checkStr(jsonObject.getString("archivesType"))){
if (!checkStr(jsonObject.getString("archivesType"))) {
return BaseResult.getFailureMessageEntity("档案类型为空");
}
if(!checkStr(jsonObject.getString("usercode"))){
if (!checkStr(jsonObject.getString("usercode"))) {
return BaseResult.getFailureMessageEntity("usercode为空");
}
if(!checkStr(jsonObject.getString("password"))){
if (!checkStr(jsonObject.getString("password"))) {
return BaseResult.getFailureMessageEntity("password为空");
}
if(!checkStr(jsonObject.getString("trantype"))){
if (!checkStr(jsonObject.getString("trantype"))) {
return BaseResult.getFailureMessageEntity("trantype为空");
}
if(!checkStr(jsonObject.getString("system"))){
if (!checkStr(jsonObject.getString("system"))) {
return BaseResult.getFailureMessageEntity("system为空");
}
if(!checkStr(jsonObject.getString("data"))){
if (!checkStr(jsonObject.getString("data"))) {
return BaseResult.getFailureMessageEntity("data为空");
}
List<String> fzhs = Arrays.asList(new String[]{"1", "2", "6", "73", "D01" , "jobass" , "93" , "96", "22"});
if(!fzhs.contains(jsonObject.getString("archivesType"))){
List<String> fzhs = Arrays.asList(new String[]{"1", "2", "6", "73", "D01", "jobass", "93", "96", "22"});
if (!fzhs.contains(jsonObject.getString("archivesType"))) {
return BaseResult.getFailureMessageEntity("档案类型错误,请联系管理员");
}
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
@ -309,7 +313,7 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
post.setHeader("secretKey", secretKey);
post.setHeader("appId", appId);
CloseableHttpResponse response = null;
switch (jsonObject.getString("archivesType")){
switch (jsonObject.getString("archivesType")) {
case "1"://人员对照
post.setHeader("apiCode", ryApiCodexz);
break;
@ -342,7 +346,38 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
}
StringBuilder body = new StringBuilder();
try {
ByteArrayEntity byteArrayEntity = new ByteArrayEntity(jsonObject.getString("data").getBytes("UTF-8"));
String senddata = jsonObject.getString("data");
if ("1".equals(jsonObject.getString("archivesType"))) {
JSONObject sendJson = JSONObject.parseObject(senddata);
JSONObject sendObject = new JSONObject();
if (sendJson != null) {
JSONArray psn = sendJson.getJSONArray("psn");
JSONArray sendpsn = new JSONArray();
if (psn != null && psn.size() > 0) {
for (int i = 0; i < psn.size(); i++) {
JSONObject person = psn.getJSONObject(i);
JSONObject parentvo = person.getJSONObject("parentvo");
JSONObject psnmanvo = parentvo.getJSONObject("psnmanvo");
ArchivesEntity archivesEntity = new ArchivesEntity();
archivesEntity.setArchivesType("2");
archivesEntity.setLeftCode(psnmanvo.getString("pk_deptdoc"));
archivesEntity.setLeftOrg(parentvo.getString("currentcorp"));
List<ArchivesEntity> archivesEntities = axDao.queryArchivesData(archivesEntity);
if (archivesEntities != null && archivesEntities.size() > 0) {
psnmanvo.put("pk_deptdoc",archivesEntities.get(0).getRightCode());
}
parentvo.put("psnmanvo",psnmanvo);
person.put("parentvo",parentvo);
sendpsn.add(person);
}
}
sendObject.put("psn",sendpsn);
}
senddata = sendObject.toJSONString();
}
ByteArrayEntity byteArrayEntity = new ByteArrayEntity(senddata.getBytes("UTF-8"));
byteArrayEntity.setContentType("application/json");
post.setEntity(byteArrayEntity);
response = closeableHttpClient.execute(post);
@ -351,7 +386,7 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
body.append(EntityUtils.toString(httpEntity));
}
logger.info("返回结果:" + body);
JsonResultEntity resultEntity = JSON.parseObject(body.toString(),JsonResultEntity.class);
JsonResultEntity resultEntity = JSON.parseObject(body.toString(), JsonResultEntity.class);
return resultEntity;
//todo 暂时不保存
//JsonResultEntity resultEntity = JSON.parseObject(body.toString(),JsonResultEntity.class);
@ -430,8 +465,8 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
} catch (Exception e) {
logger.error("请求错误:" + e.getMessage());
body.append(e.getMessage());
return BaseResult.getFailureMessageEntity("转发失败",body);
}finally {
return BaseResult.getFailureMessageEntity("转发失败", body);
} finally {
try {
// 关闭响应对象
if (response != null) {
@ -446,39 +481,40 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
}
}
}
/**
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
* @Author lvleigang
* @Description 档案修改
* @Date 3:42 下午 2024/4/24
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
@Override
public Object thirdInterfaceArchivesUpdate(JSONObject object) {
JSONObject jsonObject = object.getJSONObject("jsonStr");
if(jsonObject == null ){
if (jsonObject == null) {
return BaseResult.getFailureMessageEntity("数据为空,请先传递数据");
}
if(!checkStr(jsonObject.getString("archivesType"))){
if (!checkStr(jsonObject.getString("archivesType"))) {
return BaseResult.getFailureMessageEntity("档案类型为空");
}
if(!checkStr(jsonObject.getString("usercode"))){
if (!checkStr(jsonObject.getString("usercode"))) {
return BaseResult.getFailureMessageEntity("usercode为空");
}
if(!checkStr(jsonObject.getString("password"))){
if (!checkStr(jsonObject.getString("password"))) {
return BaseResult.getFailureMessageEntity("password为空");
}
if(!checkStr(jsonObject.getString("trantype"))){
if (!checkStr(jsonObject.getString("trantype"))) {
return BaseResult.getFailureMessageEntity("trantype为空");
}
if(!checkStr(jsonObject.getString("system"))){
if (!checkStr(jsonObject.getString("system"))) {
return BaseResult.getFailureMessageEntity("system为空");
}
if(!checkStr(jsonObject.getString("data"))){
if (!checkStr(jsonObject.getString("data"))) {
return BaseResult.getFailureMessageEntity("data为空");
}
List<String> fzhs = Arrays.asList(new String[]{"1", "2", "6", "73", "D01" , "jobass" , "93" , "96", "22"});
if(!fzhs.contains(jsonObject.getString("archivesType"))){
List<String> fzhs = Arrays.asList(new String[]{"1", "2", "6", "73", "D01", "jobass", "93", "96", "22"});
if (!fzhs.contains(jsonObject.getString("archivesType"))) {
return BaseResult.getFailureMessageEntity("档案类型错误,请联系管理员");
}
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
@ -495,7 +531,7 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
post.setHeader("secretKey", secretKey);
post.setHeader("appId", appId);
CloseableHttpResponse response = null;
switch (jsonObject.getString("archivesType")){
switch (jsonObject.getString("archivesType")) {
case "1"://人员对照
post.setHeader("apiCode", ryApiCodexg);
break;
@ -537,7 +573,7 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
body.append(EntityUtils.toString(httpEntity));
}
logger.info("返回结果:" + body);
JsonResultEntity resultEntity = JSON.parseObject(body.toString(),JsonResultEntity.class);
JsonResultEntity resultEntity = JSON.parseObject(body.toString(), JsonResultEntity.class);
return resultEntity;
//JsonResultEntity resultEntity = JSON.parseObject(body.toString(),JsonResultEntity.class);
//if(resultEntity.isFlag() && "200".equals(resultEntity.getStatus())){
@ -605,8 +641,8 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
} catch (Exception e) {
logger.error("请求错误:" + e.getMessage());
body.append(e.getMessage());
return BaseResult.getFailureMessageEntity("转发失败",body);
}finally {
return BaseResult.getFailureMessageEntity("转发失败", body);
} finally {
try {
// 关闭响应对象
if (response != null) {
@ -621,39 +657,40 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
}
}
}
/**
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
* @Author lvleigang
* @Description 档案删除
* @Date 3:42 下午 2024/4/24
* @param object
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
@Override
public Object thirdInterfaceArchivesDelete(JSONObject object) {
JSONObject jsonObject = object.getJSONObject("jsonStr");
if(jsonObject == null ){
if (jsonObject == null) {
return BaseResult.getFailureMessageEntity("数据为空,请先传递数据");
}
if(!checkStr(jsonObject.getString("archivesType"))){
if (!checkStr(jsonObject.getString("archivesType"))) {
return BaseResult.getFailureMessageEntity("档案类型为空");
}
if(!checkStr(jsonObject.getString("usercode"))){
if (!checkStr(jsonObject.getString("usercode"))) {
return BaseResult.getFailureMessageEntity("usercode为空");
}
if(!checkStr(jsonObject.getString("password"))){
if (!checkStr(jsonObject.getString("password"))) {
return BaseResult.getFailureMessageEntity("password为空");
}
if(!checkStr(jsonObject.getString("trantype"))){
if (!checkStr(jsonObject.getString("trantype"))) {
return BaseResult.getFailureMessageEntity("trantype为空");
}
if(!checkStr(jsonObject.getString("system"))){
if (!checkStr(jsonObject.getString("system"))) {
return BaseResult.getFailureMessageEntity("system为空");
}
if(!checkStr(jsonObject.getString("data"))){
if (!checkStr(jsonObject.getString("data"))) {
return BaseResult.getFailureMessageEntity("data为空");
}
List<String> fzhs = Arrays.asList(new String[]{"1", "2", "6", "73", "D01" , "jobass" , "93" , "96", "22"});
if(!fzhs.contains(jsonObject.getString("archivesType"))){
List<String> fzhs = Arrays.asList(new String[]{"1", "2", "6", "73", "D01", "jobass", "93", "96", "22"});
if (!fzhs.contains(jsonObject.getString("archivesType"))) {
return BaseResult.getFailureMessageEntity("档案类型错误,请联系管理员");
}
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
@ -670,7 +707,7 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
post.setHeader("secretKey", secretKey);
post.setHeader("appId", appId);
CloseableHttpResponse response = null;
switch (jsonObject.getString("archivesType")){
switch (jsonObject.getString("archivesType")) {
case "1"://人员对照
post.setHeader("apiCode", ryApiCodesc);
break;
@ -712,7 +749,7 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
body.append(EntityUtils.toString(httpEntity));
}
logger.info("返回结果:" + body);
JsonResultEntity resultEntity = JSON.parseObject(body.toString(),JsonResultEntity.class);
JsonResultEntity resultEntity = JSON.parseObject(body.toString(), JsonResultEntity.class);
return resultEntity;
//JsonResultEntity resultEntity = JSON.parseObject(body.toString(),JsonResultEntity.class);
//if(resultEntity.isFlag() && "200".equals(resultEntity.getStatus())){
@ -780,8 +817,8 @@ public class AxServiceImpl extends BaseService<ArchivesEntity, String> implement
} catch (Exception e) {
logger.error("请求错误:" + e.getMessage());
body.append(e.getMessage());
return BaseResult.getFailureMessageEntity("转发失败",body);
}finally {
return BaseResult.getFailureMessageEntity("转发失败", body);
} finally {
try {
// 关闭响应对象
if (response != null) {