lc/lc123/cloud/app/plugin/operate/cas/PaymentbillPushPaystateOp.java

103 lines
4.8 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package tqq9.lc123.cloud.app.plugin.operate.cas;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.args.AfterOperationArgs;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import org.apache.commons.lang3.StringUtils;
import tqq9.lc123.cloud.app.plugin.utils.FWRestfulUtils;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 付款单付款状态回传泛微kd.bos.form.plugin.bdctrl.AssignQueryPluginNew
*/
public class PaymentbillPushPaystateOp extends AbstractOperationServicePlugIn {
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
super.afterExecuteOperationTransaction(e);
DynamicObject[] dataEntities = e.getDataEntities();
for (DynamicObject dataEntity : dataEntities) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
dataEntity = BusinessDataServiceHelper.loadSingle(dataEntity.getPkValue(), dataEntity.getDynamicObjectType().getName());
String tqq9_fwrequestid = dataEntity.getString("tqq9_fwrequestid");//泛微流程ID
if(StringUtils.isNotBlank(tqq9_fwrequestid)){
Date paydate = dataEntity.getDate("paydate");//付款日期
String jyrq = sdf.format(paydate);
String jyzy = dataEntity.getString("description");//摘要
String tqq9_cwztfkzt = dataEntity.getString("tqq9_cwztfkzt");//财务中台付款状态
// [0:中台接收成功,
// 1:中台接收失败,
// 2:发送E企明成功,
// 3:发送E企明失败,
// 4:交易成功E企明付款成功, 交易成功:E企明付款成功。-D
// 5:交易失败E企明付款失败, 交易失败:E企明付款失败。-F
// 6:交易处理中E企明付款处理中, 交易处理中:E企明付款处理中。-E
// 7:交易退回E企明付款被退回] 交易退回:E企明付款被退回。-G
String fkzt = null;
if("D".equals(tqq9_cwztfkzt)){
fkzt = "4";
}else if("F".equals(tqq9_cwztfkzt)){
fkzt = "5";
}else if("E".equals(tqq9_cwztfkzt)){
fkzt = "6";
}else if("G".equals(tqq9_cwztfkzt)){
fkzt = "7";
}
String tqq9_dzhdbh = dataEntity.getString("tqq9_dzhdbh");//电子回单编号
String tqq9_digital_receipt = dataEntity.getString("tqq9_digital_receipt");//电子回单编号
String filename = "";
try {
URL url = new URL(tqq9_digital_receipt);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// 尝试从响应头获取
String disposition = conn.getHeaderField("Content-Disposition");
if (disposition != null && disposition.contains("filename=")) {
filename = disposition.split("filename=")[1].replace("\"", "").trim();
}
} catch (MalformedURLException ex) {
throw new RuntimeException(ex);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
if(StringUtils.isBlank(filename)){
filename = "银行电子回单"+new Date().getTime()+".pdf";
}
JSONObject mainTable = new JSONObject();
mainTable.put("lcid", tqq9_fwrequestid);
mainTable.put("fkzt", fkzt);
mainTable.put("dzhdwjbh", tqq9_dzhdbh);
mainTable.put("jyrq", jyrq);
mainTable.put("jyzy", jyzy);
JSONArray files = new JSONArray();
JSONObject file = new JSONObject();
file.put("name", filename);
file.put("content", tqq9_digital_receipt);
files.add(file);
mainTable.put("dzhdwj", files);
String billno = dataEntity.getString("billno");
DynamicObject creator = dataEntity.getDynamicObject("creator");
creator = BusinessDataServiceHelper.loadSingle(creator.getPkValue(),"bos_user");
String tqq9_fwuserid = creator.getString("tqq9_fwuserid");
FWRestfulUtils fwRestfulUtils = new FWRestfulUtils();
fwRestfulUtils.pushData(mainTable, tqq9_fwuserid, billno, "cas_paybill");
}
}
}
}