zhuguifei
2026-03-10 58402bd5e762361363a0f7d7907153c77dbb819f
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
package com.shlanbao.tzsc.pms.equ.effective.controller;
 
import java.util.Date;
 
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
 
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
 
import com.shlanbao.tzsc.base.mapping.EqmCullRecordBean;
import com.shlanbao.tzsc.base.model.DataGrid;
import com.shlanbao.tzsc.base.model.Json;
import com.shlanbao.tzsc.base.model.PageParams;
import com.shlanbao.tzsc.base.model.SessionInfo;
import com.shlanbao.tzsc.pms.cos.spare.beans.CosSparePartsBean;
import com.shlanbao.tzsc.pms.equ.effective.beans.EffectiveGraphBean;
import com.shlanbao.tzsc.pms.equ.effective.beans.EffectiveOperaBean;
import com.shlanbao.tzsc.pms.equ.effective.beans.EffectiveRunTime;
import com.shlanbao.tzsc.pms.equ.effective.beans.EffectiveUtilizeTime;
import com.shlanbao.tzsc.pms.equ.effective.service.EffectiveOperaServiceI;
import com.shlanbao.tzsc.utils.tools.DateUtil;
/**
 *
* @ClassName: EffectiveOperaController
* @Description: 设备有效作业率、运行效率查询
* @author luo
* @date 2015年3月9日 下午4:18:46
*
 */
@Controller
@RequestMapping("/pms/effect")
public class EffectiveOperaController {
 
    @Autowired
    public EffectiveOperaServiceI effectiveOperaServiceI;
    /**
     * <p>功能描述:设备有效作业率查询</p>
     *@param bean
     *@param pageParams
     *@return
     *shisihai
     *2016上午10:26:43
     */
    @ResponseBody
    @RequestMapping("/queryDataGrid")
    public DataGrid queryDataGrid(EffectiveOperaBean bean,PageParams pageParams){
        return effectiveOperaServiceI.queryList(bean, pageParams);
    }
    /**
     *
    * @Title: queryGraph
    * @Description: 设备有效作用率图表查询方法
    * @param  bean
    * @return EffectiveGraphBean    返回类型
    * @throws
     */
    @ResponseBody
    @RequestMapping("/queryGraph")
    public EffectiveGraphBean queryGraph(EffectiveOperaBean bean){
        return effectiveOperaServiceI.queryGraph(bean);
    }
 
    /**
     *
    * @Title: queryRunTimeEffective
    * @Description: 设备运行效率
    * @param  bean
    * @param  pageParams
    * @return DataGrid   返回类型
    * @throws
     */
    @ResponseBody
    @RequestMapping("/queryRunTimeEffect")
    public DataGrid queryRunTimeEffective(EffectiveRunTime bean,PageParams pageParams){
        return effectiveOperaServiceI.queryRunTimeEffective(bean, pageParams);
    }
 
    /**
     *
    * @Title: queryRunTimeEffectivesChart
    * @Description: 设备运行效率图表
    * @param @param bean
    * @param @return    设定文件
    * @return EffectiveGraphBean    返回类型
    * @throws
     */
    @ResponseBody
    @RequestMapping("/queryRunTimeEffectChart")
    public EffectiveGraphBean queryRunTimeEffectivesChart(EffectiveRunTime bean){
        return effectiveOperaServiceI.queryRunTimeEffectiveChart(bean);
    }
 
 
    @ResponseBody
    @RequestMapping("/queryUtilizeEffective")
    public DataGrid queryUtilizeEffective(EffectiveUtilizeTime bean,PageParams pageParams){
        return effectiveOperaServiceI.quertyUtilizeEffective(bean, pageParams);
    }
 
    @ResponseBody
    @RequestMapping("/queryUtilizeEffectiveChart")
    public EffectiveGraphBean queryUtilizeEffectiveChart(EffectiveUtilizeTime bean){
        return effectiveOperaServiceI.quertyUtilizeEffectiveChart(bean);
    }
 
