opt:优化点位及任务相关查询,操作

This commit is contained in:
2025-03-09 00:58:57 +08:00
parent 042231c8aa
commit 48dc9de1e0
19 changed files with 257 additions and 77 deletions

View File

@@ -77,6 +77,12 @@ public enum StatusEnum {
SORT_TYPE(ForkMap.of(
"升序", "1", null, "降序", "2", null
)),
POINT_TYPE(ForkMap.of(
"空货架", "0", null, "满货架", "1", null
)),
BIND_TYPE(ForkMap.of(
"解绑", "0", null, "绑定", "1", null
));
/**
* L:label

View File

@@ -60,8 +60,8 @@ public class InterationUtil {
}
return response.toJavaObject(TableDataInfo.class);
} catch (Exception ex) {
log.info("ACS反馈异常----------------------------------------+"+api+",---"+ex.getMessage());
throw new BadRequestException("acs网络不通"+ex.getMessage());
log.error("ACS反馈异常----------------------------------------+"+api+",---"+ex.getMessage());
throw new BadRequestException("ACS反馈异常"+ex.getMessage());
}
}
public static TableDataInfo asyncNotifyExt(String api, JSONObject param) {

View File

@@ -5,6 +5,7 @@ import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.TableDataInfo;
@@ -45,7 +46,7 @@ public class SchBasePointController {
@GetMapping
public ResponseEntity<Object> query(SchBasePointQuery whereJson, PageQuery page) {
return new ResponseEntity<>(TableDataInfo.build(pointService.page(page.build(SchBasePoint.class), whereJson.build())), HttpStatus.OK);
return new ResponseEntity<>(TableDataInfo.build(pointService.queryAll(whereJson, page)), HttpStatus.OK);
}
@PostMapping
@@ -61,9 +62,23 @@ public class SchBasePointController {
@PutMapping
@Log("更新点位")
public ResponseEntity<Object> update(@Validated @RequestBody SchBasePoint entity) {
entity.setUpdate_name(SecurityUtils.getCurrentNickName());
entity.setUpdate_time(DateUtil.now());
pointService.updateById(entity);
LambdaUpdateWrapper<SchBasePoint> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
//绑定或解绑
if (entity.getVehicle_code() != null) {
TableDataInfo result = pointService.bindOrUnbind(entity.getCode(), entity.getVehicle_code(), (entity.getPriority()));
if (!"200".equals(result.getCode())) {
throw new BadRequestException( "地面站点:" + entity.getCode() + "绑定或解绑" + entity.getVehicle_code() + "指令下发CTU返回操作失败失败原因:" +result.getMsg());
}
}
lambdaUpdateWrapper.set(SchBasePoint::getProduct_area, entity.getProduct_area());
lambdaUpdateWrapper.set(SchBasePoint::getRegion_code, entity.getRegion_code());
lambdaUpdateWrapper.set(SchBasePoint::getPoint_type, entity.getPoint_type());
lambdaUpdateWrapper.set(SchBasePoint::getLock_type, entity.getLock_type());
lambdaUpdateWrapper.set(SchBasePoint::getIs_used, entity.getIs_used());
lambdaUpdateWrapper.set(SchBasePoint::getUpdate_name, SecurityUtils.getCurrentNickName());
lambdaUpdateWrapper.set(SchBasePoint::getUpdate_time, DateUtil.now());
lambdaUpdateWrapper.eq(SchBasePoint::getId, entity.getId());
pointService.update(lambdaUpdateWrapper);
return new ResponseEntity<>(HttpStatus.OK);
}

View File

@@ -1,7 +1,13 @@
package org.nl.wms.dispatch_manage.point.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.common.TableDataInfo;
import org.nl.common.domain.entity.PageQuery;
import org.nl.wms.dispatch_manage.point.service.dao.SchBasePoint;
import org.nl.wms.dispatch_manage.point.service.dto.SchBasePointQuery;
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
import org.nl.wms.dispatch_manage.task.service.dto.SchBaseTaskQuery;
import java.util.List;
@@ -15,13 +21,23 @@ import java.util.List;
*/
public interface ISchBasePointService extends IService<SchBasePoint> {
/**
* 查询数据分页
*
* @param whereJson 条件
* @param pageable 分页参数
* @return IPage<SchBaseTask>
*/
IPage<SchBasePoint> queryAll(SchBasePointQuery whereJson, PageQuery pageable);
/**
* 二楼货架与地面站点绑定或解绑
* @param siteCode 点位
* @param shelfCode 货架编号
* @param mode 0解绑1绑定
*/
void bindOrUnbind(String siteCode,String shelfCode,String mode);
TableDataInfo bindOrUnbind(String siteCode, String shelfCode, String mode);
/**
@@ -32,9 +48,10 @@ public interface ISchBasePointService extends IService<SchBasePoint> {
* @param sortType 点位排序规则1升序2降序
* @param pointType 0空载具1满载具
* @param pointCode 点位编码
* @param vehicleIsNull 载具是否为空
* @return List<SchBasePoint>
*/
List<SchBasePoint> checkEndPointTask(String regionCode, String getLockType, String sortType, String
pointType, String pointCode);
pointType, String pointCode, String vehicleIsNull);
}

