提交 | 用户 | 时间
|
b26949
|
1 |
package cn.stylefeng.guns.modular.kb.greaseBoard; |
懒 |
2 |
|
|
3 |
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo; |
|
4 |
import cn.stylefeng.guns.modular.gm.greaseManage.entity.GreaseManage; |
|
5 |
import cn.stylefeng.guns.modular.gm.greaseManage.model.params.GreaseManageParam; |
21fde8
|
6 |
import cn.stylefeng.guns.modular.gm.greaseManage.model.result.GreaseManageResult; |
b26949
|
7 |
import cn.stylefeng.guns.modular.gm.greaseManage.service.GreaseManageService; |
懒 |
8 |
import cn.stylefeng.guns.modular.kb.utils.IPUtil; |
|
9 |
import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult; |
|
10 |
import cn.stylefeng.guns.modular.sc.kanbanConf.model.params.KanbanConfParam; |
|
11 |
import cn.stylefeng.guns.modular.sc.kanbanConf.service.KanbanConfService; |
21fde8
|
12 |
import cn.stylefeng.guns.plcserver.opc.unit.OPCUnit; |
b26949
|
13 |
import cn.stylefeng.roses.core.base.controller.BaseController; |
懒 |
14 |
import cn.stylefeng.roses.kernel.model.response.ResponseData; |
|
15 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
16 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
17 |
import javafx.stage.Stage; |
|
18 |
import org.springframework.beans.factory.annotation.Autowired; |
|
19 |
import org.springframework.stereotype.Controller; |
|
20 |
import org.springframework.web.bind.annotation.CrossOrigin; |
|
21 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
22 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
23 |
|
|
24 |
import javax.servlet.ServletOutputStream; |
|
25 |
import javax.servlet.http.HttpServletRequest; |
|
26 |
import java.text.SimpleDateFormat; |
|
27 |
import java.time.LocalDate; |
|
28 |
import java.time.format.DateTimeFormatter; |
|
29 |
import java.time.temporal.ChronoUnit; |
|
30 |
import java.util.*; |
|
31 |
|
|
32 |
/** |
|
33 |
* 返修上线看板 |
|
34 |
* |
|
35 |
* @author cl |
|
36 |
* @Date 2022-10-27 15:50:56 |
|
37 |
*/ |
|
38 |
@Controller |
|
39 |
@RequestMapping("/greaseBoard") |
|
40 |
public class GreaseBoardController extends BaseController { |
|
41 |
|
|
42 |
private String PREFIX = "modular/kb/greaseBoard"; |
|
43 |
@Autowired |
|
44 |
private KanbanConfService kanbanConfService; |
|
45 |
|
|
46 |
@Autowired |
|
47 |
private GreaseManageService greaseManageService; |
|
48 |
/** |
|
49 |
* 跳转到主页面 |
|
50 |
* |
|
51 |
* @author cl |
|
52 |
* @Date 2022-10-27 |
|
53 |
*/ |
|
54 |
@RequestMapping("") |
|
55 |
public String index() { |
|
56 |
return PREFIX + "/greaseBoard.html"; |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* 新增看板配置页面 |
|
61 |
* |
|
62 |
* @author cl |
|
63 |
* @Date 2022-10-31 |
|
64 |
*/ |
|
65 |
@RequestMapping("/add") |
|
66 |
public String add() { |
|
67 |
return PREFIX + "/kanbanConf_add.html"; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* 编辑页面 |
|
72 |
* |
|
73 |
* @author cl |
|
74 |
* @Date 2022-10-31 |
|
75 |
*/ |
|
76 |
@RequestMapping("/edit") |
|
77 |
public String edit() { |
|
78 |
return PREFIX + "/kanbanConf_edit.html"; |
|
79 |
} |
|
80 |
|
|
81 |
@RequestMapping("/orderEdit") |
|
82 |
public String orderEdit() { |
|
83 |
return PREFIX + "/kanbanConf_orderEdit.html"; |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* 新增接口 |
|
88 |
* |
|
89 |
* @author cl |
|
90 |
* @Date 2022-10-31 |
|
91 |
*/ |
|
92 |
@RequestMapping("/addKanBanConfItem") |
|
93 |
@ResponseBody |
|
94 |
public ResponseData addItem(KanbanConfParam kanbanConfParam, HttpServletRequest request) { |
|
95 |
String realIp = IPUtil.getRealIp(request); |
|
96 |
kanbanConfParam.setIpAddress(realIp); |
|
97 |
kanbanConfParam.setWarehouseCode(kanbanConfParam.getScrapReason()); |
|
98 |
kanbanConfParam.setWarehouseName(kanbanConfParam.getScrapCategory()); |
|
99 |
this.kanbanConfService.add(kanbanConfParam); |
|
100 |
return ResponseData.success(); |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* 新增接口 |
|
105 |
* MIGICC17500E00136V250WX23K03A0003B |
|
106 |
* @author cl |
|
107 |
* @Date 2022-10-31 |
|
108 |
*/ |
|
109 |
@RequestMapping("/updategreaseManage") |
|
110 |
@ResponseBody |
|
111 |
public ResponseData updategreaseManage(GreaseManageParam greaseManageParam) { |
|
112 |
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); |
|
113 |
String currentDate = format.format(new Date()); |
|
114 |
String barCode = greaseManageParam.getBarcode(); |
|
115 |
String lastTwelveChars = barCode.substring(barCode.length() - 12); |
|
116 |
String locationCode = getLocationCode(lastTwelveChars); |
|
117 |
String DuaDate = getDuaDate(lastTwelveChars); |
|
118 |
GreaseManage greaseManage = new GreaseManage(); |
|
119 |
greaseManage.setBarcode(barCode); |
|
120 |
greaseManage.setLocationCode(locationCode); |
|
121 |
greaseManage.setDuaDate(DuaDate); |
|
122 |
greaseManage.setDaysRemaining(getRemainder(currentDate,DuaDate)); |
|
123 |
greaseManage.setCreateTime(new Date()); |
|
124 |
greaseManage.setCreateUser("admin"); |
|
125 |
// greaseManageService.save(greaseManage); |
|
126 |
greaseManageService.update(greaseManage,new LambdaQueryWrapper<GreaseManage>().eq(GreaseManage::getLocationCode, locationCode)); |
|
127 |
return ResponseData.success(); |
|
128 |
} |
|
129 |
|
|
130 |
@ResponseBody |
|
131 |
@CrossOrigin |
|
132 |
@RequestMapping("/bigListGreaseBoard") |
|
133 |
public ResponseData orderDescListFive() { |
|
134 |
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); |
|
135 |
String currentDate = format.format(new Date()); |
|
136 |
List list = new ArrayList(); |
|
137 |
List<GreaseManage> results = greaseManageService.list(); |
|
138 |
for (GreaseManage result : results) { |
|
139 |
String DuaDate = result.getDuaDate(); |
|
140 |
String remainder = getRemainder(currentDate, DuaDate); |
|
141 |
if(Integer.valueOf(remainder)<=90){ |
|
142 |
List itemList = new ArrayList(); |
|
143 |
itemList.add(boldText(result.getLocationCode())); |
|
144 |
itemList.add(boldText(DuaDate)); |
|
145 |
itemList.add(boldText(remainder)); |
|
146 |
list.add(itemList); |
|
147 |
}else { |
|
148 |
List itemList = new ArrayList(); |
|
149 |
itemList.add(whiteBoldText(result.getLocationCode())); |
|
150 |
itemList.add(whiteBoldText(DuaDate)); |
|
151 |
itemList.add(whiteBoldText(remainder)); |
|
152 |
list.add(itemList); |
|
153 |
} |
|
154 |
|
|
155 |
} |
|
156 |
return ResponseData.success(list); |
|
157 |
} |
|
158 |
|
21fde8
|
159 |
@ResponseBody |
懒 |
160 |
@CrossOrigin |
|
161 |
@RequestMapping("/testhandleOilState") |
|
162 |
public long handleOilState(){ |
|
163 |
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); |
|
164 |
String currentDate = format.format(new Date()); |
|
165 |
GreaseManageParam param = new GreaseManageParam(); |
|
166 |
param.setLocationCode("OP050"); |
|
167 |
List<GreaseManageResult> list = greaseManageService.findListBySpec(param); |
|
168 |
if(list.size()>0) { |
|
169 |
String duaDate = list.get(0).getDuaDate(); |
|
170 |
// |
|
171 |
long daysBetween = Long.parseLong(getRemainder(currentDate,duaDate)); |
|
172 |
|
|
173 |
// long daysBetween = ChronoUnit.DAYS.between(date1, date2); |
|
174 |
// return daysBetween; |
|
175 |
} |
|
176 |
return 0; |
|
177 |
} |
|
178 |
|
b26949
|
179 |
public static String boldText(String param){ |
懒 |
180 |
return "<span style='font-size: 20px' class='colorRed'>"+param+"</span>"; |
|
181 |
} |
|
182 |
|
|
183 |
public static String whiteBoldText(String param){ |
|
184 |
return "<span style='font-size: 20px'>"+param+"</span>"; |
|
185 |
} |
|
186 |
|
|
187 |
public static void main(String[] args) { |
|
188 |
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyyMMdd"); |
|
189 |
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); |
|
190 |
String format1 = format.format(new Date()); |
|
191 |
System.out.println("Difference in days: " + getRemainder("20231215",format1)); |
|
192 |
} |
|
193 |
|
|
194 |
public static String getRemainder(String currentDate,String tableDate){ |
|
195 |
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyyMMdd"); |
|
196 |
LocalDate localDate1 = LocalDate.parse(currentDate, dateFormatter); |
|
197 |
LocalDate localDate2 = LocalDate.parse(tableDate, dateFormatter); |
21fde8
|
198 |
long days = ChronoUnit.DAYS.between(localDate1, localDate2); |
b26949
|
199 |
return String.valueOf(days); |
懒 |
200 |
} |
|
201 |
|
|
202 |
public static String getDuaDate(String str){ |
|
203 |
String year = str.substring(1,3); |
|
204 |
String month = getMonth(str.substring(3,4)); |
|
205 |
String day = str.substring(4,6); |
|
206 |
return "20"+year+month+day; |
|
207 |
} |
|
208 |
|
|
209 |
public static String getLocationCode(String str){ |
|
210 |
String locationCode = ""; |
|
211 |
switch (str.substring(0,1)) { |
|
212 |
case "X": |
|
213 |
locationCode = "DOP020"; |
|
214 |
break; |
|
215 |
case "Y": |
|
216 |
locationCode = "OP050"; |
|
217 |
break; |
|
218 |
case "Z": |
9b98a7
|
219 |
locationCode = "BOP030/040"; |
b26949
|
220 |
break; |
懒 |
221 |
default: |
|
222 |
break; |
|
223 |
} |
|
224 |
return locationCode; |
|
225 |
} |
|
226 |
|
|
227 |
public static String getMonth(String str){ |
|
228 |
String Month = ""; |
|
229 |
switch (str) { |
|
230 |
case "A": |
|
231 |
Month = "1"; |
|
232 |
break; |
|
233 |
case "B": |
|
234 |
Month = "2"; |
|
235 |
break; |
|
236 |
case "C": |
|
237 |
Month = "3"; |
|
238 |
break; |
|
239 |
case "D": |
|
240 |
Month = "4"; |
|
241 |
break; |
|
242 |
case "E": |
|
243 |
Month = "5"; |
|
244 |
break; |
|
245 |
case "F": |
|
246 |
Month = "6"; |
|
247 |
break; |
|
248 |
case "G": |
|
249 |
Month = "7"; |
|
250 |
break; |
|
251 |
case "H": |
|
252 |
Month = "8"; |
|
253 |
break; |
|
254 |
case "I": |
|
255 |
Month = "9"; |
|
256 |
break; |
|
257 |
case "J": |
|
258 |
Month = "10"; |
|
259 |
break; |
|
260 |
case "K": |
|
261 |
Month = "11"; |
|
262 |
break; |
|
263 |
case "L": |
|
264 |
Month = "12"; |
|
265 |
break; |
|
266 |
default: |
|
267 |
break; |
|
268 |
} |
|
269 |
return Month; |
|
270 |
} |
|
271 |
|
|
272 |
|
|
273 |
/** |
|
274 |
* 编辑接口 |
|
275 |
* |
|
276 |
* @author cl |
|
277 |
* @Date 2022-10-31 |
|
278 |
*/ |
|
279 |
@RequestMapping("/editKanBanConfItem") |
|
280 |
@ResponseBody |
|
281 |
public ResponseData editItem(KanbanConfParam kanbanConfParam) { |
|
282 |
this.kanbanConfService.update(kanbanConfParam); |
|
283 |
return ResponseData.success(); |
|
284 |
} |
|
285 |
|
|
286 |
/** |
|
287 |
* 查询列表 |
|
288 |
* |
|
289 |
* @author cl |
|
290 |
* @Date 2022-10-31 |
|
291 |
*/ |
|
292 |
@ResponseBody |
|
293 |
@RequestMapping("/qryKBConflist") |
|
294 |
public LayuiPageInfo list(KanbanConfParam kanbanConfParam, HttpServletRequest request) { |
|
295 |
String realIp = IPUtil.getRealIp(request); |
|
296 |
kanbanConfParam.setIpAddress(realIp); |
|
297 |
|
|
298 |
return this.kanbanConfService.findPageBySpec(kanbanConfParam); |
|
299 |
} |
|
300 |
} |