Commit 2c32ed93 by hzc

测试

parent 49f44161
...@@ -12,6 +12,7 @@ import com.keymobile.indicators.result.Result; ...@@ -12,6 +12,7 @@ import com.keymobile.indicators.result.Result;
import com.keymobile.indicators.service.ConfigInfoService; import com.keymobile.indicators.service.ConfigInfoService;
import com.keymobile.indicators.service.SystemAuthService; import com.keymobile.indicators.service.SystemAuthService;
import com.keymobile.indicators.service.dataenter.TaskRuleService; 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.LogManager;
import com.keymobile.indicators.utils.SystemUserUtil; import com.keymobile.indicators.utils.SystemUserUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -44,7 +45,8 @@ public class TaskRuleCtrl { ...@@ -44,7 +45,8 @@ public class TaskRuleCtrl {
@Autowired @Autowired
private SystemAuthService systemAuthService; private SystemAuthService systemAuthService;
@Autowired
private TaskService taskService;
@ApiOperation("根据规则类型和关键字分页查找任务规则") @ApiOperation("根据规则类型和关键字分页查找任务规则")
@GetMapping("findByPage") @GetMapping("findByPage")
public Page<TaskRule> findByPage(@ApiParam("规则类型:1 省级 2 市级 3 县级") public Page<TaskRule> findByPage(@ApiParam("规则类型:1 省级 2 市级 3 县级")
...@@ -81,26 +83,31 @@ public class TaskRuleCtrl { ...@@ -81,26 +83,31 @@ public class TaskRuleCtrl {
TaskRule temp = taskRuleService.findRuleByName(rule.getRuleLevel(), rule.getName()); TaskRule temp = taskRuleService.findRuleByName(rule.getRuleLevel(), rule.getName());
if (temp != null && !temp.getId().equals(rule.getId())) { if (temp != null && !temp.getId().equals(rule.getId())) {
result = Result.genFailedResult("已经存在同名任务规则定义!"); 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 { } else {
Date now = new Date(); TaskRule t = taskRuleService.getById(rule.getId(), false);
String currentUserId = SystemUserUtil.getCurrentUserId(); rule.setCreator(t.getCreator());
rule.setUpdater(currentUserId); rule.setCreateTime(t.getCreateTime());
rule.setUpdateTime(now); taskRuleService.updateRule(rule);
rule.setState(Constants.DATA_STATE_A); LogManager.logInfo(Constants.LOG_INDICATOR_TASK_START_API, "修改id={}, name={} 的任务规则", rule.getId(), rule.getName());
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);
} }
result = Result.genOkResult(rule);
return result; return result;
} }
@ApiOperation("根据机构编号获取对应的规则名类别") @ApiOperation("根据机构编号获取对应的规则名类别")
...@@ -109,30 +116,37 @@ public class TaskRuleCtrl { ...@@ -109,30 +116,37 @@ public class TaskRuleCtrl {
List<String> levels = new ArrayList<>(); List<String> levels = new ArrayList<>();
String key = ""; String key = "";
if(BooleanUtils.isTrue(sysAdmin)){ if(BooleanUtils.isTrue(sysAdmin)){
//省对应的规则级别 // //省对应的规则级别
ConfigInfo prinvinceConfigInfo= configInfoService.getConfigInfoById(Constants.RULE_NAME_PRINVINCE); // ConfigInfo prinvinceConfigInfo= configInfoService.getConfigInfoById(Constants.RULE_NAME_PRINVINCE);
//市对应的规则级别 // //市对应的规则级别
ConfigInfo cityConfigInfo= configInfoService.getConfigInfoById(Constants.RULE_NAME_CITY); // ConfigInfo cityConfigInfo= configInfoService.getConfigInfoById(Constants.RULE_NAME_CITY);
//县对应的规则级别 // //县对应的规则级别
ConfigInfo countyConfigInfo= configInfoService.getConfigInfoById(Constants.RULE_NAME_COUNTY); // ConfigInfo countyConfigInfo= configInfoService.getConfigInfoById(Constants.RULE_NAME_COUNTY);
StringBuffer value = new StringBuffer( prinvinceConfigInfo.getCfValue()); List<ConfigInfo> configInfos = configInfoService.getConfigInfoByLikeKey(Constants.TASK_TYPE_NAME);
value.append(Constants.SEP_COMMA); StringBuffer value = new StringBuffer("");
value.append(cityConfigInfo.getCfValue()); if(configInfos!=null&&configInfos.size()>0){
value.append(Constants.SEP_COMMA); value.append(configInfos.get(0).getCfValue());
value.append(countyConfigInfo.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); String[] split = value.toString().split(Constants.SEP_COMMA);
levels = Arrays.asList(split); levels = Arrays.asList(split);
}else if(StringUtils.isNotBlank(orgNo)){ }else if(StringUtils.isNotBlank(orgNo)){
switch (orgNo.length()){ // switch (orgNo.length()){
case 2: key=Constants.RULE_NAME_PRINVINCE; // case 2: key=Constants.RULE_NAME_PRINVINCE;
break; // break;
case 4: key = Constants.RULE_NAME_CITY; // case 4: key = Constants.RULE_NAME_CITY;
break; // break;
case 6: key = Constants.RULE_NAME_COUNTY; // case 6: key = Constants.RULE_NAME_COUNTY;
break; // break;
default: key=null; // default: key=null;
} // }
key=Constants.TASK_TYPE_NAME+orgNo;
if(key!=null){ if(key!=null){
ConfigInfo configInfoById = configInfoService.getConfigInfoById(key); ConfigInfo configInfoById = configInfoService.getConfigInfoById(key);
String cfValue = configInfoById.getCfValue(); String cfValue = configInfoById.getCfValue();
......
...@@ -224,7 +224,8 @@ public class Constants { ...@@ -224,7 +224,8 @@ public class Constants {
public static final String PRIVINCE_TO_COUNTY = "省对县"; public static final String PRIVINCE_TO_COUNTY = "省对县";
public static final String CITY_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_PRINVINCE = "RULE_NAME_PRINVINCE";
public static final String RULE_NAME_CITY = "RULE_NAME_CITY"; public static final String RULE_NAME_CITY = "RULE_NAME_CITY";
public static final String RULE_NAME_COUNTY = "RULE_NAME_COUNTY"; public static final String RULE_NAME_COUNTY = "RULE_NAME_COUNTY";
......
...@@ -30,4 +30,11 @@ public interface ConfigInfoMapper extends BaseMapper<ConfigInfo> { ...@@ -30,4 +30,11 @@ public interface ConfigInfoMapper extends BaseMapper<ConfigInfo> {
long findConfigInfoCount(@Param("keyword") String keyword); long findConfigInfoCount(@Param("keyword") String keyword);
ConfigInfo getById(@Param("id") String id); 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; ...@@ -4,6 +4,8 @@ import com.keymobile.indicators.model.entity.ConfigInfo;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.List;
/** /**
* 配置项管理服务接口 * 配置项管理服务接口
*/ */
...@@ -50,4 +52,13 @@ public interface ConfigInfoService { ...@@ -50,4 +52,13 @@ public interface ConfigInfoService {
* 刷新缓存 * 刷新缓存
*/ */
void refreshCache(); 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 { ...@@ -230,4 +230,11 @@ public interface TaskService {
* @Author hzc * @Author hzc
**/ **/
List<TaskIndValueTmp> findOldValueToEdit(Map<String,Object> maps); 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 { ...@@ -843,7 +843,60 @@ public class TaskServiceImpl implements TaskService {
return result; 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 @Override
public TaskAnalysisResult stateCounts(QueryTaskParam param) { public TaskAnalysisResult stateCounts(QueryTaskParam param) {
......
...@@ -70,4 +70,14 @@ public class ConfigInfoServiceImpl implements ConfigInfoService { ...@@ -70,4 +70,14 @@ public class ConfigInfoServiceImpl implements ConfigInfoService {
public void refreshCache() { public void refreshCache() {
redisCacheService.removeLike(CACHE_CONFIG_KEY_PRE); 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 @@ ...@@ -25,5 +25,9 @@
from config_info from config_info
where id = #{id} where id = #{id}
</select> </select>
<select id="findConfigInfoByLikeKey" resultType="com.keymobile.indicators.model.entity.ConfigInfo">
select *
from config_info
where id like concat(#{key},'%')
</select>
</mapper> </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