ShowTableRecodUtil.java 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465
  1. package com.zhcs.dt.controller.information.annualPlan;
  2. import java.io.IOException;
  3. import java.math.BigDecimal;
  4. import java.math.BigInteger;
  5. import java.text.SimpleDateFormat;
  6. import java.util.ArrayList;
  7. import java.util.Date;
  8. import java.util.HashMap;
  9. import java.util.List;
  10. import java.util.Map;
  11. import java.util.Properties;
  12. import javax.annotation.Resource;
  13. import org.springframework.core.io.support.PropertiesLoaderUtils;
  14. import com.zhcs.dt.service.information.annualPlan.impl.AnnualDailyCompService;
  15. import com.zhcs.dt.util.PageData;
  16. public class ShowTableRecodUtil {
  17. private AnnualDailyCompService annualDailyCompService;
  18. private String[] dailyPlanType = { "CLEAN_PLAN_COST", "PATROL_PLAN_COST", "SUBGRADE_PLAN_COST",
  19. "PAVEMENT_PLAN_COST", "BRIDGE_PLAN_COST", "CULVERT_PLAN_COST", "TUNNEL_PLAN_COST", "GREEN_PLAN_COST",
  20. "SAFE_PLAN_COST", "LINE_PLAN_COST", "CAR_PLAN_COST", "EMERGENCY_PLAN_COST" };
  21. // private String[] dailyCompType = {"CLEAN_COST", "PATROL_COST", "SUBGRADE_COST","PAVEMENT_COST",
  22. // "BRIDGE_COST","CULVERT_COST","TUNNEL_COST","GREEN_COST","SAFE_COST","LINE_COST",
  23. // "CAR_COST","EMERGENCY_COST"};
  24. private String[] annDailyCompType = { "CLEAN_COST", "PATROL_COST", "SUBGRADE_COST", "PAVEMENT_COST", "BRIDGE_COST",
  25. "CULVERT_COST", "TUNNEL_COST", "TRAFFIC_SAFE_COST", "ROADSIDE_COST", "GREEN_COST", "MAINT_COST",
  26. "EMERGENCY_COST" };
  27. public List<PageData> showTableRecod(AnnualDailyCompService annualDailyCompService, PageData pd) throws Exception {
  28. this.annualDailyCompService = annualDailyCompService;
  29. List<PageData> varList = new ArrayList<PageData>();
  30. PageData varPg = new PageData();
  31. String tableType = pd.getString("TABLETYPE");
  32. if ("highway_plan_comp_sumtable".equalsIgnoreCase(tableType)) {
  33. // 计划费用
  34. // PageData tempPg = annualDailyCompService.findDaliyPlanRecord(pd); // 日常养护
  35. // String dailyPlanCost = dailyPlanCostSum(tempPg);
  36. // varPg = annualDailyCompService.findTableInfo(pd);
  37. // varPg.put("YEAR", pd.get("YEAR"));
  38. // varPg = getPlanRecods(putPlanRecods(), varPg, pd);
  39. // String scientificPlanSum = findScientificPlanSum(pd);
  40. // if (scientificPlanSum != null) {
  41. // varPg.put("SCIENTIFIC_DESIGN", Double.parseDouble(scientificPlanSum)); // 科研项目
  42. // }
  43. // String equipmentPlanSum = findEquipmentPlanSum(pd);
  44. // if (equipmentPlanSum != null) {
  45. // varPg.put("DEVICE_DESIGN", Double.parseDouble(equipmentPlanSum)); // 设备大修
  46. // }
  47. // if (dailyPlanCost != "") {
  48. // varPg.put("DAILY_PLAN_COST", Double.parseDouble(dailyPlanCost));
  49. // }
  50. //
  51. // // 完成费用
  52. // varPg = getCompRecods(putCompRecods(), varPg, pd);
  53. pd.put("VIEW_NAME", "annual_comp_sumtable_view");
  54. varPg = annualDailyCompService.findViewRecords(pd); //获取视图返回结果
  55. pd.put("FROM_TABLE", "highway_annual_plan_sumtable");
  56. PageData tempPg = annualDailyCompService.findAllRecods(pd);
  57. if(tempPg != null){
  58. if(tempPg.get("DAILY_REMARKS") != null){
  59. varPg.put("DAILY_REMARKS", tempPg.get("DAILY_REMARKS"));
  60. }
  61. if(tempPg.get("PREVENTION_REMARKS") != null){
  62. varPg.put("PREVENTION_REMARKS", tempPg.get("PREVENTION_REMARKS"));
  63. }
  64. if(tempPg.get("REPAIR_REMARKS") != null){
  65. varPg.put("REPAIR_REMARKS", tempPg.get("REPAIR_REMARKS"));
  66. }
  67. if(tempPg.get("TEST_REMARKS") != null){
  68. varPg.put("TEST_REMARKS", tempPg.get("TEST_REMARKS"));
  69. }
  70. if(tempPg.get("SCIENTIFIC_REMARKS") != null){
  71. varPg.put("SCIENTIFIC_REMARKS", tempPg.get("SCIENTIFIC_REMARKS"));
  72. }
  73. if(tempPg.get("DEVICE_REMARKS") != null){
  74. varPg.put("DEVICE_REMARKS", tempPg.get("DEVICE_REMARKS"));
  75. }
  76. if(tempPg.get("RESERVE_REMARKS") != null){
  77. varPg.put("RESERVE_REMARKS", tempPg.get("RESERVE_REMARKS"));
  78. }
  79. }
  80. varPg = dealCompSum(varPg);
  81. varList.add(varPg);
  82. } else if ("highway_daily_plan_statable".equalsIgnoreCase(tableType)) {
  83. pd.put("FROM_TABLE", "highway_daily_plan_statable");
  84. varList = annualDailyCompService.getAllRecords(pd); // 计划
  85. } else if ("highway_prevention_plan_sumtable".equalsIgnoreCase(tableType)) {
  86. pd.put("FROM_TABLE", "highway_prevention_project_dettable");
  87. List<PageData> tempList = annualDailyCompService.getAllRecords(pd); // 计划
  88. for (PageData temppd : tempList) {
  89. if(temppd.get("QUANTITIES") != null){
  90. temppd.put("PLAN_QUANTITIES", temppd.get("QUANTITIES"));
  91. }
  92. if(temppd.get("AUDIT_FEE") != null){
  93. temppd.put("PLAN_COST", temppd.get("AUDIT_FEE"));
  94. }else{
  95. temppd.put("PLAN_COST", temppd.get("TOTAL_COST"));
  96. }
  97. if(temppd.get("SJWCGCL") != null){
  98. temppd.put("ACTUAL_QUANTITIES", temppd.get("SJWCGCL"));
  99. }
  100. temppd.put("PROJECT_TYPE", temppd.get("CATEGORY"));
  101. temppd.put("SCALE", temppd.get("PROJECT_SCALE"));
  102. if(temppd.get("OTHER_MATTER") != null){
  103. temppd.put("REMARKS", temppd.get("OTHER_MATTER"));
  104. }
  105. pd.put("FROM_TABLE", "monthly_prevention_completion");
  106. pd.put("PROJECT_NAME", temppd.get("PROJECT_NAME"));
  107. Object actualCost = annualDailyCompService.getCompSumForProject(pd); // 获取每个项目的实际费用
  108. if(actualCost != null){
  109. BigDecimal actual = getBigDecimal(actualCost);
  110. temppd.put("ACTUAL_COST", actual);
  111. }
  112. if(temppd.get("ACTUAL_COST") != null && temppd.get("PLAN_COST")!= null){
  113. temppd.put("COMPLETE_RATIO", math(temppd.get("ACTUAL_COST"),temppd.get("PLAN_COST")).toString());
  114. }
  115. varList.add(temppd);
  116. }
  117. } else if ("highway_repair_comp_sumtable".equalsIgnoreCase(tableType)) {
  118. pd.put("FROM_TABLE", "highway_repair_project_dettable");
  119. List<PageData> tempList = annualDailyCompService.getAllRecords(pd); // 计划
  120. for (PageData temppd : tempList) {
  121. if(temppd.get("QUANTITIES") != null){
  122. temppd.put("PLAN_QUANTITIES", temppd.get("QUANTITIES"));
  123. }
  124. if(temppd.get("AUDIT_FEE") != null){
  125. temppd.put("PLAN_COST", temppd.get("AUDIT_FEE"));
  126. }else if(temppd.get("TOTAL_COST") != null){
  127. temppd.put("PLAN_COST", temppd.get("TOTAL_COST"));
  128. }
  129. if(temppd.get("SJWCGCL") != null){
  130. temppd.put("ACTUAL_QUANTITIES", temppd.get("SJWCGCL"));
  131. }
  132. temppd.put("PROJECT_TYPE", temppd.get("CATEGORY"));
  133. temppd.put("SCALE", temppd.get("PROJECT_SCALE"));
  134. if(temppd.get("OTHER_MATTER") != null){
  135. temppd.put("REMARKS", temppd.get("OTHER_MATTER"));
  136. }
  137. pd.put("FROM_TABLE", "monthly_repair_completion");
  138. pd.put("PROJECT_NAME", temppd.get("PROJECT_NAME"));
  139. Object actualCost = annualDailyCompService.getCompSumForProject(pd); // 获取每个项目的实际费用
  140. if(actualCost != null){
  141. BigDecimal actual = getBigDecimal(actualCost);
  142. temppd.put("ACTUAL_COST", actual);
  143. }
  144. if(temppd.get("ACTUAL_COST") != null && temppd.get("PLAN_COST")!= null){
  145. if(!"0.0".equals(temppd.get("PLAN_COST").toString())){
  146. temppd.put("COMPLETE_RATIO", math(temppd.get("ACTUAL_COST"),temppd.get("PLAN_COST")).toString());
  147. }
  148. }
  149. varList.add(temppd);
  150. }
  151. } else if ("highway_daily_comp_sumtable".equalsIgnoreCase(tableType)) {
  152. // pd.put("FROM_TABLE", "highway_daily_plan_statable");
  153. // List<PageData> tempList = annualDailyCompService.getAllRecords(pd); // 计划
  154. // PageData temppd = new PageData();
  155. // if(tempList.size() > 0){
  156. // temppd = tempList.get(0);
  157. // }else{
  158. // temppd = pd;
  159. // }
  160. // for(String type : annDailyCompType){
  161. // pd.put("TYPE", type);
  162. // String payCost = annualDailyCompService.getDaliyCompRecord(pd); // 获取每个项目的实际费用
  163. // if(payCost != null){
  164. // temppd.put(type, payCost);
  165. // }
  166. // }
  167. pd.put("VIEW_NAME", "annual_daily_comp_sumtable_view");
  168. PageData temppd = annualDailyCompService.findViewRecords(pd); //获取视图返回结果
  169. if(temppd != null){
  170. varList.add(temppd);
  171. }
  172. } else if ("highway_special_comp_sumtable".equalsIgnoreCase(tableType)) {
  173. /*pd.put("FROM_TABLE", "highway_special_plan_statable");
  174. List<PageData> tempList = annualDailyCompService.getAllRecords(pd); // 计划
  175. for (PageData temppd : tempList) {
  176. temppd.put("PLAN_COST", temppd.get("ESTIMATION"));
  177. pd.put("FROM_TABLE", "monthly_special_completion");
  178. pd.put("PROJECT_NAME", temppd.get("SPECIAL_PROJECT_NAME"));
  179. String compSum = annualDailyCompService.getCompSumForProject(pd); // 获取每个项目的实际费用
  180. if (compSum != null) {
  181. temppd.put("ACTUAL_COST", Double.parseDouble(compSum));
  182. }
  183. varList.add(temppd);
  184. }*/
  185. pd.put("FROM_TABLE", "highway_special_comp_sumtable_view");
  186. List<PageData> tempList = annualDailyCompService.getAllRecords(pd); // 计划
  187. for (PageData temppd : tempList) {
  188. if(temppd.get("PLAN_COST") != null){
  189. temppd.put("PLAN_COST", temppd.get("PLAN_COST"));
  190. }
  191. Object actualCost = temppd.get("ACTUAL_COST");
  192. if(actualCost != null){
  193. BigDecimal actual = getBigDecimal(actualCost);
  194. temppd.put("ACTUAL_COST", actual);
  195. }
  196. varList.add(temppd);
  197. }
  198. } else if ("highway_test_comp_sumtable".equalsIgnoreCase(tableType)) {
  199. // 计划费用
  200. pd.put("FROM_TABLE", "highway_test_plan_statable");
  201. List<PageData> tempList = annualDailyCompService.getAllRecords(pd); // 计划
  202. for (PageData temppd : tempList) {
  203. if(temppd.get("COST_ESTIMAT") != null){
  204. temppd.put("PLAN_COST", temppd.get("COST_ESTIMAT"));
  205. }
  206. pd.put("FROM_TABLE", "monthly_test_project_completion");
  207. if(temppd.get("PROJECT_NAME") != null){
  208. pd.put("PROJECT_NAME", temppd.get("PROJECT_NAME"));
  209. }
  210. String compSum = annualDailyCompService.getCompSumForProject(pd); // 获取每个项目的实际费用
  211. if (compSum != null) {
  212. BigDecimal actual = getBigDecimal(compSum);
  213. temppd.put("ACTUAL_COST", actual);
  214. }
  215. varList.add(temppd);
  216. }
  217. } else if ("highway_scientific_comp_sumtable".equalsIgnoreCase(tableType)) { // 科研项目
  218. // 计划费用
  219. pd.put("FROM_TABLE", "highway_scientific_plan_statable");
  220. List<PageData> tempList = annualDailyCompService.getAllRecords(pd); // 计划
  221. for (PageData temppd : tempList) {
  222. temppd.put("PLAN_COST", temppd.get("COST_ESTIMAT"));
  223. pd.put("FROM_TABLE", "monthly_scientific_project_completion");
  224. pd.put("PROJECT_NAME", temppd.get("PROJECT_NAME"));
  225. String compSum = annualDailyCompService.getCompSumForProject(pd); // 获取每个项目的实际费用
  226. if (compSum != null) {
  227. temppd.put("ACTUAL_COST", Double.parseDouble(compSum));
  228. }
  229. varList.add(temppd);
  230. }
  231. } else if ("highway_equipment_overhaul_comp_sumtable".equalsIgnoreCase(tableType)) { // 设备大修
  232. // 计划费用
  233. pd.put("FROM_TABLE", "highway_equipment_overhaul_plan_statable");
  234. List<PageData> tempList = annualDailyCompService.getAllRecords(pd); // 计划
  235. for (PageData temppd : tempList) {
  236. temppd.put("PLAN_COST", temppd.get("ESTIMATE_COST"));
  237. pd.put("FROM_TABLE", "monthly_equipment_overhaul_completion");
  238. pd.put("PROJECT_NAME", temppd.get("PROJECT_NAME"));
  239. String compSum = annualDailyCompService.getCompSumForProject(pd); // 获取每个项目的实际费用
  240. if (compSum != null) {
  241. temppd.put("ACTUAL_COST", compSum);
  242. }
  243. varList.add(temppd);
  244. }
  245. } else if ("highway_quality_goals_table".equalsIgnoreCase(tableType)) { // 高速公路养护质量目标表
  246. PageData temppd = annualDailyCompService.getQualityRecords(pd); // 现状
  247. /*StringBuffer TECHNOLOGY_STATUS = new StringBuffer();
  248. if (temppd != null) {
  249. TECHNOLOGY_STATUS.append("一类桥梁占比:" + temppd.get("ONE_BRIDGE_PRO"));
  250. TECHNOLOGY_STATUS.append("\r\n");
  251. TECHNOLOGY_STATUS.append("二类桥梁占比:" + temppd.get("TWO_BRIDGE_PRO"));
  252. temppd.put("TECHNOLOGY_STATUS", TECHNOLOGY_STATUS.toString());*/
  253. varList.add(temppd);
  254. // }
  255. } else if ("highway_annual_plan_sumtable".equalsIgnoreCase(tableType)) {
  256. // 计划费用
  257. /*PageData tempPg = annualDailyCompService.findDaliyPlanRecord(pd); // 日常养护
  258. String dailyPlanCost = dailyPlanCostSum(tempPg);
  259. varPg = annualDailyCompService.findTableInfo(pd);
  260. varPg.put("YEAR", pd.get("YEAR"));
  261. varPg = getPlanRecods(putPlanRecods(), varPg, pd);
  262. String scientificPlanSum = findScientificPlanSum(pd);
  263. if (scientificPlanSum != null) {
  264. varPg.put("SCIENTIFIC_PLAN_COST", Double.parseDouble(scientificPlanSum)); // 科研项目
  265. }
  266. String equipmentPlanSum = findEquipmentPlanSum(pd);
  267. if (equipmentPlanSum != null) {
  268. varPg.put("DEVICE_PLAN_COST", Double.parseDouble(equipmentPlanSum)); // 设备大修
  269. }
  270. if (dailyPlanCost != "") {
  271. varPg.put("DAILY_PLAN_COST", Double.parseDouble(dailyPlanCost));
  272. }
  273. PageData totalCost = annualDailyCompService.getReserveFeesTotal(pd);
  274. if (totalCost != null) {
  275. if(totalCost.get("TOTAL_COST") != null){
  276. varPg.put("RESERVE_PLAN_COST", Double.parseDouble(totalCost.get("TOTAL_COST").toString()));
  277. }
  278. }*/
  279. //pd.put("VIEW_NAME", "annual_comp_sumtable_view");
  280. pd.put("VIEW_NAME", "highway_annual_plan_sumtable_view");
  281. varPg = annualDailyCompService.findViewRecords(pd); //获取视图返回结果
  282. /*if(varPg != null){
  283. List<Object> subVar = new ArrayList<Object>();
  284. subVar.add(varPg.get("MINOR_PREVENTION_DESIGN"));
  285. subVar.add(varPg.get("MIDDLE_PREVENTION_DESIGN"));
  286. subVar.add(varPg.get("OVERHAUL_PREVENTION_DESIGN"));
  287. String sum1 = getSum(subVar);
  288. if(!"0.0".equalsIgnoreCase(sum1)){
  289. varPg.put("PREVENTION_PLAN_COST", sum1);
  290. }
  291. subVar = new ArrayList<Object>();
  292. subVar.add(varPg.get("MINOR_REPAIR_DESIGN"));
  293. subVar.add(varPg.get("MIDDLE_REPAIR_DESIGN"));
  294. subVar.add(varPg.get("OVERHAUL_DESIGN"));
  295. String sum2 = getSum(subVar);
  296. if(!"0.0".equalsIgnoreCase(sum2)){
  297. varPg.put("REPAIR_PLAN_COST", sum2);
  298. }
  299. }*/
  300. pd.put("FROM_TABLE", "highway_annual_plan_sumtable");
  301. PageData tempPg = annualDailyCompService.findAllRecods(pd);
  302. if(tempPg != null){
  303. if(tempPg.get("DAILY_REMARKS") != null){
  304. varPg.put("DAILY_REMARKS", tempPg.get("DAILY_REMARKS"));
  305. }
  306. if(tempPg.get("PREVENTION_REMARKS") != null){
  307. varPg.put("PREVENTION_REMARKS", tempPg.get("PREVENTION_REMARKS"));
  308. }
  309. if(tempPg.get("REPAIR_REMARKS") != null){
  310. varPg.put("REPAIR_REMARKS", tempPg.get("REPAIR_REMARKS"));
  311. }
  312. if(tempPg.get("TEST_REMARKS") != null){
  313. varPg.put("TEST_REMARKS", tempPg.get("TEST_REMARKS"));
  314. }
  315. if(tempPg.get("SCIENTIFIC_REMARKS") != null){
  316. varPg.put("SCIENTIFIC_REMARKS", tempPg.get("SCIENTIFIC_REMARKS"));
  317. }
  318. if(tempPg.get("DEVICE_REMARKS") != null){
  319. varPg.put("DEVICE_REMARKS", tempPg.get("DEVICE_REMARKS"));
  320. }
  321. if(tempPg.get("RESERVE_REMARKS") != null){
  322. varPg.put("RESERVE_REMARKS", tempPg.get("RESERVE_REMARKS"));
  323. }
  324. }
  325. varList.add(varPg);
  326. } else if ("highway_prevention_plan_statable".equalsIgnoreCase(tableType)) { // 预防养护计划统计
  327. pd.put("FROM_TABLE", tableType);
  328. varList = annualDailyCompService.getAllRecords(pd); // 计划
  329. for(PageData tpd: varList){
  330. if(tpd.get("AUDIT_FEE") != null){
  331. tpd.put("ESTIMATION", tpd.get("AUDIT_FEE"));
  332. }
  333. }
  334. } else if ("highway_repair_plan_statable".equalsIgnoreCase(tableType)) { // 修复养护计划统计
  335. pd.put("FROM_TABLE", tableType);
  336. varList = annualDailyCompService.getAllRecords(pd); // 计划
  337. for(PageData tpd: varList){
  338. if(tpd.get("AUDIT_FEE") != null){
  339. tpd.put("ESTIMATION", tpd.get("AUDIT_FEE"));
  340. }
  341. }
  342. } else if ("highway_special_plan_statable".equalsIgnoreCase(tableType)) { // 专项养护计划统计
  343. pd.put("FROM_TABLE", tableType);
  344. varList = annualDailyCompService.getSpecialRecords(pd); // 计划
  345. for(PageData tpd: varList){
  346. if(tpd.get("AUDIT_FEE") != null){
  347. tpd.put("ESTIMATION", tpd.get("AUDIT_FEE"));
  348. }else if(tpd.get("PROJECT_COST") != null){
  349. tpd.put("ESTIMATION", tpd.get("PROJECT_COST"));
  350. }
  351. }
  352. } else if ("highway_test_plan_statable".equalsIgnoreCase(tableType)) { // 检测项目计划统计
  353. pd.put("FROM_TABLE", tableType);
  354. varList = annualDailyCompService.getAllRecords(pd); // 计划
  355. for(PageData tpd: varList){
  356. if(tpd.get("AUDIT_FEE") != null){
  357. tpd.put("COST_ESTIMAT", tpd.get("AUDIT_FEE"));
  358. }
  359. }
  360. } else if ("highway_scientific_plan_statable".equalsIgnoreCase(tableType)) { // 科研项目计划统计
  361. pd.put("FROM_TABLE", tableType);
  362. varList = annualDailyCompService.getAllRecords(pd); // 计划
  363. for (PageData var : varList) {
  364. if (var.get("RESEARCH_CONTENTS") != null) {
  365. var.put("CONTENTS", var.get("RESEARCH_CONTENTS"));
  366. }
  367. if(var.get("AUDIT_FEE") != null){
  368. var.put("COST_ESTIMAT", var.get("AUDIT_FEE"));
  369. }
  370. }
  371. } else if ("highway_equipment_overhaul_plan_statable".equalsIgnoreCase(tableType)) { // 设备大修计划统计
  372. pd.put("FROM_TABLE", tableType);
  373. varList = annualDailyCompService.getAllRecords(pd); // 计划
  374. for(PageData tpd: varList){
  375. if(tpd.get("AUDIT_FEE") != null){
  376. tpd.put("ESTIMATE_COST", tpd.get("AUDIT_FEE"));
  377. }
  378. }
  379. } else if ("highway_reserve_fees_sumtable".endsWith(tableType)) { // 预备费
  380. pd.put("FROM_TABLE", tableType);
  381. List<PageData> tempList = annualDailyCompService.getAllRecords(pd);
  382. PageData totalCost = annualDailyCompService.getReserveFeesTotal(pd);
  383. if (tempList.size() > 0) {
  384. for (PageData varpd : tempList) {
  385. BigDecimal actual_cost = getBigDecimal(varpd.get("ACTUAL_COST"));
  386. varpd.put("ACTUAL_COST", actual_cost);
  387. varList.add(varpd);
  388. }
  389. }
  390. if (totalCost != null && totalCost.get("TOTAL_COST") != null) {
  391. pd.put("TOTAL_COST", Double.parseDouble(totalCost.get("TOTAL_COST").toString()));
  392. }
  393. //varList.add(pd);
  394. }
  395. // 年度总报告数据
  396. else if ("annual_comp_sumtable".equalsIgnoreCase(tableType)) { // 单位养护计划完成情况汇总表
  397. varList = getAnnualCompRecods(pd);
  398. } else if ("annual_daily_comp_sumtable".equalsIgnoreCase(tableType)) { // 日常养护计划完成情况汇总表
  399. varList = getAnnualDailyCompRecod(pd);
  400. } else if ("annual_prevention_comp_sumtable".equalsIgnoreCase(tableType)) { // 预防养护计划完成情况汇总表
  401. varList = getPreventionCompRecod(pd);
  402. } else if ("annual_repair_comp_sumtable".equalsIgnoreCase(tableType)) { // 单位修复养护计划完成情况汇总表
  403. varList = getRepairCompRecod(pd);
  404. } else if ("annual_plan_sumtable".equalsIgnoreCase(tableType)) { // 单位养护计划汇总表
  405. //varList = getAnnualPlanRecod(pd);
  406. pd.put("VIEW_NAME", "annual_comp_sumtable_view");
  407. varList = annualDailyCompService.findViewRecordsList(pd); //获取视图返回结果
  408. } else if ("annual_daily_plan_sumtable".equalsIgnoreCase(tableType)) { // 单位日常养护计划汇总表
  409. varList = getAnnualDailyPlanRecod(pd);
  410. } else if ("annual_prevention_plan_sumtable".equalsIgnoreCase(tableType)) { // 单位预防养护计划汇总表
  411. //varList = getPreventionPlanRecod(pd);
  412. pd.put("VIEW_NAME", "annual_prevention_comp_sumtable_view");
  413. varList = annualDailyCompService.findViewRecordsList(pd); //获取视图返回结果
  414. } else if ("annual_repair_plan_sumtable".equalsIgnoreCase(tableType)) { // 单位修复养护计划汇总表
  415. //varList = getRepairPlanRecod(pd);
  416. pd.put("VIEW_NAME", "annual_repair_comp_sumtable_view");
  417. varList = annualDailyCompService.findViewRecordsList(pd); //获取视图返回结果
  418. }
  419. return varList;
  420. }
  421. // 算完成比例
  422. public Double math(Object act_cost, Object plan_cost) throws NumberFormatException, Exception {
  423. return Double.parseDouble(act_cost.toString())/Double.parseDouble(plan_cost.toString())*100;
  424. }
  425. // 计算费用/公里
  426. public Double mathKm(Object act_cost, Object plan_cost) throws NumberFormatException, Exception {
  427. return Double.parseDouble(act_cost.toString())/Double.parseDouble(plan_cost.toString());
  428. }
  429. private PageData dealCompSum(PageData varPg){
  430. if(varPg != null){
  431. List<Object> subVar = new ArrayList<Object>();
  432. subVar.add(varPg.get("MINOR_PREVENTION_DESIGN"));
  433. subVar.add(varPg.get("MIDDLE_PREVENTION_DESIGN"));
  434. subVar.add(varPg.get("OVERHAUL_PREVENTION_DESIGN"));
  435. String sum1 = getSum(subVar);
  436. if(!"0.0".equalsIgnoreCase(sum1)){
  437. varPg.put("PREVENTION_PLAN_COST", sum1);
  438. }
  439. subVar = new ArrayList<Object>();
  440. subVar.add(varPg.get("MINOR_PREVENTION_COMPLETE"));
  441. subVar.add(varPg.get("MIDDLE_PREVENTION_COMPLETE"));
  442. subVar.add(varPg.get("OVERHAUL_PREVENTION_COMPLETE"));
  443. String sum3 = getSum(subVar);
  444. if(!"0.0".equalsIgnoreCase(sum3)){
  445. varPg.put("PREVENTION_COMPLETE_COST", sum3);
  446. }
  447. subVar = new ArrayList<Object>();
  448. subVar.add(varPg.get("MINOR_REPAIR_DESIGN"));
  449. subVar.add(varPg.get("MIDDLE_REPAIR_DESIGN"));
  450. subVar.add(varPg.get("OVERHAUL_DESIGN"));
  451. String sum2 = getSum(subVar);
  452. if(!"0.0".equalsIgnoreCase(sum2)){
  453. varPg.put("REPAIR_PLAN_COST", sum2);
  454. }
  455. subVar = new ArrayList<Object>();
  456. subVar.add(varPg.get("MINOR_REPAIR_COMPLETE"));
  457. subVar.add(varPg.get("MIDDLE_REPAIR_COMPLETE"));
  458. subVar.add(varPg.get("OVERHAUL_COMPLETE"));
  459. String sum4 = getSum(subVar);
  460. if(!"0.0".equalsIgnoreCase(sum4)){
  461. varPg.put("REPAIR_COMPLETE_COST", sum4);
  462. }
  463. if(varPg.get("SPECIAL_DESIGN")!=null){
  464. varPg.put("SPECIAL_PLAN_COST", varPg.get("SPECIAL_DESIGN"));
  465. }
  466. if(varPg.get("SPECIAL_COMPLETE")!=null){
  467. varPg.put("SPECIAL_COMPLETE_COST", varPg.get("SPECIAL_COMPLETE"));
  468. }
  469. if(varPg.get("EMERGENCY_DESIGN")!=null){
  470. varPg.put("EMERGENCY_PLAN_COST", varPg.get("EMERGENCY_DESIGN"));
  471. }
  472. if(varPg.get("EMERGENCY_COMPLETE")!=null){
  473. varPg.put("EMERGENCY_COMPLETE_COST", varPg.get("EMERGENCY_COMPLETE"));
  474. }
  475. if(varPg.get("TEST_DESIGN")!=null){
  476. varPg.put("TEST_PLAN_COST", varPg.get("TEST_DESIGN"));
  477. }
  478. if(varPg.get("TEST_COMPLETE")!=null){
  479. varPg.put("TEST_COMPLETE_COST", varPg.get("TEST_COMPLETE"));
  480. }
  481. if(varPg.get("SCIENTIFIC_DESIGN")!=null){
  482. varPg.put("SCIENTIFIC_PLAN_COST", varPg.get("SCIENTIFIC_DESIGN"));
  483. }
  484. if(varPg.get("SCIENTIFIC_COMPLETE")!=null){
  485. varPg.put("SCIENTIFIC_COMPLETE_COST", varPg.get("SCIENTIFIC_COMPLETE"));
  486. }
  487. if(varPg.get("DEVICE_DESIGN")!=null){
  488. varPg.put("DEVICE_PLAN_COST", varPg.get("DEVICE_DESIGN"));
  489. }
  490. if(varPg.get("DEVICE_COMPLETE")!=null){
  491. varPg.put("DEVICE_COMPLETE_COST", varPg.get("DEVICE_COMPLETE"));
  492. }
  493. if(varPg.get("RESERVE_DESIGN")!=null){
  494. varPg.put("RESERVE_PLAN_COST", varPg.get("RESERVE_DESIGN"));
  495. }
  496. if(varPg.get("RESERVE_COMPLETE")!=null){
  497. varPg.put("RESERVE_COMPLETE_COST", varPg.get("RESERVE_COMPLETE"));
  498. }
  499. if(varPg.get("DAILY_DESIGN")!=null){
  500. varPg.put("DAILY_PLAN_COST", varPg.get("DAILY_DESIGN"));
  501. }
  502. if(varPg.get("DAILY_COMPLETE")!=null){
  503. varPg.put("DAILY_COMPLETE_COST", varPg.get("DAILY_COMPLETE"));
  504. }
  505. }
  506. return varPg;
  507. }
  508. private String getSum(List<Object> subVar){
  509. Double sumNum = (double) 0;
  510. for(Object var : subVar){
  511. if(var != null){
  512. sumNum += Double.parseDouble(var.toString());
  513. }
  514. }
  515. return String.valueOf(sumNum);
  516. }
  517. private List<PageData> getAnnualPlanRecod(PageData pd) throws Exception {
  518. List<PageData> pdateList = annualDailyCompService.getKmInfo(pd);
  519. for (PageData pdata : pdateList) {
  520. pd.put("ROAD_ID", pdata.get("ROAD_ID"));
  521. pd.put("ROAD", pdata.get("ROAD"));
  522. pdata.put("YEAR", pd.get("YEAR"));
  523. PageData tempPg = annualDailyCompService.findDaliyPlanRecord(pd); // 日常养护
  524. String dailyPlanCost = dailyPlanCostSum(tempPg);
  525. if (dailyPlanCost != null && !"".equals(dailyPlanCost)) {
  526. pdata.put("DAILY_COST", Double.parseDouble(dailyPlanCost)); // 日常养护计划费用
  527. }
  528. pdata = getPreAndRepPlanCost(pd, pdata, "highway_prevention_project_dettable_cost",
  529. "highway_prevention_project_dettable", "PREVENTION"); // 获取预防养护大中小修的计划费用
  530. pdata = getPreAndRepPlanCost(pd, pdata, "highway_repair_project_dettable_cost",
  531. "highway_repair_project_dettable", "REPAIR"); // 获取修复养护大中小修的计划费用
  532. Map<String, String> tableInfo = new HashMap<String, String>();
  533. tableInfo.put("highway_special_project_dettable", "SPECIAL"); // 专项养护
  534. tableInfo.put("highway_test_project_dettable", "TEST_PROJECT"); // 试验检测项目
  535. pdata = getPlanRecods(tableInfo, pdata, pd);
  536. String scientificPlanSum = findScientificPlanSum(pd);
  537. if (scientificPlanSum != null && !"".equals(scientificPlanSum)) {
  538. pdata.put("SCIENTIFIC", Double.parseDouble(scientificPlanSum)); // 科研项目
  539. }
  540. String equipmentPlanSum = findEquipmentPlanSum(pd);
  541. if (equipmentPlanSum != null && !"".equals(equipmentPlanSum)) {
  542. pdata.put("DEVICE", Double.parseDouble(equipmentPlanSum)); // 设备大修
  543. }
  544. String reservePlanSum = findReservePlanSum(pd);
  545. if (reservePlanSum != null && !"".equals(reservePlanSum)) {
  546. pdata.put("RESERVE", Double.parseDouble(reservePlanSum)); // 预备费
  547. }
  548. }
  549. return pdateList;
  550. }
  551. private List<PageData> getRepairCompRecod(PageData pd) throws Exception {
  552. // List<PageData> pdateList = annualDailyCompService.getKmInfo(pd);
  553. // for (PageData pdata : pdateList) {
  554. // pd.put("ROAD_ID", pdata.get("ROAD_ID"));
  555. // pd.put("ROAD", pdata.get("ROAD"));
  556. // pdata.put("YEAR", pd.get("YEAR"));
  557. // Map<String, String> tableInfo = new HashMap<String, String>();
  558. // tableInfo.put("highway_repair_project_dettable", "PLAN_COST"); // 修复养护
  559. // pdata = getPlanRecods(tableInfo, pdata, pd); // 修复养护计划费用
  560. // // 按规模和类别统计完成费用
  561. // Map<String, String> preventionType = getPreventionType(); // 修复养护类型同预防养护
  562. // pdata = getRepairCompRecods(preventionType, pdata, pd);
  563. // }
  564. List<PageData> pdateList = annualDailyCompService.getRepairCompRecod(pd);
  565. for(PageData tpd : pdateList){
  566. if(tpd.get("TOTAL")!=null && tpd.get("PLAN_COST")!=null){
  567. tpd.put("COM_RETIO", math(tpd.get("TOTAL"),tpd.get("PLAN_COST")).toString());
  568. }
  569. }
  570. return pdateList;
  571. }
  572. private List<PageData> getRepairPlanRecod(PageData pd) throws Exception {
  573. List<PageData> pdateList = annualDailyCompService.getKmInfo(pd);
  574. for (PageData pdata : pdateList) {
  575. pd.put("ROAD_ID", pdata.get("ROAD_ID"));
  576. pd.put("ROAD", pdata.get("ROAD"));
  577. pdata.put("YEAR", pd.get("YEAR"));
  578. // 按规模和类别统计计划费用
  579. Map<String, String> preventionType = getPreventionPlanType(); // 修复养护类型同预防养护
  580. pdata = getRepairPlanRecods(preventionType, pdata, pd);
  581. }
  582. return pdateList;
  583. }
  584. private List<PageData> getPreventionCompRecod(PageData pd) throws Exception {
  585. List<PageData> pdateList = annualDailyCompService.getKmInfo(pd);
  586. for (PageData pdata : pdateList) {
  587. pd.put("ROAD_ID", pdata.get("ROAD_ID"));
  588. pd.put("ROAD", pdata.get("ROAD"));
  589. pdata.put("YEAR", pd.get("YEAR"));
  590. Map<String, String> tableInfo = new HashMap<String, String>();
  591. tableInfo.put("highway_prevention_project_dettable", "PLAN_COST"); // 预防养护
  592. pdata = getPlanRecods(tableInfo, pdata, pd); // 预防养护计划费用
  593. // 按类别统计完成费用
  594. Map<String, String> preventionType = getPreventionType();
  595. pdata = getPreventionCompRecods(preventionType, pdata, pd);
  596. }
  597. return pdateList;
  598. }
  599. private List<PageData> getPreventionPlanRecod(PageData pd) throws Exception {
  600. List<PageData> pdateList = annualDailyCompService.getKmInfo(pd);
  601. for (PageData pdata : pdateList) {
  602. pd.put("ROAD_ID", pdata.get("ROAD_ID"));
  603. pd.put("ROAD", pdata.get("ROAD"));
  604. pdata.put("YEAR", pd.get("YEAR"));
  605. Map<String, String> tableInfo = new HashMap<String, String>();
  606. tableInfo.put("highway_prevention_project_dettable", "TOTAL"); // 预防养护
  607. pdata = getPlanRecods(tableInfo, pdata, pd); // 预防养护计划费用
  608. // 按类别统计完成费用
  609. Map<String, String> preventionType = getPreventionPlanType();
  610. pdata = getPreventionPlanRecods(preventionType, pdata, pd);
  611. }
  612. return pdateList;
  613. }
  614. private Map<String, String> getPreventionType() throws Exception {
  615. Map<String, String> preventionType = new HashMap<String, String>();
  616. preventionType.put("路基", "SUBGRADE_COST");
  617. preventionType.put("路面", "PAVEMENT_COST");
  618. preventionType.put("桥涵", "BRIDGE_COST");
  619. preventionType.put("隧道", "TUNNEL_COST");
  620. preventionType.put("交安设施", "TRAFFIC_SAFE_COST");
  621. preventionType.put("沿线设施", "ROADSIDE_COST");
  622. preventionType.put("绿化", "GREEN_COST");
  623. preventionType.put("其他", "OTHER_COST");
  624. return preventionType;
  625. }
  626. private Map<String, String> getPreventionPlanType() throws Exception {
  627. Map<String, String> preventionType = new HashMap<String, String>();
  628. preventionType.put("路基", "SUBGRADE");
  629. preventionType.put("路面", "PAVEMENT");
  630. preventionType.put("桥涵", "BRIDGE");
  631. preventionType.put("隧道", "TUNNEL");
  632. preventionType.put("交安设施", "TRAFFIC_SAFE");
  633. preventionType.put("沿线设施", "ROADSIDE");
  634. preventionType.put("绿化", "GREEN");
  635. preventionType.put("其他", "OTHER");
  636. return preventionType;
  637. }
  638. private PageData getPreventionCompRecods(Map<String, String> preventionType, PageData pdata, PageData pd)
  639. throws Exception {
  640. Double sumCost = (double) 0;
  641. for (Map.Entry<String, String> entry : preventionType.entrySet()) {
  642. System.out.println("key=" + entry.getKey() + "\tvalue=" + entry.getValue());
  643. pd.put("CATEGORY", entry.getKey());
  644. String getRecod = annualDailyCompService.findPreventionCompRecods(pd);
  645. if (getRecod != null) {
  646. pdata.put(entry.getValue(), Double.parseDouble(getRecod));
  647. sumCost += Double.parseDouble(getRecod);
  648. }
  649. }
  650. pdata.put("SUM_COST", sumCost);
  651. return pdata;
  652. }
  653. private PageData getPreventionPlanRecods(Map<String, String> preventionType, PageData pdata, PageData pd)
  654. throws Exception {
  655. for (Map.Entry<String, String> entry : preventionType.entrySet()) {
  656. System.out.println("key=" + entry.getKey() + "\tvalue=" + entry.getValue());
  657. pd.put("CATEGORY", entry.getKey());
  658. String getRecod = annualDailyCompService.findPreventionPlanRecods(pd);
  659. if (getRecod != null) {
  660. pdata.put(entry.getValue(), Double.parseDouble(getRecod));
  661. }
  662. }
  663. return pdata;
  664. }
  665. private PageData getRepairCompRecods(Map<String, String> preventionType, PageData pdata, PageData pd)
  666. throws Exception {
  667. String[] PROJECT_SCALES = { "小修", "中修", "大修" };
  668. for (String PROJECT_SCALE : PROJECT_SCALES) {
  669. pd.put("PROJECT_SCALE", PROJECT_SCALE);
  670. Double sumCost = 0D;
  671. for (Map.Entry<String, String> entry : preventionType.entrySet()) {
  672. System.out.println("key=" + entry.getKey() + "\tvalue=" + entry.getValue());
  673. pd.put("CATEGORY", entry.getKey());
  674. String getRecod = annualDailyCompService.findRepairCompRecods(pd);
  675. if (getRecod != null) {
  676. if ("小修".equalsIgnoreCase(PROJECT_SCALE)) {
  677. pdata.put("MIN_" + entry.getValue(), Double.parseDouble(getRecod));
  678. sumCost += Double.parseDouble(getRecod);
  679. } else if ("中修".equalsIgnoreCase(PROJECT_SCALE)) {
  680. pdata.put("MID_" + entry.getValue(), Double.parseDouble(getRecod));
  681. sumCost += Double.parseDouble(getRecod);
  682. } else {
  683. pdata.put("MAX_" + entry.getValue(), Double.parseDouble(getRecod));
  684. sumCost += Double.parseDouble(getRecod);
  685. }
  686. }
  687. }
  688. if ("小修".equalsIgnoreCase(PROJECT_SCALE)) {
  689. pdata.put("MIN_SUM_COST", sumCost);
  690. } else if ("中修".equalsIgnoreCase(PROJECT_SCALE)) {
  691. pdata.put("MID_SUM_COST", sumCost);
  692. } else {
  693. pdata.put("MAX_SUM_COST", sumCost);
  694. }
  695. }
  696. return pdata;
  697. }
  698. private PageData getRepairPlanRecods(Map<String, String> preventionType, PageData pdata, PageData pd)
  699. throws Exception {
  700. String[] PROJECT_SCALES = { "小修", "中修", "大修" };
  701. for (String PROJECT_SCALE : PROJECT_SCALES) {
  702. pd.put("PROJECT_SCALE", PROJECT_SCALE);
  703. Double sumCost = 0D;
  704. for (Map.Entry<String, String> entry : preventionType.entrySet()) {
  705. System.out.println("key=" + entry.getKey() + "\tvalue=" + entry.getValue());
  706. pd.put("CATEGORY", entry.getKey());
  707. String getRecod = annualDailyCompService.findRepairPlanRecods(pd);
  708. if (getRecod != null) {
  709. if ("小修".equalsIgnoreCase(PROJECT_SCALE)) {
  710. pdata.put("MIN_" + entry.getValue(), Double.parseDouble(getRecod));
  711. sumCost += Double.parseDouble(getRecod);
  712. } else if ("中修".equalsIgnoreCase(PROJECT_SCALE)) {
  713. pdata.put("MID_" + entry.getValue(), Double.parseDouble(getRecod));
  714. sumCost += Double.parseDouble(getRecod);
  715. } else {
  716. pdata.put("MAX_" + entry.getValue(), Double.parseDouble(getRecod));
  717. sumCost += Double.parseDouble(getRecod);
  718. }
  719. }
  720. }
  721. if ("小修".equalsIgnoreCase(PROJECT_SCALE)) {
  722. pdata.put("MIN_SUM", sumCost);
  723. } else if ("中修".equalsIgnoreCase(PROJECT_SCALE)) {
  724. pdata.put("MID_SUM", sumCost);
  725. } else {
  726. pdata.put("MAX_SUM", sumCost);
  727. }
  728. }
  729. return pdata;
  730. }
  731. private List<PageData> getAnnualCompRecods(PageData pd) throws Exception {
  732. // List<PageData> pdateList = annualDailyCompService.getKmInfo(pd);
  733. // for (PageData pdata : pdateList) {
  734. // pd.put("ROAD_ID", pdata.get("ROAD_ID"));
  735. // pd.put("ROAD", pdata.get("ROAD"));
  736. // pdata.put("YEAR", pd.get("YEAR"));
  737. // PageData tempPg = annualDailyCompService.findDaliyPlanRecord(pd); // 日常养护
  738. // String dailyPlanCost = dailyPlanCostSum(tempPg);
  739. // if (dailyPlanCost != "") {
  740. // pdata.put("DAILY_DESIGN", Double.parseDouble(dailyPlanCost)); // 日常养护计划费用
  741. // }
  742. // pdata = getPreAndRepPlanCost(pd, pdata, "highway_prevention_project_dettable_cost",
  743. // "highway_prevention_project_dettable", "PREVENTION_DESIGN"); // 获取预防养护大中小修的计划费用
  744. // pdata = getPreAndRepPlanCost(pd, pdata, "highway_repair_project_dettable_cost",
  745. // "highway_repair_project_dettable", "REPAIR_DESIGN"); // 获取修复养护大中小修的计划费用
  746. //
  747. // Map<String, String> tableInfo = new HashMap<String, String>();
  748. // tableInfo.put("highway_special_project_dettable", "SPECIAL_DESIGN"); // 专项养护
  749. // tableInfo.put("highway_test_project_dettable", "TEST_DESIGN"); // 试验检测项目
  750. // pdata = getPlanRecods(tableInfo, pdata, pd);
  751. // String scientificPlanSum = findScientificPlanSum(pd);
  752. // if (scientificPlanSum != null) {
  753. // pdata.put("SCIENTIFIC_DESIGN", Double.parseDouble(scientificPlanSum)); // 科研项目
  754. // }
  755. // String equipmentPlanSum = findEquipmentPlanSum(pd);
  756. // if (equipmentPlanSum != null) {
  757. // pdata.put("DEVICE_DESIGN", Double.parseDouble(equipmentPlanSum)); // 设备大修
  758. // }
  759. // String reservePlanSum = findReservePlanSum(pd);
  760. // if (reservePlanSum != "") {
  761. // pdata.put("RESERVE_DESIGN", Double.parseDouble(reservePlanSum)); // 预备费
  762. // }
  763. // // 完成费用
  764. // pdata = getPreAndRepCompCost(pd, pdata, "monthly_prevention_completion",
  765. // "highway_prevention_project_dettable", "PREVENTION_COMPLETE"); // 获取预防养护大中小修的完成费用
  766. // pdata = getPreAndRepCompCost(pd, pdata, "monthly_repair_completion", "highway_repair_project_dettable",
  767. // "REPAIR_COMPLETE"); // 获取修复养护大中小修的完成费用
  768. // pdata = getCompRecods(putAnnualCompRecods(), pdata, pd);
  769. // // 预备费完成
  770. // String reserveCompSum = findReserveCompSum(pd);
  771. // if (reserveCompSum != "") {
  772. // pdata.put("RESERVE_COMPLETE", Double.parseDouble(reserveCompSum)); // 预备费
  773. // }
  774. // }
  775. pd.put("VIEW_NAME", "annual_comp_sumtable_view");
  776. List<PageData> pdateList = annualDailyCompService.findViewRecordsList(pd); //获取视图返回结果
  777. Double TOTAL_PREVENTION_DESIGN = 0.0;
  778. for(PageData tpd : pdateList){
  779. if(tpd.get("OVERHAUL_DESIGN") != null){
  780. tpd.put("OVERHAUL_REPAIR_DESIGN", tpd.get("OVERHAUL_DESIGN"));
  781. }
  782. if(tpd.get("OVERHAUL_COMPLETE") != null){
  783. tpd.put("OVERHAUL_REPAIR_COMPLETE", tpd.get("OVERHAUL_COMPLETE"));
  784. }
  785. TOTAL_PREVENTION_DESIGN = addThreeNum(tpd.get("MINOR_PREVENTION_DESIGN"), tpd.get("MIDDLE_PREVENTION_DESIGN"), tpd.get("OVERHAUL_PREVENTION_DESIGN"));
  786. if(TOTAL_PREVENTION_DESIGN != 0.0){
  787. tpd.put("TOTAL_PREVENTION_DESIGN", TOTAL_PREVENTION_DESIGN);
  788. }
  789. TOTAL_PREVENTION_DESIGN = addThreeNum(tpd.get("MINOR_PREVENTION_COMPLETE"), tpd.get("MIDDLE_PREVENTION_COMPLETE"), tpd.get("OVERHAUL_PREVENTION_COMPLETE"));
  790. if(TOTAL_PREVENTION_DESIGN != 0.0){
  791. tpd.put("TOTAL_PREVENTION_COMPLETE", TOTAL_PREVENTION_DESIGN);
  792. }
  793. TOTAL_PREVENTION_DESIGN = addThreeNum(tpd.get("MINOR_REPAIR_DESIGN"), tpd.get("MIDDLE_REPAIR_DESIGN"), tpd.get("OVERHAUL_DESIGN"));
  794. if(TOTAL_PREVENTION_DESIGN != 0.0){
  795. tpd.put("TOTAL_REPAIR_DESIGN", TOTAL_PREVENTION_DESIGN);
  796. }
  797. TOTAL_PREVENTION_DESIGN = addThreeNum(tpd.get("MINOR_REPAIR_COMPLETE"), tpd.get("MIDDLE_REPAIR_COMPLETE"), tpd.get("OVERHAUL_COMPLETE"));
  798. if(TOTAL_PREVENTION_DESIGN != 0.0){
  799. tpd.put("TOTAL_REPAIR_COMPLETE", TOTAL_PREVENTION_DESIGN);
  800. }
  801. //计算比例
  802. if(tpd.get("DAILY_COMPLETE") != null && tpd.get("DAILY_DESIGN")!= null){
  803. tpd.put("DAILY_PROPORTION", math(tpd.get("DAILY_COMPLETE"),tpd.get("DAILY_DESIGN")).toString());
  804. }
  805. if(tpd.get("DAILY_COMPLETE") != null && tpd.get("CARE_KM")!= null){
  806. tpd.put("DAILY_KM", mathKm(tpd.get("DAILY_COMPLETE"),tpd.get("CARE_KM")).toString());
  807. }
  808. if(tpd.get("MINOR_PREVENTION_COMPLETE") != null && tpd.get("MINOR_PREVENTION_DESIGN")!= null){
  809. tpd.put("MINOR_PREVENTION_PROPORTION", math(tpd.get("MINOR_PREVENTION_COMPLETE"),tpd.get("MINOR_PREVENTION_DESIGN")).toString());
  810. }
  811. if(tpd.get("MIDDLE_PREVENTION_COMPLETE") != null && tpd.get("MIDDLE_PREVENTION_DESIGN")!= null){
  812. tpd.put("MIDDLE_PREVENTION_PROPORTION", math(tpd.get("MIDDLE_PREVENTION_COMPLETE"),tpd.get("MIDDLE_PREVENTION_DESIGN")).toString());
  813. }
  814. if(tpd.get("OVERHAUL_PREVENTION_COMPLETE") != null && tpd.get("OVERHAUL_PREVENTION_DESIGN")!= null){
  815. tpd.put("OVERHAUL_PREVENTION_PROPORTION", math(tpd.get("OVERHAUL_PREVENTION_COMPLETE"),tpd.get("OVERHAUL_PREVENTION_DESIGN")).toString());
  816. }
  817. if(tpd.get("TOTAL_PREVENTION_COMPLETE") != null && tpd.get("TOTAL_PREVENTION_DESIGN")!= null){
  818. tpd.put("TOTAL_PREVENTION_PROPORTION", math(tpd.get("TOTAL_PREVENTION_COMPLETE"),tpd.get("TOTAL_PREVENTION_DESIGN")).toString());
  819. }
  820. if(tpd.get("MINOR_REPAIR_COMPLETE") != null && tpd.get("MINOR_REPAIR_DESIGN")!= null){
  821. tpd.put("MINOR_REPAIR_PROPORTION", math(tpd.get("MINOR_REPAIR_COMPLETE"),tpd.get("MINOR_REPAIR_DESIGN")).toString());
  822. }
  823. if(tpd.get("MIDDLE_REPAIR_COMPLETE") != null && tpd.get("MIDDLE_REPAIR_DESIGN")!= null){
  824. tpd.put("MIDDLE_REPAIR_PROPORTION", math(tpd.get("MIDDLE_REPAIR_COMPLETE"),tpd.get("MIDDLE_REPAIR_DESIGN")).toString());
  825. }
  826. if(tpd.get("OVERHAUL_REPAIR_COMPLETE") != null && tpd.get("OVERHAUL_REPAIR_DESIGN")!= null){
  827. tpd.put("OVERHAUL_REPAIR_PROPORTION", math(tpd.get("OVERHAUL_REPAIR_COMPLETE"),tpd.get("OVERHAUL_REPAIR_DESIGN")).toString());
  828. }
  829. if(tpd.get("TOTAL_REPAIR_COMPLETE") != null && tpd.get("TOTAL_REPAIR_DESIGN")!= null){
  830. tpd.put("TOTAL_REPAIR_PROPORTION", math(tpd.get("TOTAL_REPAIR_COMPLETE"),tpd.get("TOTAL_REPAIR_DESIGN")).toString());
  831. }
  832. if(tpd.get("SPECIAL_COMPLETE") != null && tpd.get("SPECIAL_DESIGN")!= null){
  833. tpd.put("SPECIAL_PROPORTION", math(tpd.get("SPECIAL_COMPLETE"),tpd.get("SPECIAL_DESIGN")).toString());
  834. }
  835. if(tpd.get("EMERGENCY_COMPLETE") != null && tpd.get("EMERGENCY_DESIGN")!= null){
  836. tpd.put("EMERGENCY_PROPORTION", math(tpd.get("EMERGENCY_COMPLETE"),tpd.get("EMERGENCY_DESIGN")).toString());
  837. }
  838. if(tpd.get("TEST_COMPLETE") != null && tpd.get("TEST_DESIGN")!= null){
  839. tpd.put("TEST_PROPORTION", math(tpd.get("TEST_COMPLETE"),tpd.get("TEST_DESIGN")).toString());
  840. }
  841. if(tpd.get("SCIENTIFIC_COMPLETE") != null && tpd.get("SCIENTIFIC_DESIGN")!= null){
  842. tpd.put("SCIENTIFIC_PROPORTION", math(tpd.get("SCIENTIFIC_COMPLETE"),tpd.get("SCIENTIFIC_DESIGN")).toString());
  843. }
  844. if(tpd.get("DEVICE_COMPLETE") != null && tpd.get("DEVICE_DESIGN")!= null){
  845. tpd.put("DEVICE_PROPORTION", math(tpd.get("DEVICE_COMPLETE"),tpd.get("DEVICE_DESIGN")).toString());
  846. }
  847. if(tpd.get("RESERVE_COMPLETE") != null && tpd.get("RESERVE_DESIGN")!= null){
  848. tpd.put("RESERVE_PROPORTION", math(tpd.get("RESERVE_COMPLETE"),tpd.get("RESERVE_DESIGN")).toString());
  849. }
  850. TOTAL_PREVENTION_DESIGN = addNineNum(tpd.get("TOTAL_PREVENTION_DESIGN"),tpd.get("TOTAL_REPAIR_DESIGN"),tpd.get("SPECIAL_DESIGN")
  851. ,tpd.get("EMERGENCY_DESIGN"),tpd.get("TEST_DESIGN"),tpd.get("SCIENTIFIC_DESIGN"),tpd.get("DEVICE_DESIGN")
  852. ,tpd.get("RESERVE_DESIGN"),tpd.get("DAILY_DESIGN"));
  853. if(TOTAL_PREVENTION_DESIGN != 0.0){
  854. tpd.put("TOTAL_DESIGN", TOTAL_PREVENTION_DESIGN);
  855. }
  856. TOTAL_PREVENTION_DESIGN = addNineNum(tpd.get("TOTAL_PREVENTION_COMPLETE"),tpd.get("TOTAL_REPAIR_COMPLETE"),tpd.get("SPECIAL_COMPLETE")
  857. ,tpd.get("EMERGENCY_COMPLETE"),tpd.get("TEST_COMPLETE"),tpd.get("SCIENTIFIC_COMPLETE"),tpd.get("DEVICE_COMPLETE")
  858. ,tpd.get("RESERVE_COMPLETE"),tpd.get("DAILY_COMPLETE"));
  859. if(TOTAL_PREVENTION_DESIGN != 0.0){
  860. tpd.put("TOTAL_COMPLETE", TOTAL_PREVENTION_DESIGN);
  861. }
  862. if(tpd.get("TOTAL_COMPLETE") != null && tpd.get("TOTAL_DESIGN")!= null){
  863. tpd.put("TOTAL_PROPORTION", math(tpd.get("TOTAL_COMPLETE"),tpd.get("TOTAL_DESIGN")).toString());
  864. }
  865. }
  866. return pdateList;
  867. }
  868. private Double addNums(List<Object> list){
  869. Double dou = 0.0;
  870. for(Object obj : list){
  871. if(obj != null){
  872. dou += Double.parseDouble(obj.toString());
  873. }
  874. }
  875. return dou;
  876. }
  877. private Double addThreeNum(Object obj1, Object obj2, Object obj3){
  878. Double dou = 0.0;
  879. if(obj1 != null){
  880. dou += Double.parseDouble(obj1.toString());
  881. }
  882. if(obj2 != null){
  883. dou += Double.parseDouble(obj2.toString());
  884. }
  885. if(obj3 != null){
  886. dou += Double.parseDouble(obj3.toString());
  887. }
  888. return dou;
  889. }
  890. private Double addNineNum(Object obj1, Object obj2, Object obj3,Object obj4, Object obj5, Object obj6,Object obj7, Object obj8, Object obj9){
  891. Double dou = 0.0;
  892. if(obj1 != null){
  893. dou += Double.parseDouble(obj1.toString());
  894. }
  895. if(obj2 != null){
  896. dou += Double.parseDouble(obj2.toString());
  897. }
  898. if(obj3 != null){
  899. dou += Double.parseDouble(obj3.toString());
  900. }
  901. if(obj4 != null){
  902. dou += Double.parseDouble(obj4.toString());
  903. }
  904. if(obj5 != null){
  905. dou += Double.parseDouble(obj5.toString());
  906. }
  907. if(obj6 != null){
  908. dou += Double.parseDouble(obj6.toString());
  909. }
  910. if(obj7 != null){
  911. dou += Double.parseDouble(obj7.toString());
  912. }
  913. if(obj8 != null){
  914. dou += Double.parseDouble(obj8.toString());
  915. }
  916. if(obj9 != null){
  917. dou += Double.parseDouble(obj9.toString());
  918. }
  919. return dou;
  920. }
  921. private Double add12Num(Object obj1, Object obj2, Object obj3,Object obj4, Object obj5, Object obj6
  922. ,Object obj7, Object obj8, Object obj9,Object obj10, Object obj11, Object obj12){
  923. Double dou = 0.0;
  924. if(obj1 != null){
  925. dou += Double.parseDouble(obj1.toString());
  926. }
  927. if(obj2 != null){
  928. dou += Double.parseDouble(obj2.toString());
  929. }
  930. if(obj3 != null){
  931. dou += Double.parseDouble(obj3.toString());
  932. }
  933. if(obj4 != null){
  934. dou += Double.parseDouble(obj4.toString());
  935. }
  936. if(obj5 != null){
  937. dou += Double.parseDouble(obj5.toString());
  938. }
  939. if(obj6 != null){
  940. dou += Double.parseDouble(obj6.toString());
  941. }
  942. if(obj7 != null){
  943. dou += Double.parseDouble(obj7.toString());
  944. }
  945. if(obj8 != null){
  946. dou += Double.parseDouble(obj8.toString());
  947. }
  948. if(obj9 != null){
  949. dou += Double.parseDouble(obj9.toString());
  950. }
  951. if(obj10 != null){
  952. dou += Double.parseDouble(obj10.toString());
  953. }
  954. if(obj11 != null){
  955. dou += Double.parseDouble(obj11.toString());
  956. }
  957. if(obj12 != null){
  958. dou += Double.parseDouble(obj12.toString());
  959. }
  960. return dou;
  961. }
  962. // 科研项目
  963. private String findScientificPlanSum(PageData pd) throws Exception {
  964. String scientificPlanSum = annualDailyCompService.findScientificPlanSum(pd);
  965. return scientificPlanSum;
  966. }
  967. // 设备大修
  968. private String findEquipmentPlanSum(PageData pd) throws Exception {
  969. String equipmentPlanSum = annualDailyCompService.findEquipmentPlanSum(pd);
  970. return equipmentPlanSum;
  971. }
  972. // 预备费计划
  973. private String findReservePlanSum(PageData pd) throws Exception {
  974. String reservePlanSum = "";
  975. pd.put("FROM_TABLE", "highway_reserve_fees_sumtable_total");
  976. PageData allRecods = annualDailyCompService.findAllRecods(pd);
  977. if (allRecods != null && allRecods.get("TOTAL_COST")!= null) {
  978. reservePlanSum = allRecods.get("TOTAL_COST").toString();
  979. }
  980. return reservePlanSum;
  981. }
  982. // 预备费完成
  983. private String findReserveCompSum(PageData pd) throws Exception {
  984. String reservePlanSum = "";
  985. pd.put("FROM_TABLE", "highway_reserve_fees_sumtable");
  986. PageData allRecods = annualDailyCompService.findAllRecods(pd);
  987. if (allRecods != null && allRecods.get("ACTUAL_COST")!=null) {
  988. reservePlanSum = allRecods.get("ACTUAL_COST").toString();
  989. }
  990. return reservePlanSum;
  991. }
  992. private PageData getPreAndRepPlanCost(PageData pd, PageData pdata, String tableNameA, String tableNameB,
  993. String kayWords) throws Exception {
  994. pd.put("FROM_TABLEA", tableNameA);
  995. pd.put("FROM_TABLEB", tableNameB);
  996. String[] PROJECT_SCALES = { "小修", "中修", "大修" };
  997. for (String PROJECT_SCALE : PROJECT_SCALES) {
  998. pd.put("PROJECT_SCALE", PROJECT_SCALE);
  999. String getRecod = annualDailyCompService.getPreAndRepPlanCost(pd);
  1000. if (getRecod != null) {
  1001. if ("小修".equalsIgnoreCase(PROJECT_SCALE)) {
  1002. pdata.put("MINOR_" + kayWords, getRecod);
  1003. } else if ("中修".equalsIgnoreCase(PROJECT_SCALE)) {
  1004. pdata.put("MIDDLE_" + kayWords, getRecod);
  1005. } else {
  1006. pdata.put("OVERHAUL_" + kayWords, getRecod);
  1007. }
  1008. }
  1009. }
  1010. return pdata;
  1011. }
  1012. private PageData getPreAndRepCompCost(PageData pd, PageData pdata, String tableNameA, String tableNameB,
  1013. String kayWords) throws Exception {
  1014. pd.put("FROM_TABLEA", tableNameA);
  1015. pd.put("FROM_TABLEB", tableNameB);
  1016. String[] PROJECT_SCALES = { "小修", "中修", "大修" };
  1017. for (String PROJECT_SCALE : PROJECT_SCALES) {
  1018. pd.put("PROJECT_SCALE", PROJECT_SCALE);
  1019. String getRecod = annualDailyCompService.getPreAndRepCompCost(pd);
  1020. if (getRecod != null) {
  1021. if ("小修".equalsIgnoreCase(PROJECT_SCALE)) {
  1022. pdata.put("MINOR_" + kayWords, getRecod);
  1023. } else if ("中修".equalsIgnoreCase(PROJECT_SCALE)) {
  1024. pdata.put("MIDDLE_" + kayWords, getRecod);
  1025. } else {
  1026. pdata.put("OVERHAUL_" + kayWords, getRecod);
  1027. }
  1028. }
  1029. }
  1030. return pdata;
  1031. }
  1032. private List<PageData> getAnnualDailyCompRecod(PageData pd) throws Exception {
  1033. // List<PageData> pdateList = annualDailyCompService.getKmInfo(pd);
  1034. // for (PageData pdata : pdateList) {
  1035. // pdata.put("YEAR", pd.get("YEAR"));
  1036. // PageData queryData = pdata;
  1037. // PageData tempPg = annualDailyCompService.findDaliyPlanRecord(queryData); // 日常养护
  1038. // String dailyPlanCost = dailyPlanCostSum(tempPg);
  1039. // if (dailyPlanCost != "") {
  1040. // pdata.put("PLAN_COST", Double.parseDouble(dailyPlanCost));
  1041. // }
  1042. // for (String dct : annDailyCompType) {
  1043. // queryData.put("TYPE", dct);
  1044. // String compPdate = annualDailyCompService.findDaliyCompRecord(queryData);
  1045. // if (compPdate != null) {
  1046. // pdata.put(dct, compPdate);
  1047. // }
  1048. // }
  1049. // }
  1050. pd.put("VIEW_NAME", "annual_daily_comp_sumtable_view");
  1051. List<PageData> pdateList = annualDailyCompService.findViewRecordsList(pd); //获取视图返回结果
  1052. for(PageData tpd : pdateList){
  1053. Double totalCost = add12Num(tpd.get("CLEAN_COST"),tpd.get("PATROL_COST"),tpd.get("SUBGRADE_COST"),tpd.get("PAVEMENT_COST")
  1054. ,tpd.get("BRIDGE_COST"),tpd.get("CULVERT_COST"),tpd.get("TUNNEL_COST"),tpd.get("GREEN_COST"),tpd.get("SAFE_COST")
  1055. ,tpd.get("LINE_COST"),tpd.get("CAR_COST"),tpd.get("EMERGENCY_COST"));
  1056. if(totalCost != 0.0){
  1057. tpd.put("TOTAL_COST", totalCost);
  1058. }
  1059. if(tpd.get("TOTAL_COST")!=null && tpd.get("CARE_KM")!=null){
  1060. tpd.put("COST_KM", mathKm(tpd.get("TOTAL_COST"),tpd.get("CARE_KM")).toString());
  1061. }
  1062. if(tpd.get("TOTAL_COST")!=null && tpd.get("PLAN_COST")!=null){
  1063. tpd.put("COM_RETIO", math(tpd.get("TOTAL_COST"),tpd.get("PLAN_COST")).toString());
  1064. }
  1065. }
  1066. return pdateList;
  1067. }
  1068. private List<PageData> getAnnualDailyPlanRecod(PageData pd) throws Exception {
  1069. // List<PageData> pdateList = annualDailyCompService.getKmInfo(pd);
  1070. // List<PageData> pdList = new ArrayList<PageData>();
  1071. // for (PageData pdata : pdateList) {
  1072. // pdata.put("YEAR", pd.get("YEAR"));
  1073. // PageData queryData = pdata;
  1074. // PageData tempPg = annualDailyCompService.getDaliyPlanRecord(queryData); // 日常养护
  1075. // if (tempPg != null) {
  1076. // tempPg.put("CARE_KM", pdata.get("CARE_KM"));
  1077. // tempPg.put("DESIGN_KM", pdata.get("DESIGN_KM"));
  1078. // pdList.add(tempPg);
  1079. // }
  1080. // }
  1081. // if (pdList.size() == 0) {
  1082. // pdList = pdateList;
  1083. // }
  1084. pd.put("VIEW_NAME", "annual_daily_comp_sumtable_view");
  1085. List<PageData> pdateList = annualDailyCompService.findViewRecordsList(pd); //获取视图返回结果
  1086. for(PageData tpd : pdateList){
  1087. if(tpd.get("PLAN_COST")!=null && tpd.get("CARE_KM")!=null){
  1088. tpd.put("COST_KM", mathKm(tpd.get("PLAN_COST"),tpd.get("CARE_KM")).toString());
  1089. }
  1090. }
  1091. return pdateList;
  1092. }
  1093. private Map<String, String> putPlanRecods() throws Exception {
  1094. Map<String, String> tableInfo = new HashMap<String, String>();
  1095. tableInfo.put("highway_prevention_project_dettable", "PREVENTION_PLAN_COST"); // 预防养护
  1096. tableInfo.put("highway_repair_project_dettable", "REPAIR_PLAN_COST"); // 修复养护
  1097. tableInfo.put("highway_special_project_dettable", "SPECIAL_PLAN_COST"); // 专项养护
  1098. tableInfo.put("highway_test_project_dettable", "TEST_PLAN_COST"); // 试验检测项目
  1099. return tableInfo;
  1100. }
  1101. private PageData getPlanRecods(Map<String, String> tableInfo, PageData varPg, PageData pd) throws Exception {
  1102. for (Map.Entry<String, String> entry : tableInfo.entrySet()) {
  1103. System.out.println("key=" + entry.getKey() + "\tvalue=" + entry.getValue());
  1104. pd.put("FROM_TABLE", entry.getKey());
  1105. String getRecod = annualDailyCompService.findOtherPlanSum(pd);
  1106. if (getRecod != null) {
  1107. varPg.put(entry.getValue(), Double.parseDouble(getRecod));
  1108. }
  1109. }
  1110. return varPg;
  1111. }
  1112. private Map<String, String> putCompRecods() throws Exception {
  1113. Map<String, String> tableInfo = new HashMap<String, String>();
  1114. tableInfo.put("monthly_daily_completion", "DAILY_COMPLETE_COST"); // 日常养护
  1115. tableInfo.put("monthly_prevention_completion", "PREVENTION_COMPLETE_COST"); // 预防养护
  1116. tableInfo.put("monthly_repair_completion", "REPAIR_COMPLETE_COST"); // 修复养护
  1117. tableInfo.put("monthly_special_completion", "SPECIAL_COMPLETE_COST"); // 专项养护
  1118. tableInfo.put("monthly_test_project_completion", "TEST_COMPLETE_COST"); // 试验检测项目
  1119. tableInfo.put("monthly_scientific_project_completion", "SCIENTIFIC_COMPLETE_COST"); // 科研项目
  1120. tableInfo.put("monthly_equipment_overhaul_completion", "DEVICE_COMPLETE_COST"); // 设备大修
  1121. tableInfo.put("monthly_emergency_completion", "EMERGENCY_COMPLETE_COST"); // 应急
  1122. return tableInfo;
  1123. }
  1124. private Map<String, String> putAnnualCompRecods() throws Exception {
  1125. Map<String, String> tableInfo = new HashMap<String, String>();
  1126. tableInfo.put("monthly_daily_completion", "DAILY_COMPLETE"); // 日常养护
  1127. tableInfo.put("monthly_special_completion", "SPECIAL_COMPLETE"); // 专项养护
  1128. tableInfo.put("monthly_test_project_completion", "TEST_COMPLETE"); // 试验检测项目
  1129. tableInfo.put("monthly_scientific_project_completion", "SCIENTIFIC_COMPLETE"); // 科研项目
  1130. tableInfo.put("monthly_equipment_overhaul_completion", "DEVICE_COMPLETE"); // 设备大修
  1131. tableInfo.put("monthly_emergency_completion", "EMERGENCY_COMPLETE"); // 应急
  1132. return tableInfo;
  1133. }
  1134. private PageData getCompRecods(Map<String, String> tableInfo, PageData varPg, PageData pd) throws Exception {
  1135. for (Map.Entry<String, String> entry : tableInfo.entrySet()) {
  1136. System.out.println("key=" + entry.getKey() + "\tvalue=" + entry.getValue());
  1137. pd.put("FROM_TABLE", entry.getKey());
  1138. String getRecod = annualDailyCompService.findCompSum(pd);
  1139. if (getRecod != null) {
  1140. varPg.put(entry.getValue(), Double.parseDouble(getRecod));
  1141. }
  1142. }
  1143. return varPg;
  1144. }
  1145. private String dailyPlanCostSum(PageData tempPg) {
  1146. String dailySum = "";
  1147. if (tempPg != null) {
  1148. Double DailySumd = 0.00;
  1149. for (String type : dailyPlanType) {
  1150. if (tempPg.get(type) != null) {
  1151. DailySumd += Double.parseDouble(tempPg.get(type).toString());
  1152. }
  1153. }
  1154. dailySum = String.valueOf(DailySumd);
  1155. }
  1156. return dailySum;
  1157. }
  1158. @SuppressWarnings("unused")
  1159. // 获取公司计划费用
  1160. private Double getPlanSum(PageData pd, AnnualDailyCompService annualDailyCompService) throws NumberFormatException, Exception {
  1161. Double planSum = 0.00;
  1162. Double a = 0.00;
  1163. Double b = 0.00;
  1164. Double c = 0.00;
  1165. Double d = 0.00;
  1166. Double e = 0.00;
  1167. Double f = 0.00;
  1168. Double g = 0.00;
  1169. Double h = 0.00;
  1170. Double i = 0.00;
  1171. // 获取公司日常计划费用
  1172. if(annualDailyCompService.getRcyhPlanSum(pd)!=null) {
  1173. a = Double.parseDouble(annualDailyCompService.getRcyhPlanSum(pd));
  1174. }
  1175. // 获取预防养护计划费用
  1176. if(annualDailyCompService.getYfyhPlanSum(pd)!=null) {
  1177. b = Double.parseDouble(annualDailyCompService.getYfyhPlanSum(pd));
  1178. }
  1179. // 获取修复养护计划费用
  1180. if(annualDailyCompService.getXfyhPlanSum(pd)!=null) {
  1181. c = Double.parseDouble(annualDailyCompService.getXfyhPlanSum(pd));
  1182. }
  1183. // 获取专项养护计划费用
  1184. if(annualDailyCompService.getZxyhPlanSum(pd)!=null) {
  1185. d = Double.parseDouble(annualDailyCompService.getZxyhPlanSum(pd));
  1186. }
  1187. // 获取试验检测计划费用
  1188. if(annualDailyCompService.getSyjcPlanSum(pd)!=null) {
  1189. e = Double.parseDouble(annualDailyCompService.getSyjcPlanSum(pd));
  1190. }
  1191. // 获取科研项目计划费用
  1192. if(annualDailyCompService.getKyxmPlanSum(pd)!=null) {
  1193. f = Double.parseDouble(annualDailyCompService.getKyxmPlanSum(pd));
  1194. }
  1195. // 获取设备大修计划费用
  1196. if(annualDailyCompService.getSbdxPlanSum(pd)!=null) {
  1197. g = Double.parseDouble(annualDailyCompService.getSbdxPlanSum(pd));
  1198. }
  1199. // 获取预备费计划费用
  1200. if(annualDailyCompService.getYbfPlanSum(pd)!=null) {
  1201. h = Double.parseDouble(annualDailyCompService.getYbfPlanSum(pd));
  1202. }
  1203. // 获取应急养护计划费用
  1204. if(annualDailyCompService.getYjyhPlanSum(pd)!=null) {
  1205. i = Double.parseDouble(annualDailyCompService.getYjyhPlanSum(pd));
  1206. }
  1207. planSum = a + b + c + d + e + f + g + h + i;
  1208. return planSum;
  1209. }
  1210. @SuppressWarnings("unused")
  1211. // 获取公司完成费用
  1212. private Double getCompSum(PageData pd, AnnualDailyCompService annualDailyCompService) throws NumberFormatException, Exception {
  1213. Double compSum = 0.00;
  1214. Double a = 0.00;
  1215. Double b = 0.00;
  1216. Double c = 0.00;
  1217. Double d = 0.00;
  1218. Double e = 0.00;
  1219. Double f = 0.00;
  1220. Double g = 0.00;
  1221. Double h = 0.00;
  1222. Double i = 0.00;
  1223. // 获取公司日常计划费用
  1224. if(annualDailyCompService.getRcyhCompSum(pd)!=null) {
  1225. a = Double.parseDouble(annualDailyCompService.getRcyhCompSum(pd));
  1226. }
  1227. // 获取预防养护计划费用
  1228. if(annualDailyCompService.getYfyhCompSum(pd)!=null) {
  1229. b = Double.parseDouble(annualDailyCompService.getYfyhCompSum(pd));
  1230. }
  1231. // 获取修复养护计划费用
  1232. if(annualDailyCompService.getXfyhCompSum(pd)!=null) {
  1233. c = Double.parseDouble(annualDailyCompService.getXfyhCompSum(pd));
  1234. }
  1235. // 获取专项养护计划费用
  1236. if(annualDailyCompService.getZxyhCompSum(pd)!=null) {
  1237. d = Double.parseDouble(annualDailyCompService.getZxyhCompSum(pd));
  1238. }
  1239. // 获取试验检测计划费用
  1240. if(annualDailyCompService.getSyjcCompSum(pd)!=null) {
  1241. e = Double.parseDouble(annualDailyCompService.getSyjcCompSum(pd));
  1242. }
  1243. // 获取科研项目计划费用
  1244. if(annualDailyCompService.getKyxmCompSum(pd)!=null) {
  1245. f = Double.parseDouble(annualDailyCompService.getKyxmCompSum(pd));
  1246. }
  1247. // 获取设备大修计划费用
  1248. if(annualDailyCompService.getSbdxCompSum(pd)!=null) {
  1249. g = Double.parseDouble(annualDailyCompService.getSbdxCompSum(pd));
  1250. }
  1251. // 获取预备费计划费用
  1252. if(annualDailyCompService.getYbfCompSum(pd)!=null) {
  1253. h = Double.parseDouble(annualDailyCompService.getYbfCompSum(pd));
  1254. }
  1255. // 获取应急养护计划费用
  1256. if(annualDailyCompService.getYjyhCompSum(pd)!=null) {
  1257. i = Double.parseDouble(annualDailyCompService.getYjyhCompSum(pd));
  1258. }
  1259. compSum = a + b + c + d + e + f + g + h + i;
  1260. return compSum;
  1261. }
  1262. // 算完成比例得方法,保留2位小数
  1263. public Double div(PageData pd, AnnualDailyCompService annualDailyCompService) throws NumberFormatException, Exception {
  1264. BigDecimal b1 = new BigDecimal(this.getPlanSum(pd,annualDailyCompService).toString());
  1265. BigDecimal b2 = new BigDecimal(this.getCompSum(pd,annualDailyCompService).toString());
  1266. if(b1.compareTo(BigDecimal.ZERO)==0) {
  1267. return 0.00;
  1268. }
  1269. return new Double(b2.divide(b1, 2, BigDecimal.ROUND_HALF_UP).doubleValue());
  1270. }
  1271. // 计算公司完成率得分
  1272. public int getPoint(Double proportion, AnnualDailyCompService annualDailyCompService) {
  1273. int point = 0;
  1274. // 完成率大于95的得20分
  1275. if (proportion > 0.95) {
  1276. point = 20;
  1277. }
  1278. // 完成率大于90小于等于0.95的得15分
  1279. if (proportion > 0.90 && proportion <= 0.95) {
  1280. point = 15;
  1281. }
  1282. // 完成率大于等于85小于等于90得10分
  1283. if (proportion >= 0.85 && proportion <= 0.90) {
  1284. point = 10;
  1285. }
  1286. // 完成率小于85的得5分
  1287. if (proportion < 0.85) {
  1288. point = 5;
  1289. }
  1290. return point;
  1291. }
  1292. // 获取上报及时信息
  1293. public int getReportInfo(PageData pd, AnnualDailyCompService annualDailyCompService) throws Exception {
  1294. // 获取改公司所有上报表格时间
  1295. List<PageData> pdList = new ArrayList<PageData>();
  1296. // List dateList = new ArrayList();
  1297. int point = 0;
  1298. //记录如果有不符合时间得就加1
  1299. int a = 0;
  1300. int b = 0;
  1301. int c = 0;
  1302. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  1303. Date pz1 = sdf.parse(this.getProperties("pz1"));
  1304. Date pz2 = sdf.parse(this.getProperties("pz2"));
  1305. pdList = annualDailyCompService.getcompanysReport(pd);
  1306. for (PageData pdData : pdList) {
  1307. Date date = new Date();
  1308. if(pdData.get("SPTIME")!=null) {
  1309. date = sdf.parse(pdData.get("SPTIME").toString()) ;
  1310. }
  1311. if (date.before(pz1)) {
  1312. a = a + 1;
  1313. if (date.before(pz1)&&date.after(pz2)) {
  1314. b = b + 1;
  1315. if (date.before(pz2)) {
  1316. c = c + 1;
  1317. }
  1318. }
  1319. }
  1320. }
  1321. if (a == 0) {
  1322. point = 5;
  1323. }
  1324. if (b == 0) {
  1325. point = 3;
  1326. }
  1327. if (c == 0) {
  1328. point = 1;
  1329. }
  1330. return point;
  1331. }
  1332. // 读取配置文件方法
  1333. public String getProperties(String str) throws IOException {
  1334. Properties properties = PropertiesLoaderUtils.loadAllProperties("plantime.properties");
  1335. String test = properties.getProperty(str);
  1336. return test;
  1337. }
  1338. // 读取编制得分
  1339. public Double getBzPoint(PageData pd,AnnualDailyCompService annualDailyCompService) throws Exception {
  1340. Double bpoint =0.0;
  1341. if(annualDailyCompService.getBzPoint(pd)!=null)
  1342. {
  1343. bpoint = Double.parseDouble(annualDailyCompService.getBzPoint(pd));
  1344. }
  1345. return bpoint;
  1346. }
  1347. // 获取所有公司信息
  1348. public List<PageData> getAllcompanys(AnnualDailyCompService annualDailyCompService,PageData pg) throws Exception {
  1349. PageData pageData = new PageData();
  1350. // 获取公司信息
  1351. List<PageData> compList = annualDailyCompService.getAllcompanys(pageData);
  1352. // 返回前台处理过的公司信息List
  1353. List<PageData> newCompList = new ArrayList<PageData>();
  1354. //前台传入年份year
  1355. // if(pg.getString("EVET_CODE")!=null)
  1356. // {
  1357. String year = pg.getString("EVET_CODE");
  1358. // }
  1359. for (PageData comp : compList) {
  1360. PageData pd = new PageData();
  1361. // 获得公司名字
  1362. String compName = comp.getString("NAME");
  1363. // 获得公司ID
  1364. String compId = comp.getString("BIANMA");
  1365. pd.put("COMPANY_ID", compId);
  1366. pd.put("COMPANY_NAME", compName);
  1367. pd.put("YEAR", year);
  1368. // 获得公司完成比例
  1369. Double proportion = this.div(pd,annualDailyCompService);
  1370. //pd.put("PROPORTION", proportion);
  1371. // 完成率得分
  1372. int wpoint = this.getPoint(proportion,annualDailyCompService);
  1373. pd.put("WPOINT", wpoint);
  1374. // 获取上报及时获取得得分
  1375. int spoint = this.getReportInfo(pd,annualDailyCompService);
  1376. pd.put("SPOINT", spoint);
  1377. //获得编制质量得分
  1378. int bpoint = new Double(this.getBzPoint(pd,annualDailyCompService)).intValue();
  1379. pd.put("BPOINT", bpoint);
  1380. //总分
  1381. int point = wpoint+spoint+bpoint;
  1382. if(!year.equals("2019")) {
  1383. point = 100;
  1384. }
  1385. pd.put("POINT", point);
  1386. newCompList.add(pd);
  1387. }
  1388. return newCompList;
  1389. }
  1390. /**
  1391. * object => bigdecimal
  1392. * @param value
  1393. * @return
  1394. */
  1395. public static BigDecimal getBigDecimal( Object value ) {
  1396. BigDecimal ret = null;
  1397. if( value != null ) {
  1398. if( value instanceof BigDecimal ) {
  1399. ret = (BigDecimal) value;
  1400. } else if( value instanceof String ) {
  1401. ret = new BigDecimal( (String) value );
  1402. } else if( value instanceof BigInteger ) {
  1403. ret = new BigDecimal( (BigInteger) value );
  1404. } else if( value instanceof Number ) {
  1405. ret = new BigDecimal( ((Number)value).doubleValue() );
  1406. } else {
  1407. throw new ClassCastException("Not possible to coerce ["+value+"] from class "+value.getClass()+" into a BigDecimal.");
  1408. }
  1409. }
  1410. return ret;
  1411. }
  1412. }