根据生产单号查询检验结果list
This commit is contained in:
parent
a509e54803
commit
f5342d1427
@ -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<String> 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<ParEleValue> todayEleValueList = parEleValueServiceBiz.list(new QueryWrapper<ParEleValue>()
|
||||
.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<ParEleValue> yesterdayEleValueList = parEleValueServiceBiz.list(new QueryWrapper<ParEleValue>()
|
||||
.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<ParEleValue> dateEleValueList = parEleValueServiceBiz.list(new QueryWrapper<ParEleValue>()
|
||||
.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<String,Float> 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<ParEleValue> timeWeekEleValueList = parEleValueServiceBiz.list(new QueryWrapper<ParEleValue>()
|
||||
.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<String,Float> 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<ParEleValue> timeMonthEleValueList = parEleValueServiceBiz.list(new QueryWrapper<ParEleValue>()
|
||||
.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<String,Float> 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<ParEleValue> timeYearEleValueList = parEleValueServiceBiz.list(new QueryWrapper<ParEleValue>()
|
||||
.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<String,Float> 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<String> 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<ApmsCheckResult> getApmsCheckResult(String sheetNo){
|
||||
return apmsCheckResultServiceBiz.list(new QueryWrapper<ApmsCheckResult>().eq(ApmsCheckResult.SHEET_NO,sheetNo));
|
||||
}
|
||||
|
||||
@PostMapping(value = "eletric")
|
||||
@ApiOperation(value = "根据任务id获取消耗情况")
|
||||
public R<String> 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<ParEleValue> todayEleValueList = parEleValueServiceBiz.list(new QueryWrapper<ParEleValue>()
|
||||
.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<ParEleValue> yesterdayEleValueList = parEleValueServiceBiz.list(new QueryWrapper<ParEleValue>()
|
||||
.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<ParEleValue> dateEleValueList = parEleValueServiceBiz.list(new QueryWrapper<ParEleValue>()
|
||||
.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<String,Float> 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<ParEleValue> timeWeekEleValueList = parEleValueServiceBiz.list(new QueryWrapper<ParEleValue>()
|
||||
.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<String,Float> 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<ParEleValue> timeMonthEleValueList = parEleValueServiceBiz.list(new QueryWrapper<ParEleValue>()
|
||||
.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<String,Float> 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<ParEleValue> timeYearEleValueList = parEleValueServiceBiz.list(new QueryWrapper<ParEleValue>()
|
||||
.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<String,Float> 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());
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<PageVo<TaskHisQueryVo>> taskHisPage(TaskHisQueryParam param) {
|
||||
QueryWrapper<TaskHis> 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<TaskHis> page = taskHisService.page(new Page<>(param.getCurrent(), param.getSize()), queryWrapper);
|
||||
|
Loading…
Reference in New Issue
Block a user