View File

@@ -1,10 +1,11 @@
package org.nl.wms.dispatch_manage.point.service.dao;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* <p>
* 点位基础表
@@ -100,6 +101,9 @@ public class SchBasePoint implements Serializable {
*/
private String form_data;
/**
* 是否解绑
*/
private String priority;
/**

View File

@@ -1,7 +1,10 @@
package org.nl.wms.dispatch_manage.point.service.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.nl.wms.dispatch_manage.point.service.dao.SchBasePoint;
import org.nl.wms.dispatch_manage.point.service.dto.SchBasePointQuery;
/**
* <p>
@@ -12,5 +15,6 @@ import org.nl.wms.dispatch_manage.point.service.dao.SchBasePoint;
* @since 2024-06-12
*/
public interface SchBasePointMapper extends BaseMapper<SchBasePoint> {
IPage<SchBasePoint> selectPointPage(IPage<SchBasePoint> pages, @Param("whereJson") SchBasePointQuery whereJson);
}

View File

@@ -1,5 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.nl.wms.dispatch_manage.point.service.dao.mapper.SchBasePointMapper">
<select id="selectPointPage" resultType="org.nl.wms.dispatch_manage.point.service.dao.SchBasePoint">
SELECT
t.*
FROM
`sch_base_point` t
<where>
<if test="whereJson.product_area != null">
AND t.product_area = #{whereJson.product_area}
</if>
<if test="whereJson.search != null">
AND t.code LIKE '%${whereJson.search}%'
</if>
<if test="whereJson.region_code != null">
AND t.region_code = #{whereJson.region_code}
</if>
<if test="whereJson.point_type != null">
AND t.point_type = #{whereJson.point_type}
</if>
<if test="whereJson.lock_type != null">
AND t.lock_type = #{whereJson.lock_type}
</if>
</where>
ORDER BY t.create_time
</select>
</mapper>

View File

@@ -13,6 +13,10 @@ import org.nl.wms.dispatch_manage.point.service.dao.SchBasePoint;
@Data
public class SchBasePointQuery extends BaseQuery<SchBasePoint> {
private String search;
private String product_area;
private String region_code;
private String point_type;
private String lock_type;
@Override
public void paramMapping() {

View File

@@ -1,27 +1,33 @@
package org.nl.wms.dispatch_manage.point.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.TableDataInfo;
import org.nl.common.domain.entity.PageQuery;
import org.nl.common.domain.exception.BadRequestException;
import org.nl.common.enums.StatusEnum;
import org.nl.common.utils.SecurityUtils;
import org.nl.wms.dispatch_manage.point.service.ISchBasePointService;
import org.nl.wms.dispatch_manage.point.service.dao.SchBasePoint;
import org.nl.wms.dispatch_manage.point.service.dao.mapper.SchBasePointMapper;
import org.nl.wms.dispatch_manage.point.service.dto.SchBasePointQuery;
import org.nl.wms.dispatch_manage.task.service.ISchBaseTaskService;
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
import org.nl.wms.external_system.acs.service.WmsToAcsService;
import org.nl.wms.stor_manage.struct.service.IStIvtStructattrService;
import org.nl.wms.stor_manage.struct.service.dao.StIvtStructattr;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@@ -46,6 +52,15 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
private IStIvtStructattrService iStIvtStructattrService;
@Override
public IPage<SchBasePoint> queryAll(SchBasePointQuery whereJson, PageQuery page) {
page.setSize(20);
IPage<SchBasePoint> pages = new Page<>(page.getPage() + 1, page.getSize());
pages = this.baseMapper.selectPointPage(pages, whereJson);
return pages;
}
/**
* 二楼货架与地面站点绑定或解绑
*
@@ -55,19 +70,19 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void bindOrUnbind(String siteCode, String shelfCode, String mode) {
public TableDataInfo bindOrUnbind(String siteCode, String shelfCode, String mode) {
List<SchBasePoint> pointList = this.list(new LambdaQueryWrapper<SchBasePoint>().eq(SchBasePoint::getCode, siteCode).eq(SchBasePoint::getIs_used, true));
if (ObjectUtils.isEmpty(pointList)) {
throw new BadRequestException("输入的站点编号有误或被禁用,请检查!");
}
//检查是否为空架
List<StIvtStructattr> stIvtStructattrList = iStIvtStructattrService.list(new LambdaQueryWrapper<StIvtStructattr>()
.eq(StIvtStructattr::getIs_used, true)
.eq(StIvtStructattr::getSect_code, shelfCode));
List<StIvtStructattr> notEmptyList = stIvtStructattrList.stream().filter(r -> StringUtils.isNotBlank(r.getVehicle_code())).collect(Collectors.toList());
if (ObjectUtils.isNotEmpty(notEmptyList)) {
throw new BadRequestException("该货架的货位:" + notEmptyList.get(0).getStruct_code() + ",存在未出库的料箱:" + notEmptyList.get(0).getVehicle_code() + ",请检查!");
}
// List<StIvtStructattr> stIvtStructattrList = iStIvtStructattrService.list(new LambdaQueryWrapper<StIvtStructattr>()
// .eq(StIvtStructattr::getIs_used, true)
// .eq(StIvtStructattr::getSect_code, shelfCode));
// List<StIvtStructattr> notEmptyList = stIvtStructattrList.stream().filter(r -> StringUtils.isNotBlank(r.getVehicle_code())).collect(Collectors.toList());
// if (ObjectUtils.isNotEmpty(notEmptyList)) {
// throw new BadRequestException("该货架的货位:" + notEmptyList.get(0).getStruct_code() + ",存在未出库的料箱:" + notEmptyList.get(0).getVehicle_code() + ",请检查!");
// }
List<SchBasePoint> shelfCodePointList = this.list(new LambdaQueryWrapper<SchBasePoint>().eq(SchBasePoint::getVehicle_code, shelfCode));
LambdaUpdateWrapper<SchBasePoint> wrapper = new LambdaUpdateWrapper<SchBasePoint>()
.eq(SchBasePoint::getCode, siteCode);
@@ -103,22 +118,23 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
.set(SchBasePoint::getUpdate_name, SecurityUtils.getCurrentNickName());
this.update(wrapper);
//绑定状态同步至ACS
wmsToAcsService.bindPodAndBerth(shelfCode,siteCode,mode, "bindPodAndBerth");
return wmsToAcsService.bindPodAndBerth(shelfCode, siteCode, mode, "bindPodAndBerth");
}
/**
* 查询没有搬运任务的空的目标点位
*
* @param regionCode 点位类型
* @param getLockType 锁定状态
* @param sortType 点位排序规则1升序2降序
* @param pointType 0空载具1满载具
* @param pointCode 点位编码
* @param regionCode 点位类型
* @param getLockType 锁定状态
* @param sortType 点位排序规则1升序2降序
* @param pointType 0空载具1满载具
* @param pointCode 点位编码
* @param vehicleIsNull 载具是否为空
* @return List<SchBasePoint>
*/
@Override
public List<SchBasePoint> checkEndPointTask(String regionCode, String getLockType, String sortType, String
pointType, String pointCode) {
pointType, String pointCode, String vehicleIsNull) {
Set<String> pointSets;
List<SchBaseTask> taskList;
List<SchBasePoint> returList = new ArrayList<>();
@@ -135,6 +151,14 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
if (StringUtils.isNotEmpty(pointType)) {
queryWrapper.eq(SchBasePoint::getPoint_type, pointType);
}
if (StringUtils.isNotEmpty(vehicleIsNull)) {
boolean isNull = Boolean.parseBoolean(vehicleIsNull);
if (isNull) {
queryWrapper.isNull(SchBasePoint::getVehicle_code);
} else {
queryWrapper.isNotNull(SchBasePoint::getVehicle_code);
}
}
if (StatusEnum.SORT_TYPE.code("升序").equals(sortType)) {
queryWrapper.orderByAsc(SchBasePoint::getCode);
} else if (StatusEnum.SORT_TYPE.code("降序").equals(sortType)) {

View File

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.TableDataInfo;
import org.nl.common.domain.exception.BadRequestException;
import org.nl.common.enums.StatusEnum;
import org.nl.common.utils.CodeUtil;
@@ -16,6 +17,7 @@ import org.nl.wms.dispatch_manage.point.service.dao.SchBasePoint;
import org.nl.wms.dispatch_manage.task.handler.AbstractTask;
import org.nl.wms.dispatch_manage.task.service.ISchBaseTaskService;
import org.nl.wms.dispatch_manage.task.service.dao.SchBaseTask;
import org.nl.wms.external_system.acs.service.WmsToAcsService;
import org.nl.wms.md_manage.vehicleMater.service.IMdPbVehicleMaterService;
import org.nl.wms.md_manage.vehicleMater.service.dao.MdPbVehicleMater;
import org.nl.wms.stor_manage.record.service.IStIvtStructivtflowService;
@@ -32,7 +34,8 @@ import org.springframework.transaction.annotation.Transactional;
@Service("secondFloorAgvTransfer")
@Slf4j
public class SecondFloorAgvTransferTask extends AbstractTask {
@Autowired
private WmsToAcsService wmsToAcsService;
@Autowired
private IStIvtStructivtflowService structIvtFlowService;
@Autowired
@@ -80,11 +83,19 @@ public class SecondFloorAgvTransferTask extends AbstractTask {
data.put("status", StatusEnum.FORM_STATUS.code("完成"));
this.updateTask(data);
SchBaseTask schBaseTask = iSchBaseTaskService.getOne(new QueryWrapper<SchBaseTask>().eq("task_code", data.getString("task_code")));
//货架解绑
TableDataInfo tableDataInfo = wmsToAcsService.bindPodAndBerth(schBaseTask.getPoint_code3(), schBaseTask.getPoint_code1(), "0", "bindPodAndBerth");
String bindResult = "200".equals(tableDataInfo.getCode()) ? "地面站点:" + schBaseTask.getPoint_code1() + "解绑" + schBaseTask.getPoint_code3() + "指令下发CTU返回解绑成功" :
"地面站点:" + schBaseTask.getPoint_code1() + "解绑" + schBaseTask.getPoint_code3() + "指令下发CTU返回解绑失败请操作站点解绑失败原因" + tableDataInfo.getMsg();
iSchBaseTaskService.update(new LambdaUpdateWrapper<SchBaseTask>()
.set(SchBaseTask::getRemark, bindResult)
.eq(SchBaseTask::getId, schBaseTask.getId()));
//起点位解锁
iSchBasePointService.update(new LambdaUpdateWrapper<SchBasePoint>()
.set(SchBasePoint::getLock_type, StatusEnum.LOCK.code("无锁"))
.set(SchBasePoint::getVehicle_code, null)
.set(SchBasePoint::getUpdate_time, DateUtil.now())
.set(SchBasePoint::getRemark, bindResult)
.set(SchBasePoint::getUpdate_name, SecurityUtils.getCurrentNickName())
.eq(SchBasePoint::getCode, schBaseTask.getPoint_code1()));
//终点点位绑定货架,Point_type为满架

View File

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.TableDataInfo;
import org.nl.common.domain.exception.BadRequestException;
import org.nl.common.enums.StatusEnum;
import org.nl.common.utils.CodeUtil;
@@ -85,7 +86,12 @@ public class SecondFloorEmptyShelfTask extends AbstractTask {
.set(SchBasePoint::getUpdate_name, SecurityUtils.getCurrentNickName())
.eq(SchBasePoint::getCode, schBaseTask.getPoint_code1()));
//货架绑定
iSchBasePointService.bindOrUnbind(schBaseTask.getPoint_code2(), schBaseTask.getVehicle_code(), "1");
TableDataInfo tableDataInfo = iSchBasePointService.bindOrUnbind(schBaseTask.getPoint_code2(), schBaseTask.getVehicle_code(), "1");
String bindResult = "200".equals(tableDataInfo.getCode()) ? "地面站点:" + schBaseTask.getPoint_code2() + "解绑" + schBaseTask.getVehicle_code() + "指令下发CTU返回解绑成功" :
"地面站点:" + schBaseTask.getPoint_code2() + "解绑" + schBaseTask.getVehicle_code() + "指令下发CTU返回解绑失败请操作站点绑定失败原因" + tableDataInfo.getMsg();
iSchBaseTaskService.update(new LambdaUpdateWrapper<SchBaseTask>()
.set(SchBaseTask::getRemark, bindResult)
.eq(SchBaseTask::getId, schBaseTask.getId()));
}

View File

@@ -24,7 +24,7 @@ import java.util.Set;
* @since 2024-05-06
*/
public interface SchBaseTaskMapper extends BaseMapper<SchBaseTask> {
IPage<SchBaseTask> selectPageLeftJoin(IPage<SchBaseTask> pages, @Param("whereJson") SchBaseTaskQuery whereJson, @Param("collect") List<String> collect);
IPage<SchBaseTask> selectPageLeftJoin(IPage<SchBaseTask> pages, @Param("whereJson") SchBaseTaskQuery whereJson, @Param("collect") List<String> collect, @Param("taskTypes") List<String> taskTypes);
List<Map> getByVehicle(@Param("vehicles") List<String> vehicles);

View File

@@ -38,6 +38,12 @@
#{code}
</foreach>
</if>
<if test="taskTypes != null and taskTypes != ''">
AND t.task_type IN
<foreach collection="taskTypes" item="code" separator="," open="(" close=")">
#{code}
</foreach>
</if>
</where>
ORDER BY t.create_time DESC
</select>

View File

@@ -12,6 +12,7 @@ import java.io.Serializable;
public class SchBaseTaskQuery implements Serializable {
private String task_id;
private String task_code;
private String task_type;
private String vehicle_code;
private String point_code;
private String start_time;

View File

@@ -82,8 +82,15 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
whereJson.setUnFinished(StatusEnum.FORM_STATUS.code("执行中"));
}
}
List<String> taskTypes = ObjectUtil.isNotEmpty(whereJson.getTask_type())
? Arrays.stream(whereJson.getTask_type().split(",")).collect(Collectors.toList()) : null;
if (taskTypes != null) {
if (taskTypes.contains("")) {
taskTypes = null;
}
}
IPage<SchBaseTask> pages = new Page<>(page.getPage() + 1, page.getSize());
pages = this.baseMapper.selectPageLeftJoin(pages, whereJson, collect);
pages = this.baseMapper.selectPageLeftJoin(pages, whereJson, collect,taskTypes);
return pages;
}

View File

@@ -79,7 +79,7 @@ public class ApplyShelfScheduleService {
List<SchBasePoint> cxPointLists = iSchBasePointService.checkEndPointTask(
StatusEnum.REGION_INFO.code("二楼AGV产线对接位"),
StatusEnum.LOCK.code("无锁"),
StatusEnum.SORT_TYPE.code("升序"), "0", null);
StatusEnum.SORT_TYPE.code("升序"), "0", null,"false");
if (ObjectUtils.isNotEmpty(cxPointLists)) {
startPointCode = cxPointLists.get(0).getCode();
vehicleCode = cxPointLists.get(0).getVehicle_code();
@@ -87,7 +87,7 @@ public class ApplyShelfScheduleService {
StatusEnum.REGION_INFO.code("二楼CTU货架对接位"),
StatusEnum.LOCK.code("无锁"),
StatusEnum.SORT_TYPE.code("升序"), null, null
);
,"true");
if (ObjectUtils.isNotEmpty(ctuPointList)) {
endPointCode = ctuPointList.get(0).getCode();
}
@@ -96,7 +96,7 @@ public class ApplyShelfScheduleService {
endPointCode = iSchBasePointService.checkEndPointTask(
StatusEnum.REGION_INFO.code("二楼CTU货架对接位"),
StatusEnum.LOCK.code("无锁"),
StatusEnum.SORT_TYPE.code("升序"), null, null
StatusEnum.SORT_TYPE.code("升序"), null, null,"true"
).get(0).getCode();
}
if (StringUtils.isNotBlank(startPointCode) && StringUtils.isNotBlank(endPointCode)) {

View File

@@ -108,7 +108,7 @@ public class TaskScheduleService {
// 终点满足条件
List<SchBasePoint> endPointList = iSchBasePointService.checkEndPointTask(null,
StatusEnum.LOCK.code("无锁"),
StatusEnum.SORT_TYPE.code("升序"), "0",targetCode);
StatusEnum.SORT_TYPE.code("升序"), "0", targetCode, "true");
if (ObjectUtils.isEmpty(endPointList)) {
return;
}