|
|
@@ -0,0 +1,357 @@
|
|
|
+package com.yw.bpm.client.action;
|
|
|
+
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
+
|
|
|
+import com.yw.bpm.data.model.Data;
|
|
|
+import com.yw.bpm.flow.dao.FlowModelDao;
|
|
|
+import com.yw.bpm.flow.model.FlowFormElement;
|
|
|
+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.form.service.FormFormulaService;
|
|
|
+import com.yw.bpm.instance.service.FlowService;
|
|
|
+import com.yw.bpm.instance.util.InstanceUtil;
|
|
|
+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.framework.util.StringUtils;
|
|
|
+import com.yw.core.session.AppSession;
|
|
|
+import com.yw.core.session.OASession;
|
|
|
+import com.yw.core.utils.Constant;
|
|
|
+import com.yw.core.utils.DateUtil;
|
|
|
+import com.yw.core.utils.RegisterCodeImpl;
|
|
|
+import com.yw.core.utils.StringUtil;
|
|
|
+import com.yw.eu.base.user.model.Group;
|
|
|
+
|
|
|
+import net.sf.json.JSONArray;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 用于客户端流程表单
|
|
|
+ *
|
|
|
+ * @author oyj
|
|
|
+ *
|
|
|
+ */
|
|
|
+public class BpmClientFlowForm2Action extends RequestAbs {
|
|
|
+
|
|
|
+ public final String serviceId = "bpm_20180525getflowform";
|
|
|
+
|
|
|
+ private ApplicationContext cxt = null;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getResult() {
|
|
|
+ // 获取请求的参数
|
|
|
+ String param = getParameters();
|
|
|
+ JSONObject json = JSONObject.fromObject(param);
|
|
|
+ String userid = json.getString("staffId");
|
|
|
+ String formId = json.getString("formId");
|
|
|
+ String tmodelId = json.getString("tmodelId");
|
|
|
+ //以下5个参数用于 getFormDefaultValue()方法中oasession需要的当前人员数据
|
|
|
+ String loginID = json.getString("loginID");
|
|
|
+ String groupName = json.getString("groupName");
|
|
|
+ String name = json.getString("name");
|
|
|
+ String currentPosition = json.getString("currentPosition");
|
|
|
+ String id = json.getString("id");
|
|
|
+
|
|
|
+ OASession oaSession = new OASession();
|
|
|
+ Group group = new Group();
|
|
|
+ oaSession.setLoginID(Long.valueOf(loginID)); //loginID 8970258956979
|
|
|
+ group.setGroupName(groupName); //groupName 开发组
|
|
|
+ oaSession.setGroup(group);
|
|
|
+ oaSession.setName(name); //name 测试3
|
|
|
+ oaSession.setCurrentPosition(currentPosition); //currentPosition 员工
|
|
|
+ group.setId(Long.valueOf(id)); //id 347517153919893
|
|
|
+ oaSession.setUnit(group);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 返回数据
|
|
|
+ ResultVo rv = null;
|
|
|
+ if (!StringUtils.isEmpty(userid)) {
|
|
|
+ String responseJson = this.flowForm(formId, tmodelId,oaSession);
|
|
|
+ if (!"0".equals(responseJson)) {
|
|
|
+ rv = new ResultVo();
|
|
|
+ rv.setReturnCode("0");
|
|
|
+ rv.setReturnMsg("success");
|
|
|
+ rv.setReturnParams(responseJson);
|
|
|
+ return JSONObject.fromObject(rv, config).toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rv = new ResultVo();
|
|
|
+ rv.setReturnCode("1");
|
|
|
+ rv.setReturnMsg("failed");
|
|
|
+ rv.setReturnParams("");
|
|
|
+ return JSONObject.fromObject(rv, config).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取流程表单
|
|
|
+ * @param oaSession
|
|
|
+ *
|
|
|
+ * @param tinsid
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @SuppressWarnings({ "rawtypes", "unchecked" })
|
|
|
+ private String flowForm(String formId, String tmodelId, OASession oaSession) {
|
|
|
+ try {
|
|
|
+ if (null == cxt) {
|
|
|
+ cxt = AppSession.getApplicationContext();
|
|
|
+ }
|
|
|
+ FlowService flowService = (FlowService) cxt.getBean("bpmFlowService");
|
|
|
+ FormDao bpmFormDao = (FormDao) cxt.getBean("bpmFormDao");
|
|
|
+ FormEnumDao bpmFormEnumDao = (FormEnumDao) cxt.getBean("bpmFormEnumDao");
|
|
|
+ DataCommonDao dataCommonDao = (DataCommonDao) cxt.getBean("dataCommonDao");
|
|
|
+ FlowModelDao bpmFlowModelDao = (FlowModelDao) cxt.getBean("bpmFlowModelDao");
|
|
|
+ FormSealInfoDao bpmFormSealDao = (FormSealInfoDao) cxt.getBean("bpmFormSealDao");
|
|
|
+ FormFormulaService formFormulaService = (FormFormulaService) cxt.getBean("bpmFormFormulaService");
|
|
|
+ SealDao bpmSealDao = (SealDao) cxt.getBean("bpmSealDao");
|
|
|
+ String formInfo = "";
|
|
|
+ Map<String, String> formInfoMap = new HashMap<String, String>();
|
|
|
+ formInfoMap.put("formId", formId);
|
|
|
+
|
|
|
+ List formInfolist = new ArrayList();
|
|
|
+ formInfolist.add(formInfoMap);
|
|
|
+ // formInfo = JSONObject.fromObject(formInfoMap).toString();
|
|
|
+ formInfo = JSONArray.fromObject(formInfolist).toString();
|
|
|
+ if (!StringUtil.isEmptyStr(formId) ) {
|
|
|
+ // 表单信息
|
|
|
+ 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");
|
|
|
+ conditions.put("tmodelId", tmodelId);
|
|
|
+ List<FormElement> formElementList = bpmFormDao.getListOfFormElementByConditionsAddBDDZ(conditions); //根据条件获取表单元素列表(添加表单动作)
|
|
|
+ List<Map<String, String>> elementList = new ArrayList<Map<String, String>>();
|
|
|
+ StringBuffer sql = new StringBuffer("SELECT ");
|
|
|
+ sql.append( "* from " + tableName);
|
|
|
+ sql.append(" WHERE l_form_ins_id=" + tmodelId);
|
|
|
+// List<Map<String, Object>> list = dataCommonDao.querySql(sql.toString());
|
|
|
+ InstanceUtil instanceUtil = new InstanceUtil();
|
|
|
+ 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","defaults" };
|
|
|
+ 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();
|
|
|
+ String defaultValue = "";
|
|
|
+// StringBuffer sql = new StringBuffer("SELECT ");
|
|
|
+// sql.append(v_table_field + " from " + tableName);
|
|
|
+// sql.append(" WHERE l_form_ins_id=" + tmodelId);
|
|
|
+// List<Map<String, Object>> list = dataCommonDao.querySql(sql.toString());
|
|
|
+// if (list.size() > 0) {
|
|
|
+// 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();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// element.put("defaultValue", defaultValue);
|
|
|
+// } else {
|
|
|
+// element.put("defaultValue", "");
|
|
|
+// }
|
|
|
+
|
|
|
+ String l_element_id = fe.getElementId();
|
|
|
+ conditions.put("elementId", l_element_id);
|
|
|
+ String n_can_edit = "0";
|
|
|
+ String n_no_null = "0";
|
|
|
+ if (!StringUtil.isEmptyStr(tmodelId)) {
|
|
|
+ conditions.put("tmodelId", tmodelId);
|
|
|
+ FlowFormElement flowFormElement = bpmFlowModelDao.getFlowFormElementByConditions(conditions);
|
|
|
+ n_no_null = flowFormElement.getNoNull().getValue();
|
|
|
+ if(flowFormElement.getCanEdit().getValue() != null) {
|
|
|
+ n_can_edit = flowFormElement.getCanEdit().getValue();
|
|
|
+ }
|
|
|
+// int count = bpmFormDao.getCountOfCanEditForElement(conditions);
|
|
|
+// if (count == 0) {
|
|
|
+// n_can_edit = "0";
|
|
|
+// } else {
|
|
|
+// n_can_edit = flowFormElement.getCanEdit().getValue();
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// n_can_edit = "0";
|
|
|
+ }
|
|
|
+ if(n_can_edit.equals("1") && oaSession != null) {
|
|
|
+ FormElement elements = new FormElement();
|
|
|
+ elements.setElementId(fe.getElementId());
|
|
|
+ elements.setTableField(fe.getTableField());
|
|
|
+ elements.setType(fe.getType());
|
|
|
+ defaultValue = instanceUtil.getFormDefaultValue(formId, tmodelId, "", "create", "", elements, oaSession);
|
|
|
+ }
|
|
|
+ element.put("canEdit", n_can_edit);
|
|
|
+ element.put("formId", fe.getFormId().getFormId());
|
|
|
+ element.put("elementId", fe.getElementId());
|
|
|
+ element.put("elementName", fe.getElementName().replaceFirst("my:", ""));
|
|
|
+ element.put("tableField", fe.getTableField());
|
|
|
+ element.put("fieldType", fe.getFieldType().getValue());
|
|
|
+ element.put("type", fe.getType().getValue());
|
|
|
+ element.put("typeDetail", fe.getTypeDetail());
|
|
|
+ element.put("long", fe.getLength());
|
|
|
+ element.put("groupid", fe.getGroupId());
|
|
|
+ element.put("isGroup", fe.getIsGroup());
|
|
|
+ element.put("groupuid", "");
|
|
|
+ element.put("noNull", n_no_null);
|
|
|
+ element.put("Bddz", fe.getBddz());
|
|
|
+ element.put("BddzText", fe.getBddzText());
|
|
|
+ element.put("defaultValue", defaultValue);
|
|
|
+ elementList.add(element);
|
|
|
+ }
|
|
|
+ // 重复表查询
|
|
|
+// conditions.clear();
|
|
|
+// conditions.put("formId", formId);
|
|
|
+// conditions.put("isGroup", "1");
|
|
|
+// conditions.put("!type", "-1");
|
|
|
+// conditions.put("tmodelId", tmodelId);
|
|
|
+// formElementList = bpmFormDao.getListOfFormElementByConditionsAddBDDZ(conditions);//根据条件获取表单元素列表(添加表单动作)
|
|
|
+// for (int i = 0; i < formElementList.size(); i++) {
|
|
|
+// FormElement fe = formElementList.get(i);
|
|
|
+//
|
|
|
+// 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","defaults" };
|
|
|
+// 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 l_form_group_id,l_form_group_count,");
|
|
|
+// sql.append(v_table_field + " from oa_form_group_" + fe.getGroupId());
|
|
|
+// sql.append(" WHERE l_form_ins_id=" + tmodelId + " ORDER BY l_form_group_count");
|
|
|
+// List<Map<String, Object>> list = dataCommonDao.querySql(sql.toString());
|
|
|
+// if (list.size() > 0) {
|
|
|
+// for (int j = 0; j < list.size(); j++) {
|
|
|
+// Map<String, String> element = new HashMap<String, String>();
|
|
|
+// String defaultValue = "";
|
|
|
+// if (list.get(j).get(v_table_field) != null) {
|
|
|
+// defaultValue = (list.get(j).get(v_table_field)).toString();
|
|
|
+// }
|
|
|
+// if ("2".equals(fe.getFieldType().getValue())) {
|
|
|
+// defaultValue = DateUtil.formatStringDate(defaultValue, Constant.DATE_FORMATE);
|
|
|
+// }
|
|
|
+// String groupuid = (list.get(j).get("l_form_group_id")).toString();
|
|
|
+// String groupCount = (list.get(j).get("l_form_group_count")).toString();
|
|
|
+// String l_element_id = fe.getElementId();
|
|
|
+// conditions.put("elementId", l_element_id);
|
|
|
+// String n_can_edit = "1";
|
|
|
+// String n_no_null = "0";
|
|
|
+// if (!StringUtil.isEmptyStr(tmodelId)) {
|
|
|
+// conditions.put("tmodelId", tmodelId);
|
|
|
+// FlowFormElement flowFormElement = bpmFlowModelDao.getFlowFormElementByConditions(conditions);
|
|
|
+// n_no_null = flowFormElement.getNoNull().getValue();
|
|
|
+// int count = bpmFormDao.getCountOfCanEditForElement(conditions);
|
|
|
+// if (count == 0) {
|
|
|
+// n_can_edit = "0";
|
|
|
+// } else {
|
|
|
+// n_can_edit = flowFormElement.getCanEdit().getValue();
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// n_can_edit = "0";
|
|
|
+// }
|
|
|
+// element.put("defaultValue", defaultValue);
|
|
|
+// element.put("canEdit", n_can_edit);
|
|
|
+// element.put("formId", fe.getFormId().getFormId());
|
|
|
+// element.put("elementId", fe.getElementId());
|
|
|
+// element.put("elementName", fe.getElementName().replaceFirst("my:", "") + groupCount);
|
|
|
+// element.put("tableField", fe.getTableField());
|
|
|
+// element.put("fieldType", fe.getFieldType().getValue());
|
|
|
+// element.put("type", fe.getType().getValue());
|
|
|
+// element.put("typeDetail", fe.getTypeDetail());
|
|
|
+// element.put("long", fe.getLength());
|
|
|
+// element.put("isGroup", fe.getIsGroup());
|
|
|
+// element.put("groupid", fe.getGroupId());
|
|
|
+// element.put("groupuid", groupuid);
|
|
|
+// element.put("noNull", n_no_null);
|
|
|
+// element.put("Bddz", fe.getBddz());
|
|
|
+// element.put("BddzText", fe.getBddzText());
|
|
|
+// elementList.add(element);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ //获取默认值(原先默认值都为空,添加这个模块获取已配置了默认值的element的默认值)
|
|
|
+// for(int i=0; i<elementList.size(); i++) {
|
|
|
+// InstanceUtil instanceUtil = new InstanceUtil();
|
|
|
+// FormElement element = new FormElement();
|
|
|
+// FormInfo formInfo2 = new FormInfo();
|
|
|
+// formInfo2.setFormId(elementList.get(i).get( "formId" ));
|
|
|
+// element.setFormId(formInfo2);
|
|
|
+// element.setElementId(elementList.get(i).get( "elementId" ) );
|
|
|
+// element.setElementName(elementList.get(i).get( "elementName" ) );
|
|
|
+// element.setTableField(elementList.get(i).get( "tableField" ) );
|
|
|
+// Data shuju = new Data();
|
|
|
+// shuju.setValue(elementList.get(i).get( "fieldType" ));
|
|
|
+// element.setFieldType(shuju );
|
|
|
+// Data shuju2 = new Data();
|
|
|
+// shuju2.setValue(elementList.get(i).get( "type" ));
|
|
|
+// element.setType(shuju2 );
|
|
|
+// element.setTypeDetail(elementList.get(i).get( "typeDetail" ) );
|
|
|
+// element.setLength(elementList.get(i).get( "long" ) );
|
|
|
+// element.setIsGroup(elementList.get(i).get( "isGroup" ) );
|
|
|
+// element.setGroupId(elementList.get(i).get( "groupid" ));
|
|
|
+// String defaultValue = instanceUtil.getFormDefaultValue(formId, tmodelId, "", "create", "", element, oaSession);
|
|
|
+// elementList.get(i).put("defaultValue", defaultValue);
|
|
|
+// }
|
|
|
+ String formElements = JSONArray.fromObject(elementList).toString();
|
|
|
+ return ("{formInfo:" + formInfo + ",formElements:" + formElements + "}").replaceAll(":null", ":\"\"");
|
|
|
+ }
|
|
|
+ return "0";
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return "0";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getServiceId() {
|
|
|
+ return serviceId;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String url = "http://localhost:8081/ynet/clientServices.do?iscrypt=1";
|
|
|
+ String param="{\"serviceId\":\"bpm_2013V0100PHONE006\",\"params\":{\"staffId\":\"84881925266249\",\"tinsid\":\"350854841201089\",\"insId\":\"350852602978234\"}}";
|
|
|
+ String rs = RegisterCodeImpl.requestPage(url,param);
|
|
|
+ System.out.println(rs);
|
|
|
+ }
|
|
|
+}
|