报警信息接口
This commit is contained in:
		@@ -0,0 +1,45 @@
 | 
			
		||||
package com.mt.wms.empty.controller;
 | 
			
		||||
 | 
			
		||||
import com.mt.wms.core.base.BaseController;
 | 
			
		||||
import com.mt.wms.core.constants.CommonConstant;
 | 
			
		||||
import com.mt.wms.core.validator.groups.PageGroup;
 | 
			
		||||
import com.mt.wms.core.vo.PageVo;
 | 
			
		||||
import com.mt.wms.core.vo.R;
 | 
			
		||||
import com.mt.wms.empty.params.AlarmInfoQueryParam;
 | 
			
		||||
import com.mt.wms.empty.service.AlarmInfoService;
 | 
			
		||||
import com.mt.wms.empty.vo.AlarmInfoVo;
 | 
			
		||||
import io.swagger.annotations.Api;
 | 
			
		||||
import io.swagger.annotations.ApiOperation;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import org.springframework.web.bind.annotation.PostMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestBody;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import javax.validation.groups.Default;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author: liguanghao
 | 
			
		||||
 * @Date: 2021/12/16 19:22
 | 
			
		||||
 * @Version 1.0
 | 
			
		||||
 */
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping(CommonConstant.API_MODULE_BASE + "alarmInfo")
 | 
			
		||||
@Slf4j
 | 
			
		||||
@Api(value = "报警信息相关接口", tags = "报警信息相关接口", hidden = false)
 | 
			
		||||
public class AlarmInfoController extends BaseController {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private AlarmInfoService alarmInfoService;
 | 
			
		||||
 | 
			
		||||
    @PostMapping(value = "page")
 | 
			
		||||
    @ApiOperation(value = "获取分页报警基础信息")
 | 
			
		||||
    private R<PageVo<AlarmInfoVo>> page(@Validated({PageGroup.class, Default.class}) @RequestBody AlarmInfoQueryParam alarmInfoQueryParam) {
 | 
			
		||||
        return alarmInfoService.page(alarmInfoQueryParam);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,99 @@
 | 
			
		||||
package com.mt.wms.empty.controller;
 | 
			
		||||
 | 
			
		||||
import com.alibaba.fastjson.JSONObject;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
			
		||||
import com.google.gson.JsonObject;
 | 
			
		||||
import com.mt.wms.core.base.BaseController;
 | 
			
		||||
import com.mt.wms.core.constants.CommonConstant;
 | 
			
		||||
import com.mt.wms.core.dal.entity.ParEleValue;
 | 
			
		||||
import com.mt.wms.core.dal.service.ParEleValueServiceBiz;
 | 
			
		||||
import com.mt.wms.core.vo.R;
 | 
			
		||||
import com.mt.wms.empty.params.ElectricQueryParam;
 | 
			
		||||
import io.swagger.annotations.Api;
 | 
			
		||||
import io.swagger.annotations.ApiOperation;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import org.springframework.web.bind.annotation.PostMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestBody;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import javax.validation.groups.Default;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.time.LocalTime;
 | 
			
		||||
import java.time.temporal.ChronoUnit;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author: liguanghao
 | 
			
		||||
 * @Date: 2021/12/16 11:20
 | 
			
		||||
 * @Version 1.0
 | 
			
		||||
 */
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping(CommonConstant.API_MODULE_BASE + "electric")
 | 
			
		||||
@Slf4j
 | 
			
		||||
@Api(value = "电能消耗相关接口", tags = "电能消耗相关接口", hidden = false)
 | 
			
		||||
public class ElectricController extends BaseController {
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ParEleValueServiceBiz parEleValueServiceBiz;
 | 
			
		||||
 | 
			
		||||
    @PostMapping(value = "eletric")
 | 
			
		||||
    @ApiOperation(value = "根据窑炉id获取电能消耗情况")
 | 
			
		||||
    private R<String> list(@Validated({Default.class}) @RequestBody ElectricQueryParam electricQueryParam) {
 | 
			
		||||
        Long kiln = electricQueryParam.getKilnId();
 | 
			
		||||
        //窑炉id为0代表全部
 | 
			
		||||
        if (kiln==0){
 | 
			
		||||
 | 
			
		||||
        }else {
 | 
			
		||||
            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)
 | 
			
		||||
                    .orderByAsc("create_time"));
 | 
			
		||||
            Float yesterdayTotalBat= yesterdayEleValueList.get(yesterdayEleValueList.size()-1).getTotalBat()-yesterdayEleValueList.get(0).getTotalBat();
 | 
			
		||||
            jsonObject.put("yesterdayCountEle",yesterdayTotalBat);
 | 
			
		||||
 | 
			
		||||
            //指定日期当天的电能消耗
 | 
			
		||||
            if (electricQueryParam.getDateType()==1){
 | 
			
		||||
                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);
 | 
			
		||||
                //分时消耗量
 | 
			
		||||
                for (int i = 0; i < dateEleValueList.size() - 1; ++i) {
 | 
			
		||||
                    // TODO: 2021/12/16
 | 
			
		||||
                    float eleValue = dateEleValueList.get(i).getTotalBat() - dateEleValueList.get(i - 1).getTotalBat();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,38 @@
 | 
			
		||||
package com.mt.wms.empty.params;
 | 
			
		||||
 | 
			
		||||
import com.mt.wms.core.base.BaseParam;
 | 
			
		||||
import com.mt.wms.core.params.BasePageParam;
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
import lombok.experimental.Accessors;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author: liguanghao
 | 
			
		||||
 * @Date: 2021/12/16 19:03
 | 
			
		||||
 * @Version 1.0
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = false)
 | 
			
		||||
@Accessors(chain = true)
 | 
			
		||||
@ApiModel(value = "报警信息查询参数", description = "报警信息查询参数")
 | 
			
		||||
public class AlarmInfoQueryParam extends BasePageParam {
 | 
			
		||||
 | 
			
		||||
    private static final long serialVersionUID = 1L;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "设备ID", required = false)
 | 
			
		||||
    private Long equipmentID;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "报警类型", required = true)
 | 
			
		||||
    private Integer type;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "开始时间", required = false)
 | 
			
