|
|
@@ -1,17 +1,28 @@
|
|
|
package com.lc.ibps.business.service.impl;
|
|
|
|
|
|
|
|
|
+import com.lc.ibps.base.core.constants.StringPool;
|
|
|
+import com.lc.ibps.base.core.util.AppUtil;
|
|
|
+import com.lc.ibps.base.core.util.Collections;
|
|
|
import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
+import com.lc.ibps.base.web.context.ContextUtil;
|
|
|
+import com.lc.ibps.business.dto.LabsDashBoardDTO;
|
|
|
+import com.lc.ibps.business.dto.LabsDashBoardGroupDTO;
|
|
|
import com.lc.ibps.business.service.StatisticService;
|
|
|
+import com.lc.ibps.cloud.entity.APIResult;
|
|
|
+import com.lc.ibps.org.api.IPartyPositionService;
|
|
|
+import com.lc.ibps.org.party.persistence.entity.PartyPositionPo;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class StatisticServiceImpl implements StatisticService {
|
|
|
-
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(StatisticServiceImpl.class);
|
|
|
@Resource
|
|
|
private ICommonDao<?> commonDao;
|
|
|
|
|
|
@@ -22,6 +33,79 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
return (List<Map<String, Object>>) commonDao.query(typeSql,new String[]{riskId});
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<LabsDashBoardDTO> getLabsDashBoard(String year, String filter) {
|
|
|
+ String diDian = getDiDian();
|
|
|
+ if (diDian == null) return null;
|
|
|
+ List<String> deptList = getDeptList(diDian);
|
|
|
+ if(Collections.isEmpty(deptList)) return null;
|
|
|
+ List<LabsDashBoardDTO> result = new ArrayList<>();
|
|
|
+ for (Map.Entry<String,String> entry: getZhiBiao().entrySet()) {
|
|
|
+ LabsDashBoardDTO dto = new LabsDashBoardDTO();
|
|
|
+ Map<String,LabsDashBoardGroupDTO> dtoGroup = getIndex(diDian,year,deptList,entry.getKey());
|
|
|
+ dto.calcTotally(dtoGroup.values());
|
|
|
+ dto.setName(entry.getValue());
|
|
|
+ dto.generateGroups(dtoGroup,deptList,filter);
|
|
|
+ result.add(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String,String> getZhiBiao(){
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ map.put("v_LabsDashBoard_1_zaiGang","在岗人员培训");
|
|
|
+ map.put("v_LabsDashBoard_2_gangQian","岗前培训");
|
|
|
+ map.put("v_LabsDashBoard_3_waiBuZhiLiang","外部质量管理");
|
|
|
+ map.put("v_LabsDashBoard_4_neiBuBiDui","内部比对实验");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String,LabsDashBoardGroupDTO> getIndex(String diDian, String year, List<String> deptList, String viewName) {
|
|
|
+ Map<String,LabsDashBoardGroupDTO> dtoList = new HashMap<>();
|
|
|
+ String sql = "SELECT NAME_,numA,num,chu FROM %s WHERE di_dian_='%s' AND year_='%s'";
|
|
|
+ sql = String.format(sql,viewName,diDian,year);
|
|
|
+ List<Map<String, Object>> l = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
+ if (Collections.isEmpty(l)) return dtoList;
|
|
|
+ for (Map<String, Object> val : l) {
|
|
|
+ val = transformLowerCase(val);
|
|
|
+ LabsDashBoardGroupDTO group = new LabsDashBoardGroupDTO();
|
|
|
+ group.setName((String)val.get("name_") );
|
|
|
+ group.setNumAll(((Long)val.get("numa")).intValue() );
|
|
|
+ group.setNumSuccess(((Long)val.get("num")).intValue() );
|
|
|
+ group.setRate(((BigDecimal) val.get("chu")).doubleValue());
|
|
|
+ group.setNumUn(group.getNumAll() - group.getNumSuccess());
|
|
|
+ dtoList.put(group.getName(),group);
|
|
|
+ }
|
|
|
+ return dtoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getDiDian() {
|
|
|
+ IPartyPositionService partyPositionService = AppUtil.getBean(IPartyPositionService.class);
|
|
|
+ APIResult<List<PartyPositionPo>> result = partyPositionService.findByUserId(ContextUtil.getCurrentUserId());
|
|
|
+ String diDian ="";
|
|
|
+ try {
|
|
|
+ diDian = result.getData().get(0).getPath().split(StringPool.BACK_SLASH + StringPool.DOT)[1];
|
|
|
+ }catch (Exception ex){
|
|
|
+ logger.error("Can't get didian information",ex);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return diDian;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<String> getDeptList(String diDian) {
|
|
|
+ String sql = "SELECT name_ FROM ibps_party_entity WHERE party_type_='position' AND depth_ =4 AND path_ LIKE '%%%s%%' ORDER BY sn_";
|
|
|
+ sql =String.format(sql, diDian);
|
|
|
+ List<Map<String, Object>> l = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
+ if (Collections.isEmpty(l)) return null;
|
|
|
+ List<String> deptList = new ArrayList<>();
|
|
|
+ for (Map<String, Object> val : l) {
|
|
|
+ val = transformLowerCase(val);
|
|
|
+ deptList.add( (String)val.get("name_") );
|
|
|
+ }
|
|
|
+ return deptList;
|
|
|
+ }
|
|
|
+
|
|
|
private String getFetchSqlForRiskReport(String type){
|
|
|
String fetchSql = "";
|
|
|
if(type.equalsIgnoreCase("FXDJ")){
|
|
|
@@ -55,4 +139,17 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
|
|
|
return fetchSql;
|
|
|
}
|
|
|
+
|
|
|
+ private Map<String, Object> transformLowerCase(Map<String, Object> map) {
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ if (map == null || map.isEmpty()) {
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ Set<String> keySet = map.keySet();
|
|
|
+ for (String key : keySet) {
|
|
|
+ String newKey = key.toLowerCase();
|
|
|
+ resultMap.put(newKey, map.get(key));
|
|
|
+ }
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
}
|