parent
4f3165d808
commit
d667daee69
|
@ -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 -> {
|
||||||
|
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," +
|
"payeetype,payeenumber,payeracctbank,payeebank,payeebankname,paymenttype,org,bizdate,description," +
|
||||||
"shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus,bankpaystatus"
|
"shkd_pushstatus,shkd_businessnumber,shkd_businessid,shkd_businessname,billstatus,bankpaystatus"
|
||||||
, new QFilter("id", QCP.equals, dynamicObject.getPkValue())
|
, new QFilter("id", QCP.in, pkValue)
|
||||||
.and("billstatus", QCP.equals, "C")//已审核
|
.and("billstatus", QCP.equals, "C")//已审核
|
||||||
.and("shkd_pushstatus", QCP.equals, "未结算").toArray());
|
.and("shkd_pushstatus", QCP.equals, "未结算")
|
||||||
try {
|
.and("shkd_businessname", QCP.equals, "共享系统").toArray());
|
||||||
ApiService.paymentSlipsJson(dynamicObject, "BIPNO", dynamicObjectList, null);
|
if (objects == null || objects.length == 0) {
|
||||||
SaveServiceHelper.save(dynamicObjectList.toArray(new DynamicObject[0]));
|
args.setCancel(true);
|
||||||
logger.info("执行打回操作成功,单据编号:{}", dynamicObject.getString("billno"));
|
args.setCancelMessage("选择打回单据必须为BIP推送单据");
|
||||||
} catch (Exception e) {
|
} else {
|
||||||
logger.info("执行打回操作失败,错误信息 → \n{}", e);
|
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