private void del(String id) { bpmConfigDaoImpl.updateToDelete(BusinessConstant.DELETE_YES, id); List<BpmConfigRange> list = bpmConfigRangeDaoImpl.findByConfigId(id); for (BpmConfigRange bpmConfigRange : list) { bpmConfigRangeDaoImpl.updateToDelete(BusinessConstant.DELETE_YES, bpmConfigRange.getId()); } }
/** * 保存发布范围 saveRange(这里用一句话描述这个方法的作用) * * @param entity * @return void * @exception */ public void saveRange(BpmConfig entity) { List<BpmConfigRange> rangeList = findByConfigId(entity.getId()); for (BpmConfigRange range : rangeList) { delete(range); } if (entity.getRangeJson() != null) { JSONObject jsonObject = JSONObject.fromObject(entity.getRangeJson()); if (jsonObject != null) { JSONArray userArray = jsonObject.getJSONArray("users"); for (int i = 0; i < userArray.size(); i++) { if (userArray.getJSONObject(i) != null) { BpmConfigRange range = new BpmConfigRange(); range.setR_id(userArray.getJSONObject(i).getString("id")); range.setName(userArray.getJSONObject(i).getString("cname")); range.setDept_path(userArray.getJSONObject(i).getString("deptPath")); range.setDept_name(userArray.getJSONObject(i).getString("deptName")); range.setType(BusinessConstant.RANGE_TYPE_USER); range.setTemplateConfig(entity); add(range); } } JSONArray deptArray = jsonObject.getJSONArray("departments"); for (int i = 0; i < deptArray.size(); i++) { if (deptArray.getJSONObject(i) != null) { BpmConfigRange range = new BpmConfigRange(); if (deptArray.getJSONObject(i).get("includesub") != null) range.setIncludesub(deptArray.getJSONObject(i).getBoolean("includesub")); range.setR_id(deptArray.getJSONObject(i).getString("id")); range.setDept_path(deptArray.getJSONObject(i).getString("deptPath")); range.setDept_name(deptArray.getJSONObject(i).getString("deptName")); range.setType(BusinessConstant.RANGE_TYPE_DEPT); range.setTemplateConfig(entity); add(range); } } JSONArray jobsArray = jsonObject.getJSONArray("jobs"); for (int i = 0; i < jobsArray.size(); i++) { if (jobsArray.getJSONObject(i) != null) { BpmConfigRange range = new BpmConfigRange(); range.setR_id(jobsArray.getJSONObject(i).getString("id")); range.setName(jobsArray.getJSONObject(i).getString("cname")); range.setDept_path(jobsArray.getJSONObject(i).getString("deptPath")); range.setDept_name(jobsArray.getJSONObject(i).getString("deptName")); range.setType(BusinessConstant.RANGE_TYPE_POST); range.setTemplateConfig(entity); add(range); } } JSONArray rolesArray = jsonObject.getJSONArray("roles"); for (int i = 0; i < rolesArray.size(); i++) { if (rolesArray.getJSONObject(i) != null) { BpmConfigRange range = new BpmConfigRange(); range.setR_id(rolesArray.getJSONObject(i).getString("id")); range.setName(rolesArray.getJSONObject(i).getString("cname")); range.setType(BusinessConstant.RANGE_TYPE_ROLE); range.setTemplateConfig(entity); add(range); } } } } }