|
|
@@ -0,0 +1,320 @@
|
|
|
+package com.yw.bpm.client.action;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import com.yw.contract.contract.model.*;
|
|
|
+import com.yw.contract.contract.service.ContractEntryService;
|
|
|
+import com.yw.contract.contract.service.ContractPurchaseService;
|
|
|
+import com.yw.core.utils.RegisterCodeImpl;
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
+
|
|
|
+import com.yw.bpm.form.dao.FormDao;
|
|
|
+import com.yw.bpm.form.dao.FormEnumDao;
|
|
|
+import com.yw.bpm.form.dao.FormSealInfoDao;
|
|
|
+import com.yw.bpm.form.model.FormElement;
|
|
|
+import com.yw.bpm.form.model.FormEnumValue;
|
|
|
+import com.yw.bpm.form.model.FormInfo;
|
|
|
+import com.yw.bpm.form.model.FormSealInfo;
|
|
|
+import com.yw.bpm.instance.dao.FlowDao;
|
|
|
+import com.yw.bpm.instance.model.FileInfo;
|
|
|
+import com.yw.bpm.instance.model.FlowInstance;
|
|
|
+import com.yw.bpm.instance.model.TacheInstance;
|
|
|
+import com.yw.bpm.instance.service.FlowService;
|
|
|
+import com.yw.bpm.seal.dao.SealDao;
|
|
|
+import com.yw.bpm.seal.model.SealInfo;
|
|
|
+import com.yw.bpm.system.util.JsonUtil;
|
|
|
+import com.yw.core.clientImpl.model.ResultVo;
|
|
|
+import com.yw.core.clientImpl.service.RequestAbs;
|
|
|
+import com.yw.core.common.DataCommonDao;
|
|
|
+import com.yw.core.session.AppSession;
|
|
|
+import com.yw.core.utils.Constant;
|
|
|
+import com.yw.core.utils.DateUtil;
|
|
|
+import com.yw.core.utils.StringUtil;
|
|
|
+import com.yw.eu.base.system.model.UploadFile;
|
|
|
+import com.yw.eu.base.system.service.UploadFileService;
|
|
|
+
|
|
|
+import net.sf.json.JSONArray;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取流程综合信息接口(精简版)
|
|
|
+ * 包含:流程、表单数据、附件、流转过程详情
|
|
|
+ */
|
|
|
+public class BpmClientFlowInfoForMesAction extends RequestAbs {
|
|
|
+ public final String serviceId = "bpm_getFlowInfoForMes";
|
|
|
+
|
|
|
+ private ApplicationContext cxt = null;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getResult() {
|
|
|
+ // 获取请求的参数
|
|
|
+ String param = getParameters();
|
|
|
+ JSONObject json = JSONObject.fromObject(param);
|
|
|
+ String insId = json.getString("insId");
|
|
|
+
|
|
|
+ // 返回数据
|
|
|
+ ResultVo rv = null;
|
|
|
+ if (!StringUtil.isEmpty(insId)) {
|
|
|
+ String responseJson = this.getFlowSimpleInfo(insId);
|
|
|
+ if (!"0".equals(responseJson)) {
|
|
|
+ rv = new ResultVo();
|
|
|
+ rv.setReturnCode("1");
|
|
|
+ rv.setReturnMsg("success");
|
|
|
+ rv.setReturnParams(responseJson);
|
|
|
+ return JSONObject.fromObject(rv, config).toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rv = new ResultVo();
|
|
|
+ rv.setReturnCode("0");
|
|
|
+ rv.setReturnMsg("failed");
|
|
|
+ rv.setReturnParams("");
|
|
|
+ return JSONObject.fromObject(rv, config).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取流程精简信息
|
|
|
+ * @param insId 流程实例ID
|
|
|
+ * @return JSON字符串
|
|
|
+ */
|
|
|
+ @SuppressWarnings({ "rawtypes", "unchecked" })
|
|
|
+ private String getFlowSimpleInfo(String insId) {
|
|
|
+ try {
|
|
|
+ if (null == cxt) {
|
|
|
+ cxt = AppSession.getApplicationContext();
|
|
|
+ }
|
|
|
+
|
|
|
+ FlowDao flowDao = (FlowDao) cxt.getBean("bpmFlowDao");
|
|
|
+ FlowService flowService = (FlowService) cxt.getBean("bpmFlowService");
|
|
|
+ FormDao bpmFormDao = (FormDao) cxt.getBean("bpmFormDao");
|
|
|
+ FormEnumDao bpmFormEnumDao = (FormEnumDao) cxt.getBean("bpmFormEnumDao");
|
|
|
+ DataCommonDao dataCommonDao = (DataCommonDao) cxt.getBean("dataCommonDao");
|
|
|
+ FormSealInfoDao bpmFormSealDao = (FormSealInfoDao) cxt.getBean("bpmFormSealDao");
|
|
|
+ SealDao bpmSealDao = (SealDao) cxt.getBean("bpmSealDao");
|
|
|
+ UploadFileService uploadFileService = (UploadFileService) cxt.getBean("uploadFileService");
|
|
|
+
|
|
|
+ // 获取流程实例
|
|
|
+ FlowInstance finstances = flowDao.getFlowInstanceById(insId);
|
|
|
+ if (finstances == null) {
|
|
|
+ return "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> info = flowService.toInfo(insId);
|
|
|
+ if (info == null) {
|
|
|
+ return "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ FlowInstance flow = (FlowInstance) (info.get("flow"));
|
|
|
+ if (flow == null) {
|
|
|
+ return "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ String formId = flow.getFormId().getFormId();
|
|
|
+ String formInsId = flow.getFormInsId();
|
|
|
+ String modelId = flow.getModelId().getModelId();
|
|
|
+
|
|
|
+ // 0. 获取流程基本信息
|
|
|
+ Map<String, Object> flowMap = new HashMap<String, Object>();
|
|
|
+ flowMap.put("insName", flow.getInsName());
|
|
|
+ flowMap.put("insRemark", flow.getInsRemark());
|
|
|
+ flowMap.put("name", flow.getCreator().getUsername());
|
|
|
+ flowMap.put("insId", flow.getInsId());
|
|
|
+ flowMap.put("createdate", flow.getCreatedate());
|
|
|
+ flowMap.put("finishdate", flow.getFinishdate());
|
|
|
+ flowMap.put("canceldate", flow.getCanceldate());
|
|
|
+
|
|
|
+ // 1. 获取附件信息
|
|
|
+ Map<String, Object> fileMap = new HashMap<String, Object>();
|
|
|
+ List<Map<String, String>> filelist = new ArrayList<Map<String, String>>();
|
|
|
+ String fileIds = "";
|
|
|
+ List<FileInfo> fileList = (List<FileInfo>) (info.get("fileList"));
|
|
|
+ if (fileList != null && fileList.size() > 0) {
|
|
|
+ for (FileInfo fi : fileList) {
|
|
|
+ String fileId = fi.getFileId().getUniversalid();
|
|
|
+ UploadFile uploadFile = new UploadFile();
|
|
|
+ uploadFile.setFileId(StringUtil.strToLong(fileId));
|
|
|
+ uploadFile = uploadFileService.loadUploadFile(uploadFile);
|
|
|
+ if (uploadFile != null) {
|
|
|
+ fileIds = fileIds + "," + fileId;
|
|
|
+ Map<String, String> map = new HashMap<String, String>();
|
|
|
+ map.put("fileId", uploadFile.getFileId().toString());
|
|
|
+ map.put("fileName", uploadFile.getSrcFile());
|
|
|
+ map.put("path", uploadFile.getPath());
|
|
|
+ filelist.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fileMap.put("fileIds", fileIds);
|
|
|
+ fileMap.put("files", filelist);
|
|
|
+
|
|
|
+ // 2. 获取表单元素信息(仅非重复表)
|
|
|
+ List<Map<String, String>> elementList = new ArrayList<Map<String, String>>();
|
|
|
+
|
|
|
+ /*if (!StringUtil.isEmptyStr(formId) && !StringUtil.isEmptyStr(formInsId)) {
|
|
|
+ FormInfo infoForm = bpmFormDao.getFormInfoById(formId);
|
|
|
+ String tableName = infoForm.getTable();
|
|
|
+
|
|
|
+ // 查询非重复表字段
|
|
|
+ Map<String, String> conditions = new HashMap<String, String>();
|
|
|
+ conditions.put("formId", formId);
|
|
|
+ conditions.put("isGroup", "0");
|
|
|
+ conditions.put("!type", "-1");
|
|
|
+ List<FormElement> formElementList = bpmFormDao.getListOfFormElementByConditions(conditions);
|
|
|
+
|
|
|
+ for (int i = 0; i < formElementList.size(); i++) {
|
|
|
+ FormElement fe = formElementList.get(i);
|
|
|
+ Map<String, String> element = new HashMap<String, String>();
|
|
|
+
|
|
|
+ // 处理枚举类型
|
|
|
+ if (("2".equals(fe.getType().getValue()) || "4".equals(fe.getType().getValue())
|
|
|
+ || "5".equals(fe.getType().getValue())) && fe.getTypeDetail() != null) {
|
|
|
+ String n_type_detail = fe.getTypeDetail();
|
|
|
+ List<FormEnumValue> enumlist = bpmFormEnumDao.getListOfFormEnumValueByEnumId(n_type_detail);
|
|
|
+ String enumArray[] = new String[] { "enumVname" };
|
|
|
+ String enumVname = JsonUtil.getJson(enumlist, enumArray, false);
|
|
|
+ String enumstr = "{enum:" + enumVname + "}";
|
|
|
+ fe.setTypeDetail(enumstr);
|
|
|
+ } else {
|
|
|
+ String enumstr = "{}";
|
|
|
+ fe.setTypeDetail(enumstr);
|
|
|
+ }
|
|
|
+
|
|
|
+ String v_table_field = fe.getTableField();
|
|
|
+ StringBuffer sql = new StringBuffer("SELECT ");
|
|
|
+ sql.append(v_table_field + " from " + tableName);
|
|
|
+ sql.append(" WHERE l_form_ins_id=" + formInsId);
|
|
|
+
|
|
|
+ element.put("elementName", fe.getElementName().replaceFirst("my:", ""));
|
|
|
+ element.put("tableField", fe.getTableField());
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = dataCommonDao.querySql(sql.toString());
|
|
|
+ if (list.size() > 0) {
|
|
|
+ String defaultValue = "";
|
|
|
+ if (list.get(0).get(v_table_field) != null) {
|
|
|
+ defaultValue = (list.get(0).get(v_table_field)).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 日期格式化
|
|
|
+ if ("2".equals(formElementList.get(i).getFieldType().getValue())) {
|
|
|
+ defaultValue = DateUtil.formatStringDate(defaultValue, Constant.DATE_FORMATE);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 印章处理
|
|
|
+ if ("13".equals(formElementList.get(i).getType().getValue())) {
|
|
|
+ FormSealInfo formSealInfo = bpmFormSealDao.getFormSealInfoById(defaultValue);
|
|
|
+ if (formSealInfo != null) {
|
|
|
+ String sealId = formSealInfo.getFormSealId();
|
|
|
+ String type = formSealInfo.getType();
|
|
|
+ if ("1".equals(type)) {
|
|
|
+ defaultValue = sealId;
|
|
|
+ } else {
|
|
|
+ SealInfo sealInfo = bpmSealDao.getSealInfoById(sealId);
|
|
|
+ defaultValue = sealInfo.getSealFileId().getUniversalid();
|
|
|
+ String sealImgPath = sealInfo.getSealFileId().getPath();
|
|
|
+ element.put("sealImgPath", sealImgPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 密码字段脱敏
|
|
|
+ if ("25".equals(fe.getType().getValue())) {
|
|
|
+ defaultValue = "******";
|
|
|
+ }
|
|
|
+
|
|
|
+ element.put("defaultValue", defaultValue);
|
|
|
+ } else {
|
|
|
+ element.put("defaultValue", "");
|
|
|
+ }
|
|
|
+
|
|
|
+ elementList.add(element);
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+ // 3. 获取流转过程详情(control != -1 的逻辑)
|
|
|
+ List<TacheInstance> tacheList = flowService.getListOfTacheInstanceForProcess(insId);
|
|
|
+ List<Map<String, Object>> processList = new ArrayList<Map<String, Object>>();
|
|
|
+
|
|
|
+ for (TacheInstance tacheInstance : tacheList) {
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ List<Map<String, String>> tfilelist = new ArrayList<Map<String, String>>();
|
|
|
+
|
|
|
+ map.put("tmodelName", tacheInstance.getTmodelId().getTmodelName());
|
|
|
+ map.put("name", tacheInstance.getUser().getUsername());
|
|
|
+ map.put("remark", tacheInstance.getRemark());
|
|
|
+ map.put("createdate", tacheInstance.getCreatedate());
|
|
|
+ map.put("finishdate", tacheInstance.getFinishdate());
|
|
|
+ map.put("dataName", tacheInstance.getState().getDataName());
|
|
|
+ map.put("fileId", "");
|
|
|
+ map.put("files", tfilelist);
|
|
|
+ map.put("tmodelId", tacheInstance.getTmodelId().getTmodelId());
|
|
|
+ map.put("state", tacheInstance.getState().getValue());
|
|
|
+ map.put("groupName", tacheInstance.getGroupxuserid().getGroupId().getGroupName());
|
|
|
+ map.put("positionName", tacheInstance.getGroupxuserid().getPositionId().getPositionName());
|
|
|
+ map.put("processType", tacheInstance.getProcess_type());
|
|
|
+
|
|
|
+ processList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ //4、获取自定义流程表单
|
|
|
+ if("200001".equals(formId)){
|
|
|
+ //采购申请表单
|
|
|
+ ContractPurchaseService contractPurchaseService = (ContractPurchaseService) cxt.getBean("contractPurchaseService");
|
|
|
+ ContractPurchaseForm contractPurchaseForm = new ContractPurchaseForm();
|
|
|
+ contractPurchaseForm.setlFormInsId(Long.valueOf(formInsId));
|
|
|
+ contractPurchaseForm = contractPurchaseService.getContractPurchaseForm(contractPurchaseForm);
|
|
|
+ ContractPurchaseDetail contractPurchaseDetail = new ContractPurchaseDetail();
|
|
|
+ contractPurchaseDetail.setlFormInsId(Long.valueOf(formInsId));
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ List<ContractPurchaseDetail> contractPurchaseDetailList = (List<ContractPurchaseDetail>) (List<?>) contractPurchaseService.getObjectList(contractPurchaseDetail);
|
|
|
+ contractPurchaseForm.setDetails(contractPurchaseDetailList);
|
|
|
+ flowMap.put("contractPurchaseForm", contractPurchaseForm);
|
|
|
+ //flowMap.put("contractPurchaseDetailList", contractPurchaseDetailList);
|
|
|
+ }else if("200002".equals(formId)){
|
|
|
+ //合同申请表单
|
|
|
+ ContractEntryService contractEntryService = (ContractEntryService) cxt.getBean("contractEntryService");
|
|
|
+ ContractInfo contractInfo = new ContractInfo();
|
|
|
+ contractInfo.setUniversalid(Long.valueOf(formInsId));
|
|
|
+ contractInfo = (ContractInfo) contractEntryService.getObject(contractInfo);
|
|
|
+ List<ContractMaterial> contractMaterialList = contractEntryService.getContractMaterialListByContractId(contractInfo.getUniversalid());
|
|
|
+ List<ContractPayment> contractPaymentList = contractEntryService.getContractPaymentListByContractId(contractInfo.getUniversalid());
|
|
|
+ contractInfo.setContractMaterialList(contractMaterialList);
|
|
|
+ contractInfo.setContractPaymentList(contractPaymentList);
|
|
|
+ flowMap.put("contractInfo", contractInfo);
|
|
|
+ //flowMap.put("contractMaterialList", contractMaterialList);
|
|
|
+ //flowMap.put("contractPaymentList", contractPaymentList);
|
|
|
+ }
|
|
|
+ // 组装返回数据
|
|
|
+ String flowStr = JsonUtil.getJson(flowMap, true);
|
|
|
+ String formElements = JSONArray.fromObject(elementList).toString();
|
|
|
+ String fileListStr = JsonUtil.getJson(fileMap, true);
|
|
|
+ String processListStr = JsonUtil.getJson(processList, true);
|
|
|
+
|
|
|
+ return ("{\"flow\":" + flowStr +
|
|
|
+ //",\"formElements\":" + formElements +
|
|
|
+ ",\"fileList\":" + fileListStr +
|
|
|
+ ",\"processList\":" + processListStr +
|
|
|
+ "}").replaceAll(":null", ":\"\"");
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return "0";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getServiceId() {
|
|
|
+ return serviceId;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) throws Exception {
|
|
|
+ String url = "http://localhost:8180/ynet/clientServices.do?iscrypt=1";
|
|
|
+ /*String param = "{\"serviceId\":\"bpm_getFlowInfoForMes\"," +
|
|
|
+ "\"params\":{\"insId\":\"144125539930700\"}}";*/
|
|
|
+ String param = "{\"serviceId\":\"bpm_getFlowInfoForMes\"," +
|
|
|
+ "\"params\":{\"insId\":\"595068063885800\"}}";
|
|
|
+ String rs = RegisterCodeImpl.requestPage(url, param);
|
|
|
+ System.out.println(rs);
|
|
|
+ }
|
|
|
+}
|