From f5342d142776600deca7a0732d1794dc8929a2bc Mon Sep 17 00:00:00 2001 From: LGH <1746689524@qq.com> Date: Thu, 28 Jul 2022 16:41:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E7=94=9F=E4=BA=A7=E5=8D=95?= =?UTF-8?q?=E5=8F=B7=E6=9F=A5=E8=AF=A2=E6=A3=80=E9=AA=8C=E7=BB=93=E6=9E=9C?= =?UTF-8?q?list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../empty/controller/EnergyController.java | 270 +++++++++--------- .../wms/empty/params/TaskHisQueryParam.java | 2 + .../service/impl/TaskHisServiceImpl.java | 2 + 3 files changed, 143 insertions(+), 131 deletions(-) diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java index 9cf9bf7..042a587 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java @@ -82,139 +82,10 @@ public class EnergyController extends BaseController { private CurrTaskServiceBiz currTaskServiceBiz; @Autowired private TaskHisServiceBiz taskHisServiceBiz; + @Autowired + private ApmsCheckResultServiceBiz apmsCheckResultServiceBiz; - @PostMapping(value = "eletric") - @ApiOperation(value = "根据任务id获取消耗情况") - public R list(@Validated({Default.class}) @RequestBody ElectricQueryParam electricQueryParam) { - Long kiln = electricQueryParam.getKilnId(); - //工业炉id为0代表全部,存储的时候计算全部 - JSONObject jsonObject=new JSONObject(); - //指定时间节点 - LocalDate timeDate = electricQueryParam.getTime().toLocalDate(); - LocalDateTime timeStart = LocalDateTime.of(timeDate, LocalTime.MIN); - LocalDateTime timeEnd = LocalDateTime.of(timeDate, LocalTime.MAX); - //当前时间节点 - LocalDateTime todayStart = LocalDateTime.of(LocalDate.now(), LocalTime.MIN); - LocalDateTime todayEnd = LocalDateTime.of(LocalDate.now(), LocalTime.MAX); - //总电能消耗 - List todayEleValueList = parEleValueServiceBiz.list(new QueryWrapper() - .eq("kiln_id", kiln) - .between("create_time", todayStart, todayEnd) - .orderByDesc("create_time")); - Float countEleValue = todayEleValueList.get(0).getTotalBat(); - jsonObject.put("countEle",countEleValue); - - //昨日电能消耗 - LocalDateTime yesterdayStart = LocalDateTime.of(LocalDate.now().plus(1, ChronoUnit.DAYS), LocalTime.MIN); - LocalDateTime yesterdayEnd = LocalDateTime.of(LocalDate.now().plus(1, ChronoUnit.DAYS), LocalTime.MAX); - List yesterdayEleValueList = parEleValueServiceBiz.list(new QueryWrapper() - .eq("kiln_id", kiln) - .between("create_time", yesterdayStart, yesterdayEnd) - .eq("date_type",0) - .orderByAsc("create_time")); - Float yesterdayTotalBat= yesterdayEleValueList.get(yesterdayEleValueList.size()-1).getTotalBat()-yesterdayEleValueList.get(0).getTotalBat(); - jsonObject.put("yesterdayCountEle",yesterdayTotalBat); - - //指定日期当天的电能消耗 - if (electricQueryParam.getDateType()==0){ - List dateEleValueList = parEleValueServiceBiz.list(new QueryWrapper() - .eq("kiln_id", kiln) - .between("create_time", timeStart, timeEnd) - .orderByAsc("create_time")); - //总耗电量 - Float dateCountEle=0F; - if (dateEleValueList.size()!=0){ - dateCountEle= dateEleValueList.get(dateEleValueList.size()-1).getTotalBat()-dateEleValueList.get(0).getTotalBat(); - } - jsonObject.put("dateCountEle",dateCountEle); - //分时消耗量 - Map timeJsonObject=new LinkedHashMap(); - for (int i = 0; i < dateEleValueList.size() - 1; ++i) { - // TODO: 2021/12/16 - float eleValue = dateEleValueList.get(i).getTotalBat() - dateEleValueList.get(i - 1).getTotalBat(); - int j=i+1; - if (j%2==0){ - String time=(j-1)/2+":30"; - timeJsonObject.put(time,eleValue); - }else { - String time=(j-1)/2+":00"; - timeJsonObject.put(time,eleValue); - } - } - jsonObject.put("timeEle",timeJsonObject); - } - //指定日期当周的每天电能消耗 - if(electricQueryParam.getDateType()==1){ - LocalDate monday = timeDate.with(DayOfWeek.MONDAY); - LocalDate sunday = timeDate.with(DayOfWeek.SUNDAY); - List timeWeekEleValueList = parEleValueServiceBiz.list(new QueryWrapper() - .eq("kiln_id", kiln) - .between("create_time", monday, sunday.plusDays(1)) - .eq("date_type", 1) - .orderByAsc("create_time")); - //总耗电量 - Float dateCountEle=0F; - if (timeWeekEleValueList.size()!=0){ - dateCountEle= timeWeekEleValueList.get(timeWeekEleValueList.size()-1).getTotalBat()-timeWeekEleValueList.get(0).getTotalBat(); - } - jsonObject.put("dateCountEle",dateCountEle); - Map timeJsonObject=new LinkedHashMap(); - for (ParEleValue parEleValue:timeWeekEleValueList - ) { - LocalDate localDate = parEleValue.getCreateTime().toLocalDate(); - timeJsonObject.put(localDate.toString(),parEleValue.getTotalBat()); - } - jsonObject.put("timeEle",timeJsonObject); - } - //指定日期当月的每天电能消耗 - if(electricQueryParam.getDateType()==2){ - LocalDate firstday = LocalDate.of(timeDate.getYear(), timeDate.getMonthValue(), 1); - LocalDate lastDay = timeDate.with(TemporalAdjusters.lastDayOfMonth()); - List timeMonthEleValueList = parEleValueServiceBiz.list(new QueryWrapper() - .eq("kiln_id", kiln) - .between("create_time", firstday, lastDay.plusDays(1)) - .eq("date_type", 1) - .orderByAsc("create_time")); - //总耗电量 - Float dateCountEle=0F; - if (timeMonthEleValueList.size()!=0){ - dateCountEle= timeMonthEleValueList.get(timeMonthEleValueList.size()-1).getTotalBat()-timeMonthEleValueList.get(0).getTotalBat(); - } - jsonObject.put("dateCountEle",dateCountEle); - Map timeJsonObject=new LinkedHashMap(); - for (ParEleValue parEleValue:timeMonthEleValueList - ) { - LocalDate localDate = parEleValue.getCreateTime().toLocalDate(); - timeJsonObject.put(localDate.toString(),parEleValue.getTotalBat()); - } - jsonObject.put("timeEle",timeJsonObject); - } - //指定日期当年的每月电能消耗 - if(electricQueryParam.getDateType()==2){ - LocalDate firstDay = timeDate.with(TemporalAdjusters.firstDayOfYear()); - LocalDate lastDay = timeDate.with(TemporalAdjusters.lastDayOfYear()); - List timeYearEleValueList = parEleValueServiceBiz.list(new QueryWrapper() - .eq("kiln_id", kiln) - .between("create_time", firstDay, lastDay.plusDays(1)) - .eq("date_type", 2) - .orderByAsc("create_time")); - //总耗电量 - Float dateCountEle=0F; - if (timeYearEleValueList.size()!=0){ - dateCountEle= timeYearEleValueList.get(timeYearEleValueList.size()-1).getTotalBat()-timeYearEleValueList.get(0).getTotalBat(); - } - jsonObject.put("dateCountEle",dateCountEle); - Map timeJsonObject=new LinkedHashMap(); - for (ParEleValue parEleValue:timeYearEleValueList - ) { - LocalDate localDate = parEleValue.getCreateTime().toLocalDate(); - timeJsonObject.put(localDate.toString(),parEleValue.getTotalBat()); - } - jsonObject.put("timeEle",timeJsonObject); - } - return successful(jsonObject.toJSONString()); - } @PostMapping(value = "energyList") @ApiOperation(value = "根据加工炉id获取能源消耗情况") public R energyList(@Validated({Default.class}) @RequestBody ElectricQueryParam electricQueryParam){ @@ -534,5 +405,142 @@ public class EnergyController extends BaseController { BigDecimal b1 = new BigDecimal(Float.toString(b)); return a1.subtract(b1).floatValue(); } + @PostMapping(value = "checkResultList") + @ApiOperation(value = "根据生产单号获取apms检验结果") + public List getApmsCheckResult(String sheetNo){ + return apmsCheckResultServiceBiz.list(new QueryWrapper().eq(ApmsCheckResult.SHEET_NO,sheetNo)); + } + @PostMapping(value = "eletric") + @ApiOperation(value = "根据任务id获取消耗情况") + public R list(@Validated({Default.class}) @RequestBody ElectricQueryParam electricQueryParam) { + Long kiln = electricQueryParam.getKilnId(); + //工业炉id为0代表全部,存储的时候计算全部 + JSONObject jsonObject=new JSONObject(); + //指定时间节点 + LocalDate timeDate = electricQueryParam.getTime().toLocalDate(); + LocalDateTime timeStart = LocalDateTime.of(timeDate, LocalTime.MIN); + LocalDateTime timeEnd = LocalDateTime.of(timeDate, LocalTime.MAX); + //当前时间节点 + LocalDateTime todayStart = LocalDateTime.of(LocalDate.now(), LocalTime.MIN); + LocalDateTime todayEnd = LocalDateTime.of(LocalDate.now(), LocalTime.MAX); + + //总电能消耗 + List todayEleValueList = parEleValueServiceBiz.list(new QueryWrapper() + .eq("kiln_id", kiln) + .between("create_time", todayStart, todayEnd) + .orderByDesc("create_time")); + Float countEleValue = todayEleValueList.get(0).getTotalBat(); + jsonObject.put("countEle",countEleValue); + + //昨日电能消耗 + LocalDateTime yesterdayStart = LocalDateTime.of(LocalDate.now().plus(1, ChronoUnit.DAYS), LocalTime.MIN); + LocalDateTime yesterdayEnd = LocalDateTime.of(LocalDate.now().plus(1, ChronoUnit.DAYS), LocalTime.MAX); + List yesterdayEleValueList = parEleValueServiceBiz.list(new QueryWrapper() + .eq("kiln_id", kiln) + .between("create_time", yesterdayStart, yesterdayEnd) + .eq("date_type",0) + .orderByAsc("create_time")); + Float yesterdayTotalBat= yesterdayEleValueList.get(yesterdayEleValueList.size()-1).getTotalBat()-yesterdayEleValueList.get(0).getTotalBat(); + jsonObject.put("yesterdayCountEle",yesterdayTotalBat); + + //指定日期当天的电能消耗 + if (electricQueryParam.getDateType()==0){ + List dateEleValueList = parEleValueServiceBiz.list(new QueryWrapper() + .eq("kiln_id", kiln) + .between("create_time", timeStart, timeEnd) + .orderByAsc("create_time")); + //总耗电量 + Float dateCountEle=0F; + if (dateEleValueList.size()!=0){ + dateCountEle= dateEleValueList.get(dateEleValueList.size()-1).getTotalBat()-dateEleValueList.get(0).getTotalBat(); + } + jsonObject.put("dateCountEle",dateCountEle); + //分时消耗量 + Map timeJsonObject=new LinkedHashMap(); + for (int i = 0; i < dateEleValueList.size() - 1; ++i) { + // TODO: 2021/12/16 + float eleValue = dateEleValueList.get(i).getTotalBat() - dateEleValueList.get(i - 1).getTotalBat(); + int j=i+1; + if (j%2==0){ + String time=(j-1)/2+":30"; + timeJsonObject.put(time,eleValue); + }else { + String time=(j-1)/2+":00"; + timeJsonObject.put(time,eleValue); + } + } + jsonObject.put("timeEle",timeJsonObject); + } + //指定日期当周的每天电能消耗 + if(electricQueryParam.getDateType()==1){ + LocalDate monday = timeDate.with(DayOfWeek.MONDAY); + LocalDate sunday = timeDate.with(DayOfWeek.SUNDAY); + List timeWeekEleValueList = parEleValueServiceBiz.list(new QueryWrapper() + .eq("kiln_id", kiln) + .between("create_time", monday, sunday.plusDays(1)) + .eq("date_type", 1) + .orderByAsc("create_time")); + //总耗电量 + Float dateCountEle=0F; + if (timeWeekEleValueList.size()!=0){ + dateCountEle= timeWeekEleValueList.get(timeWeekEleValueList.size()-1).getTotalBat()-timeWeekEleValueList.get(0).getTotalBat(); + } + jsonObject.put("dateCountEle",dateCountEle); + Map timeJsonObject=new LinkedHashMap(); + for (ParEleValue parEleValue:timeWeekEleValueList + ) { + LocalDate localDate = parEleValue.getCreateTime().toLocalDate(); + timeJsonObject.put(localDate.toString(),parEleValue.getTotalBat()); + } + jsonObject.put("timeEle",timeJsonObject); + } + //指定日期当月的每天电能消耗 + if(electricQueryParam.getDateType()==2){ + LocalDate firstday = LocalDate.of(timeDate.getYear(), timeDate.getMonthValue(), 1); + LocalDate lastDay = timeDate.with(TemporalAdjusters.lastDayOfMonth()); + List timeMonthEleValueList = parEleValueServiceBiz.list(new QueryWrapper() + .eq("kiln_id", kiln) + .between("create_time", firstday, lastDay.plusDays(1)) + .eq("date_type", 1) + .orderByAsc("create_time")); + //总耗电量 + Float dateCountEle=0F; + if (timeMonthEleValueList.size()!=0){ + dateCountEle= timeMonthEleValueList.get(timeMonthEleValueList.size()-1).getTotalBat()-timeMonthEleValueList.get(0).getTotalBat(); + } + jsonObject.put("dateCountEle",dateCountEle); + Map timeJsonObject=new LinkedHashMap(); + for (ParEleValue parEleValue:timeMonthEleValueList + ) { + LocalDate localDate = parEleValue.getCreateTime().toLocalDate(); + timeJsonObject.put(localDate.toString(),parEleValue.getTotalBat()); + } + jsonObject.put("timeEle",timeJsonObject); + } + //指定日期当年的每月电能消耗 + if(electricQueryParam.getDateType()==2){ + LocalDate firstDay = timeDate.with(TemporalAdjusters.firstDayOfYear()); + LocalDate lastDay = timeDate.with(TemporalAdjusters.lastDayOfYear()); + List timeYearEleValueList = parEleValueServiceBiz.list(new QueryWrapper() + .eq("kiln_id", kiln) + .between("create_time", firstDay, lastDay.plusDays(1)) + .eq("date_type", 2) + .orderByAsc("create_time")); + //总耗电量 + Float dateCountEle=0F; + if (timeYearEleValueList.size()!=0){ + dateCountEle= timeYearEleValueList.get(timeYearEleValueList.size()-1).getTotalBat()-timeYearEleValueList.get(0).getTotalBat(); + } + jsonObject.put("dateCountEle",dateCountEle); + Map timeJsonObject=new LinkedHashMap(); + for (ParEleValue parEleValue:timeYearEleValueList + ) { + LocalDate localDate = parEleValue.getCreateTime().toLocalDate(); + timeJsonObject.put(localDate.toString(),parEleValue.getTotalBat()); + } + jsonObject.put("timeEle",timeJsonObject); + } + return successful(jsonObject.toJSONString()); + } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskHisQueryParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskHisQueryParam.java index bb428f9..9ff4817 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskHisQueryParam.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskHisQueryParam.java @@ -28,4 +28,6 @@ public class TaskHisQueryParam extends BasePageParam { private LocalDateTime startTime; @ApiModelProperty(value = "结束时间", example = "2021-11-25T12:05:20") private LocalDateTime endTime; + @ApiModelProperty(value = "生产单号", example = "1219391") + private String sheetNo; } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/TaskHisServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/TaskHisServiceImpl.java index 515c41d..1f2761b 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/TaskHisServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/TaskHisServiceImpl.java @@ -13,6 +13,7 @@ import com.mt.wms.empty.params.TaskHisQueryParam; import com.mt.wms.empty.service.TaskHisService; import com.mt.wms.empty.vo.CurrTaskVo; import com.mt.wms.empty.vo.TaskHisQueryVo; +import org.apache.commons.lang.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -52,6 +53,7 @@ public class TaskHisServiceImpl extends BaseService implements TaskHisService { @Override public R> taskHisPage(TaskHisQueryParam param) { QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(StringUtils.isNotBlank(param.getSheetNo()),TaskHis.SHEET_NO,param.getSheetNo()); queryWrapper.between(Objects.nonNull(param.getStartTime()) && Objects.nonNull(param.getEndTime()), TaskHis.CREATE_TIME, param.getStartTime(), param.getEndTime()) .eq(TaskHis.VALID, 1).orderByDesc(TaskHis.CREATE_TIME); Page page = taskHisService.page(new Page<>(param.getCurrent(), param.getSize()), queryWrapper);