#
18516761980
2022-07-28 65fa066e222f6472badf7323c3b301417b674fdb
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
package com.slcf.controller;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
 
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.slcf.pojo.UserBean;
import com.slcf.pojo.WaitPakOutBean;
import com.slcf.pojo.WorkDetailBean;
import com.slcf.bean.WorkMastCondition;
import com.slcf.bean.WorkDetailCondition;
import com.slcf.pojo.WorkMastBean;
import com.slcf.pojo.LocationBean;
import com.slcf.pojo.SysLogBean;
import com.slcf.service.WorkFileService;
import com.slcf.util.AuthorityCode;
import com.slcf.service.LocationService;
import com.slcf.service.RoleService;
import com.slcf.service.SysLogService;
import com.slcf.service.WaitPakOutService;
 
/**
 * 工作档管理控制器层
 * @author admin
 * @date 2018年11月22日
 */
@Controller
@RequestMapping("/work")
public class WorkFileController {
 
    @Resource
    WorkFileService workFileService;
    @Autowired
    SysLogService sysLogService;
    @Autowired
    RoleService roleService;
    @Resource
    WaitPakOutService waitPakOutService;
    @Resource
    LocationService locationService;
    
    @RequestMapping("/goWorkFile.action")
    public String goWorkFilePage(HttpServletRequest request){
        try {
            String rid = request.getSession().getAttribute("ROLEID").toString();
            String authCode = roleService.getAuthListByRoleMenu(Integer.parseInt(rid), 
                    AuthorityCode.WorkFileCode);
            request.getSession().setAttribute("AUTHCODE",authCode);
            // 插入日志
            UserBean user = (UserBean) request.getSession().getAttribute("USER");
            SysLogBean sysLog = new SysLogBean();
            sysLog.setLogin_no(user.getUser_account());
            sysLog.setMachine_ip(request.getRemoteAddr());
            sysLog.setForm_no("goWorkFile.action");
            sysLog.setTts_keyname("访问:工作主档");
            sysLog.setModi_user(user.getUser_account());
            sysLogService.insertSysLog(sysLog);
        }catch (Exception e) {
            System.out.println(e.getMessage());
        }
        return "workFile";
    }
    
    /**
     * 分页查询主档
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @ResponseBody
    @RequestMapping("/workMastList.action")
    public Map<String,Object> queryWorkMastListByPages(WorkMastCondition workMastCon){                
        Map<String,Object>map=workFileService.queryWorkMastList(workMastCon);
        return map;
    }
    
    /**
     * 分页查询明细
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @ResponseBody
    @RequestMapping("/workDetailList.action")
    public Map<String,Object> queryWorkDetailListByPages(WorkDetailCondition workDetailCon){
        if(workDetailCon.getWrk_no()==null || "".equals(workDetailCon.getWrk_no())) {
            return null;
//            locationCon.setLoc_no("1");
        }
        Map<String,Object>map=workFileService.queryWorkDetailList(workDetailCon);
        return map;
    }
    
    /**
     * 修改信息
     * @param workStatus
     * @return
     */
    @ResponseBody
    @RequestMapping("/upWorkDetl.action")
    public Integer upWorkDetl(WorkDetailBean workDetl,HttpServletRequest request){
        int result = 0;
        try {
            UserBean user=(UserBean)request.getSession().getAttribute("USER");
//            workMast.setModi_user(user.getUser_account());
            result=workFileService.upWorkDetl(workDetl);
            WaitPakOutBean waitPakOutBean = new WaitPakOutBean();
            waitPakOutBean.setLgnum(workDetl.getLgnum());
            waitPakOutBean.setTanum(workDetl.getTbnum());
            waitPakOutBean.setTapos(workDetl.getTbpos());
            waitPakOutBean.setNista(workDetl.getNista());
            waitPakOutBean.setIo_status("N");
            waitPakOutBean.setMemo("");
            result = waitPakOutService.upWaitPakOut(waitPakOutBean, 1);
            
            if(result>0) {
                // 插入日志
//                UserBean user = (UserBean) request.getSession().getAttribute("USER");
                SysLogBean sysLog = new SysLogBean();
                sysLog.setLogin_no(user.getUser_account());
                sysLog.setMachine_ip(request.getRemoteAddr());
                sysLog.setForm_no("upWorkDetl.action");
                sysLog.setTts_keyname("维护拣料数量:" + workDetl.getMatnr());
                sysLog.setModi_user(user.getUser_account());
                sysLogService.insertSysLog(sysLog);
            }
        }catch(Exception e) {
            System.out.println(e.getMessage());
        }
        return result;
    }
    
    /**
     * 根据id查询信息
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryWorkDetlById.action")
//    public WorkDetailBean queryWorkDetlById(@RequestParam("wrk_no")int wrk_no,
//            @RequestParam("matnr")String matnr){
    public WorkDetailBean queryWorkDetlById(WorkDetailBean workDetl1){
        WorkMastBean workMast = new WorkMastBean();
        workMast = workFileService.queryWorkMastById(workDetl1.getWrk_no());
        if(workMast==null || workMast.getIo_type()!=103) {
            return null;
        }
        
        WorkDetailBean workDetl = new WorkDetailBean();
        try {
            workDetl = workFileService.queryWorkDetlById(workDetl1);
        }catch(Exception e) {
            System.out.println(e.getMessage());
            return null;
        }
        return workDetl;
    }
    
    /**
     * 查询所有
     * @return
     */
    @ResponseBody
    @RequestMapping("/getWorkMast.action")
    public List<WorkMastBean> getWorkMast(){
        try {
            return workFileService.getWorkMastList();
        }catch(Exception e) {
            System.out.println(e.getMessage());
            return null;
        }        
    }
    
