Commit 9c019284 by 张祺

修改审批汇总数据功能

parent 83d6db98
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.AuthModel;
import com.keymobile.indicators.model.entity.ConfigInfo;
import com.keymobile.indicators.model.entity.RoleRefUserModel;
import com.keymobile.indicators.model.entity.dataenter.*;
......@@ -32,9 +32,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
@Service
@Slf4j
......@@ -344,12 +342,58 @@ public class TaskServiceImpl implements TaskService {
private void createCountIndValues(Task task) {
List<TaskIndicator> inds = taskIndicatorMapper.getByTaskId(task.getId());
List<TaskIndValue> values = taskIndValueMapper.getByTaskId(task.getId());
TaskRuleGroupObj groupObj = taskRuleObjMapper.getById(task.getGroupId());
List<TaskIndicator> needSumInds = new ArrayList<>();
for (TaskIndicator taskIndicator : inds) {
if (StringUtils.isNotBlank(taskIndicator.getIndFormula())) {
//TODO
taskRuleObjMapper.getById(task.getGroupId());
needSumInds.add(taskIndicator);
}
}
if (needSumInds.isEmpty()) {
return;
}
if (groupObj != null && StringUtils.isNotBlank(groupObj.getDetail())) {
List<String> ids = Arrays.asList(StringUtils.split(groupObj.getDetail(), Constants.SEP_COMMA));
List<AuthModel> models = new ArrayList<>();
switch (groupObj.getObjType()) {
case Constants.OBJ_TYPE_ORG:
List<JSONObject> list = systemAuthService.getOrgByNos(ids);
for (JSONObject jo : list) {
AuthModel model = new AuthModel();
model.setId(jo.getString("no"));
model.setName(jo.getString("name"));
models.add(model);
}
break;
}
Map<String, String> idMapValues = new HashMap<>();
for (TaskIndValue value : values) {
for (AuthModel model : models) {
if (model.getId().equals(value.getObjId())) {
idMapValues.put(value.getIndId(), value.getIndValue());
}
}
}
List<TaskIndValue> newValues = new ArrayList<>();
for (TaskIndicator indicator : needSumInds) {
for (AuthModel model : models) {
TaskIndValue value = new TaskIndValue();
value.setIndId(indicator.getIndId());
value.setIndName(indicator.getIndName());
value.setValueTime(task.getValueTime());
value.setIndUnit(indicator.getIndUnit());
value.setObjId(model.getId());
value.setObjName(model.getName());
value.setObjType(groupObj.getObjType());
value.setTaskId(task.getId());
newValues.add(value);
}
}
taskIndValueMapper.batchInsert(values);
} else {
LogManager.logError(Constants.LOG_CONTEXT_API, "上报数据出错,任务单位不存在或者内容为空" + task.getGroupId());
}
}
@Override
......
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