| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.mes.md.entity.*; |
| | | import com.mes.md.mapper.KBBTJPDrawingBPMapper; |
| | | import com.mes.md.mapper.TaskingLogMapper; |
| | | import com.mes.md.service.KBBTJPDrawingBPService; |
| | | import com.mes.md.service.LineConfigurationService; |
| | | import com.mes.md.service.PrimitiveTaskService; |
| | | import com.mes.md.service.TaskingLogService; |
| | | import com.mes.md.service.TaskingService; |
| | | import com.mes.utils.Result; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | KBBTJPDrawingBPMapper kBBTJPDrawingBPMapper; |
| | | @Autowired |
| | | TaskingLogService taskingLogService; |
| | | @Autowired |
| | | TaskingLogMapper taskingLogMapper; |
| | | @Autowired |
| | | LineConfigurationService lineConfigurationService; |
| | | |
| | | @ApiOperation("查询当前设备,未完工状态的线上任务") |
| | | @PostMapping("/selectPrimitiveTask") |
| | | @PostMapping("/findMachineTask") |
| | | @ResponseBody |
| | | public Result findMachineTask(@RequestBody PrimitiveTask primitiveTask) { |
| | | List<PrimitiveTask> list =primitiveTaskService.selectPrimitiveTask(primitiveTask); |
| | | public Result findMachineTask(@RequestBody Machine machine) { |
| | | LineConfiguration lineConfiguration = lineConfigurationService.machineLineConfiguration(machine); |
| | | List<PrimitiveTask> list =primitiveTaskService.findPrimitiveTasking(machine,lineConfiguration.getLineId()); |
| | | return Result.build(200,"成功",list); |
| | | } |
| | | |
| | |
| | | @PostMapping("/findDayNotCompleteOutput") |
| | | @ResponseBody |
| | | public Result findDayNotCompleteOutput(@RequestBody Map<String, String> map) { |
| | | int dayCount=0-Integer.valueOf(map.get("dayCount").toString()); |
| | | int dayCount=1-Integer.valueOf(map.get("dayCount").toString()); |
| | | Calendar cal = Calendar.getInstance(); |
| | | //设置当前时间 |
| | | cal.setTime(new Date()); |
| | |
| | | cal.set(Calendar.MILLISECOND, 0); |
| | | cal.add(Calendar.DATE, dayCount); |
| | | QueryWrapper<KBBTJPDrawingBP> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("scan_id,(task_quantity-isNull(report_count,0)) as notComplete,isNull((length*width*(task_quantity-isNull(report_count,0)))/1000000,0) as area_sum"). |
| | | gt("CreateDate",cal.getTime()).apply("task_quantity>isNull(report_count,0)"); |
| | | queryWrapper.select("OrderNo,(sum(task_quantity-isNull(report_count,0))) as notComplete,sum(isNull((length*width*(task_quantity-isNull(report_count,0)))/1000000,0)) as area_sum"). |
| | | gt("PlanDate",cal.getTime()).having("sum(task_quantity-isNull(report_count,0))>0") |
| | | .groupBy("OrderNo"); |
| | | List<Map> list=kBBTJPDrawingBPMapper.selectMaps((QueryWrapper)queryWrapper); |
| | | return Result.build(200,"成功",list); |
| | | } |
| | |
| | | @ApiOperation("查询 计划量 m² 片数(客户表)") |
| | | @PostMapping("/findPlannedQuantity") |
| | | @ResponseBody |
| | | public Result findPlannedQuantity(@RequestBody Map<String, String> map) { |
| | | int dayCount=Integer.valueOf(map.get("dayCount").toString()); |
| | | public Result findPlannedQuantity() { |
| | | //int dayCount=Integer.valueOf(map.get("dayCount").toString()); |
| | | Calendar cal = Calendar.getInstance(); |
| | | //设置当前时间 |
| | | cal.setTime(new Date()); |
| | |
| | | cal.set(Calendar.MINUTE, 0); |
| | | cal.set(Calendar.SECOND, 0); |
| | | cal.set(Calendar.MILLISECOND, 0); |
| | | cal.add(Calendar.DATE, 0-dayCount); |
| | | |
| | | //cal.add(Calendar.DATE, 1-dayCount); |
| | | cal.set(Calendar.DAY_OF_MONTH, 1); |
| | | Date startDate = cal.getTime(); |
| | | |
| | | // 获取当月最后一天 |
| | | Calendar lastDayCal = (Calendar) cal.clone(); |
| | | lastDayCal.add(Calendar.MONTH, 1); |
| | | lastDayCal.add(Calendar.DATE, -1); |
| | | Date endDate = lastDayCal.getTime(); |
| | | |
| | | // 获取当月天数 |
| | | int dayCount = lastDayCal.get(Calendar.DAY_OF_MONTH); |
| | | |
| | | QueryWrapper<KBBTJPDrawingBP> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("CAST(CreateDate AS DATE) AS CreateDate,isNull(sum(task_quantity),0) as task_quantity_sum,isNull(sum(length*width*task_quantity)/1000000,0) as area_sum") |
| | | .gt("CreateDate",startDate).groupBy("CAST(CreateDate AS DATE)") |
| | | .orderByAsc("CAST(CreateDate AS DATE)");; |
| | | queryWrapper.select("CAST(PlanDate AS DATE) AS CreateDate,isNull(sum(task_quantity),0) as task_quantity_sum,isNull(sum(length*width*task_quantity)/1000000,0) as area_sum") |
| | | .ge("PlanDate",startDate).le("PlanDate",endDate).groupBy("CAST(PlanDate AS DATE)") |
| | | .orderByAsc("CAST(PlanDate AS DATE)");; |
| | | List<Map> list=kBBTJPDrawingBPMapper.selectMaps((QueryWrapper)queryWrapper); |
| | | List<Map> resultDate=new ArrayList<>(); |
| | | |
| | | // 重置日历到当月第一天 |
| | | cal.setTime(startDate); |
| | | |
| | | for (int i=0;i<dayCount;i++){ |
| | | Date thisdate=cal.getTime(); |
| | | cal.add(Calendar.DATE, 1); |
| | |
| | | } |
| | | return Result.build(200,"成功",resultDate); |
| | | } |
| | | |
| | | @ApiOperation("查询 完成量 m² 片数") |
| | | @PostMapping("/findFinishQuantity") |
| | | @ResponseBody |
| | | public Result findFinishQuantity(@RequestBody Map<String, String> map) { |
| | | |
| | | Calendar cal = Calendar.getInstance(); |
| | | //设置当前时间 |
| | | cal.setTime(new Date()); |
| | | cal.set(Calendar.HOUR_OF_DAY, 0); |
| | | cal.set(Calendar.MINUTE, 0); |
| | | cal.set(Calendar.SECOND, 0); |
| | | cal.set(Calendar.MILLISECOND, 0); |
| | | |
| | | //cal.add(Calendar.DATE, 1-dayCount); |
| | | cal.set(Calendar.DAY_OF_MONTH, 1); |
| | | Date startDate = cal.getTime(); |
| | | |
| | | // 获取当月最后一天 |
| | | Calendar lastDayCal = (Calendar) cal.clone(); |
| | | lastDayCal.add(Calendar.MONTH, 1); |
| | | lastDayCal.add(Calendar.DATE, -1); |
| | | Date endDate = lastDayCal.getTime(); |
| | | |
| | | // 获取当月天数 |
| | | int dayCount = lastDayCal.get(Calendar.DAY_OF_MONTH); |
| | | |
| | | QueryWrapper<TaskingLog> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("CAST(operation_record_time AS DATE) AS CreateDate,ifNull(sum(task_quantity),0) as task_quantity_sum,ifNull(sum(length*width)/1000000,0) as area_sum") |
| | | .ge("operation_record_time",startDate).le("operation_record_time",endDate) |
| | | .in("operation_record","旋转1","旋转2") |
| | | .eq("operation_mode","结束") |
| | | .eq("work_state","完工") |
| | | .groupBy("CAST(operation_record_time AS DATE)") |
| | | .orderByAsc("CAST(operation_record_time AS DATE)"); |
| | | List<Map> list=taskingLogMapper.selectMaps((QueryWrapper)queryWrapper); |
| | | List<Map> resultDate=new ArrayList<>(); |
| | | |
| | | // 重置日历到当月第一天 |
| | | cal.setTime(startDate); |
| | | |
| | | for (int i=0;i<dayCount;i++){ |
| | | Date thisdate=cal.getTime(); |
| | | cal.add(Calendar.DATE, 1); |
| | | Map thisMap=new HashMap<>(); |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String dateString = sdf.format(thisdate); |
| | | thisMap.put("CreateDate",dateString); |
| | | // if(list.size()>0){ |
| | | // log.info("对比:{},{},{}",list.get(0).get("CreateDate"),dateString,list.get(0).get("CreateDate").toString().equals(dateString)); |
| | | // } |
| | | |
| | | if (list.size()>0&&list.get(0).get("CreateDate").toString().equals(dateString)){ |
| | | thisMap.put("task_quantity_sum",list.get(0).get("task_quantity_sum")); |
| | | thisMap.put("area_sum",list.get(0).get("area_sum")); |
| | | list.remove(0); |
| | | }else{ |
| | | thisMap.put("task_quantity_sum",0); |
| | | thisMap.put("area_sum",0); |
| | | } |
| | | resultDate.add(thisMap); |
| | | } |
| | | |
| | | return Result.build(200,"成功",resultDate); |
| | | |
| | | } |
| | | } |
| | | |