This commit is contained in:
parent
849325beb7
commit
15723bc464
Binary file not shown.
Binary file not shown.
|
|
@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
|
|
@ -31,7 +32,7 @@ public class AuthorizedStrengthController {
|
|||
@WeaPermission(publicPermission = true)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@PostMapping("/getDepartmentAuthorizedStrength")
|
||||
public WeaResult<Map<String, Object>> getDepartmentAuthorizedStrength(@RequestParam("developPlan") String developPlan,
|
||||
public WeaResult<List<Map<String, Object>>> getDepartmentAuthorizedStrength(@RequestParam("developPlan") String developPlan,
|
||||
@RequestParam("adjustDepartment") String adjustDepartment,
|
||||
@RequestParam("adjustYear") String adjustYear,
|
||||
@RequestParam("grade") String grade,
|
||||
|
|
@ -44,7 +45,7 @@ public class AuthorizedStrengthController {
|
|||
paramMap.put("grade",grade);
|
||||
paramMap.put("position",position);
|
||||
|
||||
Map<String,Object> resultMap = authorizedStrengthService.getDepartmentAuthorizedStrength(paramMap);
|
||||
List<Map<String, Object>> resultMap = authorizedStrengthService.getDepartmentAuthorizedStrength(paramMap);
|
||||
|
||||
|
||||
return WeaResult.success(resultMap);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
package com.weaver.seconddev.jcl.organization.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface AuthorizedStrengthService {
|
||||
|
||||
Map<String,Object> getDepartmentAuthorizedStrength(Map<String,String> params);
|
||||
List<Map<String, Object>> getDepartmentAuthorizedStrength(Map<String,String> params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,99 +29,125 @@ public class AuthorizedStrengthServiceImpl implements AuthorizedStrengthService
|
|||
private static final Logger log = LoggerFactory.getLogger(AuthorizedStrengthServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getDepartmentAuthorizedStrength(Map<String, String> params) {
|
||||
public List<Map<String, Object>> getDepartmentAuthorizedStrength(Map<String, String> params) {
|
||||
log.error("params: [{}]",params);
|
||||
String sql = "select * from e10_other_business.hr_est_cfg where org_id=? and plan_id=? and cfg_year=?";
|
||||
List<Map<String, Object>> dataList = databaseUtils.getSqlList(sql, CommonUtils.getParamList(params.get("adjustDepartment"),params.get("developPlan"),params.get("adjustYear")));
|
||||
String sql = "select * from e10_other_business.hr_est_cfg where org_id in ("+params.get("adjustDepartment")+") and plan_id=? and cfg_year=?";
|
||||
List<Map<String, Object>> dataList = databaseUtils.getSqlList(sql, CommonUtils.getParamList(params.get("developPlan"),params.get("adjustYear")));
|
||||
log.error("hrestcfgList: [{}]",dataList);
|
||||
List<String> cfgIds = dataList.stream().map(e->e.get("id").toString()).collect(Collectors.toList());
|
||||
String currentDate = DateUtil.getCurrentMonth();
|
||||
//人员编制统计数据 数据源
|
||||
List<Map<String, Object>> datasBySourceList = commonService.getListDatasBySourceName("人员编制统计数据","LOGIC","weaver-hr-service");
|
||||
datasBySourceList = datasBySourceList.stream().filter(e->CommonUtils.null2String(e.get("year")).equals(params.get("adjustYear")) &&
|
||||
CommonUtils.null2String(((List<Map<String,Object>>)e.get("orgId")).get(0).get("id")).equals(params.get("adjustDepartment")) &&
|
||||
params.get("adjustDepartment").contains(CommonUtils.null2String(((List<Map<String,Object>>)e.get("orgId")).get(0).get("id"))) &&
|
||||
CommonUtils.null2String(((List<Map<String,Object>>)e.get("planId")).get(0).get("id")).equals(params.get("developPlan"))).collect(Collectors.toList());
|
||||
// Map<String,List<Map<String, Object>>> datasBySourceCollect = datasBySourceList.stream().collect(Collectors.groupingBy(e->e.get("orgId").toString()));
|
||||
|
||||
//人员编制控编维度统计数据(月度周期)
|
||||
List<Map<String, Object>> personYdzqMonthList = commonService.getListDatasBySourceName("人员编制控编维度统计数据","LOGIC","weaver-hr-service");
|
||||
personYdzqMonthList = personYdzqMonthList.stream().filter(e->e.get("year").equals(params.get("adjustYear")) &&
|
||||
CommonUtils.null2String(((List<Map<String,Object>>)e.get("orgId")).get(0).get("id")).equals(params.get("adjustDepartment")) &&
|
||||
CommonUtils.null2String(((List<Map<String,Object>>)e.get("position")).get(0).get("id")).equals(params.get("position")) &&
|
||||
CommonUtils.null2String(((List<Map<String,Object>>)e.get("grade")).get(0).get("id")).equals(params.get("grade"))).collect(Collectors.toList());
|
||||
params.get("adjustDepartment").contains(CommonUtils.null2String(((List<Map<String,Object>>)e.get("orgId")).get(0).get("id"))) &&
|
||||
params.get("position").contains(CommonUtils.null2String(((List<Map<String,Object>>)e.get("position")).get(0).get("id"))) &&
|
||||
params.get("grade").contains(CommonUtils.null2String(((List<Map<String,Object>>)e.get("grade")).get(0).get("id")))).collect(Collectors.toList());
|
||||
|
||||
|
||||
sql = "select * from e10_other_business.hr_est_history where org_id=? and cfg_id in ("+String.join(",",cfgIds)+")";
|
||||
List<Map<String, Object>> historyList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(params.get("adjustDepartment")));
|
||||
sql = "select * from e10_other_business.hr_est_history where org_id in ("+params.get("adjustDepartment")+") and cfg_id in ("+String.join(",",cfgIds)+")";
|
||||
List<Map<String, Object>> historyList = databaseUtils.getSqlList(sql);
|
||||
String startDate = params.get("adjustYear")+"-01";
|
||||
List<Map<String, Object>> deparmentAdjust = Lists.newArrayList();
|
||||
List<Map<String, Object>> jobAdjust = Lists.newArrayList();
|
||||
log.error("datasBySourceList:[{}]",datasBySourceList);
|
||||
log.error("personYdzqMonthList:[{}]",personYdzqMonthList);
|
||||
|
||||
sql = "select * from eteams.department";
|
||||
List<Map<String, Object>> departmentList = databaseUtils.getSqlList(sql);
|
||||
Map<String, String> departmentMap = departmentList.stream().collect(Collectors.toMap(e->e.get("id").toString(),e->e.get("name").toString()));
|
||||
|
||||
for (int i=0;i<=11;i++){
|
||||
Map<String,Object> dataMap = Maps.newHashMap();
|
||||
Map<String,Object> dataMap2 = Maps.newHashMap();
|
||||
|
||||
|
||||
String date = DateUtil.nextMonth(startDate,i, DateUtil.yyyyMM);
|
||||
int monthValue = DateUtil.getTime(date).getMonthValue();
|
||||
List<Map<String, Object>> hrestCfg = dataList.stream().filter(e->CommonUtils.null2String(e.get("cfg_month")).equals(String.valueOf(monthValue))).collect(Collectors.toList());
|
||||
if (hrestCfg.size() == 0){
|
||||
continue;
|
||||
}
|
||||
log.error("hrestCfg: [{}]",hrestCfg);
|
||||
dataMap.put("monthvalue",monthValue);
|
||||
dataMap.put("bz",hrestCfg.get(0).get("est_count"));
|
||||
dataMap2.put("bz",hrestCfg.get(0).get("est_count"));
|
||||
dataMap2.put("monthvalue",monthValue);
|
||||
List<Map<String, Object>> hresthistory = historyList.stream().filter(e->e.get("cfg_id").equals(hrestCfg.get(0).get("id")) && e.get("history_month").equals(date)).collect(Collectors.toList());
|
||||
Map<String,List<Map<String, Object>>> dataCollect = dataList.stream().collect(Collectors.groupingBy(e->e.get("org_id").toString()));
|
||||
for (Map.Entry<String,List<Map<String, Object>>> entry: dataCollect.entrySet()){
|
||||
Map<String,Object> dataMap = Maps.newHashMap();
|
||||
Map<String,Object> dataMap2 = Maps.newHashMap();
|
||||
String org_id = entry.getKey();
|
||||
List<Map<String, Object>> hrestCfgList = entry.getValue();
|
||||
List<Map<String, Object>> hrestCfg = hrestCfgList.stream().filter(e->CommonUtils.null2String(e.get("cfg_month")).equals(String.valueOf(monthValue))).collect(Collectors.toList());
|
||||
if (hrestCfg.size() == 0){
|
||||
continue;
|
||||
}
|
||||
log.error("hrestCfg: [{}]",hrestCfg);
|
||||
dataMap.put("monthvalue",monthValue);
|
||||
dataMap.put("bz",hrestCfg.get(0).get("est_count"));
|
||||
dataMap.put("org_id",org_id);
|
||||
dataMap2.put("bz",hrestCfg.get(0).get("est_count"));
|
||||
dataMap2.put("monthvalue",monthValue);
|
||||
dataMap2.put("org_id",org_id);
|
||||
List<Map<String, Object>> hresthistory = historyList.stream().filter(e->e.get("cfg_id").equals(hrestCfg.get(0).get("id")) && e.get("history_month").equals(date)).collect(Collectors.toList());
|
||||
|
||||
List<Map<String, Object>> personYdzqMonth = personYdzqMonthList.stream().filter(e->e.get("month").equals(String.valueOf(monthValue)) && e.get("cfgId").equals(hrestCfg.get(0).get("id"))).collect(Collectors.toList());
|
||||
if (personYdzqMonth.size() > 0){
|
||||
dataMap2.put("zz",personYdzqMonth.get(0).get("numberingCount"));
|
||||
dataMap2.put("zy",personYdzqMonth.get(0).get("NumberComponent"));
|
||||
dataMap2.put("ysf",personYdzqMonth.get(0).get("preSubEmpCount"));
|
||||
dataMap2.put("kybz",personYdzqMonth.get(0).get("estLackCount"));
|
||||
}else {
|
||||
dataMap2.put("zz","");
|
||||
dataMap2.put("zy","");
|
||||
dataMap2.put("ysf","");
|
||||
dataMap2.put("kybz","");
|
||||
}
|
||||
|
||||
if (DateUtil.getTime(date).compareTo(DateUtil.getTime(currentDate))<0){
|
||||
//取历史
|
||||
if (hresthistory.size() > 0){
|
||||
dataMap.put("zz",hresthistory.get(0).get("est_count"));
|
||||
dataMap.put("zy",hresthistory.get(0).get("pre_add_count"));
|
||||
dataMap.put("ysf",hresthistory.get(0).get("pre_sub_count"));
|
||||
int kybz = Integer.valueOf(dataMap.get("bz").toString())-Integer.valueOf(dataMap.get("zz").toString())-Integer.valueOf(dataMap.get("zy").toString());
|
||||
dataMap.put("kybz",kybz);
|
||||
List<Map<String, Object>> personYdzqMonth = personYdzqMonthList.stream().filter(e->e.get("month").equals(String.valueOf(monthValue)) && e.get("cfgId").equals(hrestCfg.get(0).get("id"))).collect(Collectors.toList());
|
||||
if (personYdzqMonth.size() > 0){
|
||||
dataMap2.put("zz",personYdzqMonth.get(0).get("numberingCount"));
|
||||
dataMap2.put("zy",personYdzqMonth.get(0).get("NumberComponent"));
|
||||
dataMap2.put("ysf",personYdzqMonth.get(0).get("preSubEmpCount"));
|
||||
dataMap2.put("kybz",personYdzqMonth.get(0).get("estLackCount"));
|
||||
}else {
|
||||
dataMap.put("zz","");
|
||||
dataMap.put("zy","");
|
||||
dataMap.put("ysf","");
|
||||
dataMap.put("kybz","");
|
||||
dataMap2.put("zz","");
|
||||
dataMap2.put("zy","");
|
||||
dataMap2.put("ysf","");
|
||||
dataMap2.put("kybz","");
|
||||
}
|
||||
|
||||
}else {
|
||||
//取数据源
|
||||
if (datasBySourceList.size() > 0){
|
||||
dataMap.put("zz",datasBySourceList.get(0).get("numberingCount"));
|
||||
dataMap.put("zy",datasBySourceList.get(0).get("preAddEmpCount"));
|
||||
dataMap.put("ysf",datasBySourceList.get(0).get("preSubEmpCount"));
|
||||
dataMap.put("kybz",datasBySourceList.get(0).get("estLackCount"));
|
||||
if (DateUtil.getTime(date).compareTo(DateUtil.getTime(currentDate))<0){
|
||||
//取历史
|
||||
if (hresthistory.size() > 0){
|
||||
dataMap.put("zz",hresthistory.get(0).get("est_count"));
|
||||
dataMap.put("zy",hresthistory.get(0).get("pre_add_count"));
|
||||
dataMap.put("ysf",hresthistory.get(0).get("pre_sub_count"));
|
||||
int kybz = Integer.valueOf(dataMap.get("bz").toString())-Integer.valueOf(dataMap.get("zz").toString())-Integer.valueOf(dataMap.get("zy").toString());
|
||||
dataMap.put("kybz",kybz);
|
||||
}else {
|
||||
dataMap.put("zz","");
|
||||
dataMap.put("zy","");
|
||||
dataMap.put("ysf","");
|
||||
dataMap.put("kybz","");
|
||||
}
|
||||
|
||||
}else {
|
||||
dataMap.put("zz","");
|
||||
dataMap.put("zy","");
|
||||
dataMap.put("ysf","");
|
||||
dataMap.put("kybz","");
|
||||
//取数据源
|
||||
if (datasBySourceList.size() > 0){
|
||||
dataMap.put("zz",datasBySourceList.get(0).get("numberingCount"));
|
||||
dataMap.put("zy",datasBySourceList.get(0).get("preAddEmpCount"));
|
||||
dataMap.put("ysf",datasBySourceList.get(0).get("preSubEmpCount"));
|
||||
dataMap.put("kybz",datasBySourceList.get(0).get("estLackCount"));
|
||||
}else {
|
||||
dataMap.put("zz","");
|
||||
dataMap.put("zy","");
|
||||
dataMap.put("ysf","");
|
||||
dataMap.put("kybz","");
|
||||
}
|
||||
}
|
||||
deparmentAdjust.add(dataMap);
|
||||
jobAdjust.add(dataMap2);
|
||||
}
|
||||
deparmentAdjust.add(dataMap);
|
||||
jobAdjust.add(dataMap2);
|
||||
}
|
||||
Map<String,Object> resultMap = Maps.newHashMap();
|
||||
resultMap.put("deparmentAdjust",deparmentAdjust);
|
||||
resultMap.put("jobAdjust",jobAdjust);
|
||||
|
||||
return resultMap;
|
||||
Map<String,List<Map<String, Object>>> deparmentAdjustGroup= deparmentAdjust.stream().collect(Collectors.groupingBy(e->e.get("org_id").toString()));
|
||||
Map<String,List<Map<String, Object>>> jobAdjustGroup= jobAdjust.stream().collect(Collectors.groupingBy(e->e.get("org_id").toString()));
|
||||
List<Map<String, Object>> resultList = Lists.newArrayList();
|
||||
for (Map.Entry<String,List<Map<String, Object>>> entry: deparmentAdjustGroup.entrySet()){
|
||||
Map<String,Object> dataMap = Maps.newHashMap();
|
||||
dataMap.put("departmentId",entry.getKey());
|
||||
dataMap.put("departmentName",departmentMap.get(entry.getKey()));
|
||||
dataMap.put("deparmentAdjust",entry.getValue());
|
||||
dataMap.put("jobAdjust",jobAdjustGroup.get(entry.getKey()));
|
||||
resultList.add(dataMap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue