|  |  |  | 
|---|
|  |  |  | private Long id; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiModelProperty(value= "") | 
|---|
|  |  |  | @TableField("ste_id") | 
|---|
|  |  |  | private Integer steId; | 
|---|
|  |  |  | @TableField("rgv_id") | 
|---|
|  |  |  | private Integer rgvId; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiModelProperty(value= "") | 
|---|
|  |  |  | @TableField("ste_no") | 
|---|
|  |  |  | private Integer steNo; | 
|---|
|  |  |  | @TableField("rgv_no") | 
|---|
|  |  |  | private Integer rgvNo; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 0:正常,1:禁用 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public BasCircularShuttle() {} | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public BasCircularShuttle(Integer steId,Integer steNo,Integer status) { | 
|---|
|  |  |  | this.steId = steId; | 
|---|
|  |  |  | this.steNo = steNo; | 
|---|
|  |  |  | public BasCircularShuttle(Integer rgvId,Integer rgvNo,Integer status) { | 
|---|
|  |  |  | this.rgvId = rgvId; | 
|---|
|  |  |  | this.rgvNo = rgvNo; | 
|---|
|  |  |  | this.status = status; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.service.BasCircularShuttleService; | 
|---|
|  |  |  | import com.zy.asrs.service.BasDevpPositionService; | 
|---|
|  |  |  | import com.zy.asrs.service.BasDevpService; | 
|---|
|  |  |  | import com.zy.asrs.utils.SortTheExecutionOfTheCarUtil; | 
|---|
|  |  |  | import com.zy.asrs.utils.Utils; | 
|---|
|  |  |  | import com.zy.core.DevpThread; | 
|---|
|  |  |  | import com.zy.core.News; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Arrays; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public synchronized void updateStePosition() { | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | List<BasCircularShuttle> basCircularShuttleList = basCircularShuttleService.selectList(new EntityWrapper<BasCircularShuttle>().orderBy("ste_id", true)); | 
|---|
|  |  |  | boolean sign = false; | 
|---|
|  |  |  | Integer rgvNo = 0; | 
|---|
|  |  |  | List<BasCircularShuttle> basCircularShuttleList = basCircularShuttleService.selectList(new EntityWrapper<BasCircularShuttle>().orderBy("rgv_id", true)); | 
|---|
|  |  |  | for (BasCircularShuttle basCircularShuttle : basCircularShuttleList){ | 
|---|
|  |  |  | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basCircularShuttle.getSteNo()); | 
|---|
|  |  |  | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basCircularShuttle.getRgvNo()); | 
|---|
|  |  |  | RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); | 
|---|
|  |  |  | if (rgvProtocol.modeType != RgvModeType.AUTO || (rgvProtocol.getStatusType() != RgvStatusType.IDLE && rgvProtocol.getStatusType() != RgvStatusType.SOS1001) ){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sign = true; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | rgvNo = basCircularShuttle.getRgvNo(); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e){ | 
|---|
|  |  |  | if (sign && rgvNo!=0){ | 
|---|
|  |  |  | int[][] ints = new int[basCircularShuttleList.size()][2]; | 
|---|
|  |  |  | for (BasCircularShuttle basCircularShuttle : basCircularShuttleList){ | 
|---|
|  |  |  | ints[basCircularShuttle.getRgvNo()-1] = new int[]{basCircularShuttle.getRgvNo(),basCircularShuttle.getRgvId()}; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String[] oldList = new String[ints.length]; | 
|---|
|  |  |  | for (int[] rgv : ints){ | 
|---|
|  |  |  | oldList[rgv[0]-1] = Arrays.toString(rgv); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int[][] rgvList = SortTheExecutionOfTheCarUtil.ReorderSteId(ints, rgvNo); | 
|---|
|  |  |  | String[] newList = new String[rgvList.length]; | 
|---|
|  |  |  | for (int[] rgv : rgvList){ | 
|---|
|  |  |  | newList[rgv[0]-1] = Arrays.toString(rgv); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | log.info("更新小车排序信息:原始小车号rgvNo={},小车重新排序信息={},小车原始排序信息={}",rgvNo,Arrays.toString(newList),Arrays.toString(oldList)); | 
|---|
|  |  |  | for (BasCircularShuttle basCircularShuttle : basCircularShuttleList){ | 
|---|
|  |  |  | int[] rgv = rgvList[basCircularShuttle.getRgvNo() - 1]; | 
|---|
|  |  |  | basCircularShuttle.setRgvId(rgv[1]); | 
|---|
|  |  |  | basCircularShuttleService.updateById(basCircularShuttle); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("自动更新小车排序信息失败,异常:"+e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | return 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public static void main(String[] args) { | 
|---|
|  |  |  | int[][] ints = new int[][]{{1,1},{2,2},{3,3},{4,4},{5,5},{6,6},{7,7},{8,8},{9,9},{10,10}}; | 
|---|
|  |  |  | int[][] ints = new int[][]{{1,1},{3,3},{2,2},{4,4},{5,5},{6,6},{7,7},{8,8},{9,9},{10,10}}; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int[][] reorderSteId = ReorderSteId(ints, 2); | 
|---|
|  |  |  | for (int[] ste : reorderSteId){ | 
|---|
|  |  |  | 
|---|
|  |  |  | mainService.updateStePosition(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 任务下发 | 
|---|
|  |  |  | mainService.DevpTaskNoRun(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 任务下发 | 
|---|
|  |  |  | mainService.loopSteCharge(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | <!-- 通用查询映射结果 --> | 
|---|
|  |  |  | <resultMap id="BaseResultMap" type="com.zy.asrs.entity.BasCircularShuttle"> | 
|---|
|  |  |  | <id column="id" property="id" /> | 
|---|
|  |  |  | <result column="ste_id" property="steId" /> | 
|---|
|  |  |  | <result column="ste_no" property="steNo" /> | 
|---|
|  |  |  | <result column="rgv_id" property="rgvId" /> | 
|---|
|  |  |  | <result column="rgv_no" property="rgvNo" /> | 
|---|
|  |  |  | <result column="status" property="status" /> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </resultMap> | 
|---|