SettingsController.java
4.7 KB
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
package com.myproject.webapp.controller.system;
import com.google.common.base.Strings;
import com.myproject.bean.update.Settings;
import com.myproject.webapp.controller.storage.BaseUpdateController;
import com.myproject.webapp.controller.webService.DataCache;
import com.myproject.webapp.controller.webService.ExpireMailUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ExtendedModelMap;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;
@Controller
@RequestMapping("/system/settings.html")
public class SettingsController extends BaseUpdateController {
private final static String UPDATE_VIEW = "system/settings";
@Autowired
private DataCache dataCache;
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequest(final HttpServletRequest request) {
Model model = new ExtendedModelMap();
initMessage(request);
Settings settings = dataCache.getSettings();
String notIntoCids = request.getParameter("notIntoCids");
if(!Strings.isNullOrEmpty(notIntoCids)){
log.info("设置不入库料仓:" + notIntoCids);
settings.setNotIntoCids(notIntoCids);
settings = dataCache.updateSettings(settings);
}
String checkLineShelf = request.getParameter("checkLineShelf");
if(!Strings.isNullOrEmpty(checkLineShelf)){
log.info("设置出库前检查产线料架解绑状态:" + checkLineShelf);
settings.setCheckLineShelf(Boolean.valueOf(checkLineShelf));
settings = dataCache.updateSettings(settings);
}
//指定软件是为哪个客户单独定制的
String product = request.getParameter("pro");
if(!Strings.isNullOrEmpty(product)){
log.info("设置product=" + product);
settings.setProductCustom(product);
settings = dataCache.updateSettings(settings);
}
model.addAttribute("settings", settings);
return new ModelAndView(updateView(), model.asMap());
}
protected String updateView(){
return UPDATE_VIEW;
}
@RequestMapping(method = RequestMethod.POST)
protected String submit(@Valid Settings settings, BindingResult result,
final HttpServletRequest request, final HttpServletResponse response) throws Exception {
if(result.hasErrors()) {
return UPDATE_VIEW;
} else {
Settings oldSettings = dataCache.getSettings();
oldSettings.setMinTemperature(settings.getMinTemperature());
oldSettings.setMinTemperatureShow(settings.getMinTemperatureShow());
oldSettings.setMaxTemperature(settings.getMaxTemperature());
oldSettings.setMaxTemperatureShow(settings.getMaxTemperatureShow());
oldSettings.setMinHumidity(settings.getMinHumidity());
oldSettings.setMinHumidityShow(settings.getMinHumidityShow());
oldSettings.setMaxHumidity(settings.getMaxHumidity());
oldSettings.setMaxHumidityShow(settings.getMaxHumidityShow());
oldSettings.setReelCheckApi(settings.getReelCheckApi());
oldSettings.setInNotifyApi(settings.getInNotifyApi());
oldSettings.setOutNotifyApi(settings.getOutNotifyApi());
oldSettings.setBackupPath(settings.getBackupPath());
oldSettings.setBackupHours(settings.getBackupHours());
oldSettings.setMaintenanceEmail(settings.getMaintenanceEmail());
oldSettings.setMaintenanceDays(settings.getMaintenanceDays());
oldSettings.setPcbExpireDay(settings.getPcbExpireDay());
oldSettings.setPcbExpireEmail(settings.getPcbExpireEmail());
oldSettings.setPcbExpireTime(settings.getPcbExpireTime());
oldSettings.setOrderFileDir(settings.getOrderFileDir());
oldSettings.setInactionDay(settings.getInactionDay());
log.info("设置 停止出入库="+settings.isStopOut()+" 停止自动任务=isStopJob()");
oldSettings.setStopOut(settings.isStopOut());
oldSettings.setStopJob(settings.isStopJob());
dataCache.updateSettings(oldSettings);
saveMessage(request, getText("storage.saveSuccess", request.getLocale()));
return "redirect:/system/settings.html";
}
}
}