diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/form/ScheduleListPlugin.java b/main/java/shjh/jhzj7/fi/fi/plugin/form/ScheduleListPlugin.java index 17dceca..5f2f4ab 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/form/ScheduleListPlugin.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/form/ScheduleListPlugin.java @@ -2,9 +2,11 @@ package shjh.jhzj7.fi.fi.plugin.form; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import kd.bos.dataentity.OperateOption; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.entity.datamodel.ListSelectedRow; import kd.bos.entity.datamodel.ListSelectedRowCollection; +import kd.bos.entity.operate.OperateOptionConst; import kd.bos.entity.operate.result.OperationResult; import kd.bos.form.events.AfterDoOperationEventArgs; 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.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.operation.OperationServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper; +import kd.bos.util.StringUtils; import java.text.SimpleDateFormat; +import java.util.ArrayList; 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.unlocked_status; @@ -66,36 +72,69 @@ public class ScheduleListPlugin extends AbstractListPlugin { DynamicObject bill = BusinessDataServiceHelper.loadSingle(pk, "psd_schedulebill"); String action = "04".equals(status)? "退单" : "作废"; if (bill != null) { - //来源SAP - String shjhSapuniquevalue = bill.getString("shjh_sapuniquevalue"); - if (shjhSapuniquevalue != null && !shjhSapuniquevalue.isEmpty()) { - 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 + "成功"); + QFilter qFilter = new QFilter("billno", QCP.equals, bill.getString("sourcebillnumber")); + //如果付款申请单不是来源调整单,再判断付款申请单来源类型,来源费控调用关闭;来源sap调用反审核 + DynamicObject payapply = BusinessDataServiceHelper.loadSingle("ap_payapply", + "id,billno,shjh_sourceadjustment", qFilter.toArray()); + if (null != payapply) { + //如果付款申请单不是来源调整单 + if (!payapply.getBoolean("shjh_sourceadjustment")) { + //来源SAP + String shjhSapuniquevalue = bill.getString("shjh_sapuniquevalue"); + 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接口参数 * @param bill