¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.jcdm.main.bigScreen.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.jcdm.common.core.domain.AjaxResult; |
| | | import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
| | | import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; |
| | | import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; |
| | | import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | @RequestMapping("/bigScreen") |
| | | @RestController |
| | | public class BigScreenController { |
| | | @Autowired |
| | | private IOmProductionOrdeInfoService omProductionOrdeInfoService; |
| | | |
| | | @Autowired |
| | | private IDaPassingStationCollectionService daPassingStationCollectionService; |
| | | |
| | | /** |
| | | * 订åæ°æ® |
| | | * **/ |
| | | @GetMapping("/getOrderInformation") |
| | | public AjaxResult getOrderInformation() { |
| | | Map<String,String> resultMap = new HashMap<>(); |
| | | List<OmProductionOrdeInfo> orderList = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>().orderByDesc(OmProductionOrdeInfo::getCreateTime)); |
| | | OmProductionOrdeInfo order = orderList.get(0); // è·åææ°çä¸æ¡è®¢åä¿¡æ¯ |
| | | String workOrderNo = order.getWorkOrderNo(); |
| | | List<OmProductionOrdeInfo> finishNum = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>() |
| | | .eq(OmProductionOrdeInfo::getOrderStatus,"3") |
| | | .eq(OmProductionOrdeInfo::getWorkOrderNo,workOrderNo) |
| | | ); |
| | | resultMap.put("workOrderNo",workOrderNo); |
| | | resultMap.put("planQty",order.getPlanQty().toString()); |
| | | resultMap.put("actualQty",String.valueOf(finishNum.size())); |
| | | return AjaxResult.success(resultMap); |
| | | } |
| | | |
| | | /** |
| | | * è¿ä¸æ¥å·¥åå®æç¶ææ»è§ |
| | | * **/ |
| | | @GetMapping("completedInThePastSevenDays") |
| | | public AjaxResult completedInThePastSevenDays(){ |
| | | Map<String,List<String>> map = new HashMap<>(); |
| | | List<String> category = new ArrayList<>(); |
| | | List<String> lineData = new ArrayList<>(); |
| | | QueryWrapper<OmProductionOrdeInfo> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("TOP 7 CAST ( create_time AS DATE ) AS orderDate,COUNT ( * ) AS orderCount"); |
| | | queryWrapper.groupBy("CAST ( create_time AS DATE )"); |
| | | queryWrapper.orderByDesc("OrderDate"); |
| | | List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.list(queryWrapper); |
| | | for (OmProductionOrdeInfo omProductionOrdeInfo : list) { |
| | | category.add(omProductionOrdeInfo.getOrderDate()); |
| | | lineData.add(omProductionOrdeInfo.getOrderCount()); |
| | | } |
| | | map.put("category",category); |
| | | map.put("lineData",lineData); |
| | | return AjaxResult.success(map); |
| | | } |
| | | |
| | | /** |
| | | * æ«å·¥ä»¶èæå¹³åå¾ |
| | | * **/ |
| | | @GetMapping("averageBeatChartOfFinalWorkpiece") |
| | | public AjaxResult averageBeatChartOfFinalWorkpiece(){ |
| | | Integer maxBeatTime = 0; // æ大èææ¶é´ |
| | | List<Integer> weekLineData = new ArrayList(); |
| | | Map map = new HashMap<>(); |
| | | QueryWrapper<DaPassingStationCollection> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("sfc_code,\n" + |
| | | " location_code,\n" + |
| | | " inbound_time,\n" + |
| | | " outbound_time,\n" + |
| | | " DATEDIFF(SECOND, inbound_time, outbound_time) AS beatTime"); |
| | | queryWrapper.eq("sfc_code","2408270000011"); |
| | | queryWrapper.orderByDesc("location_code"); |
| | | List<DaPassingStationCollection> list = daPassingStationCollectionService.list(queryWrapper); |
| | | for (DaPassingStationCollection daPassingStationCollection : list) { |
| | | if(Integer.valueOf(daPassingStationCollection.getBeatTime()) > maxBeatTime){ |
| | | maxBeatTime = Integer.valueOf(daPassingStationCollection.getBeatTime()); |
| | | } |
| | | weekLineData.add(Integer.valueOf(daPassingStationCollection.getBeatTime())); |
| | | } |
| | | map.put("weekLineData", weekLineData); |
| | | map.put("maxData",roundUp(maxBeatTime)); |
| | | return AjaxResult.success(map); |
| | | } |
| | | |
| | | /** |
| | | * ææ°å·¥ä»¶è¿ç«èæç»è®¡ |
| | | * **/ |
| | | @GetMapping("latestWorkpieceTransitRhythmStatistics") |
| | | public AjaxResult latestWorkpieceTransitRhythmStatistics(){ |
| | | List<List<Object>> resultList = new ArrayList(); |
| | | QueryWrapper<DaPassingStationCollection> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("location_code AS locationCode"); |
| | | queryWrapper.groupBy("location_code"); |
| | | queryWrapper.orderByAsc("location_code"); |
| | | List<DaPassingStationCollection> list = daPassingStationCollectionService.list(queryWrapper); |
| | | for (DaPassingStationCollection daPassingStationCollection : list) { |
| | | List<Object> itemList = new ArrayList<>(); |
| | | QueryWrapper<DaPassingStationCollection> itemQueryWrapper = new QueryWrapper<>(); |
| | | itemQueryWrapper.select("TOP 1 *,DATEDIFF( SECOND, inbound_time, outbound_time ) AS beatTime"); |
| | | itemQueryWrapper.eq("location_code",daPassingStationCollection.getLocationCode()); |
| | | itemQueryWrapper.orderByDesc("inbound_time"); |
| | | List<DaPassingStationCollection> item = daPassingStationCollectionService.list(itemQueryWrapper); |
| | | itemList.add(daPassingStationCollection.getLocationCode()); |
| | | itemList.add(item.get(0).getBeatTime()); |
| | | resultList.add(itemList); |
| | | } |
| | | return AjaxResult.success(resultList); |
| | | } |
| | | |
| | | /** |
| | | * è¿ç«åæ ¼çæè¡ |
| | | * **/ |
| | | @GetMapping("passingPassRateRanking") |
| | | public AjaxResult passingPassRateRanking(){ |
| | | Map map = new HashMap(); |
| | | List xList = new ArrayList(); |
| | | List<DaPassingStationCollection> locationCode = daPassingStationCollectionService.list(new QueryWrapper<DaPassingStationCollection>() |
| | | .select("location_code as locationCode") |
| | | .groupBy("location_code")); |
| | | for (DaPassingStationCollection passingStationCollection : locationCode) { |
| | | Map map2 = new HashMap(); |
| | | map2.put("name", passingStationCollection.getLocationCode()); |
| | | List<DaPassingStationCollection> ok = daPassingStationCollectionService.list(new QueryWrapper<DaPassingStationCollection>() |
| | | .eq("out_rs_sign", 1) |
| | | .eq("location_code", passingStationCollection.getLocationCode())); |
| | | List<DaPassingStationCollection> total = daPassingStationCollectionService.list(new QueryWrapper<DaPassingStationCollection>() |
| | | .eq("location_code", passingStationCollection.getLocationCode())); |
| | | if(ok.size()>0){ |
| | | if(ok == total){ |
| | | map2.put("value", 100); |
| | | }else { |
| | | map2.put("value", locationPassRate(ok.size(), total.size())); |
| | | } |
| | | xList.add(map2); |
| | | } |
| | | } |
| | | map.put("xList", xList); |
| | | return AjaxResult.success(map); |
| | | } |
| | | |
| | | /** |
| | | * æå·¥åå®ææ°éç»è®¡ |
| | | * **/ |
| | | @GetMapping("monthlyWorkOrderCompletionQuantityStatistics") |
| | | public AjaxResult monthlyWorkOrderCompletionQuantityStatistics(){ |
| | | List<Map> resultList = new ArrayList<>(); |
| | | for (String lastTwoMonth : getLastTwoMonths()) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<OmProductionOrdeInfo> list = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>() |
| | | .eq(OmProductionOrdeInfo::getOrderStatus,"3") |
| | | .like(OmProductionOrdeInfo::getCreateTime, lastTwoMonth)); |
| | | map.put("name", lastTwoMonth); |
| | | map.put("value", list.size()); |
| | | resultList.add(map); |
| | | } |
| | | return AjaxResult.success(resultList); |
| | | } |
| | | |
| | | public static int locationPassRate(int passRate,int total) { |
| | | double percentage = (double) passRate / total * 100; |
| | | long roundedNumber = Math.round(percentage); |
| | | return (int) roundedNumber; |
| | | } |
| | | |
| | | public static int roundUp(int num) { |
| | | if (num >= 0) { |
| | | return (num + 10 - 1) / 10 * 10; |
| | | } else { |
| | | return (num - 10 + 1) / 10 * 10; |
| | | } |
| | | } |
| | | |
| | | public static List<String> getLastTwoMonths() { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.MONTH, -0); |
| | | String lastMonth = sdf.format(calendar.getTime()); |
| | | calendar.add(Calendar.MONTH, -1); |
| | | String currentMonth = sdf.format(calendar.getTime()); |
| | | |
| | | List<String> months = new ArrayList<>(); |
| | | months.add(lastMonth); |
| | | months.add(currentMonth); |
| | | |
| | | return months; |
| | | } |
| | | |
| | | |
| | | |
| | | } |