    /**
     *  功能说明:设备停机剔除时间管理-添加
     *  @param bean 数据实体对象
     *  @return
     *  @author wchuang
     *  @time 2015年7月21日16:18:46
     *
     * */
    @ResponseBody
    @RequestMapping("/addCullRecord")
    public Json addCullRecord(HttpSession session,EqmCullRecordBean bean) throws Exception{
        Json json=new Json();
        SessionInfo loginBean = (SessionInfo) session.getAttribute("sessionInfo");
        //创建人信息
        bean.setCreate_user_id(loginBean.getUser().getId());
        bean.setUpdate_user_id(loginBean.getUser().getId());
        bean.setCreate_user_name(loginBean.getUser().getName());
        bean.setUpdate_user_name(loginBean.getUser().getName());
        bean.setCreate_time(new Date());
        bean.setUpdate_time(new Date());
        //当天(结束时间  - 起始时间) = 当天(停机时间)
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date dBegin = sdf.parse(bean.getSdate());
      //  Date dEnd = sdf.parse(bean.getEdate());
        bean.setDel(1);
 
 
           Date st_date = formatter.parse(sdf.format(dBegin)+" "+bean.getStime());
           Date ed_date = formatter.parse(sdf.format(dBegin)+" "+bean.getEtime());
 
        bean.setSt_date(st_date);
        bean.setEd_date(ed_date);
           //毫秒ms
           long diff = ed_date.getTime()-st_date.getTime();
           //分钟
           int stop_time=(int) (diff/(60 * 1000));
           //当天总停机时间
           bean.setStop_time(stop_time);
 
 
        try{
            //保存
            boolean flag=effectiveOperaServiceI.addCullRecord(bean);
            json.setMsg("添加成功");
            json.setSuccess(flag);
        }catch(Exception e){
            json.setMsg("添加失败");
            json.setSuccess(false);
        }
        return json;
    }
 
    /**
     * 说明:返回日期时间段内所有日期集合
     *
     * */
     public static List<Date> findDates(Date dBegin, Date dEnd) {
            List lDate = new ArrayList();
            lDate.add(dBegin);
            Calendar calBegin = Calendar.getInstance();
            // 使用给定的 Date 设置此 Calendar 的时间
            calBegin.setTime(dBegin);
            Calendar calEnd = Calendar.getInstance();
            // 使用给定的 Date 设置此 Calendar 的时间
            calEnd.setTime(dEnd);
            // 测试此日期是否在指定日期之后
            while (dEnd.after(calBegin.getTime())) {
                // 根据日历的规则,为给定的日历字段添加或减去指定的时间量
                calBegin.add(Calendar.DAY_OF_MONTH, 1);
                lDate.add(calBegin.getTime());
            }
            return lDate;
     }
 
 
    /**
     *  【功能说明】:设备停机剔除时间管理-查询
     *  @param bean 数据实体对象
     *  @return
     *  @author wchuang
     *  @time 2015年7月22日10:36:42
     *
     * */
    @ResponseBody
    @RequestMapping("/queryCullRecord")
    public DataGrid queryCullRecord(EqmCullRecordBean bean,PageParams pageParams) throws Exception{
        return effectiveOperaServiceI.queryCullRecord(bean, pageParams);
    }
 
 
    /**
     * 【功能说明】:设备停机剔除时间管理-删除
     *  @param bean 数据实体对象
     *  @return
     *  @author wchuang
     *  @time 2015年7月22日14:26:21
     *
     * */
    @ResponseBody
    @RequestMapping("/deleteCullRecordById")
    public Json deleteCullRecordById(HttpSession session,EqmCullRecordBean bean) throws Exception{
       Json json=new Json();
       try{
            //保存
               boolean flag=effectiveOperaServiceI.deleteCullRecordById(bean);
               json.setMsg("删除成功!");
               json.setSuccess(flag);
          }catch(Exception e){
               json.setMsg("删除失败!");
               json.setSuccess(false);
          }
        return json;
    }
 
    /**
     * 批量删除
     * @param ids
     * @return
     */
    @ResponseBody
    @RequestMapping("/batchDeleteCullRecord")
    public Json batchDeleteCullRecord(String ids){
       Json json=new Json();
       try{
            //保存
               effectiveOperaServiceI.batchDeleteCullRecord(ids);
               json.setMsg("删除成功!");
               json.setSuccess(true);
          }catch(Exception e){
               json.setMsg("删除失败!");
               json.setSuccess(false);
          }
        return json;
    }
    /**
     * 导出设备有效作业率
     * @param bean
     */
    @ResponseBody
    @RequestMapping("/deriveExcel")
    public void deriveExcel(EffectiveOperaBean bean,HttpServletResponse response) {
        try {
            HSSFWorkbook wb =effectiveOperaServiceI.ExportExcelJBEffic(bean);
            String addtime=DateUtil.getNowDateTime("yyyyMMddHHmmSSS");
            response.reset();
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("Content-Disposition","attachment; filename="+addtime+".xls");
            ServletOutputStream os = response.getOutputStream();
            wb.write(os);
            os.flush();
            os.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
 
    /**
     * 导出设备运行效率
     * @param bean
     * @param response
     */
    @ResponseBody
    @RequestMapping("/deriveEqpRunEfficExcel")
    public void deriveEqpRunEfficExcel(EffectiveRunTime bean,HttpServletResponse response) {
        try {
            HSSFWorkbook wb =effectiveOperaServiceI.deriveEqpRunEfficExcel(bean);
            String addtime=DateUtil.getNowDateTime("yyyyMMddHHmmSSS");
            response.reset();
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("Content-Disposition","attachment; filename="+addtime+".xls");
            ServletOutputStream os = response.getOutputStream();
            wb.write(os);
            os.flush();
            os.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
 
}