| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | |
| | | @CrossOrigin |
| | | @RequestMapping("/lineChart") |
| | | public ResponseData lineChart(ProductionOrdeInfoParam productionOrdeInfoParam) { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | List<String> list = new ArrayList(); |
| | | List<Integer> planQtyList = new ArrayList(); |
| | | List<Integer> actualQtyList = new ArrayList(); |
| | | Map map = new HashMap<String,String>(); |
| | | // for (int i = 0; i < 7; i++) { |
| | | // String str = LocalDate.now().minusDays(i).toString(); |
| | | for (Object o : getWeek()) { |
| | | List<ProductionOrdeInfoResult> ColumnarDateList = productionOrdeInfoService.getColumnarDate(); |
| | | for (ProductionOrdeInfoResult result : ColumnarDateList) { |
| | | String s = format.format(result.getActualStartTime()); |
| | | QueryWrapper<ProductionOrdeInfo> queryWrapper = new QueryWrapper<ProductionOrdeInfo>(); |
| | | queryWrapper.select("SUM(plan_qty) as planQty,SUM(actual_qty) as actualQty"); |
| | | queryWrapper.apply("CONVERT ( VARCHAR ( 100 ), plan_start_time, 23 ) = {0}",o.toString() ); |
| | | queryWrapper.apply("CONVERT ( VARCHAR ( 100 ), actual_start_time, 23 ) = {0}",s); |
| | | ProductionOrdeInfo one = productionOrdeInfoService.getOne(queryWrapper); |
| | | if(one!=null){ |
| | | if(one.getPlanQty()!=null){ |
| | |
| | | planQtyList.add(0); |
| | | actualQtyList.add(0); |
| | | } |
| | | list.add(o.toString()); |
| | | list.add(s); |
| | | } |
| | | |
| | | // } |
| | | map.put("category",list); |
| | | map.put("lineData",planQtyList); |
| | | map.put("barData",actualQtyList); |
| | | return ResponseData.success(map); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | // List<String> weeks = getFormatDate("month"); |
| | | // System.out.println(JSONObject.toJSONString(weeks)); |
| | | // for (int i = 0; i < 7; i++) { |
| | | // System.out.println(LocalDate.now().minusDays(i)); |
| | | // } |
| | | System.out.println(getWeek()); |
| | | |
| | | } |
| | | public static List getWeek(){ |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(LocalDate.now().minusDays(6).toString()); |
| | | list.add(LocalDate.now().minusDays(5).toString()); |
| | | list.add(LocalDate.now().minusDays(4).toString()); |
| | | list.add(LocalDate.now().minusDays(3).toString()); |
| | | list.add(LocalDate.now().minusDays(2).toString()); |
| | | list.add(LocalDate.now().minusDays(1).toString()); |
| | | list.add(LocalDate.now().minusDays(0).toString()); |
| | | return list; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 下载excel导入模板 |