package shkd.repc.recon.api; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.openapi.common.custom.annotation.ApiController; import com.drew.lang.annotations.NotNull; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.openapi.common.custom.annotation.ApiParam; import kd.bos.openapi.common.custom.annotation.ApiPostMapping; import kd.bos.openapi.common.result.CustomApiResult; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.QueryServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.bos.util.StringUtils; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Set; /** * 合同签署流程回调接口(e签宝接口文档 3.6.2.1) */ @ApiController(value = "SignTechnologCallbackController",desc = "合同签署流程回调api接口,自定义插件") public class SignTechnologCallbackController implements Serializable { @ApiPostMapping(value = "/eqb_signcallback", desc = "合同签署流程回调接口") public CustomApiResult eqb_signcallback (@NotNull @ApiParam(value = "入参", example = "") String str) { CustomApiResult customApiResult = new CustomApiResult(); JSONObject jsonObject = JSONObject.parseObject(str); //回调通知数据体 JSONObject callBackProcessVO = (JSONObject)jsonObject.get("callBackProcessVO"); if (null != callBackProcessVO) { //获取合同id String businessNo = (String) callBackProcessVO.get("businessNo"); if (StringUtils.isNotEmpty(businessNo)) { DynamicObject recon_contractbill = BusinessDataServiceHelper.loadSingle("recon_contractbill", "id,billno,qeug_theothersignstatus",new QFilter[]{new QFilter("billno", QCP.equals, businessNo)}); if (null != recon_contractbill) { //待签署方列表 JSONArray nextSignerList = callBackProcessVO.getJSONArray("nextSignerList"); if (null != nextSignerList) { JSONObject jsonobject = (JSONObject)nextSignerList.get(0); String signStatus = jsonobject.getString("signStatus"); recon_contractbill.set("qeug_theothersignstatus",signStatus);//状态 SaveServiceHelper.save(new DynamicObject[]{recon_contractbill}); return customApiResult ; } //签署方列表 JSONArray signerList = callBackProcessVO.getJSONArray("signerList"); if (null != signerList) { JSONObject jsonobject = (JSONObject)nextSignerList.get(0); String signStatus = jsonobject.getString("signStatus"); recon_contractbill.set("qeug_theothersignstatus",signStatus); SaveServiceHelper.save(new DynamicObject[]{recon_contractbill}); return customApiResult ; } //拒签人信息 JSONObject refuseSigner = (JSONObject)callBackProcessVO.get("refuseSigner"); if (null != refuseSigner) { String signStatus = refuseSigner.getString("signStatus"); recon_contractbill.set("qeug_theothersignstatus",signStatus); SaveServiceHelper.save(new DynamicObject[]{recon_contractbill}); return customApiResult ; } } } } return customApiResult; } }