AnnualPlanKGController.java 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  1. package com.zhcs.dt.controller.information.annualPlan;
  2. import java.io.BufferedReader;
  3. import java.io.DataOutputStream;
  4. import java.io.InputStreamReader;
  5. import java.math.BigDecimal;
  6. import java.net.URL;
  7. import java.util.ArrayList;
  8. import java.util.Date;
  9. import java.util.HashMap;
  10. import java.util.LinkedHashMap;
  11. import java.util.List;
  12. import java.util.Map;
  13. import java.util.Set;
  14. import java.util.Map.Entry;
  15. import javax.annotation.Resource;
  16. import javax.servlet.http.HttpServletRequest;
  17. import javax.servlet.http.HttpServletResponse;
  18. import net.sf.json.JSONArray;
  19. import net.sf.json.JSONObject;
  20. import org.apache.commons.httpclient.util.HttpURLConnection;
  21. import org.apache.commons.lang.StringUtils;
  22. import org.springframework.stereotype.Controller;
  23. import org.springframework.ui.Model;
  24. import org.springframework.web.bind.annotation.RequestMapping;
  25. import org.springframework.web.bind.annotation.ResponseBody;
  26. import org.springframework.web.servlet.ModelAndView;
  27. import com.zhcs.dt.controller.base.BaseController;
  28. import com.zhcs.dt.service.information.annualPlan.AnnualPlanCompManager;
  29. import com.zhcs.dt.service.information.annualPlan.AnnualPlanManager;
  30. import com.zhcs.dt.service.information.annualPlan.DownloadZip;
  31. import com.zhcs.dt.service.information.annualPlan.MultExcelUtils;
  32. import com.zhcs.dt.service.information.annualPlan.TotalAmountUtil;
  33. import com.zhcs.dt.service.information.annualPlan.impl.AnnualBaseInfoService;
  34. import com.zhcs.dt.service.task.impl.DailyTaskService;
  35. import com.zhcs.dt.task.DailyUrlUtil;
  36. import com.zhcs.dt.task.HttpCallInterfaceUtil;
  37. import com.zhcs.dt.util.AppUtil;
  38. import com.zhcs.dt.util.Jurisdiction;
  39. import com.zhcs.dt.util.PageData;
  40. import com.zhcs.dt.util.UuidUtil;
  41. /**
  42. * 类名称:年度养护计划
  43. * 创建人:Yuanf
  44. * 创建时间:2018-11-12
  45. */
  46. @Controller
  47. @RequestMapping(value="/annualPlanKG")
  48. class AnnualPlanKGController extends BaseController {
  49. String menuUrl = "annualPlanComp/list.do"; //菜单地址(权限用)
  50. @Resource(name="annualPlanCompService")
  51. private AnnualPlanCompManager annualPlanCompService;
  52. @Resource(name="annualPlanService")
  53. private AnnualPlanManager annualPlanService;
  54. @Resource(name="dailyTaskService")
  55. private DailyTaskService dailyTaskService;
  56. @Resource(name="annualBaseInfoService")
  57. private AnnualBaseInfoService annualBaseInfoService;
  58. List<String> newTables = new ArrayList<String>();
  59. String[] tabls = {"annual_plan_list","annual_plan_comp_list","annual_table_list"};
  60. @RequestMapping("/exporthz")
  61. public String exporthz(HttpServletRequest request,HttpServletResponse response) throws Exception{
  62. String path = request.getSession().getServletContext().getRealPath("/uploadFiles/file");
  63. ModelAndView mv = this.getModelAndView();
  64. PageData pd = new PageData();
  65. pd = this.getPageData();
  66. List<String> paths = new ArrayList<String>();
  67. List<String> result = new ArrayList<String>();
  68. //excel文档
  69. List<PageData> exceldata = setMultExcelData(pd);
  70. MultExcelUtils ex = new MultExcelUtils();
  71. String excelpath = ex.exportExcel(pd.getString("exportname")+".xlsx",path,response,exceldata);
  72. result.add(excelpath);
  73. //zip压缩下载
  74. DownloadZip.downloadZip(response,request,result,path);
  75. return null;
  76. }
  77. public List<PageData> setMultExcelData(PageData param) throws Exception {
  78. List<PageData> result = new ArrayList<PageData>();
  79. String[] modelNames = {"养护计划汇总","日常养护计划汇总","预防养护计划汇总",
  80. "修复养护计划汇总","专项养护计划汇总",
  81. "试验检测项目计划汇总","科研项目计划汇总"};
  82. String[] keyStrs = {
  83. "DESIGN_KM,CARE_KM,DAILY_DESIGN,DAILY_COMPLETE_KM,"
  84. + "MINOR_PREVENTION_DESIGN,MIDDLE_PREVENTION_DESIGN,OVERHAUL_PREVENTION_DESIGN,PREVENTION_DESIGN,"
  85. + "MINOR_REPAIR_DESIGN,MIDDLE_REPAIR_DESIGN,OVERHAUL_DESIGN,REPAIR_DESIGN,"
  86. + "SPECIAL_DESIGN,TEST_DESIGN,SCIENTIFIC_DESIGN,DEVICE_DESIGN,RESERVE_TOTAL_COST,RESERVE_DESIGN,ZFY_COST,ZFY_COMPLETE"
  87. ,"DESIGN_KM,CARE_KM,"
  88. + "CLEAN,PATROL,SUBGRADE,PAVEMENT,BRIDGE,CULVERT,TUNNEL,GREEN,SAFE,LINE,CAR,EMERGENCY,ZFY_COST,ZFY_COMPLETE"
  89. ,"DESIGN_KM,CARE_KM,"
  90. + "MIN_SUBGRADE,MIN_PAVEMENT,MIN_BRIDGE,MIN_TUNNEL,MIN_TOTAL,"
  91. + "MID_SUBGRADE,MID_PAVEMENT,MID_BRIDGE,MID_TUNNEL,MID_TOTAL,"
  92. + "MAX_SUBGRADE,MAX_PAVEMENT,MAX_BRIDGE,MAX_TUNNEL,MAX_TOTAL,"
  93. + "SUBGRADE_TOTAL,PAVEMENT_TOTAL,BRIDGE_TOTAL,TUNNEL_TOTAL,TOTAL"
  94. ,"DESIGN_KM,CARE_KM,"
  95. + "MIN_SUBGRADE,MIN_PAVEMENT,MIN_BRIDGE,MIN_TUNNEL,MIN_TRAFFIC_SAFE,MIN_ROADSIDE,MIN_GREEN,MIN_OTHER,MIN_TOTAL,"
  96. + "MID_SUBGRADE,MID_PAVEMENT,MID_BRIDGE,MID_TUNNEL,MID_TRAFFIC_SAFE,MID_ROADSIDE,MID_GREEN,MID_OTHER,MID_TOTAL,"
  97. + "MAX_SUBGRADE,MAX_PAVEMENT,MAX_BRIDGE,MAX_TUNNEL,MAX_TRAFFIC_SAFE,MAX_ROADSIDE,MAX_GREEN,MAX_OTHER,MAX_TOTAL,"
  98. + "SUBGRADE_TOTAL,PAVEMENT_TOTAL,BRIDGE_TOTAL,TUNNEL_TOTAL,TRAFFIC_SAFE_TOTAL,ROADSIDE_TOTAL,GREEN_TOTAL,OTHER_TOTAL,HJ_TOTAL"
  99. ,"DESIGN_KM,CARE_KM,"
  100. + "SUBGRADE,PAVEMENT,BRIDGE,TUNNEL,TRAFFIC_SAFE,ROADSIDE,GREEN,OTHER,TOTAL"
  101. ,"DESIGN_KM,CARE_KM,"
  102. + "SUBGRADE,PAVEMENT,BRIDGE,TUNNEL,TRAFFIC_SAFE,ROADSIDE,OTHER,TOTAL"
  103. ,"DESIGN_KM,CARE_KM,"
  104. + "SUBGRADE,PAVEMENT,BRIDGE,OTHER,TOTAL"
  105. };
  106. String[] tableNames = {"annual_comp_sumtable_view","annual_daily_comp_sumtable_view","annual_prevention_comp_sumtable_view",
  107. "annual_repair_comp_sumtable_view","annual_special_comp_sumtable_view",
  108. "annual_test_comp_sumtable_view","annual_scientific_comp_sumtable_view"};
  109. int[] startRowIndexs = {3,2,3,4,2,2,2};
  110. int[] tabletype = {6,6,6,6,6,6,6};
  111. int[] totalRange = {2,2,2,2,2,2,2};
  112. String[][][] funcArrys = {
  113. {
  114. {"percent","DAILY_COMPLETE_KM","ROUND(IF(ISERROR((F#row#/E#row#)),\"0\",(F#row#/E#row#)),1)"},
  115. {"percent","ZFY_COMPLETE","ROUND(IF(ISERROR((V#row#/E#row#)),\"0\",(V#row#/E#row#)),1)"},
  116. },
  117. {
  118. {"percent","ZFY_COMPLETE","ROUND(IF(ISERROR((R#row#/E#row#)),\"0\",(R#row#/E#row#)),1)"}
  119. },{},{},{},{},{}};
  120. PageData pd = new PageData();
  121. for (int i = 0; i < tableNames.length; i++) {
  122. PageData data = new PageData();
  123. pd.put("type", tableNames[i]);
  124. pd.put("YEAR", param.get("YEAR"));
  125. pd.put("table", "oa_department_"+param.get("YEAR").toString());
  126. List<PageData> list = annualPlanCompService.gethzdata(pd);
  127. //养护计划汇总,总费用、总费用/公里计算
  128. if(i==0){
  129. list = TotalAmountUtil.yhjhTotalAmount(list);
  130. }
  131. //日常养护汇总
  132. if(i==1){
  133. list = TotalAmountUtil.rcyhTotalAmount(list);
  134. }
  135. data.put("list", list);
  136. data.put("modelName", modelNames[i]);
  137. data.put("keyStr", keyStrs[i]);
  138. data.put("startRowIndex", startRowIndexs[i]);
  139. data.put("tabletype", tabletype[i]);
  140. data.put("funcArry", funcArrys[i]);
  141. data.put("totalRange", totalRange[i]);
  142. data.put("pd", pd);
  143. result.add(data);
  144. }
  145. return result;
  146. }
  147. @RequestMapping("/exportmx")
  148. public String exportmx(HttpServletRequest request,HttpServletResponse response) throws Exception{
  149. String path = request.getSession().getServletContext().getRealPath("/uploadFiles/file");
  150. ModelAndView mv = this.getModelAndView();
  151. PageData pd = new PageData();
  152. pd = this.getPageData();
  153. List<String> paths = new ArrayList<String>();
  154. List<String> result = new ArrayList<String>();
  155. //excel文档
  156. List<PageData> exceldata = setMxExcelData(pd);
  157. MultExcelUtils ex = new MultExcelUtils();
  158. String excelpath = ex.exportExcel(pd.getString("exportname")+".xlsx",path,response,exceldata);
  159. result.add(excelpath);
  160. //zip压缩下载
  161. DownloadZip.downloadZip(response,request,result,path);
  162. return null;
  163. }
  164. public List<PageData> setMxExcelData(PageData param) throws Exception {
  165. List<PageData> result = new ArrayList<PageData>();
  166. String[] modelNames = {"预防养护计划统计表","修复养护计划统计表","专项养护计划统计表","应急养护计划统计表"
  167. ,"试验检测项目计划统计表","科研项目计划统计表","设备大修项目计划统计表"};
  168. String[] keyStrs = {
  169. "PROJECT_NAME,PROJECT_TYPE,SCALE,PLAN_QUANTITIES,PLAN_COST,REMARKS"
  170. ,"PROJECT_NAME,PROJECT_TYPE,SCALE,PLAN_QUANTITIES,PLAN_COST,REMARKS"
  171. ,"SPECIAL_PROJECT_NAME,MAIN_WORK_CONTENTS,PLAN_COST,REMARKS"
  172. ,"PROJECT_NAME,PROJECT_TYPE,SCALE,PLAN_QUANTITIES,PLAN_COST,REMARKS"
  173. ,"PROJECT_NAME,PROJECT_TYPE,CONTENT,PLAN_COST,REMARKS"
  174. ,"PROJECT_NAME,PROJECT_TYPE,CONTENT,PLAN_COST,MATTER_YEAR,MATTER_NEW_CARRY,MATTER_CONSULT"
  175. ,"PROJECT_NAME,PROJECT_TYPE,COMPLETE_DESCRIBE,PLAN_COST,REMARKS"
  176. };
  177. String[] tableNames = {"highway_prevention_plan_sumtable_view2","highway_repair_comp_sumtable_view2","highway_special_comp_sumtable_view2"
  178. ,"highway_emergency_comp_sumtable_view2","highway_test_comp_sumtable_view2"
  179. ,"highway_scientific_comp_sumtable_view2","highway_equipment_overhaul_comp_sumtable_view2"
  180. };
  181. int[] startRowIndexs = {3,3,3,3,3,3,3};
  182. int[] tabletype = {6,6,6,6,6,6,6};
  183. int[] totalRange = {6,6,4,5,5,5,5};
  184. String[][][] funcArrys = {
  185. {
  186. {"null","REMARKS","\"\""}
  187. },{
  188. {"null","REMARKS","\"\""}
  189. },{
  190. {"null","REMARKS","\"\""}
  191. },{
  192. {"null","REMARKS","\"\""}
  193. },{
  194. {"null","REMARKS","\"\""}
  195. },{
  196. {"null","REMARKS","\"\""}
  197. },{
  198. {"null","REMARKS","\"\""}
  199. }
  200. };
  201. PageData pd = new PageData();
  202. for (int i = 0; i < tableNames.length; i++) {
  203. PageData data = new PageData();
  204. pd.put("type", tableNames[i]);
  205. pd.put("YEAR", param.get("YEAR"));
  206. pd.put("table", "oa_department_"+param.get("YEAR"));
  207. List<PageData> list = annualPlanCompService.getProjectData(pd);
  208. data.put("list", list);
  209. data.put("modelName", modelNames[i]);
  210. data.put("keyStr", keyStrs[i]);
  211. data.put("startRowIndex", startRowIndexs[i]);
  212. data.put("tabletype", tabletype[i]);
  213. data.put("funcArry", funcArrys[i]);
  214. data.put("totalRange", totalRange[i]);
  215. data.put("totalCost", "");
  216. if (tabletype[i]==7) {
  217. String totalCost = annualPlanCompService.getFeesTotalCost(Integer.parseInt(param.getString("YEAR"))-1+"");
  218. data.put("totalCost", totalCost);
  219. }
  220. data.put("pd", pd);
  221. result.add(data);
  222. }
  223. return result;
  224. }
  225. /**查询所选汇总表
  226. * @param
  227. * @throws Exception
  228. */
  229. @RequestMapping(value="/showSumTable")
  230. public ModelAndView showSumTable(Model model)throws Exception{
  231. ModelAndView mv = this.getModelAndView();
  232. PageData pd = new PageData();
  233. pd = this.getPageData();
  234. mv.setViewName("information/annualPlan/annualSumTablePlan/"+pd.get("type"));
  235. //设置查询oa_department的动态表名
  236. String oa_department_table = "oa_department_"+pd.get("YEAR");
  237. pd.put("table", oa_department_table);
  238. List<PageData> varList = annualPlanCompService.getdata(pd);
  239. //处理前段显示值
  240. //1.养护计划汇总 控制格式化
  241. varList = formatEmptyString(varList);
  242. if( null != pd.get("type") && !pd.get("type").toString().isEmpty()&& null != varList && varList.size()>0 ){
  243. //养护计划汇总-合计总费用
  244. if(pd.get("type").toString().equals("annual_comp_sumtable_view")){
  245. varList = formatAnnualCompSumtable(varList);
  246. }
  247. }
  248. mv.addObject("varList", varList);
  249. mv.addObject("pd", pd);
  250. mv.addObject("QX",Jurisdiction.getHC()); //按钮权限
  251. return mv;
  252. }
  253. /**查询日常汇总表
  254. * @param
  255. * @throws Exception
  256. */
  257. @RequestMapping(value="/showDailySumTable")
  258. public ModelAndView showDailySumTable(Model model)throws Exception{
  259. ModelAndView mv = this.getModelAndView();
  260. PageData pd = new PageData();
  261. pd = this.getPageData();
  262. pd.put("table", "oa_department_"+pd.getString("YEAR"));
  263. mv.setViewName("information/annualPlan/annualSumTablePlan/highway_daily_plan_statable");
  264. List<PageData> varList = annualPlanCompService.getDailydata(pd);
  265. mv.addObject("varList", varList);
  266. mv.addObject("pd", pd);
  267. mv.addObject("QX",Jurisdiction.getHC()); //按钮权限
  268. return mv;
  269. }
  270. /**查询所选明细表
  271. * @param
  272. * @throws Exception
  273. */
  274. @RequestMapping(value="/showDettTable")
  275. public ModelAndView showDettTable(Model model)throws Exception{
  276. ModelAndView mv = this.getModelAndView();
  277. PageData pd = new PageData();
  278. pd = this.getPageData();
  279. pd.put("table", "oa_department_"+pd.get("YEAR").toString());
  280. mv.setViewName("information/annualPlan/annualSumTablePlan/"+pd.get("type"));
  281. List<PageData> dettList = annualPlanCompService.getDettData(pd);
  282. if(dettList ==null || dettList.equals(" ") || dettList.isEmpty() ) {
  283. mv.addObject("dettList", "");
  284. }else {
  285. LinkedHashMap<String, LinkedHashMap<String, ArrayList<PageData>>> varMap = new LinkedHashMap<String, LinkedHashMap<String, ArrayList<PageData>>>();
  286. Double sumPlanCost = (double) 0;
  287. Double sumActualCost = (double) 0;
  288. Double sumAuditFee = (double) 0;
  289. String prevCompanyName = "";
  290. String prevCompanyID = "";
  291. LinkedHashMap<String, ArrayList<PageData>> xjroadMap = new LinkedHashMap<String, ArrayList<PageData>>();
  292. for(PageData tpd : dettList){
  293. String company = tpd.get("COMPANY").toString();
  294. String companyid = tpd.get("COMPANY_ID").toString();
  295. String road = tpd.get("ROAD").toString();
  296. if(varMap.containsKey(company)){
  297. LinkedHashMap<String, ArrayList<PageData>> roadMap = varMap.get(company);
  298. if(roadMap != null && roadMap.containsKey(road)){
  299. if(tpd.get("PLAN_COST")!=null){
  300. double plan = Double.parseDouble(tpd.get("PLAN_COST").toString());
  301. plan = formatNum(plan);
  302. sumPlanCost += plan;
  303. }
  304. if(tpd.get("ACTUAL_COST")!=null){
  305. double actual = Double.parseDouble(tpd.get("ACTUAL_COST").toString());
  306. actual = formatNum(actual);
  307. sumActualCost += actual;
  308. }
  309. if(tpd.get("AUDIT_FEE")!=null){
  310. double fee = Double.parseDouble(tpd.get("AUDIT_FEE").toString());
  311. fee = formatNum(fee);
  312. sumAuditFee += fee;
  313. }
  314. ArrayList<PageData> pList = roadMap.get(road);
  315. pList.add(tpd);
  316. }else{
  317. if(tpd.get("PLAN_COST")!=null){
  318. double planc = Double.parseDouble(tpd.get("PLAN_COST").toString());
  319. planc = formatNum(planc);
  320. sumPlanCost += planc;
  321. }
  322. if(tpd.get("ACTUAL_COST")!=null){
  323. double actualc = Double.parseDouble(tpd.get("ACTUAL_COST").toString());
  324. actualc = formatNum(actualc);
  325. sumActualCost += actualc;
  326. }
  327. if(tpd.get("AUDIT_FEE")!=null){
  328. double feec = Double.parseDouble(tpd.get("AUDIT_FEE").toString());
  329. feec = formatNum(feec);
  330. sumAuditFee += feec;
  331. }
  332. ArrayList<PageData> npList = new ArrayList<PageData>();
  333. npList.add(tpd);
  334. roadMap.put(road, npList);
  335. }
  336. xjroadMap = roadMap;
  337. prevCompanyName = company;
  338. prevCompanyID = companyid;
  339. }else{
  340. if(varMap.size() > 0){
  341. ArrayList<PageData> xjList = new ArrayList<PageData>();
  342. PageData xjPd = new PageData();
  343. xjPd.put("COMPANY", prevCompanyName);
  344. xjPd.put("COMPANY_ID", prevCompanyID);
  345. xjPd.put("ROAD", "小计");
  346. xjPd.put("PROJECT_NAME", "");
  347. xjPd.put("PROJECT_TYPE", "");
  348. xjPd.put("SCALE", "");
  349. xjPd.put("PLAN_QUANTITIES", "");
  350. xjPd.put("PLAN_COST", sumPlanCost);
  351. xjPd.put("ACTUAL_QUANTITIES", "");
  352. xjPd.put("PLAN_COST", sumPlanCost);
  353. xjPd.put("REMARKS", "");
  354. xjPd.put("AUDIT_FEE", sumAuditFee);
  355. xjList.add(xjPd);
  356. xjroadMap = varMap.get(prevCompanyName);
  357. xjroadMap.put("小计", xjList);
  358. varMap.put(prevCompanyName, xjroadMap);
  359. }
  360. ArrayList<PageData> mpList = new ArrayList<PageData>();
  361. LinkedHashMap<String, ArrayList<PageData>> mroadMap = new LinkedHashMap<String, ArrayList<PageData>>();
  362. mpList.add(tpd);
  363. mroadMap.put(road, mpList);
  364. varMap.put(company, mroadMap);
  365. prevCompanyName = company;
  366. prevCompanyID = companyid;
  367. sumPlanCost = (double) 0;
  368. sumActualCost = (double) 0;
  369. if(tpd.get("PLAN_COST")!=null){
  370. double planco = Double.parseDouble(tpd.get("PLAN_COST").toString());
  371. planco = formatNum(planco);
  372. sumPlanCost += planco;
  373. }
  374. if(tpd.get("ACTUAL_COST")!=null){
  375. double actualco = Double.parseDouble(tpd.get("ACTUAL_COST").toString());
  376. actualco = formatNum(actualco);
  377. sumActualCost += actualco;
  378. }
  379. if(tpd.get("AUDIT_FEE")!=null){
  380. double feeco = Double.parseDouble(tpd.get("AUDIT_FEE").toString());
  381. feeco = formatNum(feeco);
  382. sumAuditFee += feeco;
  383. }
  384. }
  385. }
  386. PageData lastxjPd = new PageData();
  387. lastxjPd.put("COMPANY", prevCompanyName);
  388. lastxjPd.put("COMPANY_ID", prevCompanyID);
  389. lastxjPd.put("ROAD", "小计");
  390. lastxjPd.put("PROJECT_NAME", "");
  391. lastxjPd.put("PROJECT_TYPE", "");
  392. lastxjPd.put("SCALE", "");
  393. lastxjPd.put("PLAN_QUANTITIES", "");
  394. lastxjPd.put("PLAN_COST", sumPlanCost);
  395. lastxjPd.put("ACTUAL_QUANTITIES", "");
  396. lastxjPd.put("AUDIT_FEE", sumAuditFee);
  397. lastxjPd.put("REMARKS", "");
  398. lastxjPd.put("ACTUAL_COST", sumActualCost);
  399. List<PageData> dettListNew = new ArrayList<PageData>();
  400. for(Entry<String, LinkedHashMap<String, java.util.ArrayList<PageData>>> centry : varMap.entrySet()){
  401. HashMap<String, java.util.ArrayList<PageData>> roadMap = centry.getValue();
  402. for(Entry<String, java.util.ArrayList<PageData>> rentry : roadMap.entrySet()){
  403. ArrayList<PageData> projectList = rentry.getValue();
  404. for(PageData ppd : projectList){
  405. dettListNew.add(ppd);
  406. }
  407. }
  408. }
  409. dettListNew.add(lastxjPd);
  410. mv.addObject("dettList", dettListNew);
  411. }
  412. mv.addObject("pd", pd);
  413. mv.addObject("QX",Jurisdiction.getHC()); //按钮权限
  414. return mv;
  415. }
  416. /**查询所选汇总表
  417. * @param
  418. * @throws Exception
  419. */
  420. @RequestMapping(value="/showPlanList")
  421. public ModelAndView showPlanList()throws Exception{
  422. ModelAndView mv = this.getModelAndView();
  423. PageData pd = new PageData();
  424. pd = this.getPageData();
  425. pd.put("table", "oa_department_"+pd.getString("YEAR"));
  426. String sptime = annualPlanCompService.getSPTime(pd);
  427. List<PageData> nPlanList = annualPlanCompService.getnPlanList(pd);
  428. List<PageData> planList = annualPlanCompService.getPlanList(pd);
  429. mv.addObject("nPlanList", nPlanList);
  430. mv.addObject("planList", planList);
  431. mv.addObject("sptime", sptime);
  432. mv.addObject("pd", pd);
  433. mv.setViewName("information/annualPlan/annualPlan_showPlanList");
  434. return mv;
  435. }
  436. /**查询所有公司和路段
  437. * @param
  438. * @throws Exception
  439. */
  440. @RequestMapping(value="/showCompanyRoadList")
  441. public ModelAndView showCompanyRoadList()throws Exception{
  442. ModelAndView mv = this.getModelAndView();
  443. PageData pd = new PageData();
  444. pd = this.getPageData();
  445. //动态oa_department表
  446. pd.put("table", "oa_department_"+pd.getString("YEAR").toString());
  447. List<PageData> companyRoadList = annualPlanCompService.getCompanyRoadList(pd);
  448. Map<String,List<String>> companyRoad = new HashMap<String,List<String>>();
  449. List<String> companyList = new ArrayList<String>();
  450. for(PageData tpd : companyRoadList){
  451. if(tpd.get("PARENT_ID").equals("0")){
  452. companyList.add(tpd.get("NAME").toString());
  453. List<String> roadList = new ArrayList<String>();
  454. for(PageData tempPd : companyRoadList){
  455. if(tempPd.get("PARENT_ID").equals(tpd.get("DEPARTMENT_ID"))){
  456. roadList.add(tempPd.get("NAME").toString());
  457. }
  458. }
  459. companyRoad.put(tpd.get("NAME").toString(), roadList);
  460. }
  461. }
  462. mv.addObject("companyList", companyList);
  463. mv.addObject("companyRoad", JSONArray.fromObject(companyRoad));
  464. mv.addObject("pd", pd);
  465. mv.setViewName("information/annualPlan/annualPlanComp/annualPlan_showCompanyRoadList");
  466. return mv;
  467. }
  468. /**显示、编辑子表格
  469. * @param
  470. * @throws Exception
  471. */
  472. @RequestMapping(value="/showTableRecod")
  473. public ModelAndView showTableRecod()throws Exception{
  474. ModelAndView mv = this.getModelAndView();
  475. PageData pd = new PageData();
  476. pd = this.getPageData();
  477. List<PageData> varList = new ArrayList<PageData>();
  478. JSONArray arr = JSONArray.fromObject(varList);
  479. mv.addObject("varList", arr);
  480. String year = pd.get("YEAR").toString();
  481. pd.put("table", "oa_department_"+year);
  482. pd = annualBaseInfoService.findRoadId(pd);
  483. pd.put("YEAR", year);
  484. //mv.setViewName("information/annualPlan/annualTableRecord/highway_daily_comp_dettable");
  485. mv.setViewName("information/annualPlan/annualTableRecord/highway_daily_comp_dettable_dy");
  486. mv.addObject("pd", pd);
  487. mv.addObject("QX",Jurisdiction.getHC()); //按钮权限
  488. return mv;
  489. }
  490. /**修改计划和下面立项表的状态
  491. * @param
  492. * @throws Exception
  493. */
  494. @RequestMapping(value="/changePlanStatus")
  495. @ResponseBody
  496. public Object changePlanStatus()throws Exception{
  497. Map<String,String> map = new HashMap<String,String>();
  498. PageData pd = new PageData();
  499. pd = this.getPageData();
  500. if(pd.get("TYPE") != null){
  501. if("1".equalsIgnoreCase(pd.get("TYPE").toString())){
  502. pd.put("STATUS", "审批通过");
  503. }else{
  504. pd.put("STATUS", "控股驳回");
  505. }
  506. }
  507. try{
  508. annualPlanCompService.changeCompPlanStatus(pd); //同步修改COMP表状态
  509. for(String tableName : tabls){
  510. pd.put("TABLE_NAME", tableName);
  511. if("annual_table_list".equalsIgnoreCase(tableName) && "控股驳回".equalsIgnoreCase(pd.get("STATUS").toString())){
  512. pd.put("STATUS", "审批不通过");
  513. }
  514. annualPlanCompService.changePlanStatus(pd); //修改状态
  515. }
  516. map.put("result", "success");
  517. //TODO 调用接口发送数据
  518. String sendStr="";
  519. pd.put("table", "oa_department_"+pd.get("YEAR"));
  520. List<PageData> passPlanList = annualPlanService.getPassPlan(pd);
  521. if(null != passPlanList && passPlanList.size()>0){
  522. JSONArray jsonArray=JSONArray.fromObject(passPlanList);
  523. sendStr = jsonArray.toString();
  524. System.out.println(sendStr);
  525. DailyUrlUtil dailyUrlUtil = new DailyUrlUtil();
  526. String approvalurl = dailyUrlUtil.getApprovalUrl();
  527. String result = HttpCallInterfaceUtil.sendPost(approvalurl, sendStr, false);
  528. if(null != result && !result.isEmpty()){
  529. JSONObject jsonObj = JSONObject.fromObject(result);
  530. /** 请求结果保存进 数据库日志*/
  531. saveLog(sendStr,jsonObj.get("msg").toString(),jsonObj.get("data").toString());
  532. }
  533. else{
  534. saveLog(sendStr,"","");
  535. }
  536. }
  537. }catch(Exception e){
  538. map.put("result", "操作失败");
  539. }
  540. return AppUtil.returnObject(new PageData(), map);
  541. }
  542. /**更新立项表中的审批费用和备注
  543. * @param
  544. * @throws Exception
  545. */
  546. @RequestMapping(value="/saveData")
  547. @ResponseBody
  548. public Object saveData()throws Exception{
  549. Map<String,String> map = new HashMap<String,String>();
  550. PageData pd = new PageData();
  551. pd = this.getPageData();
  552. JSONArray jsonarray = JSONArray.fromObject(pd.get("data"));
  553. String tableName = pd.get("TABLETYPE").toString();
  554. String year = pd.get("YEAR").toString();
  555. List<PageData> pdList = dealData(jsonarray, year,tableName);
  556. try{
  557. for(PageData tpd : pdList){
  558. annualPlanCompService.updateAuditFee(tpd);
  559. }
  560. map.put("msg", "success");
  561. }catch(Exception e){
  562. System.out.println(e);
  563. map.put("msg", "操作失败");
  564. }
  565. return AppUtil.returnObject(new PageData(), map);
  566. }
  567. /**
  568. * 处理审批费用
  569. */
  570. @ResponseBody
  571. public List<PageData> dealData(JSONArray jsonarray, String year, String tableName) throws Exception {
  572. List<PageData> pdList = new ArrayList<PageData>();
  573. if (jsonarray.size() > 0) {
  574. for (int i = 0; i < jsonarray.size(); i++) {
  575. PageData pd = new PageData();
  576. JSONObject job = jsonarray.getJSONObject(i);
  577. // if(!"".equalsIgnoreCase(job.get("AUDIT_FEE").toString().trim())){
  578. pd.put("YEAR", year);
  579. pd.put("TABLE_NAME", tableName);
  580. pd.put("COMPANY_ID", job.get("COMPANY_ID"));
  581. pd.put("ROAD_ID", job.get("ROAD_ID"));
  582. pd.put("PROJECT_NAME", job.get("PROJECT_NAME"));
  583. pd.put("AUDIT_FEE", job.get("AUDIT_FEE"));
  584. pd.put("AUDIT_MAKER", job.get("AUDIT_MAKER"));
  585. pdList.add(pd);
  586. // }
  587. }
  588. }
  589. return pdList;
  590. }
  591. /**更新日常养护计划中的审核费用
  592. * @param
  593. * @throws Exception
  594. */
  595. @RequestMapping(value="/saveDailyData")
  596. @ResponseBody
  597. public Object saveDailyData(String data)throws Exception{
  598. Map<String,String> map = new HashMap<String,String>();
  599. PageData pd = new PageData();
  600. pd = this.getPageData();
  601. JSONArray jsonarray = JSONArray.fromObject(pd.get("data"));
  602. String tableName = pd.get("TABLETYPE").toString();
  603. String year = pd.get("YEAR").toString();
  604. List<PageData> pdList = dealDailyData(jsonarray, year,tableName);
  605. try{
  606. for(PageData tpd : pdList){
  607. annualPlanCompService.editTableRecod(tpd);
  608. }
  609. map.put("msg", "success");
  610. }catch(Exception e){
  611. System.out.println(e);
  612. map.put("msg", "操作失败");
  613. }
  614. return AppUtil.returnObject(new PageData(), map);
  615. }
  616. /**
  617. * 处理日常养护审批费用
  618. */
  619. @ResponseBody
  620. public List<PageData> dealDailyData(JSONArray jsonarray, String year, String tableName) throws Exception {
  621. List<PageData> pdList = new ArrayList<PageData>();
  622. for (Object object : jsonarray) {
  623. PageData tpd = new PageData();
  624. JSONObject arrMap = JSONObject.fromObject(object);
  625. Set entryarray = arrMap.entrySet();
  626. ArrayList<Object> keyarray = new ArrayList<Object>();
  627. ArrayList<Object> valuearray = new ArrayList<Object>();
  628. for (Object entry : entryarray) {
  629. Object[] arr = entry.toString().split("=");
  630. boolean saveFlag = true;
  631. if (entry != null){
  632. saveFlag = !"ROAD".equals(arr[0]) && !"YEAR".equals(arr[0]) && !"COMPANY".equals(arr[0])
  633. &&!"ROAD_ID".equals(arr[0]) && !"COMPANY_ID".equals(arr[0]);
  634. if (saveFlag) {
  635. if (arr.length > 1) {
  636. keyarray.add(arr[0]);
  637. valuearray.add(arr[1]);
  638. }
  639. }
  640. }
  641. }
  642. if(!keyarray.isEmpty()){
  643. tpd.put("KEYS", StringUtils.join(keyarray.toArray(), ","));
  644. tpd.put("KEYARRAY", keyarray);
  645. tpd.put("VALUEARRAY", valuearray);
  646. tpd.put("ROAD_ID", arrMap.get("ROAD_ID"));
  647. tpd.put("COMPANY_ID", arrMap.get("COMPANY_ID"));
  648. tpd.put("YEAR", arrMap.get("YEAR"));
  649. pdList.add(tpd);
  650. }
  651. }
  652. return pdList;
  653. }
  654. /**设置提交时间阈值
  655. * @param
  656. * @throws Exception
  657. */
  658. @RequestMapping(value="/saveTime")
  659. @ResponseBody
  660. public Object saveTime()throws Exception{
  661. Map<String,String> map = new HashMap<String,String>();
  662. PageData pd = new PageData();
  663. pd = this.getPageData();
  664. try{
  665. String timepd = annualPlanCompService.getSPTime(pd);
  666. if(timepd != null){
  667. annualPlanCompService.updateSPTime(pd);
  668. }else{
  669. annualPlanCompService.insertSPTime(pd);
  670. }
  671. map.put("result", "success");
  672. }catch(Exception e){
  673. map.put("result", "操作失败");
  674. }
  675. return AppUtil.returnObject(new PageData(), map);
  676. }
  677. /**更新养护计划汇总的审批费用
  678. * @param
  679. * @throws Exception
  680. */
  681. @RequestMapping(value="/saveAuditFee")
  682. @ResponseBody
  683. public Object saveAuditFee(String inputData)throws Exception{
  684. System.out.print("inputData::"+inputData);
  685. PageData pd = new PageData();
  686. pd = this.getPageData();
  687. JSONArray jsonarray = JSONArray.fromObject(inputData);
  688. List<PageData> data = dealData(jsonarray);
  689. //判断执行update 还是 insert
  690. annualPlanCompService.saveOrUpdatBatchAuditFee(data);
  691. Map<String,String> map = new HashMap<String,String>();
  692. map.put("result", "success");
  693. return AppUtil.returnObject(new PageData(), map);
  694. }
  695. public List<PageData> dealData(JSONArray jsonarray) throws Exception {
  696. List<PageData> pdList = new ArrayList<PageData>();
  697. if (jsonarray.size() > 0) {
  698. for (int i = 0; i < jsonarray.size(); i++) {
  699. PageData pd = new PageData();
  700. JSONObject job = jsonarray.getJSONObject(i);
  701. pd.put("AUDIT_FEE", job.get("AUDIT_FEE"));
  702. pd.put("COMPANY_ID", job.get("COMPANY_ID"));
  703. pd.put("COMPANY", job.get("COMPANY"));
  704. pd.put("ROAD", job.get("ROAD"));
  705. pd.put("ROAD_ID", job.get("ROAD_ID"));
  706. pd.put("YEAR", job.get("YEAR"));
  707. pdList.add(pd);
  708. }
  709. }
  710. return pdList;
  711. }
  712. /**
  713. * 格式化decimal类型空值
  714. * @param type
  715. * @param varList
  716. * @return
  717. */
  718. public List<PageData> formatEmptyString(List<PageData> varList){
  719. if(null != varList && varList.size()>0){
  720. BigDecimal bigDecimal = new BigDecimal("0");
  721. for(PageData o:varList){
  722. if(null != o ){
  723. if(null != o.get("RESERVE_DESIGN")){
  724. BigDecimal oBigDecimal = (BigDecimal)o.get("RESERVE_DESIGN");
  725. if(oBigDecimal.compareTo(bigDecimal) ==0){
  726. o.put("RESERVE_DESIGN", "");
  727. }
  728. else{
  729. BigDecimal ten = new BigDecimal("10.00");
  730. if(oBigDecimal.compareTo(ten)<1){
  731. oBigDecimal = oBigDecimal.setScale(1, BigDecimal.ROUND_HALF_UP);
  732. }
  733. else{
  734. oBigDecimal = oBigDecimal.setScale(0, BigDecimal.ROUND_HALF_UP);
  735. }
  736. o.put("RESERVE_DESIGN", oBigDecimal);
  737. }
  738. }
  739. }
  740. }
  741. }
  742. return varList;
  743. }
  744. /**
  745. * 养护计划汇总-合计总费用
  746. * @param varList
  747. * @return
  748. */
  749. public List<PageData> formatAnnualCompSumtable(List<PageData> varList){
  750. for(PageData data:varList){
  751. BigDecimal zfy = new BigDecimal("0");
  752. BigDecimal daily_decimal = new BigDecimal("0");
  753. BigDecimal prevention_decimal = new BigDecimal("0");
  754. BigDecimal repair_decimal = new BigDecimal("0");
  755. BigDecimal special_decimal = new BigDecimal("0");
  756. BigDecimal test_decimal = new BigDecimal("0");
  757. BigDecimal scientific_decimal = new BigDecimal("0");
  758. BigDecimal device_decimal = new BigDecimal("0");
  759. BigDecimal reserve_decimal = new BigDecimal("0");
  760. BigDecimal audit_fee_decimal = new BigDecimal("0");
  761. //日常养护-费用
  762. if(null != data.get("DAILY_DESIGN")){
  763. daily_decimal = TotalAmountUtil.getBigDecimal(data.get("DAILY_DESIGN"));
  764. }
  765. //预防养护-费用
  766. if(null != data.get("PREVENTION_DESIGN")){
  767. prevention_decimal = TotalAmountUtil.getBigDecimal(data.get("PREVENTION_DESIGN"));
  768. }
  769. //修复养护-费用
  770. if(null != data.get("REPAIR_DESIGN")){
  771. repair_decimal = TotalAmountUtil.getBigDecimal(data.get("REPAIR_DESIGN"));
  772. }
  773. //专项养护-费用
  774. if(null != data.get("SPECIAL_DESIGN")){
  775. special_decimal = TotalAmountUtil.getBigDecimal(data.get("SPECIAL_DESIGN"));
  776. }
  777. //试验检测-费用
  778. if(null != data.get("TEST_DESIGN")){
  779. test_decimal = TotalAmountUtil.getBigDecimal(data.get("TEST_DESIGN"));
  780. }
  781. //科研项目-费用
  782. if(null != data.get("SCIENTIFIC_DESIGN")){
  783. scientific_decimal = TotalAmountUtil.getBigDecimal(data.get("SCIENTIFIC_DESIGN"));
  784. }
  785. //设备大修-费用
  786. if(null != data.get("DEVICE_DESIGN")){
  787. device_decimal = TotalAmountUtil.getBigDecimal(data.get("DEVICE_DESIGN"));
  788. }
  789. //预备费-计划费用
  790. if(null != data.get("RESERVE_TOTAL_COST")){
  791. reserve_decimal = TotalAmountUtil.getBigDecimal(data.get("RESERVE_TOTAL_COST"));
  792. }
  793. //预备费-审核费用
  794. if(null != data.get("RESERVE_AUDIT_FEE")){
  795. audit_fee_decimal = TotalAmountUtil.getBigDecimal(data.get("RESERVE_AUDIT_FEE"));
  796. BigDecimal ten = new BigDecimal("10.00");
  797. if(audit_fee_decimal.compareTo(ten)<1){
  798. audit_fee_decimal = audit_fee_decimal.setScale(1, BigDecimal.ROUND_HALF_UP);
  799. }
  800. else{
  801. audit_fee_decimal = audit_fee_decimal.setScale(0, BigDecimal.ROUND_HALF_UP);
  802. }
  803. }
  804. if(audit_fee_decimal.compareTo(BigDecimal.ZERO)!=0){
  805. zfy = audit_fee_decimal.add(device_decimal.add(scientific_decimal.add(test_decimal.add(special_decimal.add(repair_decimal.add(prevention_decimal.add(daily_decimal)))))));
  806. }
  807. else{
  808. zfy = reserve_decimal.add(device_decimal.add(scientific_decimal.add(test_decimal.add(special_decimal.add(repair_decimal.add(prevention_decimal.add(daily_decimal)))))));
  809. }
  810. data.put("TOTAL_ZFY", zfy);
  811. }
  812. return varList;
  813. }
  814. /**
  815. * 格式化金额
  816. * @param cost_num
  817. * @return
  818. */
  819. public double formatNum(double cost_num){
  820. String planstr = "";
  821. if(cost_num < 10){
  822. planstr = String.format("%.1f", cost_num);
  823. }
  824. else{
  825. planstr = String.format("%.0f", cost_num);
  826. }
  827. cost_num = Double.parseDouble(planstr);
  828. return cost_num;
  829. }
  830. /**
  831. * 调用情况保存进数据库
  832. * @param orgId
  833. * @param yearMonth
  834. * @param responseCode
  835. * @param responseResult
  836. */
  837. public void saveLog(String paramStr,String responseCode,String responseResult){
  838. try {
  839. PageData pd = new PageData();
  840. pd.put("ID", UuidUtil.get32UUID());
  841. pd.put("INTERFACE_NAME", "getPassPlan");
  842. pd.put("PARAM", paramStr);
  843. pd.put("RESPONSE_CODE", responseCode);
  844. pd.put("RESPONSE_TEXT",responseResult);
  845. pd.put("CREATE_TIME", new Date());
  846. dailyTaskService.save(pd);
  847. } catch (Exception e) {
  848. e.printStackTrace();
  849. }
  850. }
  851. }