Merge remote-tracking branch 'origin/dongj' into dongj
This commit is contained in:
commit
f238847fc4
|
@ -42,4 +42,18 @@ public interface INingboBankPluginService {
|
|||
* @param apiCode
|
||||
*/
|
||||
void queryResult(List<HashMap<String, Object>> hashMaps,String apiCode);
|
||||
|
||||
/**
|
||||
* 查询OA附件,并上传到宁波银行
|
||||
* @param oaId oa主键id
|
||||
* @return 宁波银行附件上传编码
|
||||
*/
|
||||
String fileUpload(String oaId);
|
||||
|
||||
/**
|
||||
* 更新u8c单据状态
|
||||
* @param billCode oa单据编号
|
||||
* @param dwbm 公司编码
|
||||
*/
|
||||
void updateU8CStatus(String billCode,String dwbm);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import cn.hutool.core.map.MapBuilder;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.ningboBankTreasury.dto.req.SingleTransferReq;
|
||||
import com.hzya.frame.ningboBankTreasury.dto.req.TTRemitReq;
|
||||
|
@ -13,14 +14,17 @@ import com.hzya.frame.ningboBankTreasury.dto.res.AccTransactionRes;
|
|||
import com.hzya.frame.ningboBankTreasury.enums.CurrencyEnum;
|
||||
import com.hzya.frame.ningboBankTreasury.enums.PayStatusEnum;
|
||||
import com.hzya.frame.ningboBankTreasury.enums.TTPayStatusEnum;
|
||||
import com.hzya.frame.ningboBankTreasury.service.INingboBankTreasuryService;
|
||||
import com.hzya.frame.plugin.a8bill.dao.IPayBillPluginInitializerDao;
|
||||
import com.hzya.frame.plugin.a8bill.entity.PayBillEntity;
|
||||
import com.hzya.frame.plugin.a8bill.service.INingboBankPluginService;
|
||||
import com.hzya.frame.seeyon.dongj.entity.Formmain0044Entity;
|
||||
import com.hzya.frame.seeyon.dongj.service.IFormmain0044Service;
|
||||
import com.hzya.frame.seeyon.util.RestUtil;
|
||||
import com.hzya.frame.stringutil.StringUtil;
|
||||
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
|
||||
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -28,7 +32,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -44,7 +51,10 @@ private IFormmain0044Service formmain0044Service;
|
|||
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
|
||||
@Autowired
|
||||
private IPayBillPluginInitializerDao payBillDao;
|
||||
|
||||
@Autowired
|
||||
private RestUtil restUtil;
|
||||
@Autowired
|
||||
private INingboBankTreasuryService ningboBankTreasuryService;
|
||||
@Value("${OA.data_source_code}")
|
||||
private String oa_data_source_code;
|
||||
|
||||
|
@ -69,13 +79,17 @@ private IFormmain0044Service formmain0044Service;
|
|||
main.put(key, hashMap.get(key));
|
||||
}
|
||||
String param = "";
|
||||
//单笔转账
|
||||
if ("8000360000".equals(apiCode)){
|
||||
SingleTransferReq singleTransferReq = JSONObject.parseObject(main.toString(), SingleTransferReq.class);
|
||||
param = JSONObject.toJSONString(singleTransferReq);
|
||||
}else if("8000360003".equals(apiCode)){
|
||||
//TT汇款
|
||||
TTRemitReq ttRemitReq = JSONObject.parseObject(main.toString(), TTRemitReq.class);
|
||||
if ("01".equals(ttRemitReq.getPayMode()) || "1".equals(ttRemitReq.getPayMode())){
|
||||
ttRemitReq.setFileUploadCodes(Convert.toList(String.class,"0a736c17-e79f-48be-b3cd-710585165d55"));
|
||||
//货到付款时,要上传附件
|
||||
if ("01".equals(ttRemitReq.getPayMode())){
|
||||
String fileCode = fileUpload(main.getString("id"));
|
||||
ttRemitReq.setFileUploadCodes(Convert.toList(String.class,fileCode));
|
||||
}
|
||||
param = JSONObject.toJSONString(ttRemitReq);
|
||||
}
|
||||
|
@ -143,6 +157,8 @@ private IFormmain0044Service formmain0044Service;
|
|||
//修改推送状态,防止重复推送
|
||||
oaBillEntity.setSql(str);
|
||||
payBillDao.updateStateForId(str,oaBillEntity);
|
||||
//更新u8c付款单状态
|
||||
updateU8CStatus(main.getString("serialNo"),main.getString("dwbm"));
|
||||
}catch (Exception e){
|
||||
logger.info("宁波银行付款接口调用出错:{}",e);
|
||||
}
|
||||
|
@ -311,6 +327,84 @@ private IFormmain0044Service formmain0044Service;
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询OA附件,并上传到宁波银行
|
||||
*
|
||||
* @param oaId oa主键id
|
||||
* @return 宁波银行附件上传编码
|
||||
*/
|
||||
@Override
|
||||
public String fileUpload(String oaId) {
|
||||
if (StrUtil.isNotEmpty(oaId)){
|
||||
try {
|
||||
//查询oa单据关联附件
|
||||
PayBillEntity oaBillEntity = new PayBillEntity();
|
||||
oaBillEntity.setDataSourceCode(oa_data_source_code);
|
||||
String sql = " SELECT\n" +
|
||||
" formmain_0058.id,\n" +
|
||||
" formmain_0058.field0024 ,\n" +
|
||||
" CTP_ATTACHMENT.FILE_URL,\n" +
|
||||
" CTP_ATTACHMENT.FILENAME\n" +
|
||||
"FROM\n" +
|
||||
" formmain_0058 \n" +
|
||||
" LEFT JOIN CTP_ATTACHMENT ON CTP_ATTACHMENT.SUB_REFERENCE = formmain_0058.field0024 \n" +
|
||||
"WHERE\n" +
|
||||
" formmain_0058.field0061 = '境外'\n" +
|
||||
" and formmain_0058.id = '" + oaId+"'";
|
||||
oaBillEntity.setSql(sql);
|
||||
List<HashMap<String, Object>> dataList = payBillDao.getOaBillData(sql, oaBillEntity);
|
||||
if (CollectionUtils.isNotEmpty(dataList)){
|
||||
HashMap<String, Object> oaDataMap = dataList.get(0);
|
||||
String fileUrl = String.valueOf(oaDataMap.get("FILE_URL"));
|
||||
String fileName = String.valueOf(oaDataMap.get("FILENAME"));
|
||||
if (StrUtil.isNotEmpty(fileUrl)){
|
||||
//下载OA附件
|
||||
byte[] bytes = restUtil.downloadFileBytes("oa1", "8000340000", fileUrl, fileName);
|
||||
//上传到宁波银行
|
||||
logger.info("上传附件到宁波银行:{},{}",fileUrl,fileName);
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("fileName",fileName);
|
||||
param.put("bytes",bytes);
|
||||
param.put("channelNo","open-filegateway");
|
||||
String res = executeEsb(param.toString(), "8000360008");
|
||||
JsonResultEntity jsonResultEntity = JSONObject.parseObject(res, JsonResultEntity.class);
|
||||
if (null != jsonResultEntity && jsonResultEntity.isFlag()){
|
||||
JSONObject attribute = JSONObject.parseObject(String.valueOf(jsonResultEntity.getAttribute()));
|
||||
JSONObject data = attribute.getJSONObject("Data");
|
||||
String fileCode = data.getString("data");
|
||||
return fileCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.error("上传附件到宁波银行出错:{}",e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新u8c单据状态
|
||||
* @param billCode oa单据编号
|
||||
* @param dwbm 公司编码
|
||||
*/
|
||||
@Override
|
||||
public void updateU8CStatus(String billCode,String dwbm) {
|
||||
if (StrUtil.isNotEmpty(billCode)){
|
||||
JSONObject billObj = new JSONObject();
|
||||
billObj.put("djbh",billCode);
|
||||
billObj.put("dwbm",dwbm);
|
||||
billObj.put("operatedate",DateUtil.today());
|
||||
billObj.put("operatorid","yonyou02");
|
||||
billObj.put("result","0");
|
||||
JSONArray bills = new JSONArray();
|
||||
bills.add(bills);
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("bills",bills);
|
||||
String s = executeEsb(param.toString(), "8000350044");
|
||||
logger.info("调用U8C付款单审批返回参数:{}",s);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getAccLogXmlTemplate(){
|
||||
// return "<forms version=\"2.1\"><formExport><summary id=\"1828182906863371818\" name=\"formmain_0044\"/><definitions><column id=\"field0001\" type=\"0\" name=\"我方账号\" isNullable=\"false\" length=\"200\"/><column id=\"field0017\" type=\"0\" name=\"我方开户行\" isNullable=\"false\" length=\"200\"/><column id=\"field0024\" type=\"0\" name=\"我方户名\" isNullable=\"false\" length=\"200\"/><column id=\"field0029\" type=\"0\" name=\"客户方账号\" isNullable=\"false\" length=\"200\"/><column id=\"field0022\" type=\"0\" name=\"客户方户名\" isNullable=\"false\" length=\"2000\"/><column id=\"field0030\" type=\"0\" name=\"客户方开户行\" isNullable=\"false\" length=\"500\"/><column id=\"field0018\" type=\"2\" name=\"交易日期\" isNullable=\"false\" length=\"255\"/><column id=\"field0019\" type=\"0\" name=\"交易流水号\" isNullable=\"false\" length=\"100\"/><column id=\"field0020\" type=\"4\" name=\"收款金额\" isNullable=\"false\" length=\"20\"/><column id=\"field0021\" type=\"0\" name=\"摘要\" isNullable=\"false\" length=\"500\"/><column id=\"field0025\" type=\"0\" name=\"银行类型\" isNullable=\"false\" length=\"100\"/><column id=\"field0026\" type=\"0\" name=\"银行流水号\" isNullable=\"false\" length=\"100\"/><column id=\"field0027\" type=\"0\" name=\"币种\" isNullable=\"false\" length=\"100\"/><column id=\"field0028\" type=\"0\" name=\"用途\" isNullable=\"false\" length=\"800\"/><column id=\"field0031\" type=\"0\" name=\"关联客户号\" isNullable=\"false\" length=\"100\"/><column id=\"field0032\" type=\"0\" name=\"客商编号\" isNullable=\"false\" length=\"100\"/><column id=\"field0033\" type=\"0\" name=\"交易代码\" isNullable=\"false\" length=\"100\"/><column id=\"field0034\" type=\"0\" name=\"客商名称\" isNullable=\"false\" length=\"100\"/><column id=\"field0035\" type=\"0\" name=\"对账码\" isNullable=\"false\" length=\"100\"/><column id=\"field0036\" type=\"0\" name=\"备注\" isNullable=\"false\" length=\"800\"/><column id=\"field0037\" type=\"0\" name=\"ERP业务参考号\" isNullable=\"false\" length=\"100\"/><column id=\"field0038\" type=\"0\" name=\"币种ID\" isNullable=\"false\" length=\"100\"/><column id=\"field0039\" type=\"0\" name=\"币种编码\" isNullable=\"false\" length=\"100\"/><column id=\"field0040\" type=\"0\" name=\"控制只关联1次\" isNullable=\"false\" length=\"100\"/><column id=\"field0044\" type=\"4\" name=\"收款剩余金额\" isNullable=\"false\" length=\"20\"/><column id=\"field0045\" type=\"0\" name=\"收款完成情况\" isNullable=\"false\" length=\"100\"/><column id=\"field0046\" type=\"4\" name=\"是否收款完成\" isNullable=\"false\" length=\"20\"/></definitions><values><column name=\"我方账号\"><value><![CDATA[{}]]></value></column><column name=\"我方开户行\"><value><![CDATA[{}]]></value></column><column name=\"我方户名\"><value><![CDATA[{}]]></value></column><column name=\"客户方账号\"><value><![CDATA[{}]]></value></column><column name=\"客户方户名\"><value><![CDATA[{}]]></value></column><column name=\"客户方开户行\"><value><![CDATA[{}]]></value></column><column name=\"交易日期\"><value><![CDATA[{}]]></value></column><column name=\"交易流水号\"><value><![CDATA[{}]]></value></column><column name=\"收款金额\"><value><![CDATA[{}]]></value></column><column name=\"摘要\"><value><![CDATA[{}]]></value></column><column name=\"银行类型\"><value><![CDATA[{}]]></value></column><column name=\"银行流水号\"><value><![CDATA[{}]]></value></column><column name=\"币种\"><value><![CDATA[{}]]></value></column><column name=\"用途\"><value><![CDATA[{}]]></value></column><column name=\"关联客户号\"><value><![CDATA[{}]]></value></column><column name=\"客商编号\"><value><![CDATA[{}]]></value></column><column name=\"交易代码\"><value><![CDATA[{}]]></value></column><column name=\"客商名称\"><value><![CDATA[{}]]></value></column><column name=\"对账码\"><value><![CDATA[{}]]></value></column><column name=\"备注\"><value><![CDATA[{}]]></value></column><column name=\"ERP业务参考号\"><value><![CDATA[{}]]></value></column><column name=\"币种ID\"><value><![CDATA[{}]]></value></column><column name=\"币种编码\"><value><![CDATA[{}]]></value></column><column name=\"控制只关联1次\"><value><![CDATA[{}]]></value></column><column name=\"收款剩余金额\"><value><![CDATA[{}]]></value></column><column name=\"收款完成情况\"><value><![CDATA[{}]]></value></column><column name=\"是否收款完成\"><value><![CDATA[{}]]></value></column></values><subForms/></formExport></forms>";
|
||||
|
|
|
@ -69,6 +69,26 @@ public class RestUtil {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 附件下载
|
||||
* @param loginName oa登录名
|
||||
* @param apiCode 接口编码
|
||||
* @param fileId 附件id
|
||||
* @param fileName 附件名
|
||||
* @return 附件字节数组
|
||||
*/
|
||||
public byte[] downloadFileBytes(String loginName,String apiCode,String fileId,String fileName){
|
||||
if (StrUtil.isNotEmpty(apiCode)){
|
||||
SysApplicationApiEntity sysApp = getByCode(apiCode);
|
||||
String token = getToken(loginName,sysApp);
|
||||
String appUrl = sysApp.getAppUrl();
|
||||
String url = "/seeyon/rest/attachment/file/@ctp_file_ID@?fileName=@文件名@&token=@token@";
|
||||
url = url.replaceAll("@ctp_file_ID@",fileId).replaceAll("@文件名@",fileName).replaceAll("@token@",token);
|
||||
byte[] bytes = HttpUtil.downloadBytes(appUrl + url);
|
||||
return bytes;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 获取token
|
||||
* @param login_name
|
||||
|
@ -78,36 +98,45 @@ public class RestUtil {
|
|||
public String getToken(String login_name,String api_code){
|
||||
if (StrUtil.isNotEmpty(api_code)){
|
||||
SysApplicationApiEntity sysApp = getByCode(api_code);
|
||||
if (null != sysApp){
|
||||
HashMap<String, String> hashMap = new HashMap<>();
|
||||
String app_url = sysApp.getAppUrl();
|
||||
String url = app_url+"/seeyon/rest/token";
|
||||
String headerIn = sysApp.getHeaderIn();
|
||||
JSONArray headers = JSON.parseArray(headerIn);
|
||||
for (int i = 0; i < headers.size(); i++) {
|
||||
JSONObject object1 = headers.getJSONObject(i);
|
||||
String parameterName = object1.getString("parameterName");
|
||||
if ("userName".equals(parameterName) || "password".equals(parameterName) || "loginName".equals(parameterName)){
|
||||
String example = object1.getString("example");
|
||||
hashMap.put(parameterName,example);
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotEmpty(login_name)){
|
||||
hashMap.put("loginName",login_name);
|
||||
}
|
||||
String result = HttpRequest.post(url).body(JSON.toJSONString(hashMap)).execute().body();
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if (null != jsonObject) {
|
||||
logger.info("======token:{}======" ,jsonObject.getString("id"));
|
||||
return jsonObject.getString("id");
|
||||
}
|
||||
}
|
||||
return getToken(login_name,sysApp);
|
||||
}else {
|
||||
throw new BaseSystemException("api_code不能为空");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
* @param login_name oa登录名
|
||||
* @param sysApp 应用信息
|
||||
* @return
|
||||
*/
|
||||
public String getToken(String login_name,SysApplicationApiEntity sysApp){
|
||||
if (null != sysApp){
|
||||
HashMap<String, String> hashMap = new HashMap<>();
|
||||
String app_url = sysApp.getAppUrl();
|
||||
String url = app_url+"/seeyon/rest/token";
|
||||
String headerIn = sysApp.getHeaderIn();
|
||||
JSONArray headers = JSON.parseArray(headerIn);
|
||||
for (int i = 0; i < headers.size(); i++) {
|
||||
JSONObject object1 = headers.getJSONObject(i);
|
||||
String parameterName = object1.getString("parameterName");
|
||||
if ("userName".equals(parameterName) || "password".equals(parameterName) || "loginName".equals(parameterName)){
|
||||
String example = object1.getString("example");
|
||||
hashMap.put(parameterName,example);
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotEmpty(login_name)){
|
||||
hashMap.put("loginName",login_name);
|
||||
}
|
||||
String result = HttpRequest.post(url).body(JSON.toJSONString(hashMap)).execute().body();
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
if (null != jsonObject) {
|
||||
logger.info("======token:{}======" ,jsonObject.getString("id"));
|
||||
return jsonObject.getString("id");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private SysApplicationApiEntity getByCode(String api_code){
|
||||
if (StrUtil.isNotEmpty(api_code)){
|
||||
SysApplicationApiEntity sysApp = new SysApplicationApiEntity();
|
||||
|
|
|
@ -2103,7 +2103,7 @@ public class SysApplicationServiceImpl extends BaseService<SysApplicationEntity,
|
|||
JSONObject jsonObject1 = JSONObject.parseObject(body);
|
||||
String retCode = jsonObject1.getString("retCode");
|
||||
if(retCode != null && "0000".equals(retCode)){
|
||||
JSONObject jsonObject2 = JSONObject.parseObject(jsonObject1.getString("data"));
|
||||
JSONObject jsonObject2 = JSONObject.parseObject(jsonObject1.getString("Data"));
|
||||
String fileBytes = jsonObject2.getString("fileBytes");
|
||||
if(fileBytes != null && !"".equals(fileBytes)){
|
||||
jsonObject2.put("fileBytes","");
|
||||
|
|
Loading…
Reference in New Issue