Commit 2c32ed93 by hzc

测试

parent 49f44161
......@@ -12,6 +12,7 @@ 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;
import com.keymobile.indicators.utils.LogManager;
import com.keymobile.indicators.utils.SystemUserUtil;
import io.swagger.annotations.Api;
......@@ -44,7 +45,8 @@ public class TaskRuleCtrl {
@Autowired
private SystemAuthService systemAuthService;
@Autowired
private TaskService taskService;
@ApiOperation("根据规则类型和关键字分页查找任务规则")
@GetMapping("findByPage")
public Page<TaskRule> findByPage(@ApiParam("规则类型:1 省级 2 市级 3 县级")
......@@ -81,26 +83,31 @@ public class TaskRuleCtrl {
TaskRule temp = taskRuleService.findRuleByName(rule.getRuleLevel(), rule.getName());
if (temp != null && !temp.getId().equals(rule.getId())) {
result = Result.genFailedResult("已经存在同名任务规则定义!");
return result;
}
result= taskService.checkTask(rule);
//检查规则是否合理
if(!result.isSuccess()){
return result;
}
Date now = new Date();
String currentUserId = SystemUserUtil.getCurrentUserId();
rule.setUpdater(currentUserId);
rule.setUpdateTime(now);
rule.setState(Constants.DATA_STATE_A);
if (rule.getId() == null || rule.getId() == 0) {
rule.setCreateTime(now);
rule.setCreator(currentUserId);
taskRuleService.createRule(rule);
LogManager.logInfo(Constants.LOG_INDICATOR_TASK_START_API, "创建了规则id={},name={}", rule.getId(), rule.getName());
} else {
Date now = new Date();
String currentUserId = SystemUserUtil.getCurrentUserId();
rule.setUpdater(currentUserId);
rule.setUpdateTime(now);
rule.setState(Constants.DATA_STATE_A);
if (rule.getId() == null || rule.getId() == 0) {
rule.setCreateTime(now);
rule.setCreator(currentUserId);
taskRuleService.createRule(rule);
LogManager.logInfo(Constants.LOG_INDICATOR_TASK_START_API, "创建了规则id={},name={}", rule.getId(), rule.getName());
} else {
TaskRule t = taskRuleService.getById(rule.getId(), false);
rule.setCreator(t.getCreator());
rule.setCreateTime(t.getCreateTime());
taskRuleService.updateRule(rule);
LogManager.logInfo(Constants.LOG_INDICATOR_TASK_START_API, "修改id={}, name={} 的任务规则", rule.getId(), rule.getName());
}
result = Result.genOkResult(rule);
TaskRule t = taskRuleService.getById(rule.getId(), false);
rule.setCreator(t.getCreator());
rule.setCreateTime(t.getCreateTime());
taskRuleService.updateRule(rule);
LogManager.logInfo(Constants.LOG_INDICATOR_TASK_START_API, "修改id={}, name={} 的任务规则", rule.getId(), rule.getName());
}
result = Result.genOkResult(rule);
return result;
}
@ApiOperation("根据机构编号获取对应的规则名类别")
......@@ -109,30 +116,37 @@ public class TaskRuleCtrl {
List<String> levels = new ArrayList<>();
String key = "";
if(BooleanUtils.isTrue(sysAdmin)){
//省对应的规则级别
ConfigInfo prinvinceConfigInfo= configInfoService.getConfigInfoById(Constants.RULE_NAME_PRINVINCE);
//市对应的规则级别
ConfigInfo cityConfigInfo= configInfoService.getConfigInfoById(Constants.RULE_NAME_CITY);
//县对应的规则级别
ConfigInfo countyConfigInfo= configInfoService.getConfigInfoById(Constants.RULE_NAME_COUNTY);
StringBuffer value = new StringBuffer( prinvinceConfigInfo.getCfValue());
value.append(Constants.SEP_COMMA);
value.append(cityConfigInfo.getCfValue());
value.append(Constants.SEP_COMMA);
value.append(countyConfigInfo.getCfValue());
// //省对应的规则级别
// ConfigInfo prinvinceConfigInfo= configInfoService.getConfigInfoById(Constants.RULE_NAME_PRINVINCE);
// //市对应的规则级别
// ConfigInfo cityConfigInfo= configInfoService.getConfigInfoById(Constants.RULE_NAME_CITY);
// //县对应的规则级别
// ConfigInfo countyConfigInfo= configInfoService.getConfigInfoById(Constants.RULE_NAME_COUNTY);
List<ConfigInfo> configInfos = configInfoService.getConfigInfoByLikeKey(Constants.TASK_TYPE_NAME);
StringBuffer value = new StringBuffer("");
if(configInfos!=null&&configInfos.size()>0){
value.append(configInfos.get(0).getCfValue());
}
if(configInfos.size()>1){
for(int i=1;i<configInfos.size();i++){
value.append(Constants.SEP_COMMA);
value.append(configInfos.get(i).getCfValue());
}
}
String[] split = value.toString().split(Constants.SEP_COMMA);
levels = Arrays.asList(split);
}else if(StringUtils.isNotBlank(orgNo)){
switch (orgNo.length()){
case 2: key=Constants.RULE_NAME_PRINVINCE;
break;
case 4: key = Constants.RULE_NAME_CITY;
break;
case 6: key = Constants.RULE_NAME_COUNTY;
break;
default: key=null;
}
// switch (orgNo.length()){
// case 2: key=Constants.RULE_NAME_PRINVINCE;
// break;
// case 4: key = Constants.RULE_NAME_CITY;
// break;
// case 6: key = Constants.RULE_NAME_COUNTY;
// break;
// default: key=null;
// }
key=Constants.TASK_TYPE_NAME+orgNo;
if(key!=null){
ConfigInfo configInfoById = configInfoService.getConfigInfoById(key);
String cfValue = configInfoById.getCfValue();
......
......@@ -224,7 +224,8 @@ public class Constants {
public static final String PRIVINCE_TO_COUNTY = "省对县";
public static final String CITY_TO_COUNTY = "市对县";
//获取规则类别:TASK_TYPE_NAME_机构编码
public static final String TASK_TYPE_NAME = "TASK_TYPE_NAME_";
public static final String RULE_NAME_PRINVINCE = "RULE_NAME_PRINVINCE";
public static final String RULE_NAME_CITY = "RULE_NAME_CITY";
public static final String RULE_NAME_COUNTY = "RULE_NAME_COUNTY";
......
......@@ -30,4 +30,11 @@ public interface ConfigInfoMapper extends BaseMapper<ConfigInfo> {
long findConfigInfoCount(@Param("keyword") String keyword);
ConfigInfo getById(@Param("id") String id);
/**
* @Description 查询任务级别-管理员 key模糊查询 右模糊
* @Param [taskTypeName]
* @Date 2021/1/19 15:33
* @Author hzc
**/
List<ConfigInfo> findConfigInfoByLikeKey(@Param("key")String key);
}
......@@ -4,6 +4,8 @@ import com.keymobile.indicators.model.entity.ConfigInfo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* 配置项管理服务接口
*/
......@@ -50,4 +52,13 @@ public interface ConfigInfoService {
* 刷新缓存
*/
void refreshCache();
/**
* @Description 查询任务级别-管理员 key模糊查询 右模糊
* @Param [taskTypeName]
* @Date 2021/1/19 15:33
* @Author hzc
**/
List<ConfigInfo> getConfigInfoByLikeKey(String key);
}
......@@ -230,4 +230,11 @@ public interface TaskService {
* @Author hzc
**/
List<TaskIndValueTmp> findOldValueToEdit(Map<String,Object> maps);
/**
* @Description 检查规则的合理性
* @Param [rule]
* @Date 2021/1/19 14:52
* @Author hzc
**/
Result checkTask( TaskRule rule);
}
......@@ -843,7 +843,60 @@ public class TaskServiceImpl implements TaskService {
return result;
}
/**
* @Description 检查规则的合理性
* @Param [rule]
* @Date 2021/1/19 14:52
* @Author hzc
**/
@Override
public Result checkTask( TaskRule rule){
Integer ruleId= rule.getId();
Result result = Result.genOkResult();
String roleIdStr = rule.getToRoleIds();
if (StringUtils.isNotBlank(roleIdStr)) {
List<RoleRefUserModel> users = getUserByRoleIdStr(roleIdStr);
if (users.size() > 0) {
List<TaskRuleIndicator> indicators = rule.getIndicators();
if (CollectionUtils.isNotEmpty(indicators)) {
List<TaskIndicator> taskIndicators = new ArrayList<>();
for (TaskRuleIndicator indicator : indicators) {
List<BaseIndDef> baseIndDefs =this.indRelService.getRelByIndId(indicator.getIndId(), "1");
getBaseIndDef(ruleId, null, baseIndDefs, taskIndicators);
}
if (CollectionUtils.isNotEmpty(taskIndicators)) {
//数据项按归属部门分组
ImmutableListMultimap<String, TaskIndicator> deptMapInds =
Multimaps.index(taskIndicators, (taskIndicator) -> taskIndicator.getIndDept());
//角色关联用户按归属部门分组
ImmutableListMultimap<String, RoleRefUserModel> deptUsers =
Multimaps.index(users, (roleRefUser) -> roleRefUser.getRefIndDept());
for (String dept : deptMapInds.keySet()) {
List<RoleRefUserModel> refUsers = deptUsers.get(dept);
if (CollectionUtils.isEmpty(refUsers)) {
result = Result.genFailedResult("该规则对应的数据项所属部门{" + dept + "}找不到对应的用户");
break;
}
} }else {
result = Result.genFailedResult("规则配置的指标没有可用的数据项");
}
} else {
result = Result.genFailedResult("规则没有配置相关的指标");
}
} else {
result = Result.genFailedResult("找不到用户来生成任务");
}
} else {
result = Result.genFailedResult("规则没有配置对应的下发对象");
}
if (result.isSuccess()) {
LogManager.logInfo(Constants.LOG_INDICATOR_TASK_START_API, "检查任务id:{},名字:{}-正常", rule.getId(), rule.getName() );
} else {
LogManager.logInfo(Constants.LOG_INDICATOR_TASK_START_API, "检查任务id:{},名字:{}-失败, {}",
rule.getId(), rule.getName(), result.getMsg() );
}
return result;
}
@Override
public TaskAnalysisResult stateCounts(QueryTaskParam param) {
......
......@@ -70,4 +70,14 @@ public class ConfigInfoServiceImpl implements ConfigInfoService {
public void refreshCache() {
redisCacheService.removeLike(CACHE_CONFIG_KEY_PRE);
}
/**
* @Description 查询任务级别-管理员 key模糊查询 右模糊
* @Param [taskTypeName]
* @Date 2021/1/19 15:33
* @Author hzc
**/
@Override
public List<ConfigInfo> getConfigInfoByLikeKey(String key) {
return configInfoMapper.findConfigInfoByLikeKey(key);
}
}
......@@ -25,5 +25,9 @@
from config_info
where id = #{id}
</select>
<select id="findConfigInfoByLikeKey" resultType="com.keymobile.indicators.model.entity.ConfigInfo">
select *
from config_info
where id like concat(#{key},'%')
</select>
</mapper>
\ No newline at end of file
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