预付款单

This commit is contained in:
lvleigang 2024-10-30 09:24:49 +08:00
parent 93f351f17c
commit db93567ca4
2 changed files with 199 additions and 104 deletions

View File

@ -63,8 +63,8 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
prepaymentEntity.setDocNo("RE-1563"); prepaymentEntity.setDocNo("RE-1563");
prepaymentEntity.setDataSourceCode(datasourceCode); prepaymentEntity.setDataSourceCode(datasourceCode);
if (StrUtil.isEmpty(taskId)){ if (StrUtil.isEmpty(taskId)){
prepaymentEntity.setStartTime(startTime); //prepaymentEntity.setStartTime(startTime);
prepaymentEntity.setEndTime(endTime); //prepaymentEntity.setEndTime(endTime);
}else { }else {
prepaymentEntity.setId(taskId); prepaymentEntity.setId(taskId);
} }
@ -83,170 +83,201 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
List<PrepaymentDetailEntity> prepaymentDetailList = prepaymentDetailServiceImpl.queryDetails(prepaymentDetailEntity); List<PrepaymentDetailEntity> prepaymentDetailList = prepaymentDetailServiceImpl.queryDetails(prepaymentDetailEntity);
if (CollectionUtils.isNotEmpty(prepaymentDetailList) && CollectionUtils.isNotEmpty(prepaymentSuppList)){ if (CollectionUtils.isNotEmpty(prepaymentDetailList) && CollectionUtils.isNotEmpty(prepaymentSuppList)){
//主表 //主表
JSONObject formmain_0668 = new JSONObject(); JSONObject zb = new JSONObject();
//单据类型 //单据类型
formmain_0668.put("field0001",prepayment.getDocumentTypeName()); zb.put("field0001",prepayment.getDocumentTypeName());
//币种 //币种
formmain_0668.put("field0002",prepayment.getCurrencyName()); zb.put("field0002",prepayment.getCurrencyName());
//单号 //单号
formmain_0668.put("field0003",prepayment.getDocNo()); zb.put("field0003",prepayment.getDocNo());
//业务员 //业务员
formmain_0668.put("field0004",prepayment.getTransactorName()); zb.put("field0004",prepayment.getTransactorName());
//申请日期 //申请日期
formmain_0668.put("field0005",prepayment.getPayRFDate()); zb.put("field0005",prepayment.getPayRFDate());
//部门 //部门
formmain_0668.put("field0006",prepayment.getDeptName()); zb.put("field0006",prepayment.getDeptName());
//预计付款日 //预计付款日
formmain_0668.put("field0007",prepayment.getExpectPayDate()); zb.put("field0007",prepayment.getExpectPayDate());
//付款方式 //付款方式
formmain_0668.put("field0008",prepayment.getPayModeCode()); zb.put("field0008",prepayment.getPayModeCode());
//请款对象 //请款对象
formmain_0668.put("field0009",prepayment.getRequestObjTypeCode()); zb.put("field0009",prepayment.getRequestObjTypeCode());
//状态 //状态
formmain_0668.put("field0010",prepayment.getDocStatusName()); zb.put("field0010",prepayment.getDocStatusName());
//请款用途 //请款用途
formmain_0668.put("field0011",prepaymentDetailList.get(0).getReqFundUseName()); zb.put("field0011",prepaymentDetailList.get(0).getReqFundUseName());
//出纳确认 //出纳确认
formmain_0668.put("field0012",prepayment.getCashierConfirmed()); zb.put("field0012",prepayment.getCashierConfirmed());
//折扣前请款金额合计 //折扣前请款金额合计
formmain_0668.put("field0044",""); zb.put("field0044","");
//请款对应折扣合计 //请款对应折扣合计
formmain_0668.put("field0045",""); zb.put("field0045","");
//折扣后请款金额合计 //折扣后请款金额合计
formmain_0668.put("field0046",""); zb.put("field0046","");
//付款本币金额合计 //付款本币金额合计
formmain_0668.put("field0047",""); zb.put("field0047","");
//请款金额合计 //请款金额合计
formmain_0668.put("field0053",""); zb.put("field0053","");
//请款数量合计 //请款数量合计
formmain_0668.put("field0061",""); zb.put("field0061","");
//请款金额和明细合计 //请款金额和明细合计
formmain_0668.put("field0063",""); zb.put("field0063","");
//单据编号 //单据编号
formmain_0668.put("field0070",""); zb.put("field0070","");
//发起人 //发起人
formmain_0668.put("field0071",""); zb.put("field0071","");
//发起部门 //发起部门
formmain_0668.put("field0072",""); zb.put("field0072","");
//发起时间 //发起时间
formmain_0668.put("field0073",""); zb.put("field0073","");
//子表 //子表
List<JSONObject> formson69List = new LinkedList<>(); List<JSONObject> gysList = new LinkedList<>();//供应商
List<JSONObject> formson70List = new LinkedList<>(); List<JSONObject> qkList = new LinkedList<>();//请款
for (PrepaymentSuppEntity detail : prepaymentSuppList){ for (PrepaymentSuppEntity detail : prepaymentSuppList){
JSONObject formson_0669 = new JSONObject(); JSONObject gys = new JSONObject();
//行号 //行号
formson_0669.put("field0013",detail.getLineNum()); gys.put("field0013",detail.getLineNum());
//供应商 //供应商
formson_0669.put("field0014",detail.getSuppName()); gys.put("field0014",detail.getSuppName());
//选单 //选单
formson_0669.put("field0015","");//有问题不知道字段 gys.put("field0015","");//有问题不知道字段
//折扣前请款金额 //折扣前请款金额
formson_0669.put("field0016",detail.getRfTotalMoney()); gys.put("field0016",detail.getRfTotalMoney());
//请款对应折扣 //请款对应折扣
formson_0669.put("field0017",detail.getRfDisCount()); gys.put("field0017",detail.getRfDisCount());
//折扣后请款金额 //折扣后请款金额
formson_0669.put("field0018",detail.getRfaMoney()); gys.put("field0018",detail.getRfaMoney());
//付款本币金额 //付款本币金额
formson_0669.put("field0019",detail.getAcmPayFCMoney()); gys.put("field0019",detail.getAcmPayFCMoney());
//结算方式 //结算方式
formson_0669.put("field0020",detail.getPayType()); gys.put("field0020",detail.getPayType());
//收款银行帐号 //收款银行帐号
formson_0669.put("field0021",detail.getOppAccBkAccount()); gys.put("field0021",detail.getOppAccBkAccount());
//收款账号名称 //收款账号名称
formson_0669.put("field0022",detail.getRecBkAccName()); gys.put("field0022",detail.getRecBkAccName());
//开户银行 //开户银行
formson_0669.put("field0023",detail.getOppAccBk()); gys.put("field0023",detail.getOppAccBk());
//收支项目 //收支项目
formson_0669.put("field0024",detail.getIncomeExpendItemName()); gys.put("field0024",detail.getIncomeExpendItemName());
//部门-供应商 //部门-供应商
formson_0669.put("field0025",detail.getDeptName()); gys.put("field0025",detail.getDeptName());
//业务员-供应商 //业务员-供应商
formson_0669.put("field0026",detail.getTransactorName()); gys.put("field0026",detail.getTransactorName());
//项目-供应商 //项目-供应商
formson_0669.put("field0027",""); gys.put("field0027","");
//预付款类型 //预付款类型
formson_0669.put("field0051",""); gys.put("field0051","");
//请款金额 //请款金额
formson_0669.put("field0052",""); gys.put("field0052","");
//料品 //料品
formson_0669.put("field0054",detail.getItemName()); gys.put("field0054",detail.getItemName());
formson69List.add(formson_0669); gysList.add(gys);
} }
for (PrepaymentDetailEntity detail : prepaymentDetailList) { for (PrepaymentDetailEntity detail : prepaymentDetailList) {
JSONObject formson_0070 = new JSONObject(); JSONObject qk = new JSONObject();
//单据类型明细 //单据类型明细
formson_0070.put("field0028",detail.getDocType()); qk.put("field0028",detail.getDocType());
//应付单 //应付单
formson_0070.put("field0029",detail.getDocCode()); qk.put("field0029",detail.getDocCode());
//折扣前可请款金额 //折扣前可请款金额
formson_0070.put("field0030",detail.getCanDisposeMoney()); qk.put("field0030",detail.getCanDisposeMoney());
//可享受折扣 //可享受折扣
formson_0070.put("field0031",detail.getRfDisCount()); qk.put("field0031",detail.getRfDisCount());
//折扣前请款金额明细 //折扣前请款金额明细
formson_0070.put("field0032",detail.getRfTotalMoney()); qk.put("field0032",detail.getRfTotalMoney());
//请款享受折扣 //请款享受折扣
formson_0070.put("field0033",detail.getRfDisCount()); qk.put("field0033",detail.getRfDisCount());
//折扣后请款金额明细 //折扣后请款金额明细
formson_0070.put("field0034",detail.getRaTotalMoney()); qk.put("field0034",detail.getRaTotalMoney());
//累计确认对应金额 //累计确认对应金额
formson_0070.put("field0035",detail.getCfmMoney()); qk.put("field0035",detail.getCfmMoney());
//发票号 //发票号
formson_0070.put("field0036",detail.getInvoiceNum()); qk.put("field0036",detail.getInvoiceNum());
//发票日期 //发票日期
formson_0070.put("field0037",detail.getInvoiceDate()); qk.put("field0037",detail.getInvoiceDate());
//立账日期 //立账日期
formson_0070.put("field0038",detail.getAccrueDate()); qk.put("field0038",detail.getAccrueDate());
//记账日期 //记账日期
formson_0070.put("field0039",detail.getPostPeriod()); qk.put("field0039",detail.getPostPeriod());
//到期日 //到期日
formson_0070.put("field0040",detail.getMaturity()); qk.put("field0040",detail.getMaturity());
//付款条件 //付款条件
formson_0070.put("field0041",detail.getPayTermName()); qk.put("field0041",detail.getPayTermName());
//部门明细 //部门明细
formson_0070.put("field0042",detail.getDetpName()); qk.put("field0042",detail.getDetpName());
//业务员明细 //业务员明细
formson_0070.put("field0043",detail.getTransactorName()); qk.put("field0043",detail.getTransactorName());
//预付款类型明细 //预付款类型明细
formson_0070.put("field0055","");//有问题不知道字段 qk.put("field0055","");//有问题不知道字段
//单号明细 //单号明细
formson_0070.put("field0056","");//有问题不知道字段 qk.put("field0056","");//有问题不知道字段
//单价 //单价
formson_0070.put("field0057","");//有问题不知道字段 qk.put("field0057","");//有问题不知道字段
//数量 //数量
formson_0070.put("field0058","");//有问题不知道字段 qk.put("field0058","");//有问题不知道字段
//单位 //单位
formson_0070.put("field0059","");//有问题不知道字段 qk.put("field0059","");//有问题不知道字段
//请款数量 //请款数量
formson_0070.put("field0060","");//有问题不知道字段 qk.put("field0060","");//有问题不知道字段
//请款金额明细 //请款金额明细
formson_0070.put("field0062","");//有问题不知道字段 qk.put("field0062","");//有问题不知道字段
//费用 //费用
formson_0070.put("field0064","");//有问题不知道字段 qk.put("field0064","");//有问题不知道字段
//料号 //料号
formson_0070.put("field0065","");//有问题不知道字段 qk.put("field0065","");//有问题不知道字段
//料品明细 //料品明细
formson_0070.put("field0066","");//有问题不知道字段 qk.put("field0066","");//有问题不知道字段
//项目 //项目
formson_0070.put("field0067",detail.getProjectName()); qk.put("field0067",detail.getProjectName());
//立账供应商 //立账供应商
formson_0070.put("field0068",detail.getSuppName()); qk.put("field0068",detail.getSuppName());
//单据状态 //单据状态
formson_0070.put("field0069",prepayment.getDocumentTypeName()); qk.put("field0069",prepayment.getDocumentTypeName());
formson70List.add(formson_0070); qkList.add(qk);
} }
JSONObject formData = new JSONObject(new LinkedHashMap<>()); JSONObject formData = new JSONObject(new LinkedHashMap<>());
formData.put("formmain_0668",formmain_0668); formData.put("formmain_0664",zb);//主表
formData.put("formson_0669",formson69List); formData.put("formson_0665",gysList);
formData.put("formson_0670",formson70List); formData.put("formson_0666",qkList);
JSONObject data = new JSONObject(); JSONObject data = new JSONObject();
data.put("templateCode",""); data.put("templateCode","formmain_0664");
data.put("draft","0"); data.put("draft","0");
data.put("data",formData); data.put("data",formData);
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("appName","collaboration"); param.put("appName","collaboration");
param.put("data",data); param.put("data",data);
String s = invokeEsb(param, "800045", "8000450001"); String paramStr = param.toString();
logger.info("u9c预付单发起OA流程请求参数:{}",paramStr);
String res = null;
Boolean flag = false;
try {
JSONObject token = getToken("admin", "800045", "8000450000");
if(token.getBoolean("flag")){
res = invokeEsb(param, "800045", "8000450001",token.getString("token"));
JSONObject jsonObject = JSONObject.parseObject(res);
flag = jsonObject.getBoolean("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(prepayment.getId());
taskLivingDetail.setRootAppBill(prepayment.getDocNo());
taskLivingDetail.setPluginId("U9CPrepaymentPlugin");
taskLivingDetail.setRootAppNewData(paramStr);
taskLivingDetail.setNewTransmitInfo(res);
taskLivingDetail.setNewPushDate(new Date());
saveLog(taskId,flag,taskLivingDetail);
logger.info("u9c预付单发起OA流程返回结果:{}",res);
//todo 发送完成修改主表状态 已完成或发送失败 flag判断
}else {
//todo 没有明细不发送修改数据状态已完成没有明细不发送
} }
} }
} }
@ -274,8 +305,8 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
RequisitionEntity requisitionEntity = new RequisitionEntity(); RequisitionEntity requisitionEntity = new RequisitionEntity();
requisitionEntity.setDataSourceCode(datasourceCode); requisitionEntity.setDataSourceCode(datasourceCode);
if (StrUtil.isEmpty(taskId)){ if (StrUtil.isEmpty(taskId)){
requisitionEntity.setStartTime(startTime); //requisitionEntity.setStartTime(startTime);
requisitionEntity.setEndTime(endTime); //requisitionEntity.setEndTime(endTime);
}else { }else {
requisitionEntity.setId(taskId); requisitionEntity.setId(taskId);
} }
@ -353,10 +384,10 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
formsonList.add(formson_0653); formsonList.add(formson_0653);
} }
JSONObject formData = new JSONObject(); JSONObject formData = new JSONObject();
formData.put("formmain_0652",formmain_0652); formData.put("formmain_0673",formmain_0652);
formData.put("formson_0653",formsonList); formData.put("formson_0674",formsonList);
JSONObject data = new JSONObject(); JSONObject data = new JSONObject();
data.put("templateCode",""); data.put("templateCode","formmain_0673");
data.put("draft","0"); data.put("draft","0");
data.put("data",formData); data.put("data",formData);
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
@ -367,9 +398,14 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
String res = null; String res = null;
Boolean flag = false; Boolean flag = false;
try { try {
res = invokeEsb(param, "800045", "8000450002"); JSONObject token = getToken("admin", "800045", "8000450000");
if(token.getBoolean("flag")){
res = invokeEsb(param, "800045", "8000450002",token.getString("token"));
JSONObject jsonObject = JSONObject.parseObject(res); JSONObject jsonObject = JSONObject.parseObject(res);
flag = jsonObject.getBoolean("flag"); flag = jsonObject.getBoolean("flag");
}else {
res = token.getString("msg");
}
}catch (Exception e){ }catch (Exception e){
logger.error("调用oa接口出错:{}",e); logger.error("调用oa接口出错:{}",e);
res = e.getMessage(); res = e.getMessage();
@ -380,18 +416,63 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
taskLivingDetail.setModify_time(new Date()); taskLivingDetail.setModify_time(new Date());
taskLivingDetail.setRootAppPk(requisition.getId()); taskLivingDetail.setRootAppPk(requisition.getId());
taskLivingDetail.setRootAppBill(requisition.getDocNo()); taskLivingDetail.setRootAppBill(requisition.getDocNo());
taskLivingDetail.setPluginId("U9CPrepaymentPlugin"); taskLivingDetail.setPluginId("U9CRequisitionPlugin");
taskLivingDetail.setRootAppNewData(paramStr); taskLivingDetail.setRootAppNewData(paramStr);
taskLivingDetail.setNewTransmitInfo(res); taskLivingDetail.setNewTransmitInfo(res);
taskLivingDetail.setNewPushDate(new Date()); taskLivingDetail.setNewPushDate(new Date());
saveLog(taskId,flag,taskLivingDetail); saveLog(taskId,flag,taskLivingDetail);
logger.info("u9c请购单发起OA流程返回结果:{}",res); logger.info("u9c请购单发起OA流程返回结果:{}",res);
//todo 发送完成修改主表状态 已完成或发送失败 flag判断
}else {
//todo 没有明细不发送修改数据状态已完成没有明细不发送
} }
} }
} }
return BaseResult.getSuccessMessageEntity("德广信U9C请购单推送OA插件执行成功"); return BaseResult.getSuccessMessageEntity("德广信U9C请购单推送OA插件执行成功");
} }
/**
* @Author lvleigang
* @Description 获取token
* @Date 11:53 上午 2024/10/28
* @param code
* @param appId
* @param apiCode
* @return com.alibaba.fastjson.JSONObject
**/
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");
param.put("loginName",code);
JSONObject returnData = new JSONObject();
String res = null;
String token = null;
Boolean flag = false;
try {
res = invokeEsb(param, "800045", "8000450000",null);
JSONObject jsonObject = JSONObject.parseObject(res);
flag = jsonObject.getBoolean("flag");
if(flag){
token = jsonObject.getJSONObject("attribute").getString("id");
}
}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);
}
return returnData;
}
/** /**
* 保存日志 * 保存日志
@ -427,10 +508,13 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
} }
//调用注册好的esb接口 //调用注册好的esb接口
private String invokeEsb(JSONObject jsonObject,String appId,String apiCode){ private String invokeEsb(JSONObject jsonObject,String appId,String apiCode,String token){
String param = jsonObject.toString(); String param = jsonObject.toString();
logger.info("调用:{},请求参数:{}",apiCode,param); logger.info("调用:{},请求参数:{}",apiCode,param);
String result = HttpRequest.post(url) String result = null;
if(token != null){
result = HttpRequest.post(url)
.header("token",token)//token
.header("appId",appId)//目标应用 .header("appId",appId)//目标应用
.header("apiCode",apiCode)//目标api .header("apiCode",apiCode)//目标api
.header("publicKey","ZJYAh1QkjBK/pIrl8+vYvw190Jg/Oh84xuvDYe8sPbEtO65Ce7eDIk+3zDUT+v578prj")//调用方key .header("publicKey","ZJYAh1QkjBK/pIrl8+vYvw190Jg/Oh84xuvDYe8sPbEtO65Ce7eDIk+3zDUT+v578prj")//调用方key
@ -439,6 +523,17 @@ public class U9CPluginServiceImpl implements IU9CPluginService {
.timeout(30000) .timeout(30000)
.execute() .execute()
.body(); .body();
}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=")//调用方密钥
.body(param)
.timeout(30000)
.execute()
.body();
}
logger.info("调用:{},返回参数:{}",apiCode,result); logger.info("调用:{},返回参数:{}",apiCode,result);
return result; return result;
} }

View File

@ -45,7 +45,7 @@ savefile:
tomcatpath: /Users/apple/Desktop/log/local tomcatpath: /Users/apple/Desktop/log/local
pluginpath: /Users/apple/Desktop/log/local pluginpath: /Users/apple/Desktop/log/local
zt: zt:
url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface url: http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface
cbs8: cbs8:
appId: 1P4AGrpz appId: 1P4AGrpz
appSecret: 2c2369ae5dc04382844bbe3a5abf39e1bea9cd3a appSecret: 2c2369ae5dc04382844bbe3a5abf39e1bea9cd3a