		||||
    private LocalDateTime startTime;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "结束时间", required = false)
 | 
			
		||||
    private LocalDateTime endTime;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,34 @@
 | 
			
		||||
package com.mt.wms.empty.params;
 | 
			
		||||
 | 
			
		||||
import com.mt.wms.core.base.BaseParam;
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
import lombok.experimental.Accessors;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author: liguanghao
 | 
			
		||||
 * @Date: 2021/12/16 11:03
 | 
			
		||||
 * @Version 1.0
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = false)
 | 
			
		||||
@Accessors(chain = true)
 | 
			
		||||
@ApiModel(value = "电能消耗查询参数", description = "电能消耗查询参数")
 | 
			
		||||
public class ElectricQueryParam extends BaseParam {
 | 
			
		||||
 | 
			
		||||
    private static final long serialVersionUID = 1L;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "窑炉id", required = true)
 | 
			
		||||
    private Long kilnId;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "时间节点", required = true)
 | 
			
		||||
    private LocalDateTime time;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "时间类型:1 天,2 周,3 月,4 年", required = true)
 | 
			
		||||
    private Integer dateType;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,24 @@
 | 
			
		||||
package com.mt.wms.empty.service;
 | 
			
		||||
 | 
			
		||||
import com.mt.wms.basic.params.AlarmBaseQueryParam;
 | 
			
		||||
import com.mt.wms.basic.vo.AlarmBaseVo;
 | 
			
		||||
import com.mt.wms.core.dal.entity.AlarmInfo;
 | 
			
		||||
import com.mt.wms.core.vo.PageVo;
 | 
			
		||||
import com.mt.wms.core.vo.R;
 | 
			
		||||
import com.mt.wms.empty.params.AlarmInfoQueryParam;
 | 
			
		||||
import com.mt.wms.empty.vo.AlarmInfoVo;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author: liguanghao
 | 
			
		||||
 * @Date: 2021/12/16 19:19
 | 
			
		||||
 * @Version 1.0
 | 
			
		||||
 */
 | 
			
		||||
public interface AlarmInfoService {
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取xx分页列表
 | 
			
		||||
     *
 | 
			
		||||
     * @param alarmInfoQueryParam xx查询参数
 | 
			
		||||
     * @return xx分页列表
 | 
			
		||||
     */
 | 
			
		||||
    R<PageVo<AlarmInfoVo>> page(AlarmInfoQueryParam alarmInfoQueryParam);
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,42 @@
 | 
			
		||||
package com.mt.wms.empty.service.impl;
 | 
			
		||||
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import com.mt.wms.core.base.BaseService;
 | 
			
		||||
import com.mt.wms.core.dal.entity.AlarmInfo;
 | 
			
		||||
import com.mt.wms.core.dal.service.AlarmInfoServiceBiz;
 | 
			
		||||
import com.mt.wms.core.vo.PageVo;
 | 
			
		||||
import com.mt.wms.core.vo.R;
 | 
			
		||||
import com.mt.wms.empty.params.AlarmInfoQueryParam;
 | 
			
		||||
import com.mt.wms.empty.service.AlarmInfoService;
 | 
			
		||||
import com.mt.wms.empty.vo.AlarmInfoVo;
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author: liguanghao
 | 
			
		||||
 * @Date: 2021/12/16 19:21
 | 
			
		||||
 * @Version 1.0
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
@Transactional
 | 
			
		||||
public class AlarmInfoServiceImpl extends BaseService implements AlarmInfoService {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private AlarmInfoServiceBiz alarmInfoServiceBiz;
 | 
			
