/** * 针对单个数据集操作 包括增删改 * * @param details * @throws Exception */ public void saveSupportevaluation(Collection<Supportevaluation> details) throws Exception { if (null != details && details.size() > 0) { for (Supportevaluation item : details) { EntityState state = EntityUtils.getState(item); IUser loginUser = ContextHolder.getLoginUser(); String ucn = loginUser.getCname(); String un = loginUser.getUsername(); Date myDate = new Date(); if (state.equals(EntityState.NEW)) { fileManager(item); supportevaluationDao.saveData(item); // 对用户新增操作进行记录,在用户操作日志表中新增一条记录。 userOperationLogManager.recordUserOperationLog(0, myDate, un, ucn, "对保障评估表新增一条记录"); } else if (state.equals(EntityState.MODIFIED)) { fileManager(item); supportevaluationDao.updateData(item); // 对用户修改操作进行记录,在用户操作日志表中新增一条记录。 userOperationLogManager.recordUserOperationLog(1, myDate, un, ucn, "对保障评估表修改选定记录"); } else if (state.equals(EntityState.DELETED)) { supportevaluationDao.deleteData(item); // 对用户删除操作进行记录,在用户操作日志表中新增一条记录。 userOperationLogManager.recordUserOperationLog(2, myDate, un, ucn, "对保障评估表删除选定记录"); // fileManager(item); FileHelper.deleteFile("/Out_Supportevaluation/" + item.getOid()); // 删除相关文件 } else if (state.equals(EntityState.NONE)) { } } } }
/** * 新增订单 * * @param order * @throws Exception */ @Expose public void saveMoMaoOrders(Order order) throws Exception { IUser user = ContextHolder.getLoginUser(); if (user == null) { throw new NoneLoginException("Please login first"); } List<IDept> depts = deptService.loadUserDepts(user.getUsername()); if (depts == null || depts.size() == 0) { throw new Exception("您当前不属于任何部门,请联系管理员添加"); } String deptIds = deptUtil.getDeptIds(depts); // 查找所有要提交的记录 List<Record> list = recordUtil.getSubmitRecords(Constants.momao); if (list == null || list.size() == 0) { throw new Exception("没有需要提交的记录"); } order.setCrUser(user.getUsername()); order.setCrTime(new Date()); order.setDelTag(0); order.setOrderStatus(Constants.OrderDefaultStatus); order.setOrderStatusStr(Constants.OrderDefaultStatusStr); // 设置部门id order.setDeptId(deptIds); order.setType(Constants.momao); order = this.saveOrUpdate(order).get(0); // 保存部门和订单的关联关系 deptUtil.saveOrderDept(depts, order.getOrderId()); // 更新记录的订单ID和状态 recordUtil.updateRecordOrderId(list, order.getOrderId()); // 提交工作流 StartProcessInfo info = new StartProcessInfo(); // 流程发起人 info.setPromoter(user.getUsername()); // 订单ID info.setBusinessId(order.getOrderId().toString()); // 是否完成了开始节点,我们设置为true,表示自动提交到下一个节点 info.setCompleteStartTask(true); // 选择下一个节点采用哪个分支 // info.setSequenceFlowName(""); // 增加标记,每个实例中可以获取到 // info.setTag(""); // 传入变量到流程中,流程中可以通过EL表达式获取 Map<String, Object> variables = new HashMap<String, Object>(); variables.put("msg", "【正审】"); info.setVariables(variables); processClient.startProcessByName("磨毛审批流程", info); }
@DataProvider public void loadStudentDangAnsOnlyView(Page<OaOrder> page, Criteria criteria) throws Exception { IUser user = ContextHolder.getLoginUser(); if (user == null) { throw new NoneLoginException("Please login first"); } String userNameString = user.getUsername(); // 替换前台传入的字段名称(关联查询) Map<String, String> propertyMap = new HashMap<String, String>(); // 学生 propertyMap.put("fatherLink", "student.fatherLink"); propertyMap.put("motherLink", "student.motherLink"); propertyMap.put("otherLink", "student.otherLink"); propertyMap.put("school", "student.school"); propertyMap.put("sex", "student.sex"); // 项目组 propertyMap.put("proheader", "projectInfo.header"); // 判断登录人是不是 “校领导”角色 String queryLimitString = ""; boolean isLeader = roleCheckService.checkUserIsLeaderByGroup(userNameString, Constants.sLeaderGroupName); if (!isLeader && !user.isAdministrator()) { // 根据登陆用户获取 用户所在群组,只能查看自己群组的项目 String groupIds = roleCheckService.getGroupIdsByUserName(userNameString); if (!"".equals(groupIds)) { queryLimitString = " and c.projectInfo.groupId in ('" + groupIds + "') "; } } this.replaceProperty(criteria, propertyMap); String hql = "from " + OaOrder.class.getName() + " c where 1=1 and delTag is null "; if (!queryLimitString.isEmpty()) { hql += " " + queryLimitString; } ParseResult result = this.parseCriteria(criteria, true, "c"); // 排序sql String orderSql = this.buildOrderSql(criteria, "c"); // 默认时间倒叙排列 orderSql = OrderByUtil.createOrderStr(orderSql, "c", "createDate", "desc"); if (result != null) { hql += " and " + result.getAssemblySql().toString(); this.pagingQuery(page, hql + orderSql, "select count(*) " + hql, result.getValueMap()); } else { this.pagingQuery(page, hql + orderSql, "select count(*) " + hql); } }
/** * 学生档案中修改订单信息 * * @param projectInfos * @throws Exception */ @DataResolver public void updateStudentDangAn(Collection<OaOrder> oaOrderInfos) throws Exception { IUser user = ContextHolder.getLoginUser(); if (user == null) { throw new NoneLoginException("Please login first"); } Session session = this.getSessionFactory().openSession(); try { for (OaOrder oaOrder : oaOrderInfos) { EntityState state = EntityUtils.getState(oaOrder); if (state.equals(EntityState.MODIFIED)) { session.update(oaOrder); } } } finally { session.flush(); session.close(); } }