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
package cn.ksource.web.controller.uc;
 
import java.util.Calendar;
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.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
 
import cn.ksource.core.page.PageInfo;
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.util.StringUtil;
import cn.ksource.core.web.WebUtil;
import cn.ksource.web.facade.rcxj.RcxjFacade;
/**
 * 用户中心--日常巡检管理控制器
 * @note:
 * @version
 * @author sxj
 * @date July 18, 2016 10:35:44 AM
 */
@Controller
@RequestMapping("/uc/ucdaypatrol")
public class UcDaypatrolController {
    
    @Resource
    private RcxjFacade rcxjFacade;
    
    
    /**
     * 日常巡检列表
     * @param model
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value="ucdayPatrolInfoList.html",method=RequestMethod.GET)
    public String dayPatrolInfoList(Model model,HttpServletRequest request,HttpServletResponse response){
        long month = DateUtil.getCurrentDate6();
        long monthFirstDate = ConvertUtil.obj2Long(month+"01");
        Long defaultDate = DateUtil.getCurrentDate8();
        model.addAttribute("defaultDate", defaultDate);
        model.addAttribute("monthFirstDate", monthFirstDate);
        return "/uc/daypatrol/ucdayPatrolInfoList";
    }
    
    @RequestMapping(value="ucdayPatrolInfoListData.html",method=RequestMethod.POST)
    public String dayPatrolInfoListData(Model model,HttpServletRequest request,PageInfo pageInfo){
        Map<String,String> params = ParamsMapUtil.getParameterMap(request);
        String cusId = WebUtil.getWebLoginUserCusId(request);
        params.put("cusId", cusId);
        pageInfo = rcxjFacade.getRcxjData(pageInfo,params);
        model.addAttribute("pageInfo", pageInfo);
        return "/uc/daypatrol/ucdayPatrolInfoListData";
    }
    
    @RequestMapping(value="ucdayPatrolInfoListCount.html",method=RequestMethod.POST)
    public void dayPatrolInfoListCount(Model model,HttpServletRequest request,HttpServletResponse response){
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        String cusId = WebUtil.getWebLoginUserCusId(request);
        params.put("cusId", cusId);
        WebUtil.write(response, rcxjFacade.getRcxjCount(params).toString());
    }
    
    //首页
    @RequestMapping("ucdailyOperationIndex.html")
    public ModelAndView dailyOperationIndex(Model model,HttpServletRequest request, HttpServletResponse response) {
//        ModelAndView view = new ModelAndView("/uc/daypatrol/ucdailyOperationIndex");
        ModelAndView view = new ModelAndView("/business/pages/rcxj/rcxjIndex");
        
        String patrolDate = request.getParameter("patrolDate");
        String orderId = request.getParameter("orderId");
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        int currentYear = Integer.valueOf(patrolDate.substring(0,4));
        int currentMonth = Integer.valueOf(patrolDate.substring(4,6));
        int currentDay = Integer.valueOf(patrolDate.substring(6,8));
        params.put("cusId", WebUtil.getWebLoginUserCusId(request));
        String warnString = rcxjFacade.getMonthWarnDate(params);
        if(StringUtil.isBlank(warnString)){
            warnString = "";
        }
        String hasReportDate = rcxjFacade.getHasReportDate(params);
        if(StringUtil.isBlank(hasReportDate)){
            hasReportDate = "";
        }
        
        Calendar cal = Calendar.getInstance();
        Map calendar = getCalendar(currentYear,currentMonth);
        calendar.put("warnString", warnString);
        calendar.put("hasReportDate", hasReportDate);
        
        model.addAttribute("currentYear",String.valueOf(currentYear))
            .addAttribute("currentMonth",String.valueOf(currentMonth))
            .addAttribute("currentDay",String.valueOf(currentDay))
            .addAttribute("orderId",orderId)
            .addAttribute("patrolDate",patrolDate)
            .addAttribute("calendar",calendar);
        return view;
    }
    
    //获取日历数据
    public Map getCalendar(int year,int month){
        
        Map map = new HashMap();
        Calendar cal = Calendar.getInstance();
        cal.clear();
        cal.set(Calendar.YEAR,year);
        cal.set(Calendar.MONTH,month-1);//Java月份才0开始算
        cal.set(Calendar.DAY_OF_MONTH,1);
        //获取当月天数
        int monthDays = cal.getActualMaximum(Calendar.DATE);
        //获取当前月第一天是星期几
        int firstWeekDay = cal.get(Calendar.DAY_OF_WEEK) -1;
        map.put("monthDays", monthDays);
        map.put("firstWeekDay", firstWeekDay);
        return map;
    }
    
    
    //获取日历
    @RequestMapping("ucgetCalendarData.html")
    public void getCalendarData(HttpServletRequest request, HttpServletResponse response){
        Map<String, String> params = ParamsMapUtil.getParameterMap(request);
        int year = Integer.parseInt(request.getParameter("year"));
        int month = Integer.parseInt(request.getParameter("month"));
        Map calendar = getCalendar(year,month);
        params.put("cusId", WebUtil.getWebLoginUserCusId(request));
        
        String warnString = rcxjFacade.getMonthWarnDate(params);
        if(StringUtil.isBlank(warnString)){
            warnString = "";
        }
        calendar.put("warnString", warnString);
        String hasReportDate = rcxjFacade.getHasReportDate(params);
        if(StringUtil.isBlank(hasReportDate)){
            hasReportDate = "";
        }
        calendar.put("hasReportDate", hasReportDate);
        WebUtil.write(response, JsonUtil.map2Json(calendar));
    }
    
    @RequestMapping("ucdailyReport.html")
    public ModelAndView ciDailyDetail(Model model,HttpServletRequest request){
        ModelAndView view = new ModelAndView("/uc/daypatrol/ucdailyReport");
        String orderId = request.getParameter("orderId");
        Map info = rcxjFacade.getRcxjById(orderId);
        List<Map> commonList = rcxjFacade.getCommonPatrolItem(ConvertUtil.obj2StrBlank(info.get("cus_id")), 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);
        Map shInfo = rcxjFacade.getShInfoById(orderId);
        model.addAttribute("ciList",ciList);
        model.addAttribute("shInfo",shInfo);
        return view;
    }
    
    @RequestMapping("ucgetCurOrders.html")
    public void getCurOrders(HttpServletRequest request,HttpServletResponse response){
        String cusId = WebUtil.getWebLoginUserCusId(request);
        String patrolDate = request.getParameter("patrolDate");
        Map<String,String> params = new HashMap<String, String>();
        params.put("cusId", cusId);
        params.put("patrolDate", patrolDate);
        List<Map> list = rcxjFacade.getCurDateOrders(params);
        WebUtil.write(response, JsonUtil.list2Json(list));
    }
 
    @RequestMapping("patrolDetail.html")
    public String patrolDetail(Model model,HttpServletRequest request) {
        String orderId = request.getParameter("orderId");
        Map info = rcxjFacade.getRcxjById(orderId);
        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")));
        List<Map> ciList = rcxjFacade.getCiItemList(params);
        model.addAttribute("ciList", ciList);
        return "/uc/daypatrol/patrolDetail";
    }
    
}