HD_wangm 1 год назад
Родитель
Сommit
6f996a4380

+ 357 - 0
plugins/bpm/com/yw/bpm/client/action/BpmClientFlowForm2Action.java

@@ -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);
+	}
+}

+ 13 - 0
plugins/bpm/com/yw/bpm/form/dao/FormDao.java

@@ -379,5 +379,18 @@ public interface FormDao {
 	 * @date 2015年4月17日 下午5:12:03
 	 */
 	public Map getSumFiled(Map<String, Object> conditions);
+	
+	/**
+	 * 根据条件获取表单元素列表(添加表单动作)
+	 * @param conditions
+	 *            【{@code Map<String, String>}】 查询条件包含内容如下: <br>
+	 *            formId 【String】 表单ID <br>
+	 *            isGroup 【String】 是否是重复表元素<br>
+	 *            groupId 【String】重复表父节点<br>
+	 *            !type 【String】表单不展示的内容类型<br>
+	 *            version 【String】表单版本<br>
+	 * @return 查询出来的结果集 【{@code List<FormElement>}】
+	 */
+	public List<FormElement> getListOfFormElementByConditionsAddBDDZ(Map<String, String> conditions);
 
 }

+ 53 - 0
plugins/bpm/com/yw/bpm/form/dao/FormDaoImpl.java

@@ -22,6 +22,7 @@ import com.yw.core.framework.view.service.PagerService;
 import com.yw.core.utils.CommonUtil;
 import com.yw.core.utils.StringUtil;
 import com.yw.eu.base.system.model.UploadFile;
+import com.yw.bpm.form.dao.FormDaoImpl.FormElementMapperAddBDDZ;
 import com.yw.bpm.form.model.FormElement;
 import com.yw.bpm.form.model.FormInfo;
 import com.yw.bpm.form.model.FormInfopath;
@@ -745,5 +746,57 @@ public class FormDaoImpl extends BaseDao implements FormDao {
 			return null;
 		}
 	}
+	
+	protected class FormElementMapperAddBDDZ implements RowMapper {
+		@Override
+		public Object mapRow(ResultSet rs, int arg1) throws SQLException {
+			FormElement element = new FormElement();
+			element.getFormId().setFormId(rs.getString("l_form_id"));
+			element.setVesion(rs.getString("n_version"));
+			element.setElementName(rs.getString("v_element_name"));
+			element.setElementCode(rs.getString("v_element_code"));
+			element.setTableField(rs.getString("v_table_field"));
+			element.getFieldType().setValue(rs.getString("n_field_type"));
+			element.setFieldValidate(rs.getString("v_field_validate"));
+			element.setElementId(rs.getString("l_element_id"));
+			element.getType().setValue(rs.getString("n_type"));
+			element.setTypeDetail(rs.getString("n_type_detail"));
+			element.setSumField(rs.getString("v_sum_field"));
+			element.setSearchFiled(rs.getString("v_search_field"));
+			element.setLength(rs.getString("n_long"));
+			element.setIsGroup(rs.getString("n_is_group"));
+			element.setGroupId(rs.getString("l_group_id"));
+			element.getFieldType().setDataName(rs.getString("v_data_name"));
+			element.setBddz(rs.getString("BDDZ"));
+			element.setBddzText(rs.getString("BDDZText"));
+			return element;
+		}
+	}
+
+	@Override
+	public List<FormElement> getListOfFormElementByConditionsAddBDDZ(Map<String, String> conditions) {
+		String sql = " SELECT t.l_form_id,t.n_version,t.v_element_name,	t.v_element_code,t.v_table_field,bf.n_is_edit_detail,"
+				+ " b.v_formula_name as BDDZ,b.v_formula_text AS BDDZText,t.n_field_type,t.v_field_validate,	t.v_sum_field,	t.v_search_field,t.l_element_id,"
+				+ "	t.n_type_detail,t.n_long,t.n_is_group,t.l_group_id,	t.n_type,c.v_data_name"
+				+ "	FROM bpm_form_element t "
+				+ " LEFT JOIN bpm_data c ON t.n_field_type = c.n_value "
+				+ "	AND c.v_data_table = 'form_element' AND c.v_data_field = 'n_field_type' "
+				+ " LEFT JOIN bpm_flow_form_element bf ON bf.l_element_id = t.l_element_id "
+				+ " LEFT JOIN bpm_form_formula b ON b.l_form_id = bf.l_form_id "
+				+ "	AND b.l_form_id = t.l_form_id AND b.l_formula_id = bf.n_is_edit_detail "
+				+ "	WHERE 1 = 1 "
+				+ " AND t.l_form_id = ?"
+				+ " AND t.n_is_group = ?"
+				+ "	AND t.n_type != ?"
+				+ " AND bf.l_tmodel_id = ?"
+				+ " AND bf.n_state = 1 "
+				+ "  ORDER BY t.sort is null,t.sort asc "; 
+		List<Object> conditionList = new ArrayList<Object>();
+		conditionList.add(conditions.get("formId"));
+		conditionList.add(conditions.get("isGroup"));
+		conditionList.add(conditions.get("!type"));
+		conditionList.add(conditions.get("tmodelId"));
+		return SpringUtil.springQueryForList(jdbcTemplate, sql, conditionList.toArray(), new FormElementMapperAddBDDZ());
+	}
 
 }

+ 26 - 0
plugins/bpm/com/yw/bpm/form/model/FormElement.java

@@ -84,6 +84,15 @@ public class FormElement {
 	 */
 	private String groupId;
 	
+	/**
+	 * 깊데땡鱗츰냔
+	 */
+	private String bddz; 
+	/**
+	 * 깊데땡鱗방橙
+	 */
+	private String bddzText; 
+	
 	
 	private List<FormEnumValue> enumValueList = new ArrayList<FormEnumValue>();
 
@@ -352,4 +361,21 @@ public class FormElement {
 		this.enumValueList = enumValueList;
 	}
 
+	public String getBddz() {
+		return bddz;
+	}
+
+	public void setBddz(String bddz) {
+		this.bddz = bddz;
+	}
+
+	public String getBddzText() {
+		return bddzText;
+	}
+
+	public void setBddzText(String bddzText) {
+		this.bddzText = bddzText;
+	}
+	
+
 }