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