cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
package cn.ksource.web.controller.wechat.uwyw;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
 
import cn.ksource.core.util.ConvertUtil;
import cn.ksource.core.util.DateUtil;
import cn.ksource.core.util.JsonUtil;
import cn.ksource.core.util.ParamsMapUtil;
import cn.ksource.core.web.WebUtil;
import cn.ksource.web.facade.rcxj.RcxjFacade;
import cn.ksource.web.facade.wechat.ewyw.EwWorkplanFacade;
 
@Controller
@RequestMapping("/uwyw/uworkplan")
public class UworkplanController {
 
    @Resource
    private EwWorkplanFacade workplanFacade;
    @Resource
    private RcxjFacade rcxjFacade;
    
    @RequestMapping("uWorkplan.html")
    public ModelAndView uWorkplan(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/uwyw/uworkplan/uWorkplan");
        return modelAndView;
    }
    
    
    /**
     * 跳转到所有日常巡检日历页面
     * @param request
     * @param response
     */
    @RequestMapping("uDailyCheck.html")
    public ModelAndView uDailyCheck(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/uwyw/uworkplan/udailyCheck/uDailyCheck");
        //查询当前年前五年和后五年
        int year = DateUtil.getYear();
        List years = new ArrayList();
        for(int i=5; i>=0; i--) {
            int preYear = year-i;
            years.add(preYear);
        }
        
        for(int i=1; i<5; i++) {
            int nextYear = year+i;
            years.add(nextYear);
        }
        
        modelAndView.addObject("years", years);
        
        modelAndView.addObject("year", DateUtil.getToday("yyyy"));
        modelAndView.addObject("month", DateUtil.getToday("MM"));
        
        List months = new ArrayList();
        for(int i=1; i<=12; i++) {
            if(i<10) {
                months.add("0"+i);
            } else {
                months.add(i);
            }
        }
        
        modelAndView.addObject("months", months);
        return modelAndView;
    }
    
    
    /**
     * 查询所有日常巡检报告日历
     */
    @RequestMapping("uDailyCal.html")
    public ModelAndView uDailyCal(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/uwyw/uworkplan/udailyCheck/uDailyCal");
        Map<String,String> params = ParamsMapUtil.getParameterMap(request);
        String year = request.getParameter("year");
        String month = request.getParameter("month");
        String cusId = WebUtil.getUserWywCusId(request);
        params.put("cusId",cusId);
        Map result = workplanFacade.queryDailyCalandar(params);
        List list = (List)result.get("monthDays");
        List weekDays = (List)result.get("weekDays");
        modelAndView.addObject("calandars", list);
        modelAndView.addObject("weeks", weekDays);
        Long[] dates = DateUtil.getDateFromMonth(ConvertUtil.obj2Int(year),ConvertUtil.obj2Int(month));
        params.put("beginDate", ConvertUtil.obj2StrBlank(dates[0]));
        params.put("endDate", ConvertUtil.obj2StrBlank(dates[1]));
        List<Map> reports =  workplanFacade.queryReportByDate(params);
        if(null!=reports && reports.size()>0) {
            for(Map report : reports) {
                String patrol_date = ConvertUtil.obj2StrBlank(report.get("PATROL_DATE"));
                String week = DateUtil.getDayOfWeek4Chinese(patrol_date);
                report.put("week", week);
            }
        }
        modelAndView.addObject("reports", reports);
        return modelAndView;
    }
    
    @RequestMapping("getMonth.html")
    public void getMonth(HttpServletRequest request,HttpServletResponse response) {
        
        String yearMonth = request.getParameter("yearMonth");
        String type = request.getParameter("type");
        
        int num = 0;
        if(type.equals("1")) {
            num = -1;
        } else {
            num = 1;
        }
        long time = DateUtil.getDateAdd6FromMonth(ConvertUtil.obj2Long(yearMonth.replaceAll("-", "")),num);
        
        String year = DateUtil.format("yyyy", time);
        String month = DateUtil.format("MM", time);
        Map map = new HashMap();
        map.put("year", year);
        map.put("month", month);
        map.put("yearMonth", year+"-"+month);
        WebUtil.write(response, JsonUtil.map2Json(map));
    }
    
    /**
     * 通过日期查询日期的日常巡检报告的详情
     */
    @RequestMapping("udailyReport.html")
    public ModelAndView udailyReport(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView();
        String beginDate = request.getParameter("date");
        Map<String,String> params = ParamsMapUtil.getParameterMap(request);
        params.put("beginDate", beginDate);
        String cusId = WebUtil.getUserWywCusId(request);
        params.put("cusId",cusId);
        List<Map> reports =  workplanFacade.queryReportByDate(params);
        if(reports.size()==1) {
            Map report = reports.get(0);
            String reportId = ConvertUtil.obj2StrBlank(report.get("ID"));
            modelAndView = new ModelAndView("redirect:/uwyw/uworkplan/ureport.html?orderId="+reportId);
        } else {
            modelAndView = new ModelAndView("/business/wechat/uwyw/uworkplan/udailyCheck/uAllReports");
            modelAndView.addObject("date", beginDate);
        }
        return modelAndView;
    }
    
    
    /**
     * 查询列表数据
     */
    @RequestMapping("uAllReportList.html")
    public ModelAndView uAllReportList(HttpServletRequest request) {
        String beginDate = request.getParameter("date");
        Map<String,String> params = ParamsMapUtil.getParameterMap(request);
        params.put("beginDate", beginDate);
        String cusId = WebUtil.getUserWywCusId(request);
        params.put("cusId",cusId);
        List<Map> reports =  workplanFacade.queryReportByDate(params);
        ModelAndView modelAndView = new ModelAndView("/business/wechat/uwyw/uworkplan/udailyCheck/ureportList");
        modelAndView.addObject("reports", reports);
        return modelAndView;
    }
    
    /**
     * 查看巡检报告
     */
    @RequestMapping("ureport.html")
    public ModelAndView ereport(Model model,HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/wechat/uwyw/uworkplan/udailyCheck/ureport");
        String orderId = request.getParameter("orderId");
        Map info = rcxjFacade.getRcxjById(orderId);
        List<Map> commonList = rcxjFacade.getCommonPatrolItem(info.get("cus_id").toString(), orderId);
        model.addAttribute("info", info);
        model.addAttribute("commonList", commonList);
        Map<String,String> params = new HashMap<String, String>();
        params.put("orderId", orderId);
        params.put("cusId", ConvertUtil.obj2StrBlank(info.get("CUS_ID")));
        params.put("subCusId", ConvertUtil.obj2StrBlank(info.get("SUB_CUS_ID")));
        params.put("errflag", "1");
        List<Map> ciList = rcxjFacade.getCiItemList(params);
        model.addAttribute("ciList", ciList);
        Map shInfo = rcxjFacade.getShInfoById(orderId);
        model.addAttribute("shInfo",shInfo);
        List<Map> linkOrderList = rcxjFacade.getLinkOrderList(orderId);
        model.addAttribute("linkOrderList",linkOrderList);
        return modelAndView;
    }
}