    /**
     * 工作档资料转历史档
     * @return
     */
    @ResponseBody
    @RequestMapping("/movWorkToLog.action")
    public int movePakInToLog(@RequestParam("wrk_no")int wrk_no,HttpServletRequest request){
        int result = 0;
        try {
            result=workFileService.moveToLog(wrk_no);            
            if(result>0) {
                // 插入日志
                UserBean user = (UserBean) request.getSession().getAttribute("USER");
                SysLogBean sysLog = new SysLogBean();
                sysLog.setLogin_no(user.getUser_account());
                sysLog.setMachine_ip(request.getRemoteAddr());
                sysLog.setForm_no("movWorkToLog.action");
                sysLog.setTts_keyname("工作档资料转历史档:" + wrk_no);
                sysLog.setModi_user(user.getUser_account());
                sysLogService.insertSysLog(sysLog);
            }
        }catch(Exception e) {
            System.out.println(e.getMessage());
        }
        return result;
    }
    
    /**
     * 手工处理,完结/取消工作档
     * @return
     */
    @ResponseBody
    @RequestMapping("/opWork.action")
    public int opWork(@RequestParam("wrk_no")int wrk_no,@RequestParam("type")int type,
            HttpServletRequest request){
        int result = 0;
        try {
            UserBean user = (UserBean) request.getSession().getAttribute("USER");
            WorkMastBean workMast = new WorkMastBean();
            workMast = workFileService.queryWorkMastById(wrk_no);
            int wrk_sts=0;
            if(workMast!=null) {
                int io_type = workMast.getIo_type();
                if(type==1) {//完成
                    if(workMast.getWrk_sts()<4 || (workMast.getWrk_sts()>10 && workMast.getIo_type()==11)) {
                        wrk_sts=4;
                    }else if(workMast.getWrk_sts()>10) {
                        wrk_sts=14;
                    }
                    workMast.setWrk_sts(wrk_sts);
                    result=workFileService.upWorkMast(workMast);
                }
                else if(type==2) {//取消
                    String loc_no="";
                    String loc_sts="";
                    if(workMast.getWrk_sts()<4) {
                        if(io_type!=11) {
                            loc_no=workMast.getLoc_no();
                            loc_sts="O";
                        }else {
                            loc_no=workMast.getSource_loc_no();
                            loc_sts="F";
                            String d_loc_no = workMast.getLoc_no();
                            LocationBean location = new LocationBean();
                            location.setLoc_no(d_loc_no);
                            location.setLoc_sts("O");
                            location.setModi_user(user.getUser_account());
                            locationService.upLocation(location);
                        }
                    }else if(workMast.getWrk_sts()>10) {
                        loc_no=workMast.getSource_loc_no();
                        if(io_type>101 && io_type!=110) {
                            loc_sts="F";
                        }else if(io_type==110) {
                            loc_sts="D";
                        }else if(io_type==11) {
                            String d_loc_no = workMast.getLoc_no();
                            LocationBean location = new LocationBean();
                            location.setLoc_no(d_loc_no);
                            location.setLoc_sts("O");
                            location.setModi_user(user.getUser_account());
                            locationService.upLocation(location);
                        }
                    }
                    result=workFileService.deleteWorkFile(wrk_no,loc_no,loc_sts,type);
                }
            }
            
//            result=workFileService.moveToLog(wrk_no);            
            if(result>0) {
                // 插入日志
//                UserBean user = (UserBean) request.getSession().getAttribute("USER");
                SysLogBean sysLog = new SysLogBean();
                sysLog.setLogin_no(user.getUser_account());
                sysLog.setMachine_ip(request.getRemoteAddr());
                sysLog.setForm_no("opWork.action");
                sysLog.setTts_keyname("工作档手工完结:" + wrk_no);
                sysLog.setModi_user(user.getUser_account());
                sysLogService.insertSysLog(sysLog);
            }
        }catch(Exception e) {
            System.out.println(e.getMessage());
        }
        return result;
    }
    
    /**
     * 调整优先级
     * @param locstr
     * @param request
     * @return
     * @throws Exception
     */
    @ResponseBody
    @RequestMapping("/addIopri.action")
    public Map<String,Object> addIopri(@RequestParam("pri")String pri,
            @RequestParam("wrk_nostr")String[] wrk_nostr,HttpServletRequest request) throws Exception{
        Map<String,Object> map=new HashMap<String, Object>();
        try {
//            UserBean user=(UserBean)request.getSession().getAttribute("USER");
            if(wrk_nostr!=null) {
                for(String ids:wrk_nostr) {
                    int wrk_no = Integer.parseInt(ids);
                    WorkMastBean workMast = new WorkMastBean();
                    workMast = workFileService.queryWorkMastById(wrk_no);
                    if(workMast!=null) {
                        workMast.setIo_pri(workMast.getIo_pri() + Integer.parseInt(pri));
//                        workMast.setModi_time(modi_time);
                        int result=workFileService.upWorkMast(workMast);
                        if(result>0) {
                            map.put("code", 0);
                            map.put("msg", "调整成功");
                        }else {
                            map.put("code", 1);
                            map.put("msg", "调整失败");
                            continue;
                        }
                    }
                }
            }
        }catch(RuntimeException e) {
            System.out.println(e.getMessage());
        }
        return map;
    }
    
}