提交内容:获取电子回单附件URL

备注:获取电子回单附件URL
提交人:邹江涛
This commit is contained in:
zoujiangtao 2024-12-24 17:35:44 +08:00
parent 4f3165d808
commit d667daee69
1 changed files with 40 additions and 17 deletions

View File

@ -3,6 +3,7 @@ package shkd.sys.sys.plugin.operation;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn; import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.args.AfterOperationArgs; import kd.bos.entity.plugin.args.AfterOperationArgs;
import kd.bos.entity.plugin.args.BeforeOperationArgs;
import kd.bos.logging.Log; import kd.bos.logging.Log;
import kd.bos.logging.LogFactory; import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QCP; import kd.bos.orm.query.QCP;
@ -10,10 +11,12 @@ import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.sdk.plugin.Plugin; import kd.sdk.plugin.Plugin;
import scala.collection.mutable.StringBuilder;
import shkd.sys.sys.mservice.ApiService; import shkd.sys.sys.mservice.ApiService;
import shkd.sys.sys.plugin.form.ApiMappingBillPlugin; import shkd.sys.sys.plugin.form.ApiMappingBillPlugin;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
@ -21,25 +24,45 @@ import java.util.List;
*/ */
public class HitBackOperationServicePlugin extends AbstractOperationServicePlugIn implements Plugin { public class HitBackOperationServicePlugin extends AbstractOperationServicePlugIn implements Plugin {
private static final Log logger = LogFactory.getLog(ApiMappingBillPlugin.class); private static final Log logger = LogFactory.getLog(ApiMappingBillPlugin.class);
@Override @Override
public void afterExecuteOperationTransaction(AfterOperationArgs args) { public void beforeExecuteOperationTransaction(BeforeOperationArgs args) {
super.afterExecuteOperationTransaction(args); super.beforeExecuteOperationTransaction(args);
List<DynamicObject> dynamicObjectList = new ArrayList<>();
DynamicObject[] entities = args.getDataEntities(); DynamicObject[] entities = args.getDataEntities();
for (DynamicObject dynamicObject : entities) { List<Object> pkValue = new ArrayList<>();
BusinessDataServiceHelper.load(dynamicObject.getDataEntityType().getName(), "id,billno,actpayamt,entry,entry.e_expenseitem,entry.e_remark,settletype,payeebanknum," + Arrays.stream(entities).forEach(dynamicObject -> {
"payeetype,payeenumber,payeracctbank,payeebank,payeebankname,paymenttype,org,bizdate,description," + pkValue.add(dynamicObject.getPkValue());
"shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus,bankpaystatus" });
, new QFilter("id", QCP.equals, dynamicObject.getPkValue()) DynamicObject[] objects = BusinessDataServiceHelper.load("cas_paybill", "id,billno,actpayamt,entry,entry.e_expenseitem,entry.e_remark,settletype,payeebanknum," +
.and("billstatus", QCP.equals, "C")//已审核 "payeetype,payeenumber,payeracctbank,payeebank,payeebankname,paymenttype,org,bizdate,description," +
.and("shkd_pushstatus", QCP.equals, "未结算").toArray()); "shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus,bankpaystatus"
try { , new QFilter("id", QCP.in, pkValue)
ApiService.paymentSlipsJson(dynamicObject, "BIPNO", dynamicObjectList, null); .and("billstatus", QCP.equals, "C")//已审核
SaveServiceHelper.save(dynamicObjectList.toArray(new DynamicObject[0])); .and("shkd_pushstatus", QCP.equals, "未结算")
logger.info("执行打回操作成功,单据编号:{}", dynamicObject.getString("billno")); .and("shkd_businessname", QCP.equals, "共享系统").toArray());
} catch (Exception e) { if (objects == null || objects.length == 0) {
logger.info("执行打回操作失败,错误信息 → \n{}", e); args.setCancel(true);
args.setCancelMessage("选择打回单据必须为BIP推送单据");
} else {
StringBuilder stringBuilder = new StringBuilder();
for (DynamicObject dynamicObject : objects) {
String bankpaystatus = dynamicObject.getString("bankpaystatus");
if ("TF、NC、OF".contains(bankpaystatus)) {
List<DynamicObject> dynamicObjects = new ArrayList<>();
String result = ApiService.paymentSlipsJson(dynamicObject, "BIPNO", dynamicObjects, null);
logger.info("result信息{}", result);
if (result.contains("成功")) {
SaveServiceHelper.save(dynamicObjects.toArray(new DynamicObject[0]));
stringBuilder.append("单据编号:" + dynamicObject.getString("billno") + " → 打回成功\n");
} else {
stringBuilder.append("单据编号:" + dynamicObject.getString("billno") + "打回失败\n");
}
} else {
stringBuilder.append("单据编号:" + dynamicObject.getString("billno") + "打回失败,请确认银行支付状态\n");
}
} }
} args.setCancelMessage(stringBuilder.toString());
}
} }
} }