parent
4f3165d808
commit
d667daee69
|
@ -3,6 +3,7 @@ package shkd.sys.sys.plugin.operation;
|
|||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
import kd.bos.entity.plugin.args.BeforeOperationArgs;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
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.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import scala.collection.mutable.StringBuilder;
|
||||
import shkd.sys.sys.mservice.ApiService;
|
||||
import shkd.sys.sys.plugin.form.ApiMappingBillPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -21,25 +24,45 @@ import java.util.List;
|
|||
*/
|
||||
public class HitBackOperationServicePlugin extends AbstractOperationServicePlugIn implements Plugin {
|
||||
private static final Log logger = LogFactory.getLog(ApiMappingBillPlugin.class);
|
||||
|
||||
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs args) {
|
||||
super.afterExecuteOperationTransaction(args);
|
||||
List<DynamicObject> dynamicObjectList = new ArrayList<>();
|
||||
public void beforeExecuteOperationTransaction(BeforeOperationArgs args) {
|
||||
super.beforeExecuteOperationTransaction(args);
|
||||
DynamicObject[] entities = args.getDataEntities();
|
||||
for (DynamicObject dynamicObject : entities) {
|
||||
BusinessDataServiceHelper.load(dynamicObject.getDataEntityType().getName(), "id,billno,actpayamt,entry,entry.e_expenseitem,entry.e_remark,settletype,payeebanknum," +
|
||||
"payeetype,payeenumber,payeracctbank,payeebank,payeebankname,paymenttype,org,bizdate,description," +
|
||||
"shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus,bankpaystatus"
|
||||
, new QFilter("id", QCP.equals, dynamicObject.getPkValue())
|
||||
.and("billstatus", QCP.equals, "C")//已审核
|
||||
.and("shkd_pushstatus", QCP.equals, "未结算").toArray());
|
||||
try {
|
||||
ApiService.paymentSlipsJson(dynamicObject, "BIPNO", dynamicObjectList, null);
|
||||
SaveServiceHelper.save(dynamicObjectList.toArray(new DynamicObject[0]));
|
||||
logger.info("执行打回操作成功,单据编号:{}", dynamicObject.getString("billno"));
|
||||
} catch (Exception e) {
|
||||
logger.info("执行打回操作失败,错误信息 → \n{}", e);
|
||||
List<Object> pkValue = new ArrayList<>();
|
||||
Arrays.stream(entities).forEach(dynamicObject -> {
|
||||
pkValue.add(dynamicObject.getPkValue());
|
||||
});
|
||||
DynamicObject[] objects = BusinessDataServiceHelper.load("cas_paybill", "id,billno,actpayamt,entry,entry.e_expenseitem,entry.e_remark,settletype,payeebanknum," +
|
||||
"payeetype,payeenumber,payeracctbank,payeebank,payeebankname,paymenttype,org,bizdate,description," +
|
||||
"shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus,bankpaystatus"
|
||||
, new QFilter("id", QCP.in, pkValue)
|
||||
.and("billstatus", QCP.equals, "C")//已审核
|
||||
.and("shkd_pushstatus", QCP.equals, "未结算")
|
||||
.and("shkd_businessname", QCP.equals, "共享系统").toArray());
|
||||
if (objects == null || objects.length == 0) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue