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
package com.shlanbao.tzsc.pms.md.eqpStopMaintain.controller;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
 
import com.shlanbao.tzsc.base.mapping.*;
import com.shlanbao.tzsc.base.model.Combobox;
import com.shlanbao.tzsc.init.BaseParams;
import com.shlanbao.tzsc.pms.sch.workorder.service.WorkOrderServiceI;
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 com.google.gson.Gson;
import com.shlanbao.tzsc.base.controller.BaseController;
import com.shlanbao.tzsc.base.model.DataGrid;
import com.shlanbao.tzsc.base.model.Json;
import com.shlanbao.tzsc.pms.md.FilterCount.SchFilterCountBean;
import com.shlanbao.tzsc.pms.md.eqpStopMaintain.EqpStopMaintainBean;
import com.shlanbao.tzsc.pms.md.eqpStopMaintain.service.EqpStopMaintainServiceI;
 
@Controller
@RequestMapping("/pms/stopmaintain")
public class StopMaintainController extends BaseController{
    @Autowired
    public EqpStopMaintainServiceI eqpStopMaintainServiceI;
 
    @Autowired
    private WorkOrderServiceI workOrderService;
 
 
 
    @ResponseBody
    @RequestMapping("/getStopMaintain")
    public DataGrid getStopMaintain(EqpStopMaintainBean eqpStopMaintainBean){
        try {
                    return eqpStopMaintainServiceI.getAllStopMaintain(eqpStopMaintainBean);
        } catch (Exception e) {
            log.error("查询异常", e);
        }
        return null;
    }
    @RequestMapping("/goToStopMaintainAddJsp")
    public String goToStopMaintainAddJsp(){
        return "/pms/md/stopMaintain/eqpStopMaintainAdd";
    }
    @RequestMapping("/goToStopMaintainBatchAddJsp")
    public String goToStopMaintainBatchAddJsp(){
        return "/pms/md/stopMaintain/eqpStopMaintainBatchAdd";
    }
 
