|
|
@@ -14,18 +14,16 @@ import com.lc.ibps.common.api.IDictionaryService;
|
|
|
import com.lc.ibps.common.cat.persistence.entity.DictionaryPo;
|
|
|
import com.lc.ibps.org.api.IPartyPositionService;
|
|
|
import com.lc.ibps.org.party.persistence.entity.PartyPositionPo;
|
|
|
-import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.lang.reflect.Method;
|
|
|
+import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.DayOfWeek;
|
|
|
import java.time.LocalDate;
|
|
|
-import java.time.Year;
|
|
|
import java.time.YearMonth;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.format.TextStyle;
|
|
|
@@ -186,37 +184,77 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
// 所有设备维修次数
|
|
|
equipDTO.setScrapData(getEquipScrapList());
|
|
|
|
|
|
+ // 各部门设备资产原值统计
|
|
|
+ equipDTO.setOriginalAssets(getEquipAssetsByDept());
|
|
|
+
|
|
|
list.add(equipDTO);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ private List<Map<String,Object>> getEquipAssetsByDept(){
|
|
|
+ String sql ="SELECT p.name_ as org,p.depth_,p.id_,IFNULL(ROUND(SUM(q.zi_chan_yuan_zhi_) / 10000, 2),0.00) as assets from " +
|
|
|
+ "(SELECT name_,id_,depth_ from ibps_party_entity WHERE path_ like '%%%s%%' and DEPTH_>=3) p " +
|
|
|
+ "left join (SELECT bian_zhi_bu_men_,zi_chan_yuan_zhi_ from t_sbdj WHERE di_dian_='%s') q " +
|
|
|
+ "on q.bian_zhi_bu_men_=p.id_ GROUP BY p.id_";
|
|
|
+ String totalSQL ="SELECT IFNULL(ROUND(SUM(s.assets)/ 10000, 2),0.00) as total from (\n" +
|
|
|
+ "SELECT p.name_,p.id_,SUM(q.zi_chan_yuan_zhi_) as assets from \n" +
|
|
|
+ "(SELECT name_,id_ from ibps_party_entity WHERE path_ like '%%%s%%' and DEPTH_>=3) p \n" +
|
|
|
+ "left join (SELECT bian_zhi_bu_men_,zi_chan_yuan_zhi_ from t_sbdj WHERE di_dian_='%s') q \n" +
|
|
|
+ "on q.bian_zhi_bu_men_=p.id_ GROUP BY p.id_) s";
|
|
|
+ sql = String.format(sql,getDiDian(),getDiDian());
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
+ if (Collections.isEmpty(list)){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ for (Map<String, Object> map : list){
|
|
|
+ if ("3".equals(map.get("depth_").toString())){
|
|
|
+ map.put("assets", commonDao.queryOne(String.format(totalSQL,getDiDian(),getDiDian())).get("total"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
private List<EquipCalibrationByPositionDTO> getVerificationData(){
|
|
|
- String todoSql = "SELECT id_ from t_mjsbjdxzjh WHERE di_dian_='"+getDiDian()+"' and shi_fou_guo_shen_!='已完成' ";
|
|
|
- String aldySql = "SELECT id_ from t_mjsbjdxzjh WHERE di_dian_='"+getDiDian()+"' and shi_fou_guo_shen_ ='已完成' ";
|
|
|
- String sql = "SELECT p.name_,q.bian_zhi_bu_men_,COUNT(bian_zhi_bu_men_)as value from " +
|
|
|
- " (SELECT name_,id_ from ibps_party_entity WHERE path_ like '%%%s%%' and DEPTH_>=3) p " +
|
|
|
- " left join " +
|
|
|
- " (SELECT bian_zhi_bu_men_ from t_mjsbjdxzjhzb WHERE parent_id_ in(%s) or record_parentid_ in(%s) ) q " +
|
|
|
- " on q.bian_zhi_bu_men_=p.id_ GROUP BY p.id_";
|
|
|
- todoSql = String.format(sql,getDiDian(),todoSql,todoSql);
|
|
|
- aldySql = String.format(sql,getDiDian(),aldySql,aldySql);
|
|
|
- List<Map<String, Object>> aldyList = (List<Map<String, Object>>) commonDao.query(aldySql);
|
|
|
- List<Map<String, Object>> toDoList = (List<Map<String, Object>>) commonDao.query(todoSql);
|
|
|
+ String planSql = "SELECT p.name_,p.id_,p.depth_,COALESCE(q.assets, 0) AS assets\n" +
|
|
|
+ "FROM (SELECT name_,id_,depth_ FROM ibps_party_entity WHERE path_ LIKE '%%%s%%' AND depth_ >= 3) p \n" +
|
|
|
+ "LEFT JOIN (SELECT zb.bian_zhi_bu_men_,COUNT(*) AS assets FROM t_mjsbjdxzjhzb zb INNER JOIN t_mjsbjdxzjh jh ON zb.parent_id_ = jh.id_ \n" +
|
|
|
+ "WHERE jh.shi_fou_guo_shen_ = '已完成' AND jh.di_dian_ = '%s' GROUP BY zb.bian_zhi_bu_men_) q ON p.id_ = q.bian_zhi_bu_men_";
|
|
|
+
|
|
|
+ String finishSql = "SELECT p.name_,p.id_,p.depth_,COALESCE(q.assets, 0) AS assets\n" +
|
|
|
+ "FROM (SELECT name_,id_,depth_ FROM ibps_party_entity WHERE path_ LIKE '%%%s%%' AND depth_ >= 3) p \n" +
|
|
|
+ "LEFT JOIN (SELECT zb.bian_zhi_bu_men_,COUNT(jh.id_) AS assets FROM t_mjsbjdxzjh jh INNER JOIN t_mjsbjdxzjhzb zb ON jh.id_ = zb.record_parentid_ \n" +
|
|
|
+ "WHERE jh.shi_fou_guo_shen_ = '已完成' AND jh.di_dian_='%s' AND zb.shi_shi_ri_qi_ is not null and zb.shi_shi_ri_qi_ !='' GROUP BY zb.bian_zhi_bu_men_) q \n" +
|
|
|
+ "ON p.id_ = q.bian_zhi_bu_men_";
|
|
|
+
|
|
|
+ planSql = String.format(planSql,getDiDian(),getDiDian());
|
|
|
+ finishSql = String.format(finishSql,getDiDian(),getDiDian());
|
|
|
+ String sumPlanSql = "SELECT SUM(s.assets) as total from (%s) s";
|
|
|
+ String sumFinishSql = "SELECT SUM(s.assets) as total from (%s) s";
|
|
|
+ int planTotal = Integer.parseInt(commonDao.queryOne(String.format(sumPlanSql,planSql)).get("total").toString());
|
|
|
+ int finishTotal = Integer.parseInt(commonDao.queryOne(String.format(sumFinishSql,finishSql)).get("total").toString());
|
|
|
+ List<Map<String, Object>> planList = (List<Map<String, Object>>) commonDao.query(planSql);
|
|
|
+ List<Map<String, Object>> finishList = (List<Map<String, Object>>) commonDao.query(finishSql);
|
|
|
Map<String, EquipCalibrationByPositionDTO> mergedMap = new HashMap<>();
|
|
|
- for (Map<String, Object> entry : aldyList) {
|
|
|
+ for (Map<String, Object> entry : finishList) {
|
|
|
String org = (String) entry.get("name_");
|
|
|
- int count = ((Number) entry.get("value")).intValue();
|
|
|
+ int count = ((Number) entry.get("assets")).intValue();
|
|
|
EquipCalibrationByPositionDTO dto = mergedMap.getOrDefault(org, new EquipCalibrationByPositionDTO());
|
|
|
dto.setOrg(org);
|
|
|
dto.setNumW(count);
|
|
|
+ if ("3".equals(entry.get("depth_").toString())){
|
|
|
+ dto.setNumW(finishTotal);
|
|
|
+ }
|
|
|
mergedMap.put(org, dto);
|
|
|
}
|
|
|
- for (Map<String, Object> entry : toDoList) {
|
|
|
+ for (Map<String, Object> entry : planList) {
|
|
|
String org = (String) entry.get("name_");
|
|
|
- int count = ((Number) entry.get("value")).intValue();
|
|
|
+ int count = ((Number) entry.get("assets")).intValue();
|
|
|
EquipCalibrationByPositionDTO dto = mergedMap.getOrDefault(org, new EquipCalibrationByPositionDTO());
|
|
|
dto.setOrg(org);
|
|
|
dto.setNumJ(count);
|
|
|
+ if ("3".equals(entry.get("depth_").toString())){
|
|
|
+ dto.setNumJ(planTotal);
|
|
|
+ }
|
|
|
mergedMap.put(org, dto);
|
|
|
}
|
|
|
List<EquipCalibrationByPositionDTO> mergedList = new ArrayList<>(mergedMap.values());
|
|
|
@@ -224,15 +262,18 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
}
|
|
|
|
|
|
private List<EquipMaintenanceDTO> getEquipMaintenanceByDept(){
|
|
|
- String sql = "SELECT p.name_,q.bian_zhi_bu_men_,COUNT(bian_zhi_bu_men_)as value from " +
|
|
|
- "(SELECT name_,id_ from ibps_party_entity WHERE path_ like '%%%s%%' and DEPTH_>=3) p " +
|
|
|
- "left join " +
|
|
|
- "(SELECT bian_zhi_bu_men_ from t_mjsbwhbyjlby WHERE shi_fou_guo_shen_='%s' and di_dian_='%s') q " +
|
|
|
- " on q.bian_zhi_bu_men_=p.id_ GROUP BY p.id_ ";
|
|
|
- String finishSql = String.format(sql,getDiDian(),"已完成",getDiDian());
|
|
|
- String toDoSql = String.format(sql,getDiDian(),"待处理",getDiDian());
|
|
|
+ String sql = "SELECT p.name_,p.id_,p.depth_,COUNT(q.bian_zhi_bu_men_) AS value \n" +
|
|
|
+ "FROM ibps_party_entity p LEFT JOIN t_mjsbwhbyjlby q ON p.id_ = q.bian_zhi_bu_men_\n" +
|
|
|
+ "AND q.shi_fou_guo_shen_ = '%s' AND q.di_dian_ = '%%%s%%' \n" +
|
|
|
+ "WHERE p.path_ LIKE '%%%s%%' AND p.depth_ >= 3 GROUP BY p.id_, p.name_, p.depth_ ";
|
|
|
+ String finishSql = String.format(sql,"已完成",getDiDian(),getDiDian());
|
|
|
+ String toDoSql = String.format(sql,"待处理",getDiDian(),getDiDian());
|
|
|
List<Map<String, Object>> aldyList = (List<Map<String, Object>>) commonDao.query(finishSql);
|
|
|
List<Map<String, Object>> toDoList = (List<Map<String, Object>>) commonDao.query(toDoSql);
|
|
|
+ String sumFinishSql = "SELECT SUM(s.value) as total from (%s) s";
|
|
|
+ String sumToDoSql = "SELECT SUM(s.value) as total from (%s) s";
|
|
|
+ int toDoNum = Integer.parseInt(commonDao.queryOne(String.format(sumFinishSql,finishSql)).get("total").toString());
|
|
|
+ int finishNum = Integer.parseInt(commonDao.queryOne(String.format(sumToDoSql,toDoSql)).get("total").toString());
|
|
|
Map<String, EquipMaintenanceDTO> mergedMap = new HashMap<>();
|
|
|
for (Map<String, Object> entry : aldyList) {
|
|
|
String org = (String) entry.get("name_");
|
|
|
@@ -240,6 +281,9 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
EquipMaintenanceDTO dto = mergedMap.getOrDefault(org, new EquipMaintenanceDTO());
|
|
|
dto.setOrg(org);
|
|
|
dto.setNumC(count);
|
|
|
+ if ("3".equals(entry.get("depth_").toString())){
|
|
|
+ dto.setNumC(finishNum);
|
|
|
+ }
|
|
|
mergedMap.put(org, dto);
|
|
|
}
|
|
|
for (Map<String, Object> entry : toDoList) {
|
|
|
@@ -248,6 +292,9 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
EquipMaintenanceDTO dto = mergedMap.getOrDefault(org, new EquipMaintenanceDTO());
|
|
|
dto.setOrg(org);
|
|
|
dto.setNumP(count);
|
|
|
+ if ("3".equals(entry.get("depth_").toString())){
|
|
|
+ dto.setNumP(toDoNum);
|
|
|
+ }
|
|
|
mergedMap.put(org, dto);
|
|
|
}
|
|
|
List<EquipMaintenanceDTO> mergedList = new ArrayList<>(mergedMap.values());
|
|
|
@@ -288,13 +335,114 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
return equipList;
|
|
|
}
|
|
|
|
|
|
- private List<EquipIntactDTO> getEquipSituation(){
|
|
|
+ private List<EquipIntactDTO> getEquipSituation() {
|
|
|
+ List<EquipIntactDTO> intactData = new ArrayList<>();
|
|
|
+ Set<String> existsDept = new HashSet<>();
|
|
|
+ String sql = "SELECT p.name_, p.id_, p.depth_, COUNT(q.bian_zhi_bu_men_) AS value " +
|
|
|
+ "FROM ibps_party_entity p LEFT JOIN t_sbdj q ON q.bian_zhi_bu_men_ = p.id_ AND %s" +
|
|
|
+ "WHERE p.path_ like '%%%s%%' AND p.depth_ >= 3 GROUP BY p.id_, p.name_, p.depth_";
|
|
|
+
|
|
|
+ // 定义不同状态的条件
|
|
|
+ Map<String, String> statusConditions = new HashMap<>();
|
|
|
+ statusConditions.put("停用", "she_bei_zhuang_ta='停用' and di_dian_='%s'");
|
|
|
+ statusConditions.put("合格", "she_bei_zhuang_ta='合格' and di_dian_='%s'");
|
|
|
+ statusConditions.put("总和", "di_dian_='%s'");
|
|
|
+ statusConditions.put("限用", "she_bei_zhuang_ta='限用' and di_dian_='%s'");
|
|
|
+ statusConditions.put("报废", "she_bei_zhuang_ta='报废' and di_dian_='%s'");
|
|
|
+
|
|
|
+ // 定义每个状态对应的字段名
|
|
|
+ Map<String, String> fieldNameMap = new HashMap<>();
|
|
|
+ fieldNameMap.put("停用", "numS");
|
|
|
+ fieldNameMap.put("合格", "numR");
|
|
|
+ fieldNameMap.put("总和", "numAll");
|
|
|
+ fieldNameMap.put("限用", "numLimit");
|
|
|
+ fieldNameMap.put("报废", "numScrap");
|
|
|
+
|
|
|
+ // 处理每个状态
|
|
|
+ for (Map.Entry<String, String> entry : statusConditions.entrySet()) {
|
|
|
+ String status = entry.getKey();
|
|
|
+ String condition = entry.getValue();
|
|
|
+ String sqlCondition = String.format(condition, getDiDian());
|
|
|
+ String formattedSql = String.format(sql, sqlCondition, getDiDian());
|
|
|
+
|
|
|
+ List<Map<String, Object>> queryResult = (List<Map<String, Object>>) commonDao.query(formattedSql);
|
|
|
+ int totalNum = 0;
|
|
|
+
|
|
|
+ for (Map<String, Object> map : queryResult) {
|
|
|
+ EquipIntactDTO intact = new EquipIntactDTO();
|
|
|
+ intact.setOrg(map.get("name_").toString());
|
|
|
+ intact.setDepth(Integer.parseInt(map.get("depth_").toString()));
|
|
|
+ int value = Integer.parseInt(map.get("value").toString());
|
|
|
+ setField(intact, fieldNameMap.get(status), value);
|
|
|
+ totalNum += value;
|
|
|
+ existsDept.add(map.get("name_").toString());
|
|
|
+ intactData.add(intact);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理深度为3的部门
|
|
|
+ for (Map<String, Object> map : queryResult) {
|
|
|
+ if ("3".equals(map.get("depth_").toString())) {
|
|
|
+ EquipIntactDTO intact = new EquipIntactDTO();
|
|
|
+ intact.setOrg(map.get("name_").toString());
|
|
|
+ intact.setDepth(Integer.parseInt(map.get("depth_").toString()));
|
|
|
+ setField(intact, fieldNameMap.get(status), totalNum);
|
|
|
+ existsDept.add(map.get("name_").toString());
|
|
|
+ intactData.add(intact);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 合并相同部门的数据
|
|
|
+ Map<String, EquipIntactDTO> mergedDTOMap = new HashMap<>();
|
|
|
+ for (EquipIntactDTO dto : intactData) {
|
|
|
+ if (!mergedDTOMap.containsKey(dto.getOrg())) {
|
|
|
+ mergedDTOMap.put(dto.getOrg(), dto);
|
|
|
+ } else {
|
|
|
+ EquipIntactDTO mergedDTO = mergedDTOMap.get(dto.getOrg());
|
|
|
+ mergedDTO.setNumAll(mergedDTO.getNumAll() + dto.getNumAll());
|
|
|
+ mergedDTO.setNumS(mergedDTO.getNumS() + dto.getNumS());
|
|
|
+ mergedDTO.setNumR(mergedDTO.getNumR() + dto.getNumR());
|
|
|
+ mergedDTO.setNumLimit(mergedDTO.getNumLimit() + dto.getNumLimit());
|
|
|
+ mergedDTO.setNumScrap(mergedDTO.getNumScrap() + dto.getNumScrap());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<EquipIntactDTO> mergedList = new ArrayList<>(mergedDTOMap.values());
|
|
|
+
|
|
|
+ // 补充不存在的部门
|
|
|
+ List<EquipIntactDTO> finalList = new ArrayList<>(mergedList);
|
|
|
+ List<Map<String, Object>> deptList = getPositionBy34(getDiDian());
|
|
|
+ for (Map<String, Object> dept : deptList) {
|
|
|
+ if (!existsDept.contains(dept.get("name_"))) {
|
|
|
+ EquipIntactDTO intact = new EquipIntactDTO();
|
|
|
+ intact.setOrg(dept.get("name_").toString());
|
|
|
+ intact.setNumAll(0);
|
|
|
+ intact.setNumS(0);
|
|
|
+ intact.setNumR(0);
|
|
|
+ intact.setNumLimit(0);
|
|
|
+ intact.setNumScrap(0);
|
|
|
+ finalList.add(intact);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return finalList;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 辅助工具类,用于通过反射设置字段值
|
|
|
+ public static void setField(Object target, String fieldName, Object value) {
|
|
|
+ try {
|
|
|
+ Field field = target.getClass().getDeclaredField(fieldName);
|
|
|
+ field.setAccessible(true);
|
|
|
+ field.set(target, value);
|
|
|
+ } catch (NoSuchFieldException | IllegalAccessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<EquipIntactDTO> getEquipSituation22(){
|
|
|
List<EquipIntactDTO> intactData = new ArrayList<>();
|
|
|
Set<String> existsDept = new HashSet<>();
|
|
|
- String sql = "SELECT p.name_,q.bian_zhi_bu_men_,COUNT(bian_zhi_bu_men_)as value from ( " +
|
|
|
- "SELECT bian_zhi_bu_men_ from t_sbdj WHERE %s) q, " +
|
|
|
- "(SELECT name_,id_ from ibps_party_entity WHERE path_ like '%%%s%%' and DEPTH_>=3) p " +
|
|
|
- "where q.bian_zhi_bu_men_=p.id_ GROUP BY q.bian_zhi_bu_men_";
|
|
|
+ String sql = "SELECT p.name_,p.id_,p.depth_,COUNT(q.bian_zhi_bu_men_) AS value " +
|
|
|
+ "FROM ibps_party_entity p LEFT JOIN t_sbdj q ON q.bian_zhi_bu_men_ = p.id_ AND %s" +
|
|
|
+ "WHERE p.path_ like '%%%s%%' AND p.depth_ >= 3 GROUP BY p.id_, p.name_, p.depth_";
|
|
|
|
|
|
String stop = " she_bei_zhuang_ta='停用' and di_dian_='"+getDiDian()+"' ";
|
|
|
String enable = " she_bei_zhuang_ta='合格' and di_dian_='"+getDiDian()+"' ";
|
|
|
@@ -309,45 +457,106 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
String scrapSql = String.format(sql,scrap,getDiDian());
|
|
|
|
|
|
List<Map<String, Object>> stopList = (List<Map<String, Object>>) commonDao.query(stopSql);
|
|
|
+ int stopNum = 0;int sumNum = 0;int enableNum = 0;int limitNum = 0;int scrapNum = 0;
|
|
|
for (Map<String, Object> map : stopList){
|
|
|
EquipIntactDTO intac = new EquipIntactDTO();
|
|
|
intac.setOrg(map.get("name_").toString());
|
|
|
intac.setNumS(Integer.parseInt(map.get("value").toString()));
|
|
|
+ intac.setDepth(Integer.parseInt(map.get("depth_").toString()));
|
|
|
+ stopNum = stopNum + Integer.parseInt(map.get("value").toString());
|
|
|
existsDept.add(map.get("name_").toString());
|
|
|
intactData.add(intac);
|
|
|
}
|
|
|
+ for (Map<String, Object> map : stopList){
|
|
|
+ if ("3".equals(map.get("depth_").toString())){
|
|
|
+ EquipIntactDTO intac = new EquipIntactDTO();
|
|
|
+ intac.setOrg(map.get("name_").toString());
|
|
|
+ intac.setDepth(Integer.parseInt(map.get("depth_").toString()));
|
|
|
+ intac.setNumS(stopNum);
|
|
|
+ existsDept.add(map.get("name_").toString());
|
|
|
+ intactData.add(intac);
|
|
|
+ }
|
|
|
+ }
|
|
|
List<Map<String, Object>> enableList = (List<Map<String, Object>>) commonDao.query(enableSql);
|
|
|
for (Map<String, Object> map : enableList){
|
|
|
EquipIntactDTO intac = new EquipIntactDTO();
|
|
|
intac.setOrg(map.get("name_").toString());
|
|
|
+ intac.setDepth(Integer.parseInt(map.get("depth_").toString()));
|
|
|
intac.setNumR(Integer.parseInt(map.get("value").toString()));
|
|
|
+ enableNum = enableNum + Integer.parseInt(map.get("value").toString());
|
|
|
existsDept.add(map.get("name_").toString());
|
|
|
intactData.add(intac);
|
|
|
}
|
|
|
+ for (Map<String, Object> map : enableList){
|
|
|
+ if ("3".equals(map.get("depth_").toString())){
|
|
|
+ EquipIntactDTO intac = new EquipIntactDTO();
|
|
|
+ intac.setOrg(map.get("name_").toString());
|
|
|
+ intac.setDepth(Integer.parseInt(map.get("depth_").toString()));
|
|
|
+ intac.setNumR(enableNum);
|
|
|
+ existsDept.add(map.get("name_").toString());
|
|
|
+ intactData.add(intac);
|
|
|
+ }
|
|
|
+ }
|
|
|
List<Map<String, Object>> sumList = (List<Map<String, Object>>) commonDao.query(sumSql);
|
|
|
for (Map<String, Object> map : sumList){
|
|
|
EquipIntactDTO intac = new EquipIntactDTO();
|
|
|
intac.setOrg(map.get("name_").toString());
|
|
|
+ intac.setDepth(Integer.parseInt(map.get("depth_").toString()));
|
|
|
intac.setNumAll(Integer.parseInt(map.get("value").toString()));
|
|
|
+ sumNum = sumNum + Integer.parseInt(map.get("value").toString());
|
|
|
existsDept.add(map.get("name_").toString());
|
|
|
intactData.add(intac);
|
|
|
}
|
|
|
+ for (Map<String, Object> map : sumList){
|
|
|
+ if ("3".equals(map.get("depth_").toString())){
|
|
|
+ EquipIntactDTO intac = new EquipIntactDTO();
|
|
|
+ intac.setOrg(map.get("name_").toString());
|
|
|
+ intac.setDepth(Integer.parseInt(map.get("depth_").toString()));
|
|
|
+ intac.setNumAll(sumNum);
|
|
|
+ existsDept.add(map.get("name_").toString());
|
|
|
+ intactData.add(intac);
|
|
|
+ }
|
|
|
+ }
|
|
|
List<Map<String, Object>> limitList = (List<Map<String, Object>>) commonDao.query(limitSql);
|
|
|
for (Map<String, Object> map : limitList){
|
|
|
EquipIntactDTO intac = new EquipIntactDTO();
|
|
|
intac.setOrg(map.get("name_").toString());
|
|
|
+ intac.setDepth(Integer.parseInt(map.get("depth_").toString()));
|
|
|
intac.setNumLimit(Integer.parseInt(map.get("value").toString()));
|
|
|
+ limitNum = limitNum + Integer.parseInt(map.get("value").toString());
|
|
|
existsDept.add(map.get("name_").toString());
|
|
|
intactData.add(intac);
|
|
|
}
|
|
|
+ for (Map<String, Object> map : limitList){
|
|
|
+ if ("3".equals(map.get("depth_").toString())){
|
|
|
+ EquipIntactDTO intac = new EquipIntactDTO();
|
|
|
+ intac.setOrg(map.get("name_").toString());
|
|
|
+ intac.setDepth(Integer.parseInt(map.get("depth_").toString()));
|
|
|
+ intac.setNumLimit(limitNum);
|
|
|
+ existsDept.add(map.get("name_").toString());
|
|
|
+ intactData.add(intac);
|
|
|
+ }
|
|
|
+ }
|
|
|
List<Map<String, Object>> scrapList = (List<Map<String, Object>>) commonDao.query(scrapSql);
|
|
|
for (Map<String, Object> map : scrapList){
|
|
|
EquipIntactDTO intac = new EquipIntactDTO();
|
|
|
intac.setOrg(map.get("name_").toString());
|
|
|
+ intac.setDepth(Integer.parseInt(map.get("depth_").toString()));
|
|
|
intac.setNumScrap(Integer.parseInt(map.get("value").toString()));
|
|
|
+ scrapNum = scrapNum + Integer.parseInt(map.get("value").toString());
|
|
|
existsDept.add(map.get("name_").toString());
|
|
|
intactData.add(intac);
|
|
|
}
|
|
|
+ for (Map<String, Object> map : scrapList){
|
|
|
+ if ("3".equals(map.get("depth_").toString())){
|
|
|
+ EquipIntactDTO intac = new EquipIntactDTO();
|
|
|
+ intac.setOrg(map.get("name_").toString());
|
|
|
+ intac.setDepth(Integer.parseInt(map.get("depth_").toString()));
|
|
|
+ intac.setNumScrap(scrapNum);
|
|
|
+ existsDept.add(map.get("name_").toString());
|
|
|
+ intactData.add(intac);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
Map<String, EquipIntactDTO> mergedDTOMap = new HashMap<>();
|
|
|
for (EquipIntactDTO dto : intactData) {
|
|
|
@@ -479,25 +688,24 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
public List<EquipServiceLifeDTO> getEquipServiceLife(){
|
|
|
Set<String> existsDept = new HashSet<>();
|
|
|
List<EquipServiceLifeDTO> lifeDTOList = new ArrayList<>();
|
|
|
- String sql = "SELECT p.name_,q.bian_zhi_bu_men_,COUNT(bian_zhi_bu_men_)as value from ( " +
|
|
|
- " SELECT bian_zhi_bu_men_ FROM t_sbdj WHERE %s and di_dian_='%s') q, " +
|
|
|
- " (SELECT name_,id_ from ibps_party_entity WHERE path_ like '%%%s%%' and DEPTH_>=3) p " +
|
|
|
- " where q.bian_zhi_bu_men_=p.id_ GROUP BY q.bian_zhi_bu_men_";
|
|
|
+ String sql = "SELECT p.name_,p.id_,p.depth_,COUNT(q.bian_zhi_bu_men_)as value from \n" +
|
|
|
+ "(SELECT name_,id_,depth_ from ibps_party_entity WHERE path_ like '%%%s%%' and DEPTH_>=3) p \n" +
|
|
|
+ "left join (SELECT bian_zhi_bu_men_ FROM t_sbdj WHERE %s and di_dian_='%s') q ON p.id_=q.bian_zhi_bu_men_ GROUP BY p.id_";
|
|
|
|
|
|
String conditions = "TIMESTAMPDIFF(YEAR, chu_chang_ri_qi_, CURDATE())<1";
|
|
|
- List<Map<String, Object>> listO = (List<Map<String, Object>>) commonDao.query(String.format(sql,conditions,getDiDian(),getDiDian()));
|
|
|
+ List<Map<String, Object>> listO = (List<Map<String, Object>>) commonDao.query(String.format(sql,getDiDian(),conditions,getDiDian()));
|
|
|
getLife(listO,lifeDTOList,existsDept,"O");
|
|
|
|
|
|
conditions = "TIMESTAMPDIFF(YEAR, chu_chang_ri_qi_, CURDATE())>=1 and TIMESTAMPDIFF(YEAR, chu_chang_ri_qi_, CURDATE())<3";
|
|
|
- List<Map<String, Object>> listOT = (List<Map<String, Object>>) commonDao.query(String.format(sql,conditions,getDiDian(),getDiDian()));
|
|
|
+ List<Map<String, Object>> listOT = (List<Map<String, Object>>) commonDao.query(String.format(sql,getDiDian(),conditions,getDiDian()));
|
|
|
getLife(listOT,lifeDTOList,existsDept,"OF");
|
|
|
|
|
|
conditions = "TIMESTAMPDIFF(YEAR, chu_chang_ri_qi_, CURDATE())>=3 and TIMESTAMPDIFF(YEAR, chu_chang_ri_qi_, CURDATE())<5";
|
|
|
- List<Map<String, Object>> listTF = (List<Map<String, Object>>) commonDao.query(String.format(sql,conditions,getDiDian(),getDiDian()));
|
|
|
+ List<Map<String, Object>> listTF = (List<Map<String, Object>>) commonDao.query(String.format(sql,getDiDian(),conditions,getDiDian()));
|
|
|
getLife(listTF,lifeDTOList,existsDept,"TF");
|
|
|
|
|
|
conditions = "TIMESTAMPDIFF(YEAR, chu_chang_ri_qi_, CURDATE())>=5";
|
|
|
- List<Map<String, Object>> listF = (List<Map<String, Object>>) commonDao.query(String.format(sql,conditions,getDiDian(),getDiDian()));
|
|
|
+ List<Map<String, Object>> listF = (List<Map<String, Object>>) commonDao.query(String.format(sql,getDiDian(),conditions,getDiDian()));
|
|
|
getLife(listF,lifeDTOList,existsDept,"F");
|
|
|
|
|
|
Map<String, EquipServiceLifeDTO> mergedDTOMap = new HashMap<>();
|
|
|
@@ -513,21 +721,25 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
}
|
|
|
}
|
|
|
List<EquipServiceLifeDTO> mergedList = new ArrayList<>(mergedDTOMap.values());
|
|
|
-
|
|
|
- List<EquipServiceLifeDTO> finalList = new ArrayList<>(mergedList);
|
|
|
- List<Map<String, Object>> deptList = getPositionBy34(getDiDian());
|
|
|
- for (Map<String, Object> dept : deptList) {
|
|
|
- if (!existsDept.contains(dept.get("name_"))) {
|
|
|
- EquipServiceLifeDTO lifeDTO = new EquipServiceLifeDTO();
|
|
|
- lifeDTO.setOrg(dept.get("name_").toString());
|
|
|
- lifeDTO.setNumO(0);
|
|
|
- lifeDTO.setNumOT(0);
|
|
|
- lifeDTO.setNumTF(0);
|
|
|
- lifeDTO.setNumF(0);
|
|
|
- finalList.add(lifeDTO);
|
|
|
+ if (Collections.isEmpty(mergedList)){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ int numO = 0;int numOT= 0;int numTF= 0;int numF= 0;
|
|
|
+ for (EquipServiceLifeDTO dto : mergedList) {
|
|
|
+ numO += dto.getNumO();
|
|
|
+ numOT += dto.getNumOT();
|
|
|
+ numTF += dto.getNumTF();
|
|
|
+ numF += dto.getNumF();
|
|
|
+ }
|
|
|
+ for (EquipServiceLifeDTO dto : mergedList) {
|
|
|
+ if (dto.getDepth() == 3) {
|
|
|
+ dto.setNumO(numO);
|
|
|
+ dto.setNumOT(numOT);
|
|
|
+ dto.setNumTF(numTF);
|
|
|
+ dto.setNumF(numF);
|
|
|
}
|
|
|
}
|
|
|
- return finalList;
|
|
|
+ return mergedList;
|
|
|
}
|
|
|
|
|
|
public void getLife(List<Map<String, Object>> list,List<EquipServiceLifeDTO> lifeDTOList,Set<String> existsDept,String flag){
|
|
|
@@ -535,6 +747,7 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
EquipServiceLifeDTO lifeDTO = new EquipServiceLifeDTO();
|
|
|
lifeDTO.setOrg(map.get("name_").toString());
|
|
|
int value = Integer.parseInt(map.get("value").toString());
|
|
|
+ lifeDTO.setDepth(Integer.parseInt(map.get("depth_").toString()));
|
|
|
switch (flag){
|
|
|
case "O":
|
|
|
lifeDTO.setNumO(value);
|
|
|
@@ -559,13 +772,11 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
|
|
|
|
|
|
public List<EquipDeptDTO> getEquipByPosition(int total){
|
|
|
- String sql = "SELECT p.name_,q.bian_zhi_bu_men_,COUNT(bian_zhi_bu_men_)as value from ( " +
|
|
|
- " SELECT bian_zhi_bu_men_ from t_sbdj WHERE di_dian_='%s') q, " +
|
|
|
- " (SELECT name_,id_ from ibps_party_entity WHERE path_ like '%%%s%%' and DEPTH_>=3) p " +
|
|
|
- " where q.bian_zhi_bu_men_=p.id_ GROUP BY q.bian_zhi_bu_men_ ";
|
|
|
+ String sql = "SELECT p.name_,p.id_,p.depth_,COUNT(bian_zhi_bu_men_)as value from \n" +
|
|
|
+ "(SELECT name_,id_,depth_ from ibps_party_entity WHERE path_ like '%%%s%%' and DEPTH_>3) p \n" +
|
|
|
+ "left join (SELECT bian_zhi_bu_men_ from t_sbdj WHERE di_dian_='%s') q on q.bian_zhi_bu_men_=p.id_ GROUP BY q.bian_zhi_bu_men_ ";
|
|
|
List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(String.format(sql,getDiDian(),getDiDian()));
|
|
|
List<EquipDeptDTO> typeDTOList = new ArrayList<>();
|
|
|
- Set<String> existsDept = new HashSet<>();
|
|
|
for (Map<String, Object> map: list){
|
|
|
EquipDeptDTO typeDTO = new EquipDeptDTO();
|
|
|
int value = Integer.parseInt(map.get("value").toString());
|
|
|
@@ -573,33 +784,8 @@ public class StatisticServiceImpl implements StatisticService {
|
|
|
typeDTO.setName(map.get("name_").toString());
|
|
|
typeDTO.setRate(getRate(total,value));
|
|
|
typeDTOList.add(typeDTO);
|
|
|
- existsDept.add(map.get("name_").toString());
|
|
|
- }
|
|
|
- List<EquipDeptDTO> finalList = new ArrayList<>(typeDTOList);
|
|
|
- List<Map<String, Object>> deptList = getPositionBy34(getDiDian());
|
|
|
- for (Map<String, Object> dept : deptList) {
|
|
|
- if (!existsDept.contains(dept.get("name_"))) {
|
|
|
- EquipDeptDTO typeDTO = new EquipDeptDTO();
|
|
|
- typeDTO.setName(dept.get("name_").toString());
|
|
|
- typeDTO.setValue(0);
|
|
|
- typeDTO.setRate("0.00");
|
|
|
- finalList.add(typeDTO);
|
|
|
- }
|
|
|
- }
|
|
|
- return finalList;
|
|
|
- }
|
|
|
-
|
|
|
- public List<T> setPosition(List<T> original, Set<String> exists, Class<T> clazz) throws Exception {
|
|
|
- Method setNameMethod = clazz.getMethod("setName", String.class);
|
|
|
- List<Map<String, Object>> deptList = getPositionBy34(getDiDian());
|
|
|
- for (Map<String, Object> map : deptList) {
|
|
|
- if (!exists.contains(map.get("name_"))) {
|
|
|
- for (T t : original) {
|
|
|
- setNameMethod.invoke(t, map.get("name_"));
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
- return original;
|
|
|
+ return typeDTOList;
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> getPositionBy34(String diDian){
|