From 5209d7cfd54b053b78729a35c175b3a452d9124a Mon Sep 17 00:00:00 2001
From: lvleigang <957075182@qq.com>
Date: Sat, 2 Nov 2024 11:21:14 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=BB=84=E7=B1=BB=E5=9E=8B=E6=9F=A5?=
=?UTF-8?q?=E8=AF=A2=E5=8D=95=E6=8D=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../dgx/u9c/entity/RequisitionEntity.java | 10 +
.../dgx/u9c/entity/RequisitionEntity.xml | 7 +-
.../dgx/u9c/service/IPrepaymentService.java | 2 +-
.../service/impl/PrepaymentServiceImpl.java | 4 +-
.../service/impl/U9CPluginServiceImpl.java | 604 +++++++++---------
5 files changed, 325 insertions(+), 302 deletions(-)
diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/entity/RequisitionEntity.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/entity/RequisitionEntity.java
index 7a59630f..7582180e 100644
--- a/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/entity/RequisitionEntity.java
+++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/entity/RequisitionEntity.java
@@ -59,6 +59,8 @@ public class RequisitionEntity extends BaseEntity {
private String dataMsg;
//用户手机号
private String userPhone;
+ //用户手机号
+ private String sendPhone;
public String getStartTime() {
return startTime;
@@ -235,4 +237,12 @@ public class RequisitionEntity extends BaseEntity {
public void setUserPhone(String userPhone) {
this.userPhone = userPhone;
}
+
+ public String getSendPhone() {
+ return sendPhone;
+ }
+
+ public void setSendPhone(String sendPhone) {
+ this.sendPhone = sendPhone;
+ }
}
diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/entity/RequisitionEntity.xml b/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/entity/RequisitionEntity.xml
index 6502d31f..d16f2f62 100644
--- a/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/entity/RequisitionEntity.xml
+++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/entity/RequisitionEntity.xml
@@ -24,6 +24,7 @@
+
@@ -47,6 +48,7 @@
createdOn,
dataStatus,
dataMsg,
+ sendPhone,
userPhone
@@ -114,11 +116,12 @@
where id = #{id}
+
-
-
+
+
diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/service/IPrepaymentService.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/service/IPrepaymentService.java
index a85a6c56..3e182992 100644
--- a/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/service/IPrepaymentService.java
+++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/service/IPrepaymentService.java
@@ -25,5 +25,5 @@ public interface IPrepaymentService extends IBaseService
*/
@DS("#entity.dataSourceCode")
@Override
- public int updateStatus(PrepaymentEntity entity) {
- return 0;
+ public void updateStatus(PrepaymentEntity entity) {
+ prepaymentDao.update(entity);
}
}
diff --git a/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/service/impl/U9CPluginServiceImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/service/impl/U9CPluginServiceImpl.java
index f3d90a03..36d36170 100644
--- a/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/service/impl/U9CPluginServiceImpl.java
+++ b/base-buildpackage/src/main/java/com/hzya/frame/plugin/dgx/u9c/service/impl/U9CPluginServiceImpl.java
@@ -46,6 +46,7 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Value("${zt.url}")
private String url;
+
/**
* u9c预付单发起OA请款单流程 (预付)
*
@@ -57,23 +58,23 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
//数据源编码
String datasourceCode = requestJson.getString("sourceCode");
//开始时间
- String startTime = DateUtil.format(requestJson.getDate("startTime"),"yyyy-MM-dd HH:mm:ss");
+ String startTime = DateUtil.format(requestJson.getDate("startTime"), "yyyy-MM-dd HH:mm:ss");
//结束时间
- String endTime = DateUtil.format(requestJson.getDate("endTime"),"yyyy-MM-dd HH:mm:ss");
+ String endTime = DateUtil.format(requestJson.getDate("endTime"), "yyyy-MM-dd HH:mm:ss");
//重试id
String taskId = requestJson.getString("integration_task_living_details_id");
//查询U9C预付单
PrepaymentEntity prepaymentEntity = new PrepaymentEntity();
//prepaymentEntity.setDocNo("RE-1563");
prepaymentEntity.setDataSourceCode(datasourceCode);
- if (StrUtil.isEmpty(taskId)){
+ if (StrUtil.isEmpty(taskId)) {
//prepaymentEntity.setStartTime(startTime);
//prepaymentEntity.setEndTime(endTime);
- }else {
+ } else {
prepaymentEntity.setId(taskId);
}
List prepaymentList = prepaymentService.queryList(prepaymentEntity);
- if (CollectionUtils.isNotEmpty(prepaymentList)){
+ if (CollectionUtils.isNotEmpty(prepaymentList)) {
for (PrepaymentEntity prepayment : prepaymentList) {
//查询u9c预付单供应商明细 第一个页签
PrepaymentSuppEntity prepaymentSuppEntity = new PrepaymentSuppEntity();
@@ -85,199 +86,199 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
prepaymentDetailEntity.setMainId(prepayment.getId());
prepaymentDetailEntity.setDataSourceCode(datasourceCode);
List prepaymentDetailList = prepaymentDetailServiceImpl.queryDetails(prepaymentDetailEntity);
- if (CollectionUtils.isNotEmpty(prepaymentDetailList) && CollectionUtils.isNotEmpty(prepaymentSuppList)){
+ if (CollectionUtils.isNotEmpty(prepaymentDetailList) && CollectionUtils.isNotEmpty(prepaymentSuppList)) {
//主表
JSONObject zb = new JSONObject();
//单据类型
- zb.put("field0001",prepayment.getDocumentTypeName());
+ zb.put("field0001", prepayment.getDocumentTypeName());
//币种
- zb.put("field0002",prepayment.getCurrencyName());
+ zb.put("field0002", prepayment.getCurrencyName());
//单号
- zb.put("field0003",prepayment.getDocNo());
+ zb.put("field0003", prepayment.getDocNo());
//业务员
- zb.put("field0004",prepayment.getTransactorName());
+ zb.put("field0004", prepayment.getTransactorName());
//申请日期
- zb.put("field0005",prepayment.getPayRFDate());
+ zb.put("field0005", prepayment.getPayRFDate());
//部门
- zb.put("field0006",prepayment.getDeptName());
+ zb.put("field0006", prepayment.getDeptName());
//预计付款日
- zb.put("field0007",prepayment.getExpectPayDate());
+ zb.put("field0007", prepayment.getExpectPayDate());
//付款方式
- zb.put("field0008",prepayment.getPayModeCode());
+ zb.put("field0008", prepayment.getPayModeCode());
//请款对象
- zb.put("field0009",prepayment.getRequestObjTypeCode());
+ zb.put("field0009", prepayment.getRequestObjTypeCode());
//状态
- zb.put("field0010",prepayment.getDocStatusName());
+ zb.put("field0010", prepayment.getDocStatusName());
//请款用途
- zb.put("field0011",prepaymentDetailList.get(0).getReqFundUseName());
+ zb.put("field0011", prepaymentDetailList.get(0).getReqFundUseName());
//出纳确认
- zb.put("field0012",prepayment.getCashierConfirmed());
+ zb.put("field0012", prepayment.getCashierConfirmed());
//折扣前请款金额合计
- zb.put("field0044","");
+ zb.put("field0044", "");
//请款对应折扣合计
- zb.put("field0045","");
+ zb.put("field0045", "");
//折扣后请款金额合计
- zb.put("field0046","");
+ zb.put("field0046", "");
//付款本币金额合计
- zb.put("field0047","");
+ zb.put("field0047", "");
//请款金额合计
- zb.put("field0053","");
+ zb.put("field0053", "");
//请款数量合计
- zb.put("field0061","");
+ zb.put("field0061", "");
//请款金额和明细合计
- zb.put("field0063","");
+ zb.put("field0063", "");
//单据编号
- zb.put("field0070","");
+ zb.put("field0070", "");
//发起人
- zb.put("field0071","");
+ zb.put("field0071", "");
//发起部门
- zb.put("field0072","");
+ zb.put("field0072", "");
//发起时间
- zb.put("field0073","");
+ zb.put("field0073", "");
//子表
List gysList = new LinkedList<>();//供应商
List qkList = new LinkedList<>();//请款
- for (PrepaymentSuppEntity detail : prepaymentSuppList){
+ for (PrepaymentSuppEntity detail : prepaymentSuppList) {
JSONObject gys = new JSONObject();
//行号
- gys.put("field0013",detail.getLineNum());
+ gys.put("field0013", detail.getLineNum());
//供应商
- gys.put("field0014",detail.getSuppName());
+ gys.put("field0014", detail.getSuppName());
//选单
- gys.put("field0015","");//有问题,不知道字段
+ gys.put("field0015", "");//有问题,不知道字段
//折扣前请款金额
- gys.put("field0016",detail.getRfTotalMoney());
+ gys.put("field0016", detail.getRfTotalMoney());
//请款对应折扣
- gys.put("field0017",detail.getRfDisCount());
+ gys.put("field0017", detail.getRfDisCount());
//折扣后请款金额
- gys.put("field0018",detail.getRfaMoney());
+ gys.put("field0018", detail.getRfaMoney());
//付款本币金额
- gys.put("field0019",detail.getAcmPayFCMoney());
+ gys.put("field0019", detail.getAcmPayFCMoney());
//结算方式
- gys.put("field0020",detail.getPayType());
+ gys.put("field0020", detail.getPayType());
//收款银行帐号
- gys.put("field0021",detail.getOppAccBkAccount());
+ gys.put("field0021", detail.getOppAccBkAccount());
//收款账号名称
- gys.put("field0022",detail.getRecBkAccName());
+ gys.put("field0022", detail.getRecBkAccName());
//开户银行
- gys.put("field0023",detail.getOppAccBk());
+ gys.put("field0023", detail.getOppAccBk());
//收支项目
- gys.put("field0024",detail.getIncomeExpendItemName());
+ gys.put("field0024", detail.getIncomeExpendItemName());
//部门-供应商
- gys.put("field0025",detail.getDeptName());
+ gys.put("field0025", detail.getDeptName());
//业务员-供应商
- gys.put("field0026",detail.getTransactorName());
+ gys.put("field0026", detail.getTransactorName());
//项目-供应商
- gys.put("field0027","");
+ gys.put("field0027", "");
//预付款类型
- gys.put("field0051","");
+ gys.put("field0051", "");
//请款金额
- gys.put("field0052","");
+ gys.put("field0052", "");
//料品
- gys.put("field0054",detail.getItemName());
+ gys.put("field0054", detail.getItemName());
gysList.add(gys);
}
for (PrepaymentDetailEntity detail : prepaymentDetailList) {
JSONObject qk = new JSONObject();
//单据类型明细
- qk.put("field0028",detail.getDocType());
+ qk.put("field0028", detail.getDocType());
//应付单
- qk.put("field0029",detail.getDocCode());
+ qk.put("field0029", detail.getDocCode());
//折扣前可请款金额
- qk.put("field0030",detail.getCanDisposeMoney());
+ qk.put("field0030", detail.getCanDisposeMoney());
//可享受折扣
- qk.put("field0031",detail.getRfDisCount());
+ qk.put("field0031", detail.getRfDisCount());
//折扣前请款金额明细
- qk.put("field0032",detail.getRfTotalMoney());
+ qk.put("field0032", detail.getRfTotalMoney());
//请款享受折扣
- qk.put("field0033",detail.getRfDisCount());
+ qk.put("field0033", detail.getRfDisCount());
//折扣后请款金额明细
- qk.put("field0034",detail.getRaTotalMoney());
+ qk.put("field0034", detail.getRaTotalMoney());
//累计确认对应金额
- qk.put("field0035",detail.getCfmMoney());
+ qk.put("field0035", detail.getCfmMoney());
//发票号
- qk.put("field0036",detail.getInvoiceNum());
+ qk.put("field0036", detail.getInvoiceNum());
//发票日期
- qk.put("field0037",detail.getInvoiceDate());
+ qk.put("field0037", detail.getInvoiceDate());
//立账日期
- qk.put("field0038",detail.getAccrueDate());
+ qk.put("field0038", detail.getAccrueDate());
//记账日期
- qk.put("field0039",detail.getPostPeriod());
+ qk.put("field0039", detail.getPostPeriod());
//到期日
- qk.put("field0040",detail.getMaturity());
+ qk.put("field0040", detail.getMaturity());
//付款条件
- qk.put("field0041",detail.getPayTermName());
+ qk.put("field0041", detail.getPayTermName());
//部门明细
- qk.put("field0042",detail.getDetpName());
+ qk.put("field0042", detail.getDetpName());
//业务员明细
- qk.put("field0043",detail.getTransactorName());
+ qk.put("field0043", detail.getTransactorName());
//预付款类型明细
- qk.put("field0055","");//有问题,不知道字段
+ qk.put("field0055", "");//有问题,不知道字段
//单号明细
- qk.put("field0056","");//有问题,不知道字段
+ qk.put("field0056", "");//有问题,不知道字段
//单价
- qk.put("field0057","");//有问题,不知道字段
+ qk.put("field0057", "");//有问题,不知道字段
//数量
- qk.put("field0058","");//有问题,不知道字段
+ qk.put("field0058", "");//有问题,不知道字段
//单位
- qk.put("field0059","");//有问题,不知道字段
+ qk.put("field0059", "");//有问题,不知道字段
//请款数量
- qk.put("field0060","");//有问题,不知道字段
+ qk.put("field0060", "");//有问题,不知道字段
//请款金额明细
- qk.put("field0062","");//有问题,不知道字段
+ qk.put("field0062", "");//有问题,不知道字段
//费用
- qk.put("field0064","");//有问题,不知道字段
+ qk.put("field0064", "");//有问题,不知道字段
//料号
- qk.put("field0065","");//有问题,不知道字段
+ qk.put("field0065", "");//有问题,不知道字段
//料品明细
- qk.put("field0066","");//有问题,不知道字段
+ qk.put("field0066", "");//有问题,不知道字段
//项目
- qk.put("field0067",detail.getProjectName());
+ qk.put("field0067", detail.getProjectName());
//立账供应商
- qk.put("field0068",detail.getSuppName());
+ qk.put("field0068", detail.getSuppName());
//单据状态
- qk.put("field0069",prepayment.getDocumentTypeName());
+ qk.put("field0069", prepayment.getDocumentTypeName());
qkList.add(qk);
}
JSONObject formData = new JSONObject(new LinkedHashMap<>());
- formData.put("formmain_0664",zb);//主表
- formData.put("formson_0665",gysList);
- formData.put("formson_0666",qkList);
+ formData.put("formmain_0664", zb);//主表
+ formData.put("formson_0665", gysList);
+ formData.put("formson_0666", qkList);
JSONObject data = new JSONObject();
- data.put("templateCode","formmain_0664");
- data.put("draft","0");
- data.put("data",formData);
+ data.put("templateCode", "formmain_0664");
+ data.put("draft", "0");
+ data.put("data", formData);
JSONObject param = new JSONObject();
- param.put("appName","collaboration");
- param.put("data",data);
+ param.put("appName", "collaboration");
+ param.put("data", data);
String paramStr = param.toString();
- logger.info("u9c预付单发起OA流程请求参数:{}",paramStr);
+ logger.info("u9c预付单发起OA流程请求参数:{}", paramStr);
String res = null;
Boolean flag = false;
try {
//1、获取token
JSONObject nouserToken = getToken(null, "800045", "8000450000");
- if(nouserToken.getBoolean("flag")){
+ if (nouserToken.getBoolean("flag")) {
//2、根据电话获取code
- JSONObject usercode = getUsercode(nouserToken.getString("token"),prepayment.getUserPhone(), "800045", "8000450005");
- if(usercode.getBoolean("flag")){
+ JSONObject usercode = getUsercode(nouserToken.getString("token"), prepayment.getUserPhone(), "800045", "8000450005");
+ if (usercode.getBoolean("flag")) {
//3、根据code,再次获取token
JSONObject token = getToken(usercode.getString("code"), "800045", "8000450000");
- if(token.getBoolean("flag")){
- res = invokeEsb(param, "800045", "8000450001",token.getString("token"));
+ if (token.getBoolean("flag")) {
+ res = invokeEsb(param, "800045", "8000450001", token.getString("token"));
JSONObject jsonObject = JSONObject.parseObject(res);
flag = jsonObject.getBoolean("flag");
- }else {
+ } else {
res = token.getString("msg");
}
- }else {
+ } else {
res = usercode.getString("msg");
}
- }else {
+ } else {
res = nouserToken.getString("msg");
}
- }catch (Exception e){
- logger.error("调用oa接口出错:{}",e);
+ } catch (Exception e) {
+ logger.error("调用oa接口出错:{}", e);
res = e.getMessage();
}
//保存日志
@@ -290,25 +291,25 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
taskLivingDetail.setRootAppNewData(paramStr);
taskLivingDetail.setNewTransmitInfo(res);
taskLivingDetail.setNewPushDate(new Date());
- saveLog(taskId,flag,taskLivingDetail);
- logger.info("u9c预付单发起OA流程返回结果:{}",res);
+ saveLog(taskId, flag, taskLivingDetail);
+ logger.info("u9c预付单发起OA流程返回结果:{}", res);
// 发送完成修改主表状态 已完成或发送失败 flag判断
- if(flag){
+ if (flag) {
PrepaymentEntity updatePrepayment = new PrepaymentEntity();
updatePrepayment.setDataSourceCode(datasourceCode);
updatePrepayment.setId(prepayment.getId());
updatePrepayment.setDataStatus("1");
updatePrepayment.setDataMsg("成功");
prepaymentService.updateStatus(updatePrepayment);
- }else {
+ } else {
PrepaymentEntity updatePrepayment = new PrepaymentEntity();
updatePrepayment.setDataSourceCode(datasourceCode);
updatePrepayment.setId(prepayment.getId());
updatePrepayment.setDataStatus("1");
- updatePrepayment.setDataMsg("失败:"+res);
+ updatePrepayment.setDataMsg("失败:" + res);
prepaymentService.updateStatus(updatePrepayment);
}
- }else {
+ } else {
// 没有明细不发送,修改数据状态,已完成,没有明细不发送
PrepaymentEntity updatePrepayment = new PrepaymentEntity();
updatePrepayment.setDataSourceCode(datasourceCode);
@@ -325,6 +326,7 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
/**
* u9c请购单发起OA请购单流程
+ *
* @param requestJson
* @return
*/
@@ -333,246 +335,254 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
//数据源编码
String datasourceCode = requestJson.getString("sourceCode");
//开始时间
- String startTime = DateUtil.format(requestJson.getDate("startTime"),"yyyy-MM-dd HH:mm:ss");
+ String startTime = DateUtil.format(requestJson.getDate("startTime"), "yyyy-MM-dd HH:mm:ss");
//结束时间
- String endTime = DateUtil.format(requestJson.getDate("endTime"),"yyyy-MM-dd HH:mm:ss");
+ String endTime = DateUtil.format(requestJson.getDate("endTime"), "yyyy-MM-dd HH:mm:ss");
//重试id
String taskId = requestJson.getString("integration_task_living_details_id");
//查询u9c请购单
RequisitionEntity requisitionEntity = new RequisitionEntity();
requisitionEntity.setDataSourceCode(datasourceCode);
- if (StrUtil.isEmpty(taskId)){
+ if (StrUtil.isEmpty(taskId)) {
//requisitionEntity.setStartTime(startTime);
//requisitionEntity.setEndTime(endTime);
- }else {
+ } else {
requisitionEntity.setId(taskId);
}
List requisitionList = requisitionService.queryList(requisitionEntity);
- if (CollectionUtils.isNotEmpty(requisitionList)){
- for (RequisitionEntity requisition : requisitionList) {
- //查询u9c请购单明细
- RequisitionDetailEntity requisitionDetail = new RequisitionDetailEntity();
- requisitionDetail.setPr(requisition.getId());
- requisitionDetail.setDataSourceCode(datasourceCode);
- List requisitionDetailList = requisitionDetailServiceImpl.queryDetails(requisitionDetail);
- if (CollectionUtils.isNotEmpty(requisitionDetailList)){
- //主表
- JSONObject formmain_0652 = new JSONObject();
- //单据类型
- formmain_0652.put("field0001",requisition.getpRDocTypeName());
- //发起人
- formmain_0652.put("field0002","");
- //发起部门
- formmain_0652.put("field0003","");
- //发起时间
- formmain_0652.put("field0004",DateUtil.now());
- //需求人员
- formmain_0652.put("field0005",requisition.getReqEmployeeName());
- //来源类型
- formmain_0652.put("field0006",requisition.getSourceTypeName());
- //单号
- formmain_0652.put("field0007",requisition.getDocNo());
- //需求部门
- formmain_0652.put("field0008",requisition.getReqDepartmentName());
- //来源单号
- formmain_0652.put("field0009",requisitionDetailList.get(0).getSrcDocNo());
- //日期
- formmain_0652.put("field0010",requisition.getBusinessDate());
- //项目
- formmain_0652.put("field0011",requisitionDetailList.get(0).getProjectName());
- //厂区
- formmain_0652.put("field0012",requisitionDetailList.get(0).getFactoryName());
- //状态
- formmain_0652.put("field0013",requisition.getStatusName());
- //请购数量合计
- formmain_0652.put("field0030","");
- //子表
- List formsonList = new LinkedList<>();
- for (RequisitionDetailEntity detail : requisitionDetailList) {
- JSONObject formson_0653 = new JSONObject();
- //行号
- formson_0653.put("field0014",detail.getDocLineNo());
- //需求分类
- formson_0653.put("field0015",detail.getDemandCode());
- //厂区明细
- formson_0653.put("field0016",detail.getFactoryName());
- //项目明细
- formson_0653.put("field0017",detail.getProjectName());
- //料号
- formson_0653.put("field0018",detail.getMaterialCode());
- //品名
- formson_0653.put("field0021",detail.getMaterialName());
- //规格
- formson_0653.put("field0022",detail.getSpecs());
- //请购数量
- formson_0653.put("field0023",detail.getReqQtyTU());
- //单位
- formson_0653.put("field0024",detail.getStoreUOM());
- //单据备注
- formson_0653.put("field0025",detail.getMemo());
- //需求交货日期
- formson_0653.put("field0026",detail.getRequiredDeliveryDate());
- //来源单号明细
- formson_0653.put("field0027",detail.getSrcDocNo());
- //库存可用量
- formson_0653.put("field0028",detail.getpRInvQty());
- //状态明细
- formson_0653.put("field0029",detail.getStatus());
- formsonList.add(formson_0653);
- }
- JSONObject formData = new JSONObject();
- formData.put("formmain_0673",formmain_0652);
- formData.put("formson_0674",formsonList);
- JSONObject data = new JSONObject();
- data.put("templateCode","formmain_0673");
- data.put("draft","0");
- data.put("data",formData);
- JSONObject param = new JSONObject();
- param.put("appName","collaboration");
- param.put("data",data);
- String paramStr = param.toString();
- logger.info("u9c请购单发起OA流程请求参数:{}",paramStr);
- String res = null;
- Boolean flag = false;
- try {
- //1、获取token
- JSONObject nouserToken = getToken(null, "800045", "8000450000");
- if(nouserToken.getBoolean("flag")){
- //2、根据电话获取code
- JSONObject usercode = getUsercode(nouserToken.getString("token"),requisition.getUserPhone(), "800045", "8000450005");
- if(usercode.getBoolean("flag")){
+ if (CollectionUtils.isNotEmpty(requisitionList)) {
+ //1、获取token
+
+ for (RequisitionEntity requisition : requisitionList) {
+ //查询u9c请购单明细
+ RequisitionDetailEntity requisitionDetail = new RequisitionDetailEntity();
+ requisitionDetail.setPr(requisition.getId());
+ requisitionDetail.setDataSourceCode(datasourceCode);
+ List requisitionDetailList = requisitionDetailServiceImpl.queryDetails(requisitionDetail);
+ if (CollectionUtils.isNotEmpty(requisitionDetailList)) {
+ //主表
+ JSONObject formmain_0652 = new JSONObject();
+ //单据类型
+ formmain_0652.put("field0001", requisition.getpRDocTypeName());
+ //需求人员
+ formmain_0652.put("field0005", requisition.getReqEmployeeName());
+ //单号
+ formmain_0652.put("field0007", requisition.getDocNo());
+ //需求部门
+ formmain_0652.put("field0008", requisition.getReqDepartmentName());
+ //日期
+ formmain_0652.put("field0010", requisition.getBusinessDate());
+ //厂区
+ formmain_0652.put("field0012", requisitionDetailList.get(0).getFactoryName());
+ //状态
+ formmain_0652.put("field0013", requisition.getStatusName());
+ String res = null;
+ Boolean flag = false;
+ JSONObject token = getToken(requisition.getSendPhone(), "800045", "8000450000");
+ //3、根据code,再次获取token
+ if (token.getBoolean("flag")) {
+ //发起人
+ formmain_0652.put("field0002", token.getString("name"));
+ //发起部门
+ formmain_0652.put("field0003", token.getString("bm"));
+ //发起时间
+ formmain_0652.put("field0004", DateUtil.now());
+ //来源类型 不要
+ //formmain_0652.put("field0006",requisition.getSourceTypeName());
+ //来源单号 不要
+ //formmain_0652.put("field0009",requisitionDetailList.get(0).getSrcDocNo());
+ ////项目 不要
+ //formmain_0652.put("field0011",requisitionDetailList.get(0).getProjectName());
+ //请购数量合计 不要
+ //formmain_0652.put("field0030","");
+ //子表
+ List formsonList = new LinkedList<>();
+ for (RequisitionDetailEntity detail : requisitionDetailList) {
+ JSONObject formson_0653 = new JSONObject();
+ //行号
+ formson_0653.put("field0014", detail.getDocLineNo());
+ //需求分类
+ formson_0653.put("field0015", detail.getDemandCode());
+ //厂区明细
+ formson_0653.put("field0016", detail.getFactoryName());
+ //项目明细
+ formson_0653.put("field0017", detail.getProjectName());
+ //料号
+ formson_0653.put("field0018", detail.getMaterialCode());
+ //品名
+ formson_0653.put("field0021", detail.getMaterialName());
+ //规格
+ formson_0653.put("field0022", detail.getSpecs());
+ //请购数量
+ formson_0653.put("field0023", detail.getReqQtyTU());
+ //单位
+ formson_0653.put("field0024", detail.getStoreUOM());
+ //单据备注
+ formson_0653.put("field0025", detail.getMemo());
+ ////需求交货日期
+ //formson_0653.put("field0026", detail.getRequiredDeliveryDate());
+ ////来源单号明细
+ //formson_0653.put("field0027", detail.getSrcDocNo());
+ ////库存可用量
+ //formson_0653.put("field0028", detail.getpRInvQty());
+ //状态明细
+ formson_0653.put("field0029", detail.getStatus());
+ formsonList.add(formson_0653);
+ }
+ JSONObject formData = new JSONObject();
+ formData.put("formmain_0673", formmain_0652);
+ formData.put("formson_0674", formsonList);
+ JSONObject data = new JSONObject();
+ data.put("templateCode", "formmain_0673");
+ data.put("draft", "0");
+ data.put("data", formData);
+ JSONObject param = new JSONObject();
+ param.put("appName", "collaboration");
+ param.put("data", data);
+ String paramStr = param.toString();
+ logger.info("u9c请购单发起OA流程请求参数:{}", paramStr);
+ try {
//3、根据code,再次获取token
- JSONObject token = getToken(usercode.getString("code"), "800045", "8000450000");
- if(token.getBoolean("flag")){
- res = invokeEsb(param, "800045", "8000450002",token.getString("token"));
+ if (token.getBoolean("flag")) {
+ res = invokeEsb(param, "800045", "8000450002", token.getString("token"));
JSONObject jsonObject = JSONObject.parseObject(res);
flag = jsonObject.getBoolean("flag");
- }else {
+ } else {
res = token.getString("msg");
}
- }else {
- res = usercode.getString("msg");
+ } catch (Exception e) {
+ logger.error("调用oa接口出错:{}", e);
+ res = e.getMessage();
}
- }else {
- res = nouserToken.getString("msg");
+ //保存日志
+ IntegrationTaskLivingDetailsEntity taskLivingDetail = new IntegrationTaskLivingDetailsEntity();
+ taskLivingDetail.setCreate_time(new Date());
+ taskLivingDetail.setModify_time(new Date());
+ taskLivingDetail.setRootAppPk(requisition.getId());
+ taskLivingDetail.setRootAppBill(requisition.getDocNo());
+ taskLivingDetail.setPluginId("U9CRequisitionPlugin");
+ taskLivingDetail.setRootAppNewData(paramStr);
+ taskLivingDetail.setNewTransmitInfo(res);
+ taskLivingDetail.setNewPushDate(new Date());
+ saveLog(taskId, flag, taskLivingDetail);
+ logger.info("u9c请购单发起OA流程返回结果:{}", res);
+ // 发送完成修改主表状态 已完成或发送失败 flag判断
+ } else {
+ res = token.getString("msg");
}
- }catch (Exception e){
- logger.error("调用oa接口出错:{}",e);
- res = e.getMessage();
- }
- //保存日志
- IntegrationTaskLivingDetailsEntity taskLivingDetail = new IntegrationTaskLivingDetailsEntity();
- taskLivingDetail.setCreate_time(new Date());
- taskLivingDetail.setModify_time(new Date());
- taskLivingDetail.setRootAppPk(requisition.getId());
- taskLivingDetail.setRootAppBill(requisition.getDocNo());
- taskLivingDetail.setPluginId("U9CRequisitionPlugin");
- taskLivingDetail.setRootAppNewData(paramStr);
- taskLivingDetail.setNewTransmitInfo(res);
- taskLivingDetail.setNewPushDate(new Date());
- saveLog(taskId,flag,taskLivingDetail);
- logger.info("u9c请购单发起OA流程返回结果:{}",res);
- // 发送完成修改主表状态 已完成或发送失败 flag判断
- if(flag){
+ if (flag) {
+ RequisitionEntity updateRequisition = new RequisitionEntity();
+ updateRequisition.setDataSourceCode(datasourceCode);
+ updateRequisition.setId(requisition.getId());
+ updateRequisition.setDataStatus("1");
+ updateRequisition.setDataMsg("成功");
+ requisitionService.updateStatus(updateRequisition);
+ } else {
+ RequisitionEntity updateRequisition = new RequisitionEntity();
+ updateRequisition.setDataSourceCode(datasourceCode);
+ updateRequisition.setId(requisition.getId());
+ updateRequisition.setDataStatus("2");
+ updateRequisition.setDataMsg("失败:" + res);
+ requisitionService.updateStatus(updateRequisition);
+ }
+ } else {
+ // 没有明细不发送,修改数据状态,已完成,没有明细不发送
RequisitionEntity updateRequisition = new RequisitionEntity();
updateRequisition.setDataSourceCode(datasourceCode);
updateRequisition.setId(requisition.getId());
updateRequisition.setDataStatus("1");
- updateRequisition.setDataMsg("成功");
- requisitionService.updateStatus(updateRequisition);
- }else {
- RequisitionEntity updateRequisition = new RequisitionEntity();
- updateRequisition.setDataSourceCode(datasourceCode);
- updateRequisition.setId(requisition.getId());
- updateRequisition.setDataStatus("2");
- updateRequisition.setDataMsg("失败:"+res);
+ updateRequisition.setDataMsg("成功,没有明细不发送");
requisitionService.updateStatus(updateRequisition);
}
- }else {
- // 没有明细不发送,修改数据状态,已完成,没有明细不发送
- RequisitionEntity updateRequisition = new RequisitionEntity();
- updateRequisition.setDataSourceCode(datasourceCode);
- updateRequisition.setId(requisition.getId());
- updateRequisition.setDataStatus("1");
- updateRequisition.setDataMsg("成功,没有明细不发送");
- requisitionService.updateStatus(updateRequisition);
}
- }
+
+
}
return BaseResult.getSuccessMessageEntity("德广信U9C请购单推送OA插件执行成功");
}
- private JSONObject getUsercode(String token, String phone, String appId,String apiCode) {
+ private JSONObject getUsercode(String token, String phone, String appId, String apiCode) {
JSONObject param = new JSONObject();
- param.put("phone",phone);
- param.put("token",token);
+ param.put("phone", phone);
+ param.put("token", token);
JSONObject returnData = new JSONObject();
String res = null;
String code = null;
+ String bm = null;
+ String name = null;
Boolean flag = false;
try {
- res = invokeEsb(param, appId, apiCode,null);
+ res = invokeEsb(param, appId, apiCode, null);
JSONObject jsonObject = JSONObject.parseObject(res);
flag = jsonObject.getBoolean("flag");
- if(flag){
+ if (flag) {
code = jsonObject.getJSONObject("attribute").getString("loginName");
+ bm = jsonObject.getJSONObject("attribute").getString("orgDepartmentName");
+ name = jsonObject.getJSONObject("attribute").getString("name");
}
- }catch (Exception e){
- logger.error("调用oa接口出错:{}",e);
+ } catch (Exception e) {
+ logger.error("调用oa接口出错:{}", e);
res = e.getMessage();
}
- if(flag){
- returnData.put("flag","true");
- returnData.put("code",code);
- }else {
- returnData.put("flag","false");
- returnData.put("msg",res);
+ if (flag) {
+ returnData.put("flag", "true");
+ returnData.put("code", code);
+ returnData.put("bm", bm);
+ returnData.put("name", name);
+ } else {
+ returnData.put("flag", "false");
+ returnData.put("msg", res);
}
return returnData;
}
/**
- * @Author lvleigang
- * @Description 获取token
- * @Date 11:53 上午 2024/10/28
* @param code
* @param appId
* @param apiCode
* @return com.alibaba.fastjson.JSONObject
+ * @Author lvleigang
+ * @Description 获取token
+ * @Date 11:53 上午 2024/10/28
**/
- private JSONObject getToken(String code,String appId,String apiCode) {
+ private JSONObject getToken(String code, String appId, String apiCode) {
JSONObject param = new JSONObject();
- param.put("userName","hzyaRest");
- param.put("password","3ca9a8d7-43df-4101-8de2-8bb113cb9145");
- if(code != null){
- param.put("loginName",code);
+ param.put("userName", "hzyaRest");
+ param.put("password", "3ca9a8d7-43df-4101-8de2-8bb113cb9145");
+ if (code != null) {
+ param.put("loginName", code);
}
JSONObject returnData = new JSONObject();
String res = null;
String token = null;
Boolean flag = false;
-
+ String bm = null;
+ String name = null;
try {
- res = invokeEsb(param, appId, apiCode,null);
+ res = invokeEsb(param, appId, apiCode, null);
JSONObject jsonObject = JSONObject.parseObject(res);
flag = jsonObject.getBoolean("flag");
- if(flag){
+ if (flag) {
token = jsonObject.getJSONObject("attribute").getString("id");
+ bm = jsonObject.getJSONObject("attribute").getJSONObject("bindingUser").getString("orgDepartmentName");
+ name = jsonObject.getJSONObject("attribute").getJSONObject("bindingUser").getString("name");
}
- }catch (Exception e){
- logger.error("调用oa接口出错:{}",e);
+ } catch (Exception e) {
+ logger.error("调用oa接口出错:{}", e);
res = e.getMessage();
}
- if(flag){
- returnData.put("flag","true");
- returnData.put("token",token);
- }else {
- returnData.put("flag","false");
- returnData.put("msg",res);
+ if (flag) {
+ returnData.put("flag", "true");
+ returnData.put("token", token);
+ returnData.put("bm", bm);
+ returnData.put("name", name);
+ } else {
+ returnData.put("flag", "false");
+ returnData.put("msg", res);
}
return returnData;
}
@@ -588,56 +598,56 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
public void saveLog(String integration_task_living_details_id, Boolean flag, IntegrationTaskLivingDetailsEntity taskLivingDetail) {
try {
//判断,成功调用这个方法
- if (StrUtil.isEmpty(integration_task_living_details_id)){
- if (flag){
+ if (StrUtil.isEmpty(integration_task_living_details_id)) {
+ if (flag) {
taskLivingDetailsService.saveLogToSuccess(taskLivingDetail);
- }else {
+ } else {
//失败 调用这个方法
taskLivingDetailsService.saveLogToFail(taskLivingDetail);
}
- }else {
+ } else {
taskLivingDetail.setId(integration_task_living_details_id);
- if (flag){
+ if (flag) {
//如果是重试 成功调这个方法
taskLivingDetailsService.saveLogFailToSuccess(taskLivingDetail);
- }else {
+ } else {
//如果是重试 失败调这个方法
taskLivingDetailsService.updateLogFailToSuccess(taskLivingDetail);
}
}
- }catch (Exception e){
- logger.error("保存日志出错:{}",e);
+ } catch (Exception e) {
+ logger.error("保存日志出错:{}", e);
}
}
//调用注册好的esb接口
- private String invokeEsb(JSONObject jsonObject,String appId,String apiCode,String token){
+ private String invokeEsb(JSONObject jsonObject, String appId, String apiCode, String token) {
String param = jsonObject.toString();
- logger.info("调用:{},请求参数:{}",apiCode,param);
+ logger.info("调用:{},请求参数:{}", apiCode, param);
String result = null;
- if(token != null){
+ if (token != null) {
result = HttpRequest.post(url)
- .header("token",token)//token
- .header("appId",appId)//目标应用
- .header("apiCode",apiCode)//目标api
- .header("publicKey","ZJYAh1QkjBK/pIrl8+vYvw190Jg/Oh84xuvDYe8sPbEtO65Ce7eDIk+3zDUT+v578prj")//调用方key
- .header("secretKey","oS2ELoTO92eVwuu0wsFvvHivg3rt8iyJqZTNDxa3iiZHzw7KU9LjmJqJDi2kQNo5j3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//调用方密钥
+ .header("token", token)//token
+ .header("appId", appId)//目标应用
+ .header("apiCode", apiCode)//目标api
+ .header("publicKey", "ZJYAh1QkjBK/pIrl8+vYvw190Jg/Oh84xuvDYe8sPbEtO65Ce7eDIk+3zDUT+v578prj")//调用方key
+ .header("secretKey", "oS2ELoTO92eVwuu0wsFvvHivg3rt8iyJqZTNDxa3iiZHzw7KU9LjmJqJDi2kQNo5j3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//调用方密钥
.body(param)
.timeout(30000)
.execute()
.body();
- }else {
+ } else {
result = HttpRequest.post(url)
- .header("appId",appId)//目标应用
- .header("apiCode",apiCode)//目标api
- .header("publicKey","ZJYAh1QkjBK/pIrl8+vYvw190Jg/Oh84xuvDYe8sPbEtO65Ce7eDIk+3zDUT+v578prj")//调用方key
- .header("secretKey","oS2ELoTO92eVwuu0wsFvvHivg3rt8iyJqZTNDxa3iiZHzw7KU9LjmJqJDi2kQNo5j3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//调用方密钥
+ .header("appId", appId)//目标应用
+ .header("apiCode", apiCode)//目标api
+ .header("publicKey", "ZJYAh1QkjBK/pIrl8+vYvw190Jg/Oh84xuvDYe8sPbEtO65Ce7eDIk+3zDUT+v578prj")//调用方key
+ .header("secretKey", "oS2ELoTO92eVwuu0wsFvvHivg3rt8iyJqZTNDxa3iiZHzw7KU9LjmJqJDi2kQNo5j3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//调用方密钥
.body(param)
.timeout(30000)
.execute()
.body();
}
- logger.info("调用:{},返回参数:{}",apiCode,result);
+ logger.info("调用:{},返回参数:{}", apiCode, result);
return result;
}
@@ -646,7 +656,7 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
public SysExtensionApiEntity setQueryUrl(SysExtensionApiEntity sysExtensionApiEntity) {
String bodys = sysExtensionApiEntity.getBodys();
JSONObject jsonObject = JSON.parseObject(bodys);
- String url = jsonObject.getString("phone")+"?token="+jsonObject.getString("token");
+ String url = jsonObject.getString("phone") + "?token=" + jsonObject.getString("token");
sysExtensionApiEntity.setAddQuerys(url);
return sysExtensionApiEntity;
}