    @ResponseBody
    @RequestMapping("/addStopMaintain")
    public Json addStopMaintain(EqpStopMaintainBean eqpStopMaintainBean){
        Json json=new Json();
        try {
            eqpStopMaintainServiceI.addStopMaintain(eqpStopMaintainBean);
            json.setMsg("新增成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            log.error(message, e);
            json.setMsg("新增失败!");
            json.setSuccess(false);
        }
        return json;
    }
    @ResponseBody
    @RequestMapping("/addStopMaintainBatch")
    public Json addStopMaintainBatch(EqpStopMaintainBean eqpStopMaintainBean){
        Json json=new Json();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String [] eqps = eqpStopMaintainBean.getEqpId().split(",");
        String [] shifts = eqpStopMaintainBean.getShiftId().split(",");
        String [] contents = eqpStopMaintainBean.getContent().split(",");
        Date sDate = null;
        Date eDate = null;
        try {
            sDate = simpleDateFormat.parse(eqpStopMaintainBean.getActualDate());
            eDate = simpleDateFormat.parse(eqpStopMaintainBean.getActualDateEnd());
        } catch (ParseException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
 
 
          Calendar c = Calendar.getInstance();
 
          while(sDate.getTime()<=eDate.getTime()) {
 
              eqpStopMaintainBean.setActualDate(simpleDateFormat.format(sDate));
              for (String eqp : eqps) {
                  eqpStopMaintainBean.setEqpId(eqp);
                  for(String shift : shifts) {
                      eqpStopMaintainBean.setShiftId(shift);
 
                      SchCalendar schCalendar = workOrderService.queryTeamByDateShift(eqpStopMaintainBean.getActualDate(),shift);
                  //    SchWorkorder workOrder = workOrderService.findWorkOrderByDateShiftEqp(eqpStopMaintainBean.getActualDate(),shift,eqpStopMaintainBean.getEqpId());
                      if (schCalendar != null){
                        eqpStopMaintainBean.setTeamId(schCalendar.getMdTeam().getId());
                        for (String content : contents) {
                            eqpStopMaintainBean.setContent(content);
                            try {
                                eqpStopMaintainServiceI.addStopMaintain(eqpStopMaintainBean);
                                json.setMsg("新增成功!");
                                json.setSuccess(true);
                            } catch (Exception e) {
                                log.error(message, e);
                                json.setMsg("新增失败!");
                                json.setSuccess(false);
                            }
                        }
                    }
 
 
                  }
 
            }
              c.setTime(sDate);
              c.add(Calendar.DAY_OF_MONTH, 1);            //利用Calendar 实现 Date日期+1天
              sDate = c.getTime();
          }
 
 
 
        return json;
    }
 
 
    @RequestMapping("/goToStopMaintainEditJsp")
    public String goToStopMaintainEditJsp(HttpServletRequest request,String id){
        try {
            request.setAttribute("eqpStopMaintainBean", eqpStopMaintainServiceI.getStopMaintainById(id));
        } catch (Exception e) {
            log.error("获取ID:"+id+"的数据失败", e);
        }
        return "pms/md/stopMaintain/eqpStopMaintainEdit";
    }
 
 
    @ResponseBody
    @RequestMapping("/editStopMaintain")
    public Json editStopMaintain(EqpStopMaintainBean eqpStopMaintainBean){
        Json json=new Json();
        try {
            eqpStopMaintainServiceI.editStopMaintain(eqpStopMaintainBean);
            json.setMsg("编辑成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            log.error(message, e);
            json.setMsg("编辑失败!");
        }
        return json;
    }
 
 
    @ResponseBody
    @RequestMapping("/deleteStopMaintain")
    public Json deleteStopMaintain(String id){
        Json json=new Json();
        try {
            eqpStopMaintainServiceI.deleteStopMaintain(id);
            json.setMsg("删除成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            log.error(message, e);
            json.setMsg("删除失败!");
        }
        return json;
    }
    @ResponseBody
    @RequestMapping("/deleteStopMaintainBatch")
    public Json deleteStopMaintainBatch(String ids){
        Json json=new Json();
        String [] idStrings = ids.split(",");
        try {
            for (String id : idStrings) {
                eqpStopMaintainServiceI.deleteStopMaintain(id);
            }
            json.setMsg("删除成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            log.error(message, e);
            json.setMsg("删除失败!");
        }
        return json;
    }
 
 
    @ResponseBody
    @RequestMapping("/enableStopMaintainBatch")
    public Json enableStopMaintainBatch(String ids,int enable){
        Json json=new Json();
        String [] idStrings = ids.split(",");
        try {
            for (String id : idStrings) {
                eqpStopMaintainServiceI.enableStopMaintain(id,enable);
            }
            json.setMsg("修改成功!");
            json.setSuccess(true);
        } catch (Exception e) {
            log.error(message, e);
            json.setMsg("修改失败!");
        }
        return json;
    }
 
    @ResponseBody
    @RequestMapping("/getEqp")
    public String getEqpl(HttpServletRequest request,HttpSession session,String type)throws Exception{
        String typeName = "";
        List<Combobox> typeBeans = BaseParams.getEqpCategoryCombobox(false);
        for (Combobox bean : typeBeans){
            if (bean.getId().equals(type)){
                typeName = bean.getName();
            }
        }
        List<Combobox> list= null;
        if (typeName.equals("包装机组")){
            list = BaseParams.getAllPackersCombobox(false);
        } else if(typeName.equals("卷接机组")){
            list = BaseParams.getAllRollersCombobox(false);
        } else if(typeName.equals("封箱机组")){
            list = BaseParams.getAllBoxersCombobox(false);
        } else if(typeName.equals("成型机组")){
            list = BaseParams.getAllFiltersCombobox(false);
        } else if(typeName.equals("发射机组")){
            list = BaseParams.getAllTransmCombobox(false);
        }
        Gson gson=new Gson();
         String json = gson.toJson(list);
        //返回到前台
        return json;
    }
 
 
    @ResponseBody
    @RequestMapping("/getEqpty")
    public String getEqpty(HttpServletRequest request,HttpSession session)throws Exception{
        List<Combobox> list = BaseParams.getTeamCombobox(false);
        Gson gson=new Gson();
         String json = gson.toJson(list);
        //返回到前台
        return json;
    }
 
 
 
 
}