Commit 76d9f242 by 张祺

修改任务审批接口

parent 6fcbdfd8
package com.keymobile.indicators.api.hytobacco;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.keymobile.indicators.constant.Constants;
import com.keymobile.indicators.model.entity.AuthModel;
......@@ -64,10 +65,10 @@ public class DataEnterCtrl {
List<String> idList = Arrays.asList(ids);
switch (groupObj.getObjType()) {
case Constants.OBJ_TYPE_ORG:
List<JSONObject> orgs = systemAuthService.getOrgByIds(idList);
for (JSONObject jo : orgs) {
}
List<JSONObject> orgs = systemAuthService.getOrgByNos(idList);
// for (JSONObject jo : orgs) {
//
// }
break;
}
if (objs.isEmpty()) {
......
......@@ -42,7 +42,7 @@ public class TaskCtrl {
@ApiOperation("(启动)根据规则生成相关填报任务")
@GetMapping("generateTaskByRule")
public Result generateTaskByRule(@ApiParam("规则id") @RequestParam("ruleId") List<Integer> ruleIds,
public Result generateTaskByRule(@ApiParam("规则id") @RequestParam("ruleIds") List<Integer> ruleIds,
@ApiParam("收数月份, 格式: 2020-03、2020-06、2020-09、2020-12") @RequestParam("valueTime")String valueTime) {
Result result = null;
if (CollectionUtils.isNotEmpty(ruleIds)) {
......@@ -90,8 +90,7 @@ public class TaskCtrl {
@ApiOperation("提交任务去审核")
@GetMapping("toSubmit")
public Result toSubmit(@ApiParam("任务id") @RequestParam("taskId") String id) {
taskService.submitTask(id, SystemUserUtil.getCurrentUserId());
return Result.genOkResult();
return taskService.submitTask(id, SystemUserUtil.getCurrentUserId());
}
@ApiOperation("审核任务")
......
package com.keymobile.indicators.api.hytobacco;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.keymobile.indicators.constant.Constants;
import com.keymobile.indicators.model.entity.ConfigInfo;
......@@ -133,7 +134,8 @@ public class TaskRuleCtrl {
String value = configInfo.getCfValue();
List<String> ids = Arrays.asList(StringUtils.split(value, Constants.SEP_COMMA));
List<JSONObject> roles = systemAuthService.getRolesByIds(ids);
for (JSONObject role : roles) {
for (int i= 0; i < roles.size(); i++) {
JSONObject role = roles.get(i);
RoleModel r = new RoleModel();
r.setId(role.getString("id"));
r.setName(role.getString("disname"));
......
......@@ -139,5 +139,16 @@ public class Constants {
*/
public static final String RULE_COUNTY_AUDIT_ROLE = "COUNTY_AUDIT_ROLE";
/**
* ruleType=1 省级对标
*/
public static final int RULE_TYPE_PROVINCE = 1;
/**
* ruleType=2 市级对标
*/
public static final int RULE_TYPE_CITY = 2;
/**
* ruleType=3 县级对标
*/
public static final int RULE_TYPE_COUNTY = 3;
}
......@@ -4,7 +4,7 @@ import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@ApiModel("角色对象")
@ApiModel("组织对象")
public class OrgModel {
private String id;
......
......@@ -8,7 +8,7 @@ import lombok.Data;
@Data
public class QueryAllTaskParam {
@ApiModelProperty(name = "规则类型:1 省级 2 市级 3 县级")
@ApiModelProperty("规则类型:1 省级 2 市级 3 县级")
private Integer ruleType;
/**
* 任务级别:省对市 省对县 市对县
......@@ -19,15 +19,18 @@ public class QueryAllTaskParam {
/**
* 查询类型:1 查找填报人任务 2 查找审核人任务 3 查找全部
*/
@ApiModelProperty(name = "查询类型:1 查找填报人任务 2 查找审核人任务 3 查找全部")
@ApiModelProperty("查询类型:1 查找填报人任务 2 查找审核人任务 3 查找全部")
private int queryType = 1;
@ApiModelProperty(name = "搜索关键字(名字)")
@ApiModelProperty("搜索关键字(名字)")
private String keyword;
@ApiModelProperty(name = "填报时间")
@ApiModelProperty("填报时间")
private String valueTime;
@ApiModelProperty(name = "任务状态:1、填报中 2、审批中 3、审核通过 4、驳回")
@ApiModelProperty("任务状态:1、填报中 2、审批中 3、审核通过 4、驳回")
private Integer status;
@ApiModelProperty("归属部门,对应数据项的归属部门")
private String refIndDept;
@ApiModelProperty("当前用户id,不用传")
private String userId;
}
......@@ -8,7 +8,7 @@ import lombok.Data;
@Data
public class QueryTaskParam {
@ApiModelProperty(name = "规则类型:1 省级 2 市级 3 县级")
@ApiModelProperty("规则类型:1 省级 2 市级 3 县级")
private Integer ruleType;
/**
......@@ -19,20 +19,23 @@ public class QueryTaskParam {
/**
* 查询类型:1 查找填报人任务 2 查找审核人任务 3 查找全部
*/
@ApiModelProperty(name = "查询类型:1 查找填报人任务 2 查找审核人任务 3 查找全部")
@ApiModelProperty("查询类型:1 查找填报人任务 2 查找审核人任务 3 查找全部")
private int queryType = 1;
private String userId;
@ApiModelProperty(name = "搜索关键字(名字)")
@ApiModelProperty("搜索关键字(名字)")
private String keyword;
@ApiModelProperty(name = "填报时间")
@ApiModelProperty("填报时间")
private String valueTime;
@ApiModelProperty(name = "任务状态:1、填报中 2、审批中 3、审核通过 4、驳回")
@ApiModelProperty("任务状态:1、填报中 2、审批中 3、审核通过 4、驳回")
private Integer status;
@ApiModelProperty(name = "页码,从1开始")
@ApiModelProperty("归属部门,对应数据项的归属部门")
private String refIndDept;
@ApiModelProperty("页码,从1开始")
private int page = 1;
@ApiModelProperty(name = "每页条数")
@ApiModelProperty("每页条数")
private int pageSize = 10;
/**
......
......@@ -56,6 +56,9 @@ public class Task extends BaseModel {
@ApiModelProperty("任务规则名称")
private String ruleName;
@ApiModelProperty("归属部门(指标归属部门)")
private String refIndDept;
/**
* 任务单位id
*/
......@@ -94,6 +97,11 @@ public class Task extends BaseModel {
private String auditUsers;
/**
* 审核人员名字,多个用,分割
*/
private String auditUserNames;
/**
* 填报角色名称,多个用,分割
*/
@ApiModelProperty("填报对象,多个用,分割")
......
......@@ -58,5 +58,17 @@ public interface TaskMapper extends BaseMapper<Task> {
*/
List<Task> findAllTask(QueryAllTaskParam param);
/**
* 根据审批状态统计任务
* @param param
* @return
*/
List<TaskStatusCountResult> countTask(QueryTaskParam param);
/**
* 根据id获取任务
* @param taskId
* @return
*/
Task getById(String taskId);
}
......@@ -24,12 +24,12 @@ public interface SystemAuthService {
* @return
*/
@GetMapping("/user/list")
List<JSONObject> findUserList(@RequestParam(value = "roleId", required = false) String roleId,
@RequestParam(value = "filter")boolean filter,
@RequestParam(value = "userId", required = false)String userId,
@RequestParam(value = "orgNo", required = false)String orgNo,
@RequestParam(value = "disname", required = false)String disname,
@RequestParam(value = "page")int page, @RequestParam(value = "size")int size);
JSONObject findUserList(@RequestParam(value = "roleId", required = false) String roleId,
@RequestParam(value = "filter")boolean filter,
@RequestParam(value = "userId", required = false)String userId,
@RequestParam(value = "orgNo", required = false)String orgNo,
@RequestParam(value = "disname", required = false)String disname,
@RequestParam(value = "page")int page, @RequestParam(value = "size")int size);
/**
* 根据角色id列表获取角色列表
......@@ -40,11 +40,11 @@ public interface SystemAuthService {
List<JSONObject> getRolesByIds(@RequestParam("roleIds")List<String> roleIds);
/**
* 根据机构id列表获取角色列表
* @param orgIds
* 根据机构编号列表获取角色列表
* @param nos
* @return
*/
@GetMapping("/org/getByIds")
List<JSONObject> getOrgByIds(@RequestParam("orgIds")List<String> orgIds);
@GetMapping("/org/getByNos")
List<JSONObject> getOrgByNos(@RequestParam("nos")List<String> nos);
}
......@@ -121,7 +121,7 @@ public interface TaskService {
* @param taskId
* @param userId 提交人id
*/
void submitTask(String taskId, String userId);
Result submitTask(String taskId, String userId);
/**
* 审批任务
......
package com.keymobile.indicators.service.dataenter.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimaps;
import com.keymobile.indicators.constant.Constants;
import com.keymobile.indicators.model.entity.ConfigInfo;
import com.keymobile.indicators.model.entity.RoleRefUserModel;
import com.keymobile.indicators.model.entity.dataenter.*;
import com.keymobile.indicators.model.entity.indicators.BaseIndDef;
import com.keymobile.indicators.model.mapper.indicators.*;
import com.keymobile.indicators.result.Result;
import com.keymobile.indicators.service.ConfigInfoService;
import com.keymobile.indicators.service.SystemAuthService;
import com.keymobile.indicators.service.dataenter.TaskRuleService;
import com.keymobile.indicators.service.dataenter.TaskService;
......@@ -17,6 +21,7 @@ import com.keymobile.indicators.utils.DateUtils;
import com.keymobile.indicators.utils.IdWorker;
import com.keymobile.indicators.utils.LogManager;
import com.keymobile.indicators.utils.SystemUserUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -32,6 +37,7 @@ import java.util.Date;
import java.util.List;
@Service
@Slf4j
public class TaskServiceImpl implements TaskService {
@Autowired
......@@ -58,6 +64,12 @@ public class TaskServiceImpl implements TaskService {
@Autowired
private IndicatorsRelService indRelService;
@Autowired
private ConfigInfoService configInfoService;
@Autowired
private TaskRuleObjMapper taskRuleObjMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Task createTask(Task task) {
......@@ -199,11 +211,13 @@ public class TaskServiceImpl implements TaskService {
//角色
List<RoleRefUserModel> users = new ArrayList<>();
for (String obj : objIds) {
List<JSONObject> list =
JSONObject rolePage =
systemAuthService.findUserList(obj, true,
null, null, null, 1, 100);
if (CollectionUtils.isNotEmpty(list)) {
for (JSONObject jo : list) {
JSONArray list = rolePage.getJSONArray("content");
if (list != null && list.size() > 0) {
for (int i = 0; i< list.size(); i++) {
JSONObject jo = list.getJSONObject(i);
RoleRefUserModel user = new RoleRefUserModel();
user.setId(jo.getString("id"));
user.setDisName(jo.getString("disname"));
......@@ -222,32 +236,81 @@ public class TaskServiceImpl implements TaskService {
@Override
@Transactional(rollbackFor = Exception.class)
public void submitTask(String taskId, String userId) {
public Result submitTask(String taskId, String userId) {
Result result = null;
Date now = new Date();
Task task = taskMapper.selectByPrimaryKey(taskId);
//TODO
task.setAuditUsers(",1,");
task.setUpdater(userId);
task.setUpdateTime(now);
task.setStatus(Constants.APPLY_STATE_AUDITING);
taskMapper.updateByPrimaryKey(task);
AuditRecord auditRecord = new AuditRecord();
auditRecord.setRecordType("提交");
auditRecord.setTaskId(taskId);
auditRecord.setId(IdWorker.getStrId());
auditRecord.setPTaskId(task.getPId());
auditRecord.setCreator(userId);
auditRecord.setUpdater(userId);
auditRecord.setUpdateTime(now);
auditRecord.setCreateTime(now);
taskAuditRecordMapper.insert(auditRecord);
Task task = taskMapper.getById(taskId);
Integer ruleType = task.getRuleType();
ConfigInfo configInfo = null;
switch (ruleType) {
case Constants.RULE_TYPE_PROVINCE:
configInfo = configInfoService.getConfigInfoById(Constants.RULE_PROVINCE_AUDIT_ROLE);
break;
case Constants.RULE_TYPE_CITY:
configInfo = configInfoService.getConfigInfoById(Constants.RULE_CITY_AUDIT_ROLE);
break;
case Constants.RULE_TYPE_COUNTY:
configInfo = configInfoService.getConfigInfoById(Constants.RULE_COUNTY_AUDIT_ROLE);
break;
default:
configInfo = configInfoService.getConfigInfoById(Constants.RULE_PROVINCE_AUDIT_ROLE);
break;
}
if (configInfo != null) {
String indDept = task.getRefIndDept();
List<RoleRefUserModel> users = getUserByRoleIdStr(configInfo.getCfValue());
if (CollectionUtils.isNotEmpty(users)) {
StringBuilder userIds = new StringBuilder(Constants.SEP_COMMA);
StringBuilder userNames = new StringBuilder(Constants.SEP_COMMA);
boolean found = false;
for (RoleRefUserModel userModel : users) {
if (StringUtils.equals(userModel.getRefIndDept(), indDept)) {
found = true;
userIds.append(userModel.getId());
userIds.append(Constants.SEP_COMMA);
userNames.append(userModel.getDisName());
userNames.append(Constants.SEP_COMMA);
}
}
if (found) {
task.setAuditUsers(userIds.toString());
task.setAuditUserNames(userNames.toString());
task.setUpdater(userId);
task.setUpdateTime(now);
task.setStatus(Constants.APPLY_STATE_AUDITING);
taskMapper.updateByPrimaryKey(task);
AuditRecord auditRecord = new AuditRecord();
auditRecord.setRecordType("提交");
auditRecord.setTaskId(taskId);
auditRecord.setId(IdWorker.getStrId());
auditRecord.setPTaskId(task.getPId());
auditRecord.setCreator(userId);
auditRecord.setUpdater(userId);
auditRecord.setUpdateTime(now);
auditRecord.setCreateTime(now);
taskAuditRecordMapper.insert(auditRecord);
result = Result.genOkResult();
LogManager.logInfo(Constants.LOG_CONTEXT_API, "提交任务id:{},name:{}到审核",
taskId, task.getRuleName());
} else {
result = Result.genFailedResult("此配置此任务审批人,ruleType=" + ruleType + ",归属部门=" + indDept);
}
} else {
result = Result.genFailedResult("系统配置的角色没有用户,ruleType=" + ruleType);
}
} else {
result = Result.genFailedResult("系统没有配置此任务的审批角色,ruleType=" + ruleType);
LogManager.logInfo(Constants.LOG_CONTEXT_API, "提交任务taskId={}失败没有配置ruleType={}的审批角色",
taskId, ruleType);
}
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void auditTask(TaskAuditResult auditResult, String auditUserId) {
Date now = new Date();
Task task = taskMapper.selectByPrimaryKey(auditResult.getTaskId());
Task task = taskMapper.getById(auditResult.getTaskId());
task.setUpdateTime(now);
int status = Constants.APPLY_STATE_REJECTED;
String recordType = "审批拒绝";
......@@ -255,11 +318,13 @@ public class TaskServiceImpl implements TaskService {
status = Constants.APPLY_STATE_PASSED;
recordType = "审批通过";
taskIndValueMapper.updateTaskValueToPass(task.getId());
createCountIndValues(task);
}
task.setStatus(status);
taskMapper.updateByPrimaryKey(task);
AuditRecord auditRecord = new AuditRecord();
auditRecord.setRecordType(recordType);
auditRecord.setDescription(auditResult.getDescription());
auditRecord.setTaskId(task.getId());
auditRecord.setId(IdWorker.getStrId());
auditRecord.setPTaskId(task.getPId());
......@@ -268,6 +333,23 @@ public class TaskServiceImpl implements TaskService {
auditRecord.setUpdateTime(now);
auditRecord.setCreateTime(now);
taskAuditRecordMapper.insert(auditRecord);
LogManager.logInfo(Constants.LOG_CONTEXT_API, "{}任务:{}Id:{},ruleId:{}, ruleLevel:{}",
recordType, task.getRuleName(), task.getId(), task.getRuleId(), task.getRuleLevel());
}
/**
* 通过填报值计算出包含公式的数据项值
* @param task
*/
private void createCountIndValues(Task task) {
List<TaskIndicator> inds = taskIndicatorMapper.getByTaskId(task.getId());
List<TaskIndValue> values = taskIndValueMapper.getByTaskId(task.getId());
for (TaskIndicator taskIndicator : inds) {
if (StringUtils.isNotBlank(taskIndicator.getIndFormula())) {
//TODO
taskRuleObjMapper.getById(task.getGroupId());
}
}
}
@Override
......@@ -309,6 +391,39 @@ public class TaskServiceImpl implements TaskService {
}
}
/**
* 根据角色id字符串获取关联的用户信息
* @param roleIdStr
* @return
*/
private List<RoleRefUserModel> getUserByRoleIdStr(String roleIdStr) {
List<RoleRefUserModel> users = new ArrayList<>();
String[] roleIds = StringUtils.split(roleIdStr, Constants.SEP_COMMA);
for (String roleId : roleIds) {
JSONObject rolePage =
systemAuthService.findUserList(roleId, true,
null, null, null, 1, 100);
JSONArray list = rolePage.getJSONArray("content");
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
JSONObject jo = list.getJSONObject(i);
RoleRefUserModel user = new RoleRefUserModel();
user.setId(jo.getString("id"));
user.setDisName(jo.getString("disname"));
user.setRefIndDept(jo.getString("refIndDept"));
String refIndDept = user.getRefIndDept();
if (StringUtils.isBlank(refIndDept)) {
continue;
}
if (!users.contains(user)) {
users.add(user);
}
}
}
}
return users;
}
@Override
public Result createTaskByRule(Integer ruleId, String valueTime) {
Result result = null;
......@@ -316,28 +431,7 @@ public class TaskServiceImpl implements TaskService {
if (rule != null) {
String roleIdStr = rule.getToRoleIds();
if (StringUtils.isNotBlank(roleIdStr)) {
String[] roleIds = StringUtils.split(roleIdStr, Constants.SEP_COMMA);
List<RoleRefUserModel> users = new ArrayList<>();
for (String roleId : roleIds) {
List<JSONObject> list =
systemAuthService.findUserList(roleId, true,
null, null, null, 1, 100);
if (CollectionUtils.isNotEmpty(list)) {
for (JSONObject jo : list) {
RoleRefUserModel user = new RoleRefUserModel();
user.setId(jo.getString("id"));
user.setDisName(jo.getString("disname"));
user.setRefIndDept(jo.getString("refIndDept"));
String refIndDept = user.getRefIndDept();
if (StringUtils.isBlank(refIndDept)) {
continue;
}
if (!users.contains(user)) {
users.add(user);
}
}
}
}
List<RoleRefUserModel> users = getUserByRoleIdStr(roleIdStr);
if (users.size() > 0) {
List<TaskRuleIndicator> indicators = rule.getIndicators();
if (CollectionUtils.isNotEmpty(indicators)) {
......@@ -386,6 +480,7 @@ public class TaskServiceImpl implements TaskService {
task.setRuleId(rule.getId());
task.setRuleLevel(rule.getRuleLevel());
task.setGroupId(rule.getGroupId());
task.setRefIndDept(dept);
task.setDescription(rule.getDescription());
StringBuilder userNames = new StringBuilder(Constants.SEP_COMMA);
StringBuilder userIds = new StringBuilder(Constants.SEP_COMMA);
......
......@@ -3,6 +3,12 @@
<mapper namespace="com.keymobile.indicators.model.mapper.indicators.TaskMapper">
<select id="getById" resultType="com.keymobile.indicators.model.entity.dataenter.Task">
select *
from data_enter_task
where id = #{taskId}
</select>
<select id="getByRuleIdAndValueTime" parameterType="java.lang.Object"
resultType="com.keymobile.indicators.model.entity.dataenter.Task" >
select *
......@@ -52,6 +58,10 @@
<if test="ruleLevel != null and ruleLevel !=''">
and rule_level = #{ruleLevel}
</if>
<if test="refIndDept != null and refIndDept !=''">
and ref_ind_dept = #{refIndDept}
</if>
<if test="userId != null">
<choose>
<when test="queryType == 1">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment