add:手持出库确认
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package org.nl.wms.pda.ios_manage.controller;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.pda.ios_manage.service.PdaIosOutService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 手持入库确认 控制层
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-06-06
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/pda/iosOut")
|
||||
@Slf4j
|
||||
public class PdaIosOutController {
|
||||
|
||||
@Autowired
|
||||
private PdaIosOutService pdaIosOutService;
|
||||
|
||||
@PostMapping("/getDtl")
|
||||
@Log("获取库存明细")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> getDtl(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(pdaIosOutService.getDtl(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/confirm")
|
||||
@Log("出库确认")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> confirm(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(pdaIosOutService.confirm(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public interface PdaIosInService {
|
||||
* point_code:点位编码
|
||||
* sect_id:库区
|
||||
* }
|
||||
* @return
|
||||
* @return PdaResponse
|
||||
*/
|
||||
PdaResponse confirmIn(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.nl.wms.pda.ios_manage.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.pda.util.PdaResponse;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 手持IOS 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-06-06
|
||||
*/
|
||||
public interface PdaIosOutService {
|
||||
|
||||
/**
|
||||
* 获取库存明细
|
||||
* @param whereJson {
|
||||
* storagevehicle_code: 载具码
|
||||
* }
|
||||
* @return PdaResponse
|
||||
*/
|
||||
PdaResponse getDtl(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 出库确认
|
||||
* @param whereJson {
|
||||
* storagevehicle_code: 载具码
|
||||
* point_code: 点位编码
|
||||
* }
|
||||
* @return PdaResponse
|
||||
*/
|
||||
PdaResponse confirm(JSONObject whereJson);
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package org.nl.wms.pda.ios_manage.service.impl;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.basedata_manage.service.IStructattrService;
|
||||
import org.nl.wms.basedata_manage.service.dao.Structattr;
|
||||
import org.nl.wms.basedata_manage.service.dao.mapper.MdPbStoragevehicleextMapper;
|
||||
import org.nl.wms.pda.ios_manage.service.PdaIosOutService;
|
||||
import org.nl.wms.pda.util.PdaResponse;
|
||||
import org.nl.wms.sch_manage.enums.TaskEnum;
|
||||
import org.nl.wms.sch_manage.service.ISchBasePointService;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch_manage.service.util.tasks.BackInTask;
|
||||
import org.nl.wms.warehouse_management.enums.IOSConstant;
|
||||
import org.nl.wms.warehouse_management.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_management.service.IRawAssistIStorService;
|
||||
import org.nl.wms.warehouse_management.service.dao.IOStorInvDis;
|
||||
import org.nl.wms.warehouse_management.service.dao.IOStorInvDtl;
|
||||
import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvDisMapper;
|
||||
import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvDtlMapper;
|
||||
import org.nl.wms.warehouse_management.service.util.UpdateIvtUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 手持IOS 实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-06-06
|
||||
*/
|
||||
@Service
|
||||
public class PdaIosOutServiceImpl implements PdaIosOutService {
|
||||
|
||||
/**
|
||||
* 载具扩展属性服务
|
||||
*/
|
||||
@Autowired
|
||||
private MdPbStoragevehicleextMapper mdPbStoragevehicleextMapper;
|
||||
|
||||
/**
|
||||
* 点位服务
|
||||
*/
|
||||
@Autowired
|
||||
private ISchBasePointService iSchBasePointService;
|
||||
|
||||
/**
|
||||
* 仓位服务
|
||||
*/
|
||||
@Autowired
|
||||
private IStructattrService iStructattrService;
|
||||
|
||||
/**
|
||||
* 出入库单明细mapper
|
||||
*/
|
||||
@Autowired
|
||||
private IOStorInvDtlMapper ioStorInvDtlMapper;
|
||||
|
||||
/**
|
||||
* 出入库单分配明细mapper
|
||||
*/
|
||||
@Autowired
|
||||
private IOStorInvDisMapper ioStorInvDisMapper;
|
||||
|
||||
/**
|
||||
* 更新库存服务
|
||||
*/
|
||||
@Autowired
|
||||
private UpdateIvtUtils updateIvtUtils;
|
||||
|
||||
/**
|
||||
* 回库任务类
|
||||
*/
|
||||
@Autowired
|
||||
private BackInTask backInTask;
|
||||
|
||||
/**
|
||||
* 入库服务服务
|
||||
*/
|
||||
@Autowired
|
||||
private IRawAssistIStorService iRawAssistIStorService;
|
||||
|
||||
@Override
|
||||
public PdaResponse getDtl(JSONObject whereJson) {
|
||||
return PdaResponse.requestParamOk(mdPbStoragevehicleextMapper.getIosDtl(whereJson));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public PdaResponse confirm(JSONObject whereJson) {
|
||||
// 获取点位信息
|
||||
SchBasePoint pointDao = iSchBasePointService.getById(whereJson.getString("point_code"));
|
||||
// 获取出入库单明细信息
|
||||
IOStorInvDtl dtlDao = ioStorInvDtlMapper.selectById(pointDao.getIos_id());
|
||||
// 获取点位库存信息
|
||||
JSONObject jsonIvt = mdPbStoragevehicleextMapper.getIosDtl(whereJson).get(0);
|
||||
// 判断是否整出
|
||||
double plan_qty = dtlDao.getPlan_qty().doubleValue();
|
||||
double real_qty = NumberUtil.add(dtlDao.getReal_qty(), jsonIvt.getDoubleValue("qty")).doubleValue();
|
||||
|
||||
if (plan_qty >= real_qty) {
|
||||
// ------整出------
|
||||
// 删除当前库存记录
|
||||
mdPbStoragevehicleextMapper.deleteById(jsonIvt.getString("storagevehicleext_id"));
|
||||
// 释放点位
|
||||
iSchBasePointService.unLockPoint(pointDao.getPoint_code());
|
||||
// 更新明细实际出库重量
|
||||
dtlDao.setReal_qty(BigDecimal.valueOf(real_qty));
|
||||
ioStorInvDtlMapper.updateById(dtlDao);
|
||||
// 更新分配明细实际出库数量
|
||||
IOStorInvDis disDao = ioStorInvDisMapper.selectById(pointDao.getIos_id());
|
||||
disDao.setReal_qty(jsonIvt.getBigDecimal("qty"));
|
||||
ioStorInvDisMapper.updateById(disDao);
|
||||
} else {
|
||||
// ------剩余回库------
|
||||
// 更新库存 :变动数量 = 减可用(库存数量-(实际出库数量-计划数量))
|
||||
jsonIvt.put("type", IOSConstant.UPDATE_IVT_TYPE_SUB_CANUSE_IVT);
|
||||
BigDecimal change_qty = NumberUtil.sub(jsonIvt.getBigDecimal("qty"), NumberUtil.sub(real_qty, plan_qty));
|
||||
jsonIvt.put("change_qty", change_qty);
|
||||
jsonIvt.put("remark", "剩余回库");
|
||||
updateIvtUtils.updateIvt(jsonIvt);
|
||||
// 更新明细实际出库重量(明细计划数量)
|
||||
dtlDao.setReal_qty(BigDecimal.valueOf(plan_qty));
|
||||
ioStorInvDtlMapper.updateById(dtlDao);
|
||||
// 更新分配明细实际出库重量 = 变动数量
|
||||
IOStorInvDis disDao = ioStorInvDisMapper.selectById(pointDao.getIos_id());
|
||||
disDao.setReal_qty(change_qty);
|
||||
|
||||
// 查找入库货位
|
||||
JSONObject paramPoint = new JSONObject();
|
||||
paramPoint.put("sect_id", disDao.getSect_id());
|
||||
paramPoint.put("storagevehicle_code", jsonIvt.getString("storagevehicle_code"));
|
||||
Structattr attrDao = iRawAssistIStorService.autoDis(paramPoint);
|
||||
// 生成回库任务
|
||||
JSONObject task = new JSONObject();
|
||||
task.put("config_code", IOSConstant.BACK_IN_TASK);
|
||||
task.put("point_code1", pointDao.getPoint_code());
|
||||
task.put("point_code2", attrDao.getStruct_code());
|
||||
task.put("vehicle_code", jsonIvt.getString("storagevehicle_code"));
|
||||
task.put("Priority", TaskEnum.ACS_PRIORITY.code("1"));
|
||||
String task_id = backInTask.create(task);
|
||||
|
||||
// 更新终点锁定状态
|
||||
attrDao.setLock_type(IOSEnum.LOCK_TYPE.code("入库锁"));
|
||||
attrDao.setTaskdtl_id(task_id);
|
||||
iStructattrService.updateById(attrDao);
|
||||
}
|
||||
return PdaResponse.requestOk();
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,8 @@ import java.util.Map;
|
||||
@Getter
|
||||
public enum TaskEnum {
|
||||
|
||||
// ACS有限级别
|
||||
ACS_PRIORITY(MapOf.of("1", "1", "2", "2", "3", "4"))
|
||||
// ACS优先级别
|
||||
ACS_PRIORITY(MapOf.of("1", "1", "2", "2", "3", "3"))
|
||||
;
|
||||
|
||||
private Map<String, String> code;
|
||||
|
||||
@@ -83,4 +83,11 @@ public interface ISchBasePointService extends IService<SchBasePoint> {
|
||||
* @return SchBasePoint
|
||||
*/
|
||||
SchBasePoint selectByIdLock(String id);
|
||||
|
||||
/**
|
||||
* 释放点位
|
||||
*
|
||||
* @param point_code 点位编码
|
||||
*/
|
||||
void unLockPoint(String point_code);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ public class SchBasePoint implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "point_code")
|
||||
|
||||
private String point_code;
|
||||
|
||||
|
||||
@@ -124,6 +123,7 @@ public class SchBasePoint implements Serializable {
|
||||
|
||||
private String update_time;
|
||||
|
||||
private String ios_id;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> can_vehicle_types;
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -186,4 +187,14 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
|
||||
return pointMapper.selectByIdLock(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unLockPoint(String point_code) {
|
||||
this.update(
|
||||
new UpdateWrapper<SchBasePoint>().lambda()
|
||||
.eq(SchBasePoint::getPoint_code, point_code)
|
||||
.set(SchBasePoint::getVehicle_code, null)
|
||||
.set(SchBasePoint::getIos_id, null)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
package org.nl.wms.sch_manage.service.util.tasks;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.config.IdUtil;
|
||||
import org.nl.wms.basedata_manage.service.IStructattrService;
|
||||
import org.nl.wms.basedata_manage.service.dao.Structattr;
|
||||
import org.nl.wms.sch_manage.enums.TaskStatus;
|
||||
import org.nl.wms.sch_manage.service.ISchBasePointService;
|
||||
import org.nl.wms.sch_manage.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch_manage.service.util.AbstractTask;
|
||||
import org.nl.wms.sch_manage.service.util.AcsTaskDto;
|
||||
import org.nl.wms.sch_manage.service.util.TaskType;
|
||||
import org.nl.wms.warehouse_management.enums.IOSEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @Author: Liuxy
|
||||
* @Description: 余料回库类
|
||||
* @Date: 2025/6/6
|
||||
*/
|
||||
@Component(value = "BackInTask")
|
||||
@TaskType("BackInTask")
|
||||
public class BackInTask extends AbstractTask {
|
||||
|
||||
/**
|
||||
* 任务服务类
|
||||
*/
|
||||
@Autowired
|
||||
private ISchBaseTaskService taskService;
|
||||
|
||||
/**
|
||||
* 点位服务
|
||||
*/
|
||||
@Autowired
|
||||
private ISchBasePointService iSchBasePointService;
|
||||
|
||||
/**
|
||||
* 仓位服务
|
||||
*/
|
||||
@Autowired
|
||||
private IStructattrService iStructattrService;
|
||||
|
||||
@Override
|
||||
public String create(JSONObject json) {
|
||||
SchBaseTask task = new SchBaseTask();
|
||||
task.setTask_id(IdUtil.getStringId());
|
||||
task.setTask_code(IdUtil.getStringId());
|
||||
task.setTask_status(TaskStatus.CREATE.getCode());
|
||||
task.setConfig_code(json.getString("config_code"));
|
||||
task.setPoint_code1(json.getString("point_code1"));
|
||||
task.setPoint_code2(json.getString("point_code2"));
|
||||
task.setVehicle_code(json.getString("vehicle_code"));
|
||||
task.setRequest_param(json.toString());
|
||||
task.setPriority(json.getString("Priority"));
|
||||
task.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||
task.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
task.setCreate_time(DateUtil.now());
|
||||
taskService.save(task);
|
||||
return task.getTask_id();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AcsTaskDto sendAcsParam(String taskId) {
|
||||
SchBaseTask taskDao = taskService.getById(taskId);
|
||||
|
||||
// 组织下发给acs的数据
|
||||
AcsTaskDto acsTaskDto = new AcsTaskDto();
|
||||
acsTaskDto.setExt_task_uuid(taskDao.getTask_id());
|
||||
acsTaskDto.setTask_code(taskDao.getTask_code());
|
||||
acsTaskDto.setStart_device_code(taskDao.getPoint_code1());
|
||||
acsTaskDto.setNext_device_code(taskDao.getPoint_code2());
|
||||
acsTaskDto.setPriority(taskDao.getPriority());
|
||||
acsTaskDto.setTask_type("1");
|
||||
return acsTaskDto;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateStatus(String task_code, TaskStatus status) {
|
||||
// 校验任务
|
||||
SchBaseTask taskObj = taskService.getByCode(task_code);
|
||||
if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) {
|
||||
throw new BadRequestException("该任务已完成!");
|
||||
}
|
||||
if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) {
|
||||
throw new BadRequestException("该任务已取消!");
|
||||
}
|
||||
// 根据传来的类型去对任务进行操作
|
||||
if (status.equals(TaskStatus.EXECUTING)) {
|
||||
// 更新明细状态
|
||||
taskObj.setTask_status(TaskStatus.EXECUTING.getCode());
|
||||
taskObj.setRemark("执行中");
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
if (status.equals(TaskStatus.FINISHED)) {
|
||||
this.finishTask(taskObj);
|
||||
}
|
||||
if (status.equals(TaskStatus.CANCELED)) {
|
||||
this.cancelTask(taskObj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceFinish(String task_code) {
|
||||
SchBaseTask taskObj = taskService.getByCode(task_code);
|
||||
if (ObjectUtil.isEmpty(taskObj)) {
|
||||
throw new BadRequestException("该任务不存在");
|
||||
}
|
||||
this.finishTask(taskObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String task_code) {
|
||||
SchBaseTask taskObj = taskService.getByCode(task_code);
|
||||
if (ObjectUtil.isEmpty(taskObj)) {
|
||||
throw new BadRequestException("该任务不存在");
|
||||
}
|
||||
if (Integer.parseInt(taskObj.getTask_status()) > Integer.parseInt(TaskStatus.CREATE.getCode())) {
|
||||
throw new BadRequestException("只能取消生成中的任务!");
|
||||
}
|
||||
this.cancelTask(taskObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void backMes(String task_code) {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void finishTask(SchBaseTask taskObj) {
|
||||
// 更新终点
|
||||
iStructattrService.update(
|
||||
new UpdateWrapper<Structattr>().lambda()
|
||||
.eq(Structattr::getStruct_code, taskObj.getPoint_code2())
|
||||
.set(Structattr::getStoragevehicle_code, taskObj.getVehicle_code())
|
||||
.set(Structattr::getTaskdtl_id, null)
|
||||
.set(Structattr::getLock_type, IOSEnum.LOCK_TYPE.code("未锁定"))
|
||||
);
|
||||
// 更新起点
|
||||
iSchBasePointService.update(
|
||||
new UpdateWrapper<SchBasePoint>().lambda()
|
||||
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code1())
|
||||
.set(SchBasePoint::getVehicle_code, null)
|
||||
.set(SchBasePoint::getIos_id, null)
|
||||
);
|
||||
// 更新任务
|
||||
taskObj.setRemark("已完成");
|
||||
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void cancelTask(SchBaseTask taskObj) {
|
||||
// 更新终点
|
||||
iStructattrService.update(
|
||||
new UpdateWrapper<Structattr>().lambda()
|
||||
.eq(Structattr::getStruct_code, taskObj.getPoint_code2())
|
||||
.set(Structattr::getTaskdtl_id, null)
|
||||
.set(Structattr::getLock_type, IOSEnum.LOCK_TYPE.code("未锁定"))
|
||||
);
|
||||
// 更新任务
|
||||
taskObj.setRemark("已取消");
|
||||
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
}
|
||||
@@ -56,4 +56,9 @@ public class IOSConstant {
|
||||
* 移库任务类编码
|
||||
*/
|
||||
public final static String MOVE_CONFIG_TASK = "MoveTask";
|
||||
|
||||
/**
|
||||
* 余料回库任务类编码
|
||||
*/
|
||||
public final static String BACK_IN_TASK = "BackInTask";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user