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 newTables = new ArrayList(); 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 paths = new ArrayList(); List result = new ArrayList(); //excel文档 List 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 setMultExcelData(PageData param) throws Exception { List result = new ArrayList(); 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 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 paths = new ArrayList(); List result = new ArrayList(); //excel文档 List 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 setMxExcelData(PageData param) throws Exception { List result = new ArrayList(); 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 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 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 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 dettList = annualPlanCompService.getDettData(pd); if(dettList ==null || dettList.equals(" ") || dettList.isEmpty() ) { mv.addObject("dettList", ""); }else { LinkedHashMap>> varMap = new LinkedHashMap>>(); Double sumPlanCost = (double) 0; Double sumActualCost = (double) 0; Double sumAuditFee = (double) 0; String prevCompanyName = ""; String prevCompanyID = ""; LinkedHashMap> xjroadMap = new LinkedHashMap>(); 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> 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 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 npList = new ArrayList(); npList.add(tpd); roadMap.put(road, npList); } xjroadMap = roadMap; prevCompanyName = company; prevCompanyID = companyid; }else{ if(varMap.size() > 0){ ArrayList xjList = new ArrayList(); 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 mpList = new ArrayList(); LinkedHashMap> mroadMap = new LinkedHashMap>(); 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 dettListNew = new ArrayList(); for(Entry>> centry : varMap.entrySet()){ HashMap> roadMap = centry.getValue(); for(Entry> rentry : roadMap.entrySet()){ ArrayList 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 nPlanList = annualPlanCompService.getnPlanList(pd); List 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 companyRoadList = annualPlanCompService.getCompanyRoadList(pd); Map> companyRoad = new HashMap>(); List companyList = new ArrayList(); for(PageData tpd : companyRoadList){ if(tpd.get("PARENT_ID").equals("0")){ companyList.add(tpd.get("NAME").toString()); List roadList = new ArrayList(); 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 varList = new ArrayList(); 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 map = new HashMap(); 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 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 map = new HashMap(); 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 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 dealData(JSONArray jsonarray, String year, String tableName) throws Exception { List pdList = new ArrayList(); 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 map = new HashMap(); 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 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 dealDailyData(JSONArray jsonarray, String year, String tableName) throws Exception { List pdList = new ArrayList(); for (Object object : jsonarray) { PageData tpd = new PageData(); JSONObject arrMap = JSONObject.fromObject(object); Set entryarray = arrMap.entrySet(); ArrayList keyarray = new ArrayList(); ArrayList valuearray = new ArrayList(); 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 map = new HashMap(); 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 data = dealData(jsonarray); //判断执行update 还是 insert annualPlanCompService.saveOrUpdatBatchAuditFee(data); Map map = new HashMap(); map.put("result", "success"); return AppUtil.returnObject(new PageData(), map); } public List dealData(JSONArray jsonarray) throws Exception { List pdList = new ArrayList(); 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 formatEmptyString(List 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 formatAnnualCompSumtable(List 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(); } } }