排程退单如果付款申请单不是来源调整单,再判断付款申请单来源类型,来源费控调用关闭;来源sap调用反审核

--s
This commit is contained in:
weiyunlong 2025-06-16 17:01:23 +08:00
parent 3cf4d0bbb1
commit 2b6d7ec933
1 changed files with 63 additions and 24 deletions

View File

@ -2,9 +2,11 @@ package shjh.jhzj7.fi.fi.plugin.form;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.ListSelectedRow; import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.entity.datamodel.ListSelectedRowCollection; import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.entity.operate.OperateOptionConst;
import kd.bos.entity.operate.result.OperationResult; import kd.bos.entity.operate.result.OperationResult;
import kd.bos.form.events.AfterDoOperationEventArgs; import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.list.IListView; import kd.bos.list.IListView;
@ -14,10 +16,14 @@ import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QCP; import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.bos.util.StringUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.Map;
import static shjh.jhzj7.fi.fi.utils.SapUtils.backpayment_status; import static shjh.jhzj7.fi.fi.utils.SapUtils.backpayment_status;
import static shjh.jhzj7.fi.fi.utils.SapUtils.unlocked_status; import static shjh.jhzj7.fi.fi.utils.SapUtils.unlocked_status;
@ -66,36 +72,69 @@ public class ScheduleListPlugin extends AbstractListPlugin {
DynamicObject bill = BusinessDataServiceHelper.loadSingle(pk, "psd_schedulebill"); DynamicObject bill = BusinessDataServiceHelper.loadSingle(pk, "psd_schedulebill");
String action = "04".equals(status)? "退单" : "作废"; String action = "04".equals(status)? "退单" : "作废";
if (bill != null) { if (bill != null) {
//来源SAP QFilter qFilter = new QFilter("billno", QCP.equals, bill.getString("sourcebillnumber"));
String shjhSapuniquevalue = bill.getString("shjh_sapuniquevalue"); //如果付款申请单不是来源调整单再判断付款申请单来源类型来源费控调用关闭来源sap调用反审核
if (shjhSapuniquevalue != null && !shjhSapuniquevalue.isEmpty()) { DynamicObject payapply = BusinessDataServiceHelper.loadSingle("ap_payapply",
JSONArray IT_INPUT = createInputJSONArray(bill, status); "id,billno,shjh_sourceadjustment", qFilter.toArray());
JSONObject jsonObjects = unlocked_status(IT_INPUT, bill.getString("billno")); if (null != payapply) {
String code = jsonObjects.getString("code"); //如果付款申请单不是来源调整单
if (!"0".equals(code)) { if (!payapply.getBoolean("shjh_sourceadjustment")) {
log.info("付款排程单:" + bill.getString("billno") + "状态(SAP)" + action + "失败:" + jsonObjects.getString("msg")); //来源SAP
} else { String shjhSapuniquevalue = bill.getString("shjh_sapuniquevalue");
log.info("付款排程单:" + bill.getString("billno") + "状态(SAP)" + action + "成功"); if (StringUtils.isNotEmpty(shjhSapuniquevalue)) {
JSONArray IT_INPUT = createInputJSONArray(bill, status);
JSONObject jsonObjects = unlocked_status(IT_INPUT, bill.getString("billno"));
String code = jsonObjects.getString("code");
if (!"0".equals(code)) {
log.info("付款排程单:" + bill.getString("billno") + "状态(SAP)" + action + "失败:" + jsonObjects.getString("msg"));
} else {
log.info("付款排程单:" + bill.getString("billno") + "状态(SAP)" + action + "成功");
//反审核
closeOrUnauditApply(payapply,"unaudit");
}
return;
}
//若来源为费控,调用费控状态修改接口
String fkbillid = bill.getString("shjh_fkbillid");//获取费控单据表头ID
if (StringUtils.isNotEmpty(fkbillid)) {
//先付后记其他付款劳务报销单SAP会员退卡单回写付款状态
JSONObject jsonObjects = backpayment_status(createInputJSONArrays(bill),bill.getString("billno"));
String code = (String)jsonObjects.get("code");
if (!"0".equals(code)) {
log.info("付款排程单:" + bill.getString("billno") + "状态(FK)" + action + "失败:" + jsonObjects.getString("msg"));
} else {
log.info("付款排程单:" + bill.getString("billno") + "状态(FK)" + action + "成功");
//关闭操作
closeOrUnauditApply(payapply,"closepay");
}
return;
}
} }
return;
}
//若来源为费控,调用费控状态修改接口
String fkbillid = bill.getString("shjh_fkbillid");//获取费控单据表头ID
if (fkbillid != null && !fkbillid.isEmpty()) {
//先付后记其他付款劳务报销单SAP会员退卡单回写付款状态
JSONObject jsonObjects = backpayment_status(createInputJSONArrays(bill),bill.getString("billno"));
String code = (String)jsonObjects.get("code");
if (!"0".equals(code)) {
log.info("付款排程单:" + bill.getString("billno") + "状态(FK)" + action + "失败:" + jsonObjects.getString("msg"));
} else {
log.info("付款排程单:" + bill.getString("billno") + "状态(FK)" + action + "成功");
}
return;
} }
} }
} }
} }
private void closeOrUnauditApply(DynamicObject payapply,String status) {
OperateOption operateOption = OperateOption.create();
// 不执行警告级别校验器
operateOption.setVariableValue(OperateOptionConst.IGNOREWARN, String.valueOf(true));
// 不显示交互提示自动执行到底
operateOption.setVariableValue(OperateOptionConst.IGNOREINTERACTION, String.valueOf(true));
// 全部校验通过才保存
operateOption.setVariableValue(OperateOptionConst.STRICTVALIDATION, String.valueOf(true));
//同一个用户在多个界面操作同一张也不允许操作
operateOption.setVariableValue(OperateOptionConst.MUTEX_ISSTRICT, String.valueOf(true));
DynamicObject[] billArray = new DynamicObject[]{payapply};
OperationResult operationResult = OperationServiceHelper.executeOperate(status, "ap_payapply", billArray, operateOption);
// 可以根据需要处理 operationResult例如检查是否成功获取返回值等
if (operationResult.isSuccess()) {
log.info("执行 "+status+" 成功,单据编号:" + payapply.getPkValue());
} else {
log.error(operationResult.getMessage());
}
}
/** /**
* SAP接口参数 * SAP接口参数
* @param bill * @param bill