123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883 |
- package com.zhcs.dt.controller.information.annualPlan;
- import java.io.BufferedReader;
- import java.io.DataOutputStream;
- import java.io.InputStreamReader;
- import java.math.BigDecimal;
- import java.net.URL;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.LinkedHashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.Set;
- import java.util.Map.Entry;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import net.sf.json.JSONArray;
- import net.sf.json.JSONObject;
- import org.apache.commons.httpclient.util.HttpURLConnection;
- import org.apache.commons.lang.StringUtils;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.servlet.ModelAndView;
- import com.zhcs.dt.controller.base.BaseController;
- import com.zhcs.dt.service.information.annualPlan.AnnualPlanCompManager;
- import com.zhcs.dt.service.information.annualPlan.AnnualPlanManager;
- import com.zhcs.dt.service.information.annualPlan.DownloadZip;
- import com.zhcs.dt.service.information.annualPlan.MultExcelUtils;
- import com.zhcs.dt.service.information.annualPlan.TotalAmountUtil;
- import com.zhcs.dt.service.information.annualPlan.impl.AnnualBaseInfoService;
- import com.zhcs.dt.service.task.impl.DailyTaskService;
- import com.zhcs.dt.task.DailyUrlUtil;
- import com.zhcs.dt.task.HttpCallInterfaceUtil;
- import com.zhcs.dt.util.AppUtil;
- import com.zhcs.dt.util.Jurisdiction;
- import com.zhcs.dt.util.PageData;
- import com.zhcs.dt.util.UuidUtil;
- /**
- * 类名称:年度养护计划
- * 创建人:Yuanf
- * 创建时间:2018-11-12
- */
- @Controller
- @RequestMapping(value="/annualPlanKG")
- class AnnualPlanKGController extends BaseController {
- String menuUrl = "annualPlanComp/list.do"; //菜单地址(权限用)
- @Resource(name="annualPlanCompService")
- private AnnualPlanCompManager annualPlanCompService;
- @Resource(name="annualPlanService")
- private AnnualPlanManager annualPlanService;
- @Resource(name="dailyTaskService")
- private DailyTaskService dailyTaskService;
- @Resource(name="annualBaseInfoService")
- private AnnualBaseInfoService annualBaseInfoService;
-
- List<String> newTables = new ArrayList<String>();
- String[] tabls = {"annual_plan_list","annual_plan_comp_list","annual_table_list"};
-
- @RequestMapping("/exporthz")
- public String exporthz(HttpServletRequest request,HttpServletResponse response) throws Exception{
- String path = request.getSession().getServletContext().getRealPath("/uploadFiles/file");
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- List<String> paths = new ArrayList<String>();
- List<String> result = new ArrayList<String>();
- //excel文档
- List<PageData> exceldata = setMultExcelData(pd);
- MultExcelUtils ex = new MultExcelUtils();
- String excelpath = ex.exportExcel(pd.getString("exportname")+".xlsx",path,response,exceldata);
- result.add(excelpath);
- //zip压缩下载
- DownloadZip.downloadZip(response,request,result,path);
- return null;
- }
-
- public List<PageData> setMultExcelData(PageData param) throws Exception {
- List<PageData> result = new ArrayList<PageData>();
- String[] modelNames = {"养护计划汇总","日常养护计划汇总","预防养护计划汇总",
- "修复养护计划汇总","专项养护计划汇总",
- "试验检测项目计划汇总","科研项目计划汇总"};
- String[] keyStrs = {
- "DESIGN_KM,CARE_KM,DAILY_DESIGN,DAILY_COMPLETE_KM,"
- + "MINOR_PREVENTION_DESIGN,MIDDLE_PREVENTION_DESIGN,OVERHAUL_PREVENTION_DESIGN,PREVENTION_DESIGN,"
- + "MINOR_REPAIR_DESIGN,MIDDLE_REPAIR_DESIGN,OVERHAUL_DESIGN,REPAIR_DESIGN,"
- + "SPECIAL_DESIGN,TEST_DESIGN,SCIENTIFIC_DESIGN,DEVICE_DESIGN,RESERVE_TOTAL_COST,RESERVE_DESIGN,ZFY_COST,ZFY_COMPLETE"
- ,"DESIGN_KM,CARE_KM,"
- + "CLEAN,PATROL,SUBGRADE,PAVEMENT,BRIDGE,CULVERT,TUNNEL,GREEN,SAFE,LINE,CAR,EMERGENCY,ZFY_COST,ZFY_COMPLETE"
- ,"DESIGN_KM,CARE_KM,"
- + "MIN_SUBGRADE,MIN_PAVEMENT,MIN_BRIDGE,MIN_TUNNEL,MIN_TOTAL,"
- + "MID_SUBGRADE,MID_PAVEMENT,MID_BRIDGE,MID_TUNNEL,MID_TOTAL,"
- + "MAX_SUBGRADE,MAX_PAVEMENT,MAX_BRIDGE,MAX_TUNNEL,MAX_TOTAL,"
- + "SUBGRADE_TOTAL,PAVEMENT_TOTAL,BRIDGE_TOTAL,TUNNEL_TOTAL,TOTAL"
- ,"DESIGN_KM,CARE_KM,"
- + "MIN_SUBGRADE,MIN_PAVEMENT,MIN_BRIDGE,MIN_TUNNEL,MIN_TRAFFIC_SAFE,MIN_ROADSIDE,MIN_GREEN,MIN_OTHER,MIN_TOTAL,"
- + "MID_SUBGRADE,MID_PAVEMENT,MID_BRIDGE,MID_TUNNEL,MID_TRAFFIC_SAFE,MID_ROADSIDE,MID_GREEN,MID_OTHER,MID_TOTAL,"
- + "MAX_SUBGRADE,MAX_PAVEMENT,MAX_BRIDGE,MAX_TUNNEL,MAX_TRAFFIC_SAFE,MAX_ROADSIDE,MAX_GREEN,MAX_OTHER,MAX_TOTAL,"
- + "SUBGRADE_TOTAL,PAVEMENT_TOTAL,BRIDGE_TOTAL,TUNNEL_TOTAL,TRAFFIC_SAFE_TOTAL,ROADSIDE_TOTAL,GREEN_TOTAL,OTHER_TOTAL,HJ_TOTAL"
- ,"DESIGN_KM,CARE_KM,"
- + "SUBGRADE,PAVEMENT,BRIDGE,TUNNEL,TRAFFIC_SAFE,ROADSIDE,GREEN,OTHER,TOTAL"
- ,"DESIGN_KM,CARE_KM,"
- + "SUBGRADE,PAVEMENT,BRIDGE,TUNNEL,TRAFFIC_SAFE,ROADSIDE,OTHER,TOTAL"
- ,"DESIGN_KM,CARE_KM,"
- + "SUBGRADE,PAVEMENT,BRIDGE,OTHER,TOTAL"
- };
- String[] tableNames = {"annual_comp_sumtable_view","annual_daily_comp_sumtable_view","annual_prevention_comp_sumtable_view",
- "annual_repair_comp_sumtable_view","annual_special_comp_sumtable_view",
- "annual_test_comp_sumtable_view","annual_scientific_comp_sumtable_view"};
- int[] startRowIndexs = {3,2,3,4,2,2,2};
- int[] tabletype = {6,6,6,6,6,6,6};
- int[] totalRange = {2,2,2,2,2,2,2};
- String[][][] funcArrys = {
- {
- {"percent","DAILY_COMPLETE_KM","ROUND(IF(ISERROR((F#row#/E#row#)),\"0\",(F#row#/E#row#)),1)"},
- {"percent","ZFY_COMPLETE","ROUND(IF(ISERROR((V#row#/E#row#)),\"0\",(V#row#/E#row#)),1)"},
- },
- {
- {"percent","ZFY_COMPLETE","ROUND(IF(ISERROR((R#row#/E#row#)),\"0\",(R#row#/E#row#)),1)"}
- },{},{},{},{},{}};
- PageData pd = new PageData();
- for (int i = 0; i < tableNames.length; i++) {
- PageData data = new PageData();
- pd.put("type", tableNames[i]);
- pd.put("YEAR", param.get("YEAR"));
- pd.put("table", "oa_department_"+param.get("YEAR").toString());
- List<PageData> list = annualPlanCompService.gethzdata(pd);
- //养护计划汇总,总费用、总费用/公里计算
- if(i==0){
- list = TotalAmountUtil.yhjhTotalAmount(list);
- }
- //日常养护汇总
- if(i==1){
- list = TotalAmountUtil.rcyhTotalAmount(list);
- }
- data.put("list", list);
- data.put("modelName", modelNames[i]);
- data.put("keyStr", keyStrs[i]);
- data.put("startRowIndex", startRowIndexs[i]);
- data.put("tabletype", tabletype[i]);
- data.put("funcArry", funcArrys[i]);
- data.put("totalRange", totalRange[i]);
- data.put("pd", pd);
- result.add(data);
- }
- return result;
- }
-
- @RequestMapping("/exportmx")
- public String exportmx(HttpServletRequest request,HttpServletResponse response) throws Exception{
- String path = request.getSession().getServletContext().getRealPath("/uploadFiles/file");
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- List<String> paths = new ArrayList<String>();
- List<String> result = new ArrayList<String>();
- //excel文档
- List<PageData> exceldata = setMxExcelData(pd);
- MultExcelUtils ex = new MultExcelUtils();
- String excelpath = ex.exportExcel(pd.getString("exportname")+".xlsx",path,response,exceldata);
- result.add(excelpath);
- //zip压缩下载
- DownloadZip.downloadZip(response,request,result,path);
- return null;
- }
-
- public List<PageData> setMxExcelData(PageData param) throws Exception {
- List<PageData> result = new ArrayList<PageData>();
- String[] modelNames = {"预防养护计划统计表","修复养护计划统计表","专项养护计划统计表","应急养护计划统计表"
- ,"试验检测项目计划统计表","科研项目计划统计表","设备大修项目计划统计表"};
- String[] keyStrs = {
- "PROJECT_NAME,PROJECT_TYPE,SCALE,PLAN_QUANTITIES,PLAN_COST,REMARKS"
- ,"PROJECT_NAME,PROJECT_TYPE,SCALE,PLAN_QUANTITIES,PLAN_COST,REMARKS"
- ,"SPECIAL_PROJECT_NAME,MAIN_WORK_CONTENTS,PLAN_COST,REMARKS"
- ,"PROJECT_NAME,PROJECT_TYPE,SCALE,PLAN_QUANTITIES,PLAN_COST,REMARKS"
- ,"PROJECT_NAME,PROJECT_TYPE,CONTENT,PLAN_COST,REMARKS"
- ,"PROJECT_NAME,PROJECT_TYPE,CONTENT,PLAN_COST,MATTER_YEAR,MATTER_NEW_CARRY,MATTER_CONSULT"
- ,"PROJECT_NAME,PROJECT_TYPE,COMPLETE_DESCRIBE,PLAN_COST,REMARKS"
- };
- String[] tableNames = {"highway_prevention_plan_sumtable_view2","highway_repair_comp_sumtable_view2","highway_special_comp_sumtable_view2"
- ,"highway_emergency_comp_sumtable_view2","highway_test_comp_sumtable_view2"
- ,"highway_scientific_comp_sumtable_view2","highway_equipment_overhaul_comp_sumtable_view2"
- };
- int[] startRowIndexs = {3,3,3,3,3,3,3};
- int[] tabletype = {6,6,6,6,6,6,6};
- int[] totalRange = {6,6,4,5,5,5,5};
- String[][][] funcArrys = {
- {
- {"null","REMARKS","\"\""}
- },{
- {"null","REMARKS","\"\""}
- },{
- {"null","REMARKS","\"\""}
- },{
- {"null","REMARKS","\"\""}
- },{
- {"null","REMARKS","\"\""}
- },{
- {"null","REMARKS","\"\""}
- },{
- {"null","REMARKS","\"\""}
- }
- };
- PageData pd = new PageData();
- for (int i = 0; i < tableNames.length; i++) {
-
- PageData data = new PageData();
- pd.put("type", tableNames[i]);
- pd.put("YEAR", param.get("YEAR"));
- pd.put("table", "oa_department_"+param.get("YEAR"));
- List<PageData> list = annualPlanCompService.getProjectData(pd);
- data.put("list", list);
- data.put("modelName", modelNames[i]);
- data.put("keyStr", keyStrs[i]);
- data.put("startRowIndex", startRowIndexs[i]);
- data.put("tabletype", tabletype[i]);
- data.put("funcArry", funcArrys[i]);
- data.put("totalRange", totalRange[i]);
- data.put("totalCost", "");
- if (tabletype[i]==7) {
- String totalCost = annualPlanCompService.getFeesTotalCost(Integer.parseInt(param.getString("YEAR"))-1+"");
- data.put("totalCost", totalCost);
- }
- data.put("pd", pd);
- result.add(data);
- }
- return result;
- }
-
- /**查询所选汇总表
- * @param
- * @throws Exception
- */
- @RequestMapping(value="/showSumTable")
- public ModelAndView showSumTable(Model model)throws Exception{
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- mv.setViewName("information/annualPlan/annualSumTablePlan/"+pd.get("type"));
- //设置查询oa_department的动态表名
- String oa_department_table = "oa_department_"+pd.get("YEAR");
- pd.put("table", oa_department_table);
- List<PageData> varList = annualPlanCompService.getdata(pd);
- //处理前段显示值
- //1.养护计划汇总 控制格式化
- varList = formatEmptyString(varList);
- if( null != pd.get("type") && !pd.get("type").toString().isEmpty()&& null != varList && varList.size()>0 ){
- //养护计划汇总-合计总费用
- if(pd.get("type").toString().equals("annual_comp_sumtable_view")){
- varList = formatAnnualCompSumtable(varList);
- }
- }
- mv.addObject("varList", varList);
- mv.addObject("pd", pd);
- mv.addObject("QX",Jurisdiction.getHC()); //按钮权限
- return mv;
- }
-
- /**查询日常汇总表
- * @param
- * @throws Exception
- */
- @RequestMapping(value="/showDailySumTable")
- public ModelAndView showDailySumTable(Model model)throws Exception{
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- pd.put("table", "oa_department_"+pd.getString("YEAR"));
- mv.setViewName("information/annualPlan/annualSumTablePlan/highway_daily_plan_statable");
- List<PageData> varList = annualPlanCompService.getDailydata(pd);
- mv.addObject("varList", varList);
- mv.addObject("pd", pd);
- mv.addObject("QX",Jurisdiction.getHC()); //按钮权限
- return mv;
- }
- /**查询所选明细表
- * @param
- * @throws Exception
- */
- @RequestMapping(value="/showDettTable")
- public ModelAndView showDettTable(Model model)throws Exception{
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- pd.put("table", "oa_department_"+pd.get("YEAR").toString());
- mv.setViewName("information/annualPlan/annualSumTablePlan/"+pd.get("type"));
- List<PageData> dettList = annualPlanCompService.getDettData(pd);
- if(dettList ==null || dettList.equals(" ") || dettList.isEmpty() ) {
- mv.addObject("dettList", "");
- }else {
- LinkedHashMap<String, LinkedHashMap<String, ArrayList<PageData>>> varMap = new LinkedHashMap<String, LinkedHashMap<String, ArrayList<PageData>>>();
- Double sumPlanCost = (double) 0;
- Double sumActualCost = (double) 0;
- Double sumAuditFee = (double) 0;
- String prevCompanyName = "";
- String prevCompanyID = "";
- LinkedHashMap<String, ArrayList<PageData>> xjroadMap = new LinkedHashMap<String, ArrayList<PageData>>();
- for(PageData tpd : dettList){
- String company = tpd.get("COMPANY").toString();
- String companyid = tpd.get("COMPANY_ID").toString();
- String road = tpd.get("ROAD").toString();
- if(varMap.containsKey(company)){
- LinkedHashMap<String, ArrayList<PageData>> roadMap = varMap.get(company);
- if(roadMap != null && roadMap.containsKey(road)){
- if(tpd.get("PLAN_COST")!=null){
- double plan = Double.parseDouble(tpd.get("PLAN_COST").toString());
- plan = formatNum(plan);
- sumPlanCost += plan;
- }
- if(tpd.get("ACTUAL_COST")!=null){
- double actual = Double.parseDouble(tpd.get("ACTUAL_COST").toString());
- actual = formatNum(actual);
- sumActualCost += actual;
- }
- if(tpd.get("AUDIT_FEE")!=null){
- double fee = Double.parseDouble(tpd.get("AUDIT_FEE").toString());
- fee = formatNum(fee);
- sumAuditFee += fee;
- }
- ArrayList<PageData> pList = roadMap.get(road);
- pList.add(tpd);
- }else{
- if(tpd.get("PLAN_COST")!=null){
- double planc = Double.parseDouble(tpd.get("PLAN_COST").toString());
- planc = formatNum(planc);
- sumPlanCost += planc;
- }
- if(tpd.get("ACTUAL_COST")!=null){
- double actualc = Double.parseDouble(tpd.get("ACTUAL_COST").toString());
- actualc = formatNum(actualc);
- sumActualCost += actualc;
- }
- if(tpd.get("AUDIT_FEE")!=null){
- double feec = Double.parseDouble(tpd.get("AUDIT_FEE").toString());
- feec = formatNum(feec);
- sumAuditFee += feec;
- }
- ArrayList<PageData> npList = new ArrayList<PageData>();
- npList.add(tpd);
- roadMap.put(road, npList);
- }
- xjroadMap = roadMap;
- prevCompanyName = company;
- prevCompanyID = companyid;
- }else{
- if(varMap.size() > 0){
- ArrayList<PageData> xjList = new ArrayList<PageData>();
- PageData xjPd = new PageData();
- xjPd.put("COMPANY", prevCompanyName);
- xjPd.put("COMPANY_ID", prevCompanyID);
- xjPd.put("ROAD", "小计");
- xjPd.put("PROJECT_NAME", "");
- xjPd.put("PROJECT_TYPE", "");
- xjPd.put("SCALE", "");
- xjPd.put("PLAN_QUANTITIES", "");
- xjPd.put("PLAN_COST", sumPlanCost);
- xjPd.put("ACTUAL_QUANTITIES", "");
- xjPd.put("PLAN_COST", sumPlanCost);
- xjPd.put("REMARKS", "");
- xjPd.put("AUDIT_FEE", sumAuditFee);
- xjList.add(xjPd);
- xjroadMap = varMap.get(prevCompanyName);
- xjroadMap.put("小计", xjList);
- varMap.put(prevCompanyName, xjroadMap);
- }
- ArrayList<PageData> mpList = new ArrayList<PageData>();
- LinkedHashMap<String, ArrayList<PageData>> mroadMap = new LinkedHashMap<String, ArrayList<PageData>>();
- mpList.add(tpd);
- mroadMap.put(road, mpList);
- varMap.put(company, mroadMap);
- prevCompanyName = company;
- prevCompanyID = companyid;
- sumPlanCost = (double) 0;
- sumActualCost = (double) 0;
- if(tpd.get("PLAN_COST")!=null){
- double planco = Double.parseDouble(tpd.get("PLAN_COST").toString());
- planco = formatNum(planco);
- sumPlanCost += planco;
- }
- if(tpd.get("ACTUAL_COST")!=null){
- double actualco = Double.parseDouble(tpd.get("ACTUAL_COST").toString());
- actualco = formatNum(actualco);
- sumActualCost += actualco;
- }
- if(tpd.get("AUDIT_FEE")!=null){
- double feeco = Double.parseDouble(tpd.get("AUDIT_FEE").toString());
- feeco = formatNum(feeco);
- sumAuditFee += feeco;
- }
- }
- }
-
- PageData lastxjPd = new PageData();
- lastxjPd.put("COMPANY", prevCompanyName);
- lastxjPd.put("COMPANY_ID", prevCompanyID);
- lastxjPd.put("ROAD", "小计");
- lastxjPd.put("PROJECT_NAME", "");
- lastxjPd.put("PROJECT_TYPE", "");
- lastxjPd.put("SCALE", "");
- lastxjPd.put("PLAN_QUANTITIES", "");
- lastxjPd.put("PLAN_COST", sumPlanCost);
- lastxjPd.put("ACTUAL_QUANTITIES", "");
- lastxjPd.put("AUDIT_FEE", sumAuditFee);
- lastxjPd.put("REMARKS", "");
- lastxjPd.put("ACTUAL_COST", sumActualCost);
-
- List<PageData> dettListNew = new ArrayList<PageData>();
- for(Entry<String, LinkedHashMap<String, java.util.ArrayList<PageData>>> centry : varMap.entrySet()){
- HashMap<String, java.util.ArrayList<PageData>> roadMap = centry.getValue();
- for(Entry<String, java.util.ArrayList<PageData>> rentry : roadMap.entrySet()){
- ArrayList<PageData> projectList = rentry.getValue();
- for(PageData ppd : projectList){
- dettListNew.add(ppd);
- }
- }
- }
- dettListNew.add(lastxjPd);
-
- mv.addObject("dettList", dettListNew);
- }
-
- mv.addObject("pd", pd);
- mv.addObject("QX",Jurisdiction.getHC()); //按钮权限
- return mv;
- }
-
- /**查询所选汇总表
- * @param
- * @throws Exception
- */
- @RequestMapping(value="/showPlanList")
- public ModelAndView showPlanList()throws Exception{
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- pd.put("table", "oa_department_"+pd.getString("YEAR"));
- String sptime = annualPlanCompService.getSPTime(pd);
- List<PageData> nPlanList = annualPlanCompService.getnPlanList(pd);
- List<PageData> planList = annualPlanCompService.getPlanList(pd);
- mv.addObject("nPlanList", nPlanList);
- mv.addObject("planList", planList);
- mv.addObject("sptime", sptime);
- mv.addObject("pd", pd);
- mv.setViewName("information/annualPlan/annualPlan_showPlanList");
- return mv;
- }
-
- /**查询所有公司和路段
- * @param
- * @throws Exception
- */
- @RequestMapping(value="/showCompanyRoadList")
- public ModelAndView showCompanyRoadList()throws Exception{
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- //动态oa_department表
- pd.put("table", "oa_department_"+pd.getString("YEAR").toString());
- List<PageData> companyRoadList = annualPlanCompService.getCompanyRoadList(pd);
- Map<String,List<String>> companyRoad = new HashMap<String,List<String>>();
- List<String> companyList = new ArrayList<String>();
- for(PageData tpd : companyRoadList){
- if(tpd.get("PARENT_ID").equals("0")){
- companyList.add(tpd.get("NAME").toString());
- List<String> roadList = new ArrayList<String>();
- for(PageData tempPd : companyRoadList){
- if(tempPd.get("PARENT_ID").equals(tpd.get("DEPARTMENT_ID"))){
- roadList.add(tempPd.get("NAME").toString());
- }
- }
- companyRoad.put(tpd.get("NAME").toString(), roadList);
- }
- }
- mv.addObject("companyList", companyList);
- mv.addObject("companyRoad", JSONArray.fromObject(companyRoad));
- mv.addObject("pd", pd);
- mv.setViewName("information/annualPlan/annualPlanComp/annualPlan_showCompanyRoadList");
- return mv;
- }
-
- /**显示、编辑子表格
- * @param
- * @throws Exception
- */
- @RequestMapping(value="/showTableRecod")
- public ModelAndView showTableRecod()throws Exception{
- ModelAndView mv = this.getModelAndView();
- PageData pd = new PageData();
- pd = this.getPageData();
- List<PageData> varList = new ArrayList<PageData>();
- JSONArray arr = JSONArray.fromObject(varList);
- mv.addObject("varList", arr);
- String year = pd.get("YEAR").toString();
- pd.put("table", "oa_department_"+year);
- pd = annualBaseInfoService.findRoadId(pd);
- pd.put("YEAR", year);
- //mv.setViewName("information/annualPlan/annualTableRecord/highway_daily_comp_dettable");
- mv.setViewName("information/annualPlan/annualTableRecord/highway_daily_comp_dettable_dy");
- mv.addObject("pd", pd);
- mv.addObject("QX",Jurisdiction.getHC()); //按钮权限
- return mv;
- }
-
- /**修改计划和下面立项表的状态
- * @param
- * @throws Exception
- */
- @RequestMapping(value="/changePlanStatus")
- @ResponseBody
- public Object changePlanStatus()throws Exception{
- Map<String,String> map = new HashMap<String,String>();
- PageData pd = new PageData();
- pd = this.getPageData();
- if(pd.get("TYPE") != null){
- if("1".equalsIgnoreCase(pd.get("TYPE").toString())){
- pd.put("STATUS", "审批通过");
- }else{
- pd.put("STATUS", "控股驳回");
- }
- }
- try{
- annualPlanCompService.changeCompPlanStatus(pd); //同步修改COMP表状态
- for(String tableName : tabls){
- pd.put("TABLE_NAME", tableName);
- if("annual_table_list".equalsIgnoreCase(tableName) && "控股驳回".equalsIgnoreCase(pd.get("STATUS").toString())){
- pd.put("STATUS", "审批不通过");
- }
- annualPlanCompService.changePlanStatus(pd); //修改状态
- }
- map.put("result", "success");
- //TODO 调用接口发送数据
- String sendStr="";
- pd.put("table", "oa_department_"+pd.get("YEAR"));
- List<PageData> passPlanList = annualPlanService.getPassPlan(pd);
- if(null != passPlanList && passPlanList.size()>0){
- JSONArray jsonArray=JSONArray.fromObject(passPlanList);
- sendStr = jsonArray.toString();
- System.out.println(sendStr);
- DailyUrlUtil dailyUrlUtil = new DailyUrlUtil();
- String approvalurl = dailyUrlUtil.getApprovalUrl();
- String result = HttpCallInterfaceUtil.sendPost(approvalurl, sendStr, false);
- if(null != result && !result.isEmpty()){
- JSONObject jsonObj = JSONObject.fromObject(result);
- /** 请求结果保存进 数据库日志*/
- saveLog(sendStr,jsonObj.get("msg").toString(),jsonObj.get("data").toString());
- }
- else{
- saveLog(sendStr,"","");
- }
- }
- }catch(Exception e){
- map.put("result", "操作失败");
- }
- return AppUtil.returnObject(new PageData(), map);
- }
-
- /**更新立项表中的审批费用和备注
- * @param
- * @throws Exception
- */
- @RequestMapping(value="/saveData")
- @ResponseBody
- public Object saveData()throws Exception{
- Map<String,String> map = new HashMap<String,String>();
- PageData pd = new PageData();
- pd = this.getPageData();
- JSONArray jsonarray = JSONArray.fromObject(pd.get("data"));
- String tableName = pd.get("TABLETYPE").toString();
- String year = pd.get("YEAR").toString();
- List<PageData> pdList = dealData(jsonarray, year,tableName);
- try{
- for(PageData tpd : pdList){
- annualPlanCompService.updateAuditFee(tpd);
- }
- map.put("msg", "success");
- }catch(Exception e){
- System.out.println(e);
- map.put("msg", "操作失败");
- }
- return AppUtil.returnObject(new PageData(), map);
- }
-
- /**
- * 处理审批费用
- */
- @ResponseBody
- public List<PageData> dealData(JSONArray jsonarray, String year, String tableName) throws Exception {
- List<PageData> pdList = new ArrayList<PageData>();
- if (jsonarray.size() > 0) {
- for (int i = 0; i < jsonarray.size(); i++) {
- PageData pd = new PageData();
- JSONObject job = jsonarray.getJSONObject(i);
- // if(!"".equalsIgnoreCase(job.get("AUDIT_FEE").toString().trim())){
- pd.put("YEAR", year);
- pd.put("TABLE_NAME", tableName);
- pd.put("COMPANY_ID", job.get("COMPANY_ID"));
- pd.put("ROAD_ID", job.get("ROAD_ID"));
- pd.put("PROJECT_NAME", job.get("PROJECT_NAME"));
- pd.put("AUDIT_FEE", job.get("AUDIT_FEE"));
- pd.put("AUDIT_MAKER", job.get("AUDIT_MAKER"));
- pdList.add(pd);
- // }
- }
- }
- return pdList;
- }
-
- /**更新日常养护计划中的审核费用
- * @param
- * @throws Exception
- */
- @RequestMapping(value="/saveDailyData")
- @ResponseBody
- public Object saveDailyData(String data)throws Exception{
- Map<String,String> map = new HashMap<String,String>();
- PageData pd = new PageData();
- pd = this.getPageData();
- JSONArray jsonarray = JSONArray.fromObject(pd.get("data"));
- String tableName = pd.get("TABLETYPE").toString();
- String year = pd.get("YEAR").toString();
- List<PageData> pdList = dealDailyData(jsonarray, year,tableName);
- try{
- for(PageData tpd : pdList){
- annualPlanCompService.editTableRecod(tpd);
- }
- map.put("msg", "success");
- }catch(Exception e){
- System.out.println(e);
- map.put("msg", "操作失败");
- }
- return AppUtil.returnObject(new PageData(), map);
- }
-
- /**
- * 处理日常养护审批费用
- */
- @ResponseBody
- public List<PageData> dealDailyData(JSONArray jsonarray, String year, String tableName) throws Exception {
- List<PageData> pdList = new ArrayList<PageData>();
- for (Object object : jsonarray) {
- PageData tpd = new PageData();
- JSONObject arrMap = JSONObject.fromObject(object);
- Set entryarray = arrMap.entrySet();
- ArrayList<Object> keyarray = new ArrayList<Object>();
- ArrayList<Object> valuearray = new ArrayList<Object>();
- for (Object entry : entryarray) {
- Object[] arr = entry.toString().split("=");
- boolean saveFlag = true;
- if (entry != null){
- saveFlag = !"ROAD".equals(arr[0]) && !"YEAR".equals(arr[0]) && !"COMPANY".equals(arr[0])
- &&!"ROAD_ID".equals(arr[0]) && !"COMPANY_ID".equals(arr[0]);
- if (saveFlag) {
- if (arr.length > 1) {
- keyarray.add(arr[0]);
- valuearray.add(arr[1]);
- }
- }
- }
- }
- if(!keyarray.isEmpty()){
- tpd.put("KEYS", StringUtils.join(keyarray.toArray(), ","));
- tpd.put("KEYARRAY", keyarray);
- tpd.put("VALUEARRAY", valuearray);
- tpd.put("ROAD_ID", arrMap.get("ROAD_ID"));
- tpd.put("COMPANY_ID", arrMap.get("COMPANY_ID"));
- tpd.put("YEAR", arrMap.get("YEAR"));
- pdList.add(tpd);
- }
- }
- return pdList;
- }
-
- /**设置提交时间阈值
- * @param
- * @throws Exception
- */
- @RequestMapping(value="/saveTime")
- @ResponseBody
- public Object saveTime()throws Exception{
- Map<String,String> map = new HashMap<String,String>();
- PageData pd = new PageData();
- pd = this.getPageData();
- try{
- String timepd = annualPlanCompService.getSPTime(pd);
- if(timepd != null){
- annualPlanCompService.updateSPTime(pd);
- }else{
- annualPlanCompService.insertSPTime(pd);
- }
- map.put("result", "success");
- }catch(Exception e){
- map.put("result", "操作失败");
- }
- return AppUtil.returnObject(new PageData(), map);
- }
-
- /**更新养护计划汇总的审批费用
- * @param
- * @throws Exception
- */
- @RequestMapping(value="/saveAuditFee")
- @ResponseBody
- public Object saveAuditFee(String inputData)throws Exception{
- System.out.print("inputData::"+inputData);
- PageData pd = new PageData();
- pd = this.getPageData();
- JSONArray jsonarray = JSONArray.fromObject(inputData);
- List<PageData> data = dealData(jsonarray);
- //判断执行update 还是 insert
- annualPlanCompService.saveOrUpdatBatchAuditFee(data);
- Map<String,String> map = new HashMap<String,String>();
- map.put("result", "success");
- return AppUtil.returnObject(new PageData(), map);
- }
-
- public List<PageData> dealData(JSONArray jsonarray) throws Exception {
- List<PageData> pdList = new ArrayList<PageData>();
- if (jsonarray.size() > 0) {
- for (int i = 0; i < jsonarray.size(); i++) {
- PageData pd = new PageData();
- JSONObject job = jsonarray.getJSONObject(i);
- pd.put("AUDIT_FEE", job.get("AUDIT_FEE"));
- pd.put("COMPANY_ID", job.get("COMPANY_ID"));
- pd.put("COMPANY", job.get("COMPANY"));
- pd.put("ROAD", job.get("ROAD"));
- pd.put("ROAD_ID", job.get("ROAD_ID"));
- pd.put("YEAR", job.get("YEAR"));
- pdList.add(pd);
- }
- }
- return pdList;
- }
-
- /**
- * 格式化decimal类型空值
- * @param type
- * @param varList
- * @return
- */
- public List<PageData> formatEmptyString(List<PageData> varList){
- if(null != varList && varList.size()>0){
- BigDecimal bigDecimal = new BigDecimal("0");
- for(PageData o:varList){
- if(null != o ){
- if(null != o.get("RESERVE_DESIGN")){
- BigDecimal oBigDecimal = (BigDecimal)o.get("RESERVE_DESIGN");
- if(oBigDecimal.compareTo(bigDecimal) ==0){
- o.put("RESERVE_DESIGN", "");
- }
- else{
- BigDecimal ten = new BigDecimal("10.00");
- if(oBigDecimal.compareTo(ten)<1){
- oBigDecimal = oBigDecimal.setScale(1, BigDecimal.ROUND_HALF_UP);
- }
- else{
- oBigDecimal = oBigDecimal.setScale(0, BigDecimal.ROUND_HALF_UP);
- }
- o.put("RESERVE_DESIGN", oBigDecimal);
- }
- }
- }
- }
- }
- return varList;
- }
-
- /**
- * 养护计划汇总-合计总费用
- * @param varList
- * @return
- */
- public List<PageData> formatAnnualCompSumtable(List<PageData> varList){
- for(PageData data:varList){
- BigDecimal zfy = new BigDecimal("0");
- BigDecimal daily_decimal = new BigDecimal("0");
- BigDecimal prevention_decimal = new BigDecimal("0");
- BigDecimal repair_decimal = new BigDecimal("0");
- BigDecimal special_decimal = new BigDecimal("0");
- BigDecimal test_decimal = new BigDecimal("0");
- BigDecimal scientific_decimal = new BigDecimal("0");
- BigDecimal device_decimal = new BigDecimal("0");
- BigDecimal reserve_decimal = new BigDecimal("0");
- BigDecimal audit_fee_decimal = new BigDecimal("0");
- //日常养护-费用
- if(null != data.get("DAILY_DESIGN")){
- daily_decimal = TotalAmountUtil.getBigDecimal(data.get("DAILY_DESIGN"));
- }
- //预防养护-费用
- if(null != data.get("PREVENTION_DESIGN")){
- prevention_decimal = TotalAmountUtil.getBigDecimal(data.get("PREVENTION_DESIGN"));
- }
- //修复养护-费用
- if(null != data.get("REPAIR_DESIGN")){
- repair_decimal = TotalAmountUtil.getBigDecimal(data.get("REPAIR_DESIGN"));
- }
- //专项养护-费用
- if(null != data.get("SPECIAL_DESIGN")){
- special_decimal = TotalAmountUtil.getBigDecimal(data.get("SPECIAL_DESIGN"));
- }
- //试验检测-费用
- if(null != data.get("TEST_DESIGN")){
- test_decimal = TotalAmountUtil.getBigDecimal(data.get("TEST_DESIGN"));
- }
- //科研项目-费用
- if(null != data.get("SCIENTIFIC_DESIGN")){
- scientific_decimal = TotalAmountUtil.getBigDecimal(data.get("SCIENTIFIC_DESIGN"));
- }
- //设备大修-费用
- if(null != data.get("DEVICE_DESIGN")){
- device_decimal = TotalAmountUtil.getBigDecimal(data.get("DEVICE_DESIGN"));
- }
- //预备费-计划费用
- if(null != data.get("RESERVE_TOTAL_COST")){
- reserve_decimal = TotalAmountUtil.getBigDecimal(data.get("RESERVE_TOTAL_COST"));
- }
- //预备费-审核费用
- if(null != data.get("RESERVE_AUDIT_FEE")){
- audit_fee_decimal = TotalAmountUtil.getBigDecimal(data.get("RESERVE_AUDIT_FEE"));
- BigDecimal ten = new BigDecimal("10.00");
- if(audit_fee_decimal.compareTo(ten)<1){
- audit_fee_decimal = audit_fee_decimal.setScale(1, BigDecimal.ROUND_HALF_UP);
- }
- else{
- audit_fee_decimal = audit_fee_decimal.setScale(0, BigDecimal.ROUND_HALF_UP);
- }
- }
- if(audit_fee_decimal.compareTo(BigDecimal.ZERO)!=0){
- 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)))))));
- }
- else{
- zfy = reserve_decimal.add(device_decimal.add(scientific_decimal.add(test_decimal.add(special_decimal.add(repair_decimal.add(prevention_decimal.add(daily_decimal)))))));
- }
- data.put("TOTAL_ZFY", zfy);
- }
- return varList;
- }
- /**
- * 格式化金额
- * @param cost_num
- * @return
- */
- public double formatNum(double cost_num){
- String planstr = "";
- if(cost_num < 10){
- planstr = String.format("%.1f", cost_num);
- }
- else{
- planstr = String.format("%.0f", cost_num);
- }
- cost_num = Double.parseDouble(planstr);
- return cost_num;
- }
-
- /**
- * 调用情况保存进数据库
- * @param orgId
- * @param yearMonth
- * @param responseCode
- * @param responseResult
- */
- public void saveLog(String paramStr,String responseCode,String responseResult){
- try {
- PageData pd = new PageData();
- pd.put("ID", UuidUtil.get32UUID());
- pd.put("INTERFACE_NAME", "getPassPlan");
- pd.put("PARAM", paramStr);
- pd.put("RESPONSE_CODE", responseCode);
- pd.put("RESPONSE_TEXT",responseResult);
- pd.put("CREATE_TIME", new Date());
- dailyTaskService.save(pd);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
|