出库相关接口
This commit is contained in:
		
							
								
								
									
										1765
									
								
								5.数据库/dump-mt_wms_qj-202112230921.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1765
									
								
								5.数据库/dump-mt_wms_qj-202112230921.sql
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -18,7 +18,7 @@ import lombok.experimental.Accessors;
 | 
			
		||||
 * </p>
 | 
			
		||||
 *
 | 
			
		||||
 * @author mt
 | 
			
		||||
 * @since 2021-11-18
 | 
			
		||||
 * @since 2021-12-27
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = false)
 | 
			
		||||
@@ -104,10 +104,10 @@ public class ParEleValue extends Model<ParEleValue> {
 | 
			
		||||
    private Float totalBat;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 扩展字段1
 | 
			
		||||
     * 时间段类型。0:半小时,1:天,2:月
 | 
			
		||||
     */
 | 
			
		||||
    @TableField("add_a")
 | 
			
		||||
    private Float addA;
 | 
			
		||||
    @TableField("date_type")
 | 
			
		||||
    private Integer dateType;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 扩展字段2
 | 
			
		||||
@@ -166,7 +166,7 @@ public class ParEleValue extends Model<ParEleValue> {
 | 
			
		||||
 | 
			
		||||
    public static final String TOTAL_BAT = "total_bat";
 | 
			
		||||
 | 
			
		||||
    public static final String ADD_A = "add_a";
 | 
			
		||||
    public static final String DATE_TYPE = "date_type";
 | 
			
		||||
 | 
			
		||||
    public static final String ADD_B = "add_b";
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 | 
			
		||||
 * </p>
 | 
			
		||||
 *
 | 
			
		||||
 * @author mt
 | 
			
		||||
 * @since 2021-11-18
 | 
			
		||||
 * @since 2021-12-27
 | 
			
		||||
 */
 | 
			
		||||
public interface ParEleValueMapper extends BaseMapper<ParEleValue> {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@
 | 
			
		||||
        <result column="b_current_value" property="bCurrentValue" />
 | 
			
		||||
        <result column="c_current_value" property="cCurrentValue" />
 | 
			
		||||
        <result column="total_bat" property="totalBat" />
 | 
			
		||||
        <result column="add_a" property="addA" />
 | 
			
		||||
        <result column="date_type" property="dateType" />
 | 
			
		||||
        <result column="add_b" property="addB" />
 | 
			
		||||
        <result column="add_c" property="addC" />
 | 
			
		||||
        <result column="orther_a" property="ortherA" />
 | 
			
		||||
@@ -27,7 +27,7 @@
 | 
			
		||||
 | 
			
		||||
    <!-- 通用查询结果列 -->
 | 
			
		||||
    <sql id="Base_Column_List">
 | 
			
		||||
        id, create_time, inter_code, status, kiln_id, par_id, a_voltagev_value, b_voltagev_value, c_voltagev_value, a_current_value, b_current_value, c_current_value, total_bat, add_a, add_b, add_c, orther_a, orther_b, orther_c
 | 
			
		||||
        id, create_time, inter_code, status, kiln_id, par_id, a_voltagev_value, b_voltagev_value, c_voltagev_value, a_current_value, b_current_value, c_current_value, total_bat, date_type, add_b, add_c, orther_a, orther_b, orther_c
 | 
			
		||||
    </sql>
 | 
			
		||||
 | 
			
		||||
</mapper>
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 | 
			
		||||
 * </p>
 | 
			
		||||
 *
 | 
			
		||||
 * @author mt
 | 
			
		||||
 * @since 2021-11-18
 | 
			
		||||
 * @since 2021-12-27
 | 
			
		||||
 */
 | 
			
		||||
public interface ParEleValueServiceBiz extends IService<ParEleValue> {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
 | 
			
		||||
 * </p>
 | 
			
		||||
 *
 | 
			
		||||
 * @author mt
 | 
			
		||||
 * @since 2021-11-18
 | 
			
		||||
 * @since 2021-12-27
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class ParEleValueServiceBizImpl extends ServiceImpl<ParEleValueMapper, ParEleValue> implements ParEleValueServiceBiz {
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ import com.mt.wms.empty.params.ElectricQueryParam;
 | 
			
		||||
import io.swagger.annotations.Api;
 | 
			
		||||
import io.swagger.annotations.ApiOperation;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import org.springframework.web.bind.annotation.PostMapping;
 | 
			
		||||
@@ -19,12 +20,17 @@ import org.springframework.web.bind.annotation.RequestBody;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.PostConstruct;
 | 
			
		||||
import javax.validation.groups.Default;
 | 
			
		||||
import java.time.DayOfWeek;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.time.LocalTime;
 | 
			
		||||
import java.time.temporal.ChronoUnit;
 | 
			
		||||
import java.time.temporal.TemporalAdjusters;
 | 
			
		||||
import java.util.LinkedHashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author: liguanghao
 | 
			
		||||
@@ -37,6 +43,34 @@ import java.util.List;
 | 
			
		||||
@Api(value = "电能消耗相关接口", tags = "电能消耗相关接口", hidden = false)
 | 
			
		||||
public class ElectricController extends BaseController {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    //@PostConstruct
 | 
			
		||||
    public void test(){
 | 
			
		||||
        LocalDateTime time=LocalDateTime.of(2021, 3, 31, 0, 0, 0);
 | 
			
		||||
        Float f=29000F;
 | 
			
		||||
 | 
			
		||||
        LocalDate timeDate=time.toLocalDate();
 | 
			
		||||
        LocalDateTime timeEnd = LocalDateTime.of(timeDate, LocalTime.MAX).minus(5,ChronoUnit.SECONDS);
 | 
			
		||||
        for (int i = 0; i < 10; i++) {
 | 
			
		||||
 | 
			
		||||
            ParEleValue parEleValue=new ParEleValue();
 | 
			
		||||
            parEleValue.setDateType(2);
 | 
			
		||||
            parEleValue.setParId(1);
 | 
			
		||||
            parEleValue.setKilnId(1);
 | 
			
		||||
            parEleValue.setTotalBat(Float.valueOf(String.valueOf(f+(Math.random()*24000))));
 | 
			
		||||
            parEleValue.setCreateTime(timeEnd);
 | 
			
		||||
            timeEnd=timeEnd.plus(1,ChronoUnit.MONTHS);
 | 
			
		||||
            f=parEleValue.getTotalBat();
 | 
			
		||||
            parEleValueServiceBiz.save(parEleValue);
 | 
			
		||||
            System.out.println(parEleValue);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void test1(){
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ParEleValueServiceBiz parEleValueServiceBiz;
 | 
			
		||||
 | 
			
		||||
@@ -44,10 +78,7 @@ public class ElectricController extends BaseController {
 | 
			
		||||
    @ApiOperation(value = "根据窑炉id获取电能消耗情况")
 | 
			
		||||
    private R<String> list(@Validated({Default.class}) @RequestBody ElectricQueryParam electricQueryParam) {
 | 
			
		||||
        Long kiln = electricQueryParam.getKilnId();
 | 
			
		||||
        //窑炉id为0代表全部
 | 
			
		||||
        if (kiln==0){
 | 
			
		||||
 | 
			
		||||
        }else {
 | 
			
		||||
        //窑炉id为0代表全部,存储的时候计算全部
 | 
			
		||||
            JSONObject jsonObject=new JSONObject();
 | 
			
		||||
            //指定时间节点
 | 
			
		||||
            LocalDate timeDate = electricQueryParam.getTime().toLocalDate();
 | 
			
		||||
@@ -71,12 +102,13 @@ public class ElectricController extends BaseController {
 | 
			
		||||
            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()==1){
 | 
			
		||||
            if (electricQueryParam.getDateType()==0){
 | 
			
		||||
                List<ParEleValue> dateEleValueList = parEleValueServiceBiz.list(new QueryWrapper<ParEleValue>()
 | 
			
		||||
                        .eq("kiln_id", kiln)
 | 
			
		||||
                        .between("create_time", timeStart, timeEnd)
 | 
			
		||||
@@ -88,12 +120,90 @@ public class ElectricController extends BaseController {
 | 
			
		||||
                }
 | 
			
		||||
                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);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
            //指定日期当周的每天电能消耗
 | 
			
		||||
            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());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,9 +24,9 @@ public class AlarmInfoQueryParam extends BasePageParam {
 | 
			
		||||
    private static final long serialVersionUID = 1L;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "设备ID", required = false)
 | 
			
		||||
    private Long equipmentID;
 | 
			
		||||
    private Long equipmentId;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "报警类型", required = true)
 | 
			
		||||
    @ApiModelProperty(value = "报警类型0窑炉,1表示车辆", required = true)
 | 
			
		||||
    private Integer type;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "开始时间", required = false)
 | 
			
		||||
 
 | 
			
		||||
@@ -33,7 +33,7 @@ public class AlarmInfoServiceImpl extends BaseService implements AlarmInfoServic
 | 
			
		||||
        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())
 | 
			
		||||
                .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));
 | 
			
		||||
 
 | 
			
		||||
@@ -3,13 +3,19 @@ package com.mt.wms.empty.service.impl;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
			
		||||
import com.mt.wms.core.base.BaseService;
 | 
			
		||||
import com.mt.wms.core.dal.entity.InStockInfo;
 | 
			
		||||
import com.mt.wms.core.dal.entity.InStockInfoHis;
 | 
			
		||||
import com.mt.wms.core.dal.entity.RunTask;
 | 
			
		||||
import com.mt.wms.core.dal.entity.VehicleInfo;
 | 
			
		||||
import com.mt.wms.core.dal.service.InStockInfoHisServiceBiz;
 | 
			
		||||
import com.mt.wms.core.dal.service.InStockInfoServiceBiz;
 | 
			
		||||
import com.mt.wms.core.dal.service.RunTaskServiceBiz;
 | 
			
		||||
import com.mt.wms.core.dal.service.VehicleInfoServiceBiz;
 | 
			
		||||
import com.mt.wms.core.dal.service.impl.InStockInfoHisServiceBizImpl;
 | 
			
		||||
import com.mt.wms.core.vo.R;
 | 
			
		||||
import com.mt.wms.empty.params.OutStockParam;
 | 
			
		||||
import com.mt.wms.empty.service.OutStockService;
 | 
			
		||||
import com.mt.wms.empty.task.AsynRunTaskService;
 | 
			
		||||
import org.springframework.beans.BeanUtils;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
 | 
			
		||||
@@ -33,11 +39,14 @@ public class OutStockServiceImpl extends BaseService implements OutStockService
 | 
			
		||||
    private AsynRunTaskService asynRunTaskService;
 | 
			
		||||
    @Resource
 | 
			
		||||
    private InStockInfoServiceBiz inStockInfoServiceBiz;
 | 
			
		||||
    @Resource
 | 
			
		||||
    private RunTaskServiceBiz runTaskServiceBiz;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public R<String> outTask(OutStockParam outStockParam) {
 | 
			
		||||
        // TODO: 2021/12/17 出库
 | 
			
		||||
        Long localtionId = outStockParam.getLocaltionId();
 | 
			
		||||
        Long locationId = outStockParam.getLocaltionId();
 | 
			
		||||
        //提升台
 | 
			
		||||
        Integer code = outStockParam.getCode();
 | 
			
		||||
        //查询是否有空闲车辆,若有。占用车辆,若无,返回暂无可用车辆
 | 
			
		||||
@@ -52,14 +61,22 @@ public class OutStockServiceImpl extends BaseService implements OutStockService
 | 
			
		||||
        }else {
 | 
			
		||||
            return R.failed("暂无可用车辆!请稍后重试!");
 | 
			
		||||
        }
 | 
			
		||||
        //生成调度任务
 | 
			
		||||
        RunTask runTask=new RunTask();
 | 
			
		||||
        runTask.setBeginTime(LocalDateTime.now());
 | 
			
		||||
        runTask.setVehicleId(vehicleInfoList.get(0).getId());
 | 
			
		||||
        // TODO: 2021/12/22 库位id对应的位置 ,提升平台对应的位置
 | 
			
		||||
        runTask.setStartPosition("库位位置");
 | 
			
		||||
        runTask.setEndPosition("提升台位置");
 | 
			
		||||
        setCommonField(runTask);
 | 
			
		||||
        runTaskServiceBiz.save(runTask);
 | 
			
		||||
        //异步调用车辆
 | 
			
		||||
        asynRunTaskService.asynRunOutStock();
 | 
			
		||||
        asynRunTaskService.asynRunOutStock(runTask.getId(),locationId);
 | 
			
		||||
        //修改库位状态
 | 
			
		||||
        InStockInfo inStockInfo = inStockInfoServiceBiz
 | 
			
		||||
                .getOne(new QueryWrapper<InStockInfo>().eq("Location_id", localtionId));
 | 
			
		||||
                .getOne(new QueryWrapper<InStockInfo>().eq("Location_id", locationId));
 | 
			
		||||
        inStockInfo.setStatus(1);
 | 
			
		||||
        inStockInfoServiceBiz.updateById(inStockInfo);
 | 
			
		||||
        return R.ok("操作成功");
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -5,9 +5,11 @@ import com.mt.wms.core.base.BaseService;
 | 
			
		||||
import com.mt.wms.core.dal.entity.CurrTaskDet;
 | 
			
		||||
import com.mt.wms.core.dal.entity.InStockInfo;
 | 
			
		||||
import com.mt.wms.core.dal.entity.Location;
 | 
			
		||||
import com.mt.wms.core.dal.entity.OrderInfo;
 | 
			
		||||
import com.mt.wms.core.dal.service.CurrTaskDetServiceBiz;
 | 
			
		||||
import com.mt.wms.core.dal.service.InStockInfoServiceBiz;
 | 
			
		||||
import com.mt.wms.core.dal.service.LocationServiceBiz;
 | 
			
		||||
import com.mt.wms.core.dal.service.OrderInfoServiceBiz;
 | 
			
		||||
import com.mt.wms.core.params.IdParam;
 | 
			
		||||
import com.mt.wms.core.vo.R;
 | 
			
		||||
import com.mt.wms.empty.params.StockInfoQueryParam;
 | 
			
		||||
@@ -36,11 +38,18 @@ public class StockInfoServiceImpl extends BaseService implements StockInfoServic
 | 
			
		||||
    private LocationServiceBiz locationServiceBiz;
 | 
			
		||||
    @Resource
 | 
			
		||||
    private CurrTaskDetServiceBiz currTaskDetServiceBiz;
 | 
			
		||||
    @Resource
 | 
			
		||||
    private OrderInfoServiceBiz orderInfoServiceBiz;
 | 
			
		||||
    @Override
 | 
			
		||||
    public R<List<CurrTaskDetVo>> get(IdParam idParam) {
 | 
			
		||||
        Long taskId = inStockInfoServiceBiz.getById(idParam).getTaskId();
 | 
			
		||||
        List<CurrTaskDet> currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper<CurrTaskDet>().eq("curr_task_id", taskId));
 | 
			
		||||
        List<CurrTaskDetVo> currTaskDetVoList = com.mt.wms.core.utils.BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class);
 | 
			
		||||
        for (CurrTaskDetVo currTaskDetVo:currTaskDetVoList
 | 
			
		||||
             ) {
 | 
			
		||||
            String costomerName = orderInfoServiceBiz.getOne(new QueryWrapper<OrderInfo>().eq("order_no", currTaskDetVo.getOrderNo())).getCustomerName();
 | 
			
		||||
            currTaskDetVo.setCustomer(costomerName);
 | 
			
		||||
        }
 | 
			
		||||
        return successful(currTaskDetVoList);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -55,11 +64,13 @@ public class StockInfoServiceImpl extends BaseService implements StockInfoServic
 | 
			
		||||
            //库位为空
 | 
			
		||||
            if (location.getStatus()!=1){
 | 
			
		||||
                stockInfoVo.setEmpty(1);
 | 
			
		||||
                stockInfoVo.setLocaltionId(location.getId());
 | 
			
		||||
                stockInfoVo.setLocationId(location.getId());
 | 
			
		||||
                stockInfoVo.setLocationName(location.getLocationNameAlias());
 | 
			
		||||
            }else {
 | 
			
		||||
                InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper<InStockInfo>()
 | 
			
		||||
                        .eq("localtion_id", location.getId()));
 | 
			
		||||
                        .eq("location_id", location.getId()));
 | 
			
		||||
                BeanUtils.copyProperties(inStockInfo,stockInfoVo);
 | 
			
		||||
                stockInfoVo.setEmpty(0);
 | 
			
		||||
            }
 | 
			
		||||
            stockInfoVoList.add(stockInfoVo);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,7 @@ import com.mt.wms.core.dal.service.*;
 | 
			
		||||
import com.mt.wms.core.utils.IDGenerator;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
import org.springframework.beans.BeanUtils;
 | 
			
		||||
import org.springframework.scheduling.annotation.Async;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
@@ -32,7 +33,8 @@ public class AsynRunTaskService extends BaseService {
 | 
			
		||||
    private LocationServiceBiz locationServiceBiz;
 | 
			
		||||
    @Resource
 | 
			
		||||
    private InStockInfoServiceBiz inStockInfoServiceBiz;
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private InStockInfoHisServiceBiz inStockInfoHisServiceBiz;
 | 
			
		||||
    //窑炉可用未满的情况下,调用车辆起点为提升台终点为窑炉
 | 
			
		||||
    @Async("asyncServiceExecutor")
 | 
			
		||||
    public void asynRunTask(Long currTaskId,Long vehicleId){
 | 
			
		||||
@@ -84,6 +86,7 @@ public class AsynRunTaskService extends BaseService {
 | 
			
		||||
        runTask.setVehicleId(vehicleId);
 | 
			
		||||
        runTask.setBeginTime(LocalDateTime.now());
 | 
			
		||||
        runTask.setStartPosition(currTask.getStartPosition());
 | 
			
		||||
        // TODO: 2021/12/28 location对应的点位
 | 
			
		||||
        runTask.setEndPosition(location.getCode());
 | 
			
		||||
        runTaskServiceBiz.save(runTask);
 | 
			
		||||
        //更新 location 表对应库位状态为占用
 | 
			
		||||
@@ -135,12 +138,108 @@ public class AsynRunTaskService extends BaseService {
 | 
			
		||||
    }
 | 
			
		||||
    //窑炉加工完成,调用车辆入库到缓存区
 | 
			
		||||
    @Async("asyncServiceExecutor")
 | 
			
		||||
    public void asynRunTaskForKilnToWarehouse(Long kilnId,Long vehicleId){
 | 
			
		||||
 | 
			
		||||
    public void asynRunTaskForKilnToWarehouse(Long currTaskId,Long vehicleId){
 | 
			
		||||
        CurrTask currTask = currTaskServiceBiz.getById(currTaskId);
 | 
			
		||||
        // TODO: 2021/12/28 location排序
 | 
			
		||||
        Location location = locationServiceBiz.list(new QueryWrapper<Location>()
 | 
			
		||||
                .eq(Location.STATUS, 1)
 | 
			
		||||
                .eq(Location.VALID, 1)).get(0);
 | 
			
		||||
        currTask.setOutStartPosition(currTask.getTargetPosition());
 | 
			
		||||
        // TODO: 2021/12/28 location对应的点位
 | 
			
		||||
        currTask.setOutTargetPosition(location.getCode());
 | 
			
		||||
        currTaskServiceBiz.updateById(currTask);
 | 
			
		||||
        //新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位
 | 
			
		||||
        RunTask runTask=new RunTask();
 | 
			
		||||
        setCommonField(runTask);
 | 
			
		||||
        runTask.setTaskId(currTask.getId());
 | 
			
		||||
        runTask.setTaskCode(currTask.getTaskCode());
 | 
			
		||||
        runTask.setVehicleId(vehicleId);
 | 
			
		||||
        runTask.setBeginTime(LocalDateTime.now());
 | 
			
		||||
        runTask.setStartPosition(currTask.getOutStartPosition());
 | 
			
		||||
        runTask.setEndPosition(currTask.getOutTargetPosition());
 | 
			
		||||
        runTaskServiceBiz.save(runTask);
 | 
			
		||||
        //更新 location 表对应库位状态为占用
 | 
			
		||||
        location.setStatus(1);
 | 
			
		||||
        location.setUpdateTime(LocalDateTime.now());
 | 
			
		||||
        locationServiceBiz.updateById(location);
 | 
			
		||||
        currTask.setOutRunTaskId(runTask.getId());
 | 
			
		||||
        currTaskServiceBiz.updateById(currTask);
 | 
			
		||||
        //添加一条库位详情到in_stock_info表
 | 
			
		||||
        InStockInfo inStockInfo=new InStockInfo();
 | 
			
		||||
        inStockInfo.setStatus(1);
 | 
			
		||||
        inStockInfo.setInterCode(IDGenerator.gen("HCT", "yyyyMMddHHmm", 2, "WAREHOUSE_CODE"));
 | 
			
		||||
        inStockInfo.setTaskId(currTask.getId());
 | 
			
		||||
        inStockInfo.setTaskCode(currTask.getTaskCode());
 | 
			
		||||
        inStockInfo.setKilnId(currTask.getKilnId());
 | 
			
		||||
        inStockInfo.setKilnName(currTask.getKilnName());
 | 
			
		||||
        inStockInfo.setLocationId(location.getId());
 | 
			
		||||
        inStockInfo.setLocationName(location.getLocationNameAlias());
 | 
			
		||||
        inStockInfo.setType(0);
 | 
			
		||||
        setCommonField(inStockInfo);
 | 
			
		||||
        inStockInfoServiceBiz.save(inStockInfo);
 | 
			
		||||
        // TODO: 2021/12/14  调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认)
 | 
			
		||||
        if (true){
 | 
			
		||||
            //更新关系表状态为完成
 | 
			
		||||
            runTask.setUpdateTime(LocalDateTime.now());
 | 
			
		||||
            runTask.setStatus(2);
 | 
			
		||||
            runTask.setEndTime(LocalDateTime.now());
 | 
			
		||||
            runTaskServiceBiz.updateById(runTask);
 | 
			
		||||
            //更新currTask表
 | 
			
		||||
            currTask.setIsOut(2);
 | 
			
		||||
            currTask.setUpdateTime(LocalDateTime.now());
 | 
			
		||||
            currTask.setStatus(2);
 | 
			
		||||
            currTaskServiceBiz.updateById(currTask);
 | 
			
		||||
            //更新in_stock_info表
 | 
			
		||||
            inStockInfo.setStatus(2);
 | 
			
		||||
            inStockInfo.setInTime(LocalDateTime.now());
 | 
			
		||||
            inStockInfoServiceBiz.updateById(inStockInfo);
 | 
			
		||||
        }else {
 | 
			
		||||
            runTask.setStatus(3);
 | 
			
		||||
            runTask.setUpdateTime(LocalDateTime.now());
 | 
			
		||||
            runTaskServiceBiz.updateById(runTask);
 | 
			
		||||
            logger.info("任务 "+currTask.getTaskCode()+" 车辆从窑炉到缓存区过程中失败。");
 | 
			
		||||
            // TODO: 2021/12/14 websocket推送到前端
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    //出库。起点为缓存区库位,终点为提升台
 | 
			
		||||
    @Async("asyncServiceExecutor")
 | 
			
		||||
    public void asynRunOutStock(){
 | 
			
		||||
    public void asynRunOutStock(Long runTaskId,Long locationId){
 | 
			
		||||
        //修改调度任务状态
 | 
			
		||||
        RunTask runTask = runTaskServiceBiz.getById(runTaskId);
 | 
			
		||||
        //修改缓存区状态
 | 
			
		||||
        InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper<InStockInfo>()
 | 
			
		||||
                .eq("location_id", locationId));
 | 
			
		||||
        inStockInfo.setStatus(1);
 | 
			
		||||
        inStockInfoServiceBiz.updateById(inStockInfo);
 | 
			
		||||
 | 
			
		||||
        // TODO: 2021/12/14  调用车辆填入起终点,得到车辆执行结果,填入任务号(待确认)
 | 
			
		||||
 | 
			
		||||
        if (true){
 | 
			
		||||
            //更新关系表状态为完成
 | 
			
		||||
            runTask.setUpdateTime(LocalDateTime.now());
 | 
			
		||||
            runTask.setStatus(2);
 | 
			
		||||
            runTask.setEndTime(LocalDateTime.now());
 | 
			
		||||
            runTaskServiceBiz.updateById(runTask);
 | 
			
		||||
            //更新in_stock_info表
 | 
			
		||||
            inStockInfo.setStatus(2);
 | 
			
		||||
            inStockInfo.setInTime(LocalDateTime.now());
 | 
			
		||||
            inStockInfoServiceBiz.updateById(inStockInfo);
 | 
			
		||||
            //缓存区存储历史
 | 
			
		||||
            InStockInfoHis inStockInfoHis=new InStockInfoHis();
 | 
			
		||||
            BeanUtils.copyProperties(inStockInfo,inStockInfoHis);
 | 
			
		||||
            inStockInfoHisServiceBiz.save(inStockInfoHis);
 | 
			
		||||
            inStockInfoServiceBiz.removeById(inStockInfo.getId());
 | 
			
		||||
            //更新库位状态
 | 
			
		||||
            Location location = locationServiceBiz.getById(locationId);
 | 
			
		||||
            location.setStatus(0);
 | 
			
		||||
            locationServiceBiz.updateById(location);
 | 
			
		||||
 | 
			
		||||
        }else {
 | 
			
		||||
            runTask.setStatus(3);
 | 
			
		||||
            runTask.setUpdateTime(LocalDateTime.now());
 | 
			
		||||
            runTaskServiceBiz.updateById(runTask);
 | 
			
		||||
            logger.info("任务 "+runTask.getTaskCode()+" 车辆从缓存区到提升平台过程中失败。");
 | 
			
		||||
            // TODO: 2021/12/14 websocket推送到前端
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -106,7 +106,40 @@ public class RunTaskUtils {
 | 
			
		||||
     * 呼叫车辆暂存缓存区,车辆调度任务结束后,(结束后再查询缓存区队列避免车辆路线冲突)查询该窑炉的缓存区队列,开始下一托盘货物调度进窑炉
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public R runTaskForOutKiln(){
 | 
			
		||||
        return null;
 | 
			
		||||
    public R runTaskForOutKiln(Long kilnId){
 | 
			
		||||
        //查询正在该窑炉加工的currTask
 | 
			
		||||
        CurrTask currTask = currTaskServiceBiz.getOne(new QueryWrapper<CurrTask>()
 | 
			
		||||
                .eq("is_in", 1)
 | 
			
		||||
                .eq("status", 1)
 | 
			
		||||
                .eq("kiln_id", kilnId));
 | 
			
		||||
        //查询缓存区库位是否已满
 | 
			
		||||
        int count = locationServiceBiz.count(new QueryWrapper<Location>()
 | 
			
		||||
                .eq(Location.STATUS, 0)
 | 
			
		||||
                .eq(Location.VALID, 1));
 | 
			
		||||
        //缓存区未满
 | 
			
		||||
        if (count >0) {
 | 
			
		||||
            //查询是否有空闲车辆,若有。占用车辆,若无,返回暂无可用车辆
 | 
			
		||||
            List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>()
 | 
			
		||||
                    .eq(VehicleInfo.STATUS, 0)
 | 
			
		||||
                    .eq(VehicleInfo.VALID, 1));
 | 
			
		||||
            if (vehicleInfoList.size()>0){
 | 
			
		||||
                VehicleInfo vehicleInfo = vehicleInfoList.get(0);
 | 
			
		||||
                vehicleInfo.setStatus(1);
 | 
			
		||||
                vehicleInfo.setUpdateTime(LocalDateTime.now());
 | 
			
		||||
                vehicleInfoServiceBiz.updateById(vehicleInfo);
 | 
			
		||||
            }else {
 | 
			
		||||
                return R.failed("暂无可用车辆!请稍后重试!");
 | 
			
		||||
            }
 | 
			
		||||
            currTask.setIsOut(0);
 | 
			
		||||
            currTask.setTaskType(2);
 | 
			
		||||
            currTask.setUpdateTime(LocalDateTime.now());
 | 
			
		||||
            currTaskServiceBiz.updateById(currTask);
 | 
			
		||||
 | 
			
		||||
            //异步调用车辆
 | 
			
		||||
            asynRunTaskService.asynRunTaskForKilnToWarehouse(currTask.getId(),vehicleInfoList.get(0).getId());
 | 
			
		||||
            return R.ok("操作成功!当前目标窑炉已满,托盘加入缓存区待加工队列。");
 | 
			
		||||
        }else {
 | 
			
		||||
            return R.ok("当前缓存区已满,无法从加工炉出炉到缓存区。");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,34 @@ public class ScheduledTask {
 | 
			
		||||
     */
 | 
			
		||||
    @Scheduled
 | 
			
		||||
    public void taskForStockToKiln(){
 | 
			
		||||
        //遍历窑炉状态,若加工完毕,查询空车,占用,异步处理,继续遍历下一个窑炉状态
 | 
			
		||||
        //遍历currTask为进行中且is_in为正在加工的窑炉状态,若加工完毕,调用runTaskForOutKiln
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //每个小时的0分和30分执行
 | 
			
		||||
    @Scheduled(cron = "0 0/30 * * * ?")
 | 
			
		||||
    //获取全部窑炉每半小时电能消耗数据,计算,存储
 | 
			
		||||
    public void getAllEleValue(){
 | 
			
		||||
        // TODO: 2021/12/27
 | 
			
		||||
        //  获取每台窑炉的电度值,存入par_ele_value,dateType为0,kilnId为窑炉Id
 | 
			
		||||
        //  获取11台窑炉的电度值,相加,存入par_ele_value,dateType为0,kilnId为0
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //每日23:55执行
 | 
			
		||||
    @Scheduled(cron = "0 55 23 * * ?")
 | 
			
		||||
    //获取全部窑炉每天电能消耗数据,计算,存储
 | 
			
		||||
    public void getAllEleValueForDay(){
 | 
			
		||||
        // TODO: 2021/12/27
 | 
			
		||||
        //  获取每台窑炉的电度值,存入par_ele_value,dateType为0,kilnId为窑炉Id
 | 
			
		||||
        //  获取11台窑炉的电度值,相加,存入par_ele_value,dateType为0,kilnId为0
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //每月最后一日23:55执行
 | 
			
		||||
    @Scheduled(cron = "0 55 23 L * ?")
 | 
			
		||||
    //获取全部窑炉每天电能消耗数据,计算,存储
 | 
			
		||||
    public void getAllEleValueForMonth(){
 | 
			
		||||
        // TODO: 2021/12/27
 | 
			
		||||
        //  获取每台窑炉的电度值,存入par_ele_value,dateType为0,kilnId为窑炉Id
 | 
			
		||||
        //  获取11台窑炉的电度值,相加,存入par_ele_value,dateType为0,kilnId为0
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -87,7 +87,7 @@ public class CurrTaskDetVo extends BaseVo implements PageVo.ConvertVo {
 | 
			
		||||
     * 单位
 | 
			
		||||
     */
 | 
			
		||||
    @ApiModelProperty("单位")
 | 
			
		||||
    private Float unit;
 | 
			
		||||
    private String unit;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 数量,手动输入
 | 
			
		||||
 
 | 
			
		||||
@@ -36,12 +36,12 @@ public class StockInfoVo extends BaseVo implements PageVo.ConvertVo{
 | 
			
		||||
     * 库位id
 | 
			
		||||
     */
 | 
			
		||||
    @ApiModelProperty(value = "库位id",example = "0")
 | 
			
		||||
    private Long localtionId;
 | 
			
		||||
    private Long locationId;
 | 
			
		||||
    /**
 | 
			
		||||
     * 库位名称
 | 
			
		||||
     */
 | 
			
		||||
    @ApiModelProperty(value = "库位名称",example = "0")
 | 
			
		||||
    private String localtionName;
 | 
			
		||||
    private String locationName;
 | 
			
		||||
    /**
 | 
			
		||||
     * 任务id
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user