		||||
    @Override
 | 
			
		||||
    public R<PageVo<AlarmInfoVo>> page(AlarmInfoQueryParam alarmInfoQueryParam) {
 | 
			
		||||
 | 
			
		||||
        QueryWrapper<AlarmInfo> wrapper = new QueryWrapper<>();
 | 
			
		||||
        wrapper.between(alarmInfoQueryParam.getStartTime() != null, AlarmInfo.CREATE_TIME, alarmInfoQueryParam.getStartTime(), alarmInfoQueryParam.getEndTime())
 | 
			
		||||
                .eq(AlarmInfo.TYPE, alarmInfoQueryParam.getType())
 | 
			
		||||
                .eq(alarmInfoQueryParam.getEquipmentID() != null, AlarmInfo.EQUIPMENT_ID, alarmInfoQueryParam.getEquipmentID())
 | 
			
		||||
                .orderByDesc(AlarmInfo.CREATE_TIME);
 | 
			
		||||
        Page<AlarmInfo> page = alarmInfoServiceBiz.page(new Page<>(alarmInfoQueryParam.getCurrent(), alarmInfoQueryParam.getSize()), wrapper);
 | 
			
		||||
        return successful(new PageVo<>(page, AlarmInfoVo.class));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -109,7 +109,7 @@ public class AsynRunTaskService extends BaseService {
 | 
			
		||||
        currTask.setLocationId(location.getId());
 | 
			
		||||
        currTask.setLocationName(location.getLocationNameAlias());
 | 
			
		||||
        currTaskServiceBiz.updateById(currTask);
 | 
			
		||||
        // TODO: 2021/12/14  调用车辆填入起终点,得到车辆执行结果
 | 
			
		||||
        // TODO: 2021/12/14  调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认)
 | 
			
		||||
 | 
			
		||||
        if (true){
 | 
			
		||||
            //更新关系表状态为完成
 | 
			
		||||
@@ -133,4 +133,10 @@ public class AsynRunTaskService extends BaseService {
 | 
			
		||||
            // TODO: 2021/12/14 websocket推送到前端
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    //窑炉加工完成,调用车辆入库到缓存区
 | 
			
		||||
    @Async("asyncServiceExecutor")
 | 
			
		||||
    public void asynRunTaskForKilnToWarehouse(Long kilnId,Long vehicleId){
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,6 @@ public class ScheduledTask {
 | 
			
		||||
     */
 | 
			
		||||
    @Scheduled
 | 
			
		||||
    public void taskForStockToKiln(){
 | 
			
		||||
 | 
			
		||||
        //遍历窑炉状态,若加工完毕,查询空车,占用,异步处理,继续遍历下一个窑炉状态
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,52 @@
 | 
			
		||||
package com.mt.wms.empty.vo;
 | 
			
		||||
 | 
			
		||||
import com.mt.wms.core.base.BaseVo;
 | 
			
		||||
import com.mt.wms.core.vo.PageVo;
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Builder;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
import lombok.experimental.Accessors;
 | 
			
		||||
 | 
			
		||||
import javax.validation.constraints.NotNull;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author: liguanghao
 | 
			
		||||
 * @Date: 2021/12/16 19:09
 | 
			
		||||
 * @Version 1.0
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = false)
 | 
			
		||||
@Accessors(chain = true)
 | 
			
		||||
@Builder
 | 
			
		||||
@ApiModel(value = "报警信息视图对象", description = "用于查询报警信息信息")
 | 
			
		||||
public class AlarmInfoVo extends BaseVo implements PageVo.ConvertVo{
 | 
			
		||||
    /**
 | 
			
		||||
     * 主键,自增
 | 
			
		||||
     */
 | 
			
		||||
    @ApiModelProperty(value = "主键", example = "1")
 | 
			
		||||
    private Long id;
 | 
			
		||||
    /**
 | 
			
		||||
     * 添加时间
 | 
			
		||||
     */
 | 
			
		||||
    @ApiModelProperty(value = "添加时间", example = "0")
 | 
			
		||||
    private LocalDateTime createTime;
 | 
			
		||||
    /**
 | 
			
		||||
     * 设备名称
 | 
			
		||||
     */
 | 
			
		||||
    @ApiModelProperty(value = "设备名称",example = "0")
 | 
			
		||||
    private String equipmentName;
 | 
			
		||||
    /**
 | 
			
		||||
     * 报警类型
 | 
			
		||||
     */
 | 
			
		||||
    @ApiModelProperty(value = "报警类型",example = "0")
 | 
			
		||||
    private String alarmType;
 | 
			
		||||
    /**
 | 
			
		||||
     * 报警内容
 | 
			
		||||
     */
 | 
			
		||||
    @ApiModelProperty(value = "报警内容",example = "0")
 | 
			
		||||
    private String alarmInfo;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user