add:盘点管理
This commit is contained in:
@@ -0,0 +1,227 @@
|
||||
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.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
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.IOSConstant;
|
||||
import org.nl.wms.warehouse_management.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_management.service.IStIvtCheckdtlService;
|
||||
import org.nl.wms.warehouse_management.service.IStIvtCheckmstService;
|
||||
import org.nl.wms.warehouse_management.service.dao.StIvtCheckdtl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 盘点回库移库任务类
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-08-28
|
||||
*/
|
||||
@Component(value = "CheckBackMoveTask")
|
||||
@TaskType("CheckBackMoveTask")
|
||||
public class CheckBackMoveTask extends AbstractTask {
|
||||
|
||||
/**
|
||||
* 任务服务类
|
||||
*/
|
||||
@Autowired
|
||||
private ISchBaseTaskService taskService;
|
||||
|
||||
/**
|
||||
* 仓位服务
|
||||
*/
|
||||
@Autowired
|
||||
private IStructattrService iStructattrService;
|
||||
|
||||
/**
|
||||
* 点位服务
|
||||
*/
|
||||
@Autowired
|
||||
private ISchBasePointService iSchBasePointService;
|
||||
|
||||
/**
|
||||
* 盘点主表服务
|
||||
*/
|
||||
@Autowired
|
||||
private IStIvtCheckmstService iStIvtCheckmstService;
|
||||
|
||||
/**
|
||||
* 盘点明细服务
|
||||
*/
|
||||
@Autowired
|
||||
private IStIvtCheckdtlService iStIvtCheckdtlService;
|
||||
|
||||
@Override
|
||||
public String create(JSONObject json) {
|
||||
SchBaseTask task = new SchBaseTask();
|
||||
task.setTask_id(IdUtil.getStringId());
|
||||
task.setTask_code(CodeUtil.getNewCode("TASK_CODE"));
|
||||
task.setTask_status(TaskStatus.CREATE.getCode());
|
||||
task.setConfig_code(CheckBackMoveTask.class.getSimpleName());
|
||||
task.setPoint_code1(json.getString("point_code1"));
|
||||
task.setPoint_code2(json.getString("point_code2"));
|
||||
task.setVehicle_code(json.getString("vehicle_code"));
|
||||
task.setContact_task(json.getString("contact_task"));
|
||||
task.setGroup_id(json.getString("group_id"));
|
||||
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);
|
||||
|
||||
// 下发任务
|
||||
this.sendTaskOne(task.getTask_id());
|
||||
return task.getTask_id();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AcsTaskDto sendAcsParam(String taskId) {
|
||||
SchBaseTask taskDao = taskService.getById(taskId);
|
||||
|
||||
// 组织下发给acs的数据
|
||||
AcsTaskDto acsTaskDto = new AcsTaskDto();
|
||||
acsTaskDto.setExt_task_id(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.setVehicle_code(taskDao.getVehicle_code());
|
||||
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);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void finishTask(SchBaseTask taskObj) {
|
||||
// 完成任务
|
||||
this.taskConfirm(taskObj.getTask_code());
|
||||
// 更新任务状态
|
||||
taskObj.setRemark("已完成");
|
||||
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void cancelTask(SchBaseTask taskObj) {
|
||||
// 查询明细
|
||||
SchBaseTask moveTask = taskService.getById(taskObj.getContact_task());
|
||||
StIvtCheckdtl dtlDao = iStIvtCheckdtlService.getOne(
|
||||
new QueryWrapper<StIvtCheckdtl>().lambda()
|
||||
.eq(StIvtCheckdtl::getTask_id, moveTask.getTask_id())
|
||||
);
|
||||
// 更新盘点明细状态
|
||||
|
||||
dtlDao.setStatus(IOSEnum.CHECK_DTL_STATUS.code("盘点中") );
|
||||
dtlDao.setCheck_result(IOSConstant.ZERO);
|
||||
dtlDao.setIs_down(IOSConstant.ZERO);
|
||||
dtlDao.setCheck_optid(SecurityUtils.getCurrentUserId());
|
||||
dtlDao.setCheck_optname(SecurityUtils.getCurrentNickName());
|
||||
dtlDao.setCheck_optname(DateUtil.now());
|
||||
iStIvtCheckdtlService.updateById(dtlDao);
|
||||
|
||||
// 更新主表状态
|
||||
iStIvtCheckmstService.updateMst(dtlDao.getCheck_id());
|
||||
|
||||
// 更新任务状态
|
||||
taskObj.setRemark("已取消");
|
||||
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskConfirm(String task_code) {
|
||||
SchBaseTask taskObj = taskService.getByCode(task_code);
|
||||
SchBaseTask moveTask = taskService.getById(taskObj.getContact_task());
|
||||
// 更新起点
|
||||
iSchBasePointService.update(
|
||||
new UpdateWrapper<SchBasePoint>().lambda()
|
||||
.set(SchBasePoint::getVehicle_code, null)
|
||||
.set(SchBasePoint::getIng_task_code, null)
|
||||
.set(SchBasePoint::getPoint_status, IOSEnum.POINT_STATUS.code("空位"))
|
||||
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code1())
|
||||
);
|
||||
// 更新终点
|
||||
iStructattrService.update(
|
||||
new UpdateWrapper<Structattr>().lambda()
|
||||
.eq(Structattr::getStruct_code, taskObj.getPoint_code2())
|
||||
.set(Structattr::getStoragevehicle_code, taskObj.getVehicle_code())
|
||||
);
|
||||
|
||||
// 更新盘点明细状态
|
||||
StIvtCheckdtl dtlDao = iStIvtCheckdtlService.getOne(
|
||||
new QueryWrapper<StIvtCheckdtl>().lambda()
|
||||
.eq(StIvtCheckdtl::getTask_id, moveTask.getTask_id())
|
||||
);
|
||||
dtlDao.setStatus(IOSEnum.CHECK_DTL_STATUS.code("完成"));
|
||||
iStIvtCheckdtlService.updateById(dtlDao);
|
||||
|
||||
// 更新主表状态
|
||||
iStIvtCheckmstService.updateMst(dtlDao.getCheck_id());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
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.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
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.nl.wms.warehouse_management.service.*;
|
||||
import org.nl.wms.warehouse_management.service.dao.StIvtCheckdtl;
|
||||
import org.nl.wms.warehouse_management.service.dao.StIvtMoveinvdtl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 盘点移库任务类
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-08-28
|
||||
*/
|
||||
@Component(value = "CheckMoveTask")
|
||||
@TaskType("CheckMoveTask")
|
||||
public class CheckMoveTask extends AbstractTask {
|
||||
|
||||
/**
|
||||
* 任务服务类
|
||||
*/
|
||||
@Autowired
|
||||
private ISchBaseTaskService taskService;
|
||||
|
||||
/**
|
||||
* 仓位服务
|
||||
*/
|
||||
@Autowired
|
||||
private IStructattrService iStructattrService;
|
||||
|
||||
/**
|
||||
* 点位服务
|
||||
*/
|
||||
@Autowired
|
||||
private ISchBasePointService iSchBasePointService;
|
||||
|
||||
/**
|
||||
* 盘点主表服务
|
||||
*/
|
||||
@Autowired
|
||||
private IStIvtCheckmstService iStIvtCheckmstService;
|
||||
|
||||
/**
|
||||
* 盘点明细服务
|
||||
*/
|
||||
@Autowired
|
||||
private IStIvtCheckdtlService iStIvtCheckdtlService;
|
||||
|
||||
@Override
|
||||
public String create(JSONObject json) {
|
||||
SchBaseTask task = new SchBaseTask();
|
||||
task.setTask_id(IdUtil.getStringId());
|
||||
task.setTask_code(CodeUtil.getNewCode("TASK_CODE"));
|
||||
task.setTask_status(TaskStatus.CREATE.getCode());
|
||||
task.setConfig_code(CheckMoveTask.class.getSimpleName());
|
||||
task.setPoint_code1(json.getString("point_code1"));
|
||||
task.setPoint_code2(json.getString("point_code2"));
|
||||
task.setVehicle_code(json.getString("vehicle_code"));
|
||||
task.setGroup_id(json.getString("group_id"));
|
||||
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);
|
||||
|
||||
// 下发任务
|
||||
this.sendTaskOne(task.getTask_id());
|
||||
return task.getTask_id();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AcsTaskDto sendAcsParam(String taskId) {
|
||||
SchBaseTask taskDao = taskService.getById(taskId);
|
||||
|
||||
// 组织下发给acs的数据
|
||||
AcsTaskDto acsTaskDto = new AcsTaskDto();
|
||||
acsTaskDto.setExt_task_id(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.setVehicle_code(taskDao.getVehicle_code());
|
||||
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);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void finishTask(SchBaseTask taskObj) {
|
||||
// 完成任务
|
||||
this.taskConfirm(taskObj.getTask_code());
|
||||
// 更新任务状态
|
||||
taskObj.setRemark("已完成");
|
||||
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void cancelTask(SchBaseTask taskObj) {
|
||||
// 更新盘点明细状态
|
||||
iStIvtCheckdtlService.update(
|
||||
new UpdateWrapper<StIvtCheckdtl>().lambda()
|
||||
.set(StIvtCheckdtl::getStatus, IOSEnum.CHECK_DTL_STATUS.code("生成") )
|
||||
.set(StIvtCheckdtl::getTask_id, "")
|
||||
.eq(StIvtCheckdtl::getTask_id, taskObj.getTask_id())
|
||||
);
|
||||
|
||||
// 更新任务状态
|
||||
taskObj.setRemark("已取消");
|
||||
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskConfirm(String task_code) {
|
||||
SchBaseTask taskObj = taskService.getByCode(task_code);
|
||||
// 更新起点
|
||||
iStructattrService.update(
|
||||
new UpdateWrapper<Structattr>().lambda()
|
||||
.eq(Structattr::getStruct_code, taskObj.getPoint_code1())
|
||||
.set(Structattr::getStoragevehicle_code, null)
|
||||
);
|
||||
// 更新终点
|
||||
iSchBasePointService.update(
|
||||
new UpdateWrapper<SchBasePoint>().lambda()
|
||||
.set(SchBasePoint::getVehicle_code, taskObj.getVehicle_code())
|
||||
.set(SchBasePoint::getPoint_status, IOSEnum.POINT_STATUS.code("有箱有料"))
|
||||
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code2())
|
||||
.set(SchBasePoint::getIng_task_code, taskObj.getTask_id())
|
||||
);
|
||||
|
||||
// 更新盘点明细状态
|
||||
StIvtCheckdtl dtlDao = iStIvtCheckdtlService.getOne(
|
||||
new QueryWrapper<StIvtCheckdtl>().lambda()
|
||||
.eq(StIvtCheckdtl::getTask_id, taskObj.getTask_id())
|
||||
);
|
||||
dtlDao.setStatus(IOSEnum.CHECK_DTL_STATUS.code("盘点中"));
|
||||
iStIvtCheckdtlService.updateById(dtlDao);
|
||||
|
||||
// 更新主表状态
|
||||
iStIvtCheckmstService.updateMst(dtlDao.getCheck_id());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.warehouse_management.service.IStIvtCheckmstService;
|
||||
import org.nl.wms.warehouse_management.service.dao.StIvtCheckdtl;
|
||||
import org.nl.wms.warehouse_management.service.dto.CheckInsertDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -64,13 +65,20 @@ public class CheckController {
|
||||
@GetMapping("/getDtl")
|
||||
@Log("获取明细")
|
||||
public ResponseEntity<Object> getDtl(@RequestParam Map whereJson) {
|
||||
return new ResponseEntity<>(iStIvtCheckmstService.getDtl(whereJson),HttpStatus.OK);
|
||||
return new ResponseEntity<>(iStIvtCheckmstService.getDtl(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/saveCheck")
|
||||
@Log("保存盘点")
|
||||
public ResponseEntity<Object> saveCheck(@RequestBody CheckInsertDto dto) {
|
||||
iStIvtCheckmstService.saveCheck(dto);
|
||||
@PostMapping("/dtlCheckConfirm")
|
||||
@Log("明细盘点确认")
|
||||
public ResponseEntity<Object> dtlCheckConfirm(@RequestBody StIvtCheckdtl dao) {
|
||||
iStIvtCheckmstService.dtlCheckConfirm(dao);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/sendMoveTask")
|
||||
@Log("下发移库任务")
|
||||
public ResponseEntity<Object> sendMoveTask(@RequestBody CheckInsertDto dto) {
|
||||
iStIvtCheckmstService.sendMoveTask(dto);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public enum IOSEnum {
|
||||
|
||||
// 移库任务配置类编码
|
||||
MOVE_CONFIG_CODE(MapOf.of("2001","InsideMoveTask", "2002", "CombinedBoxMoveTask",
|
||||
"2003", "PieceBoxMoveTask", "2004", "2004"
|
||||
"2003", "PieceBoxMoveTask", "CheckMoveTask", "2004"
|
||||
)),
|
||||
|
||||
//入库分配明细状态
|
||||
@@ -106,7 +106,7 @@ public enum IOSEnum {
|
||||
CHECK_MST_STATUS(MapOf.of("生成", "10", "盘点中", "20", "完成", "99")),
|
||||
|
||||
// 盘点明细状态
|
||||
CHECK_DTL_STATUS(MapOf.of("生成", "10", "盘点中", "20", "已盘点", "30", "完成", "99")),
|
||||
CHECK_DTL_STATUS(MapOf.of("生成", "10", "移库中", "15", "盘点中", "20", "回库中", "30", "完成", "99")),
|
||||
|
||||
// 拼箱主表状态
|
||||
PIECE_MST_STATUS(MapOf.of("生成", "10", "拼箱中", "20", "完成", "99")),
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.warehouse_management.service.dao.StIvtCheckdtl;
|
||||
import org.nl.wms.warehouse_management.service.dao.StIvtCheckmst;
|
||||
import org.nl.wms.warehouse_management.service.dto.CheckInsertDto;
|
||||
|
||||
@@ -56,10 +57,10 @@ public interface IStIvtCheckmstService extends IService<StIvtCheckmst> {
|
||||
List<JSONObject> getDtl(Map whereJson);
|
||||
|
||||
/**
|
||||
* 保存盘点单
|
||||
* @param dto 新增修改dto实体类
|
||||
* 明细盘点确认
|
||||
* @param dao 明细实体类
|
||||
*/
|
||||
void saveCheck(CheckInsertDto dto);
|
||||
void dtlCheckConfirm(StIvtCheckdtl dao);
|
||||
|
||||
/**
|
||||
* 确认盘点
|
||||
@@ -72,4 +73,11 @@ public interface IStIvtCheckmstService extends IService<StIvtCheckmst> {
|
||||
* @param check_id 主表id
|
||||
*/
|
||||
void updateMst(String check_id);
|
||||
|
||||
/**
|
||||
* 下发移库任务
|
||||
* @param dto 实体类dto
|
||||
*/
|
||||
void sendMoveTask(CheckInsertDto dto);
|
||||
|
||||
}
|
||||
|
||||
@@ -100,10 +100,15 @@ public class StIvtCheckdtl implements Serializable {
|
||||
private BigDecimal fac_qty;
|
||||
|
||||
/**
|
||||
* 盘点结果
|
||||
* 盘点结果 1-正常 2-异常
|
||||
*/
|
||||
private String check_result;
|
||||
|
||||
/**
|
||||
* 任务标识
|
||||
*/
|
||||
private String task_id;
|
||||
|
||||
/**
|
||||
* 盘点人
|
||||
*/
|
||||
|
||||
@@ -114,6 +114,11 @@ public class StIvtCheckmst implements Serializable {
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 是否异常
|
||||
*/
|
||||
private String is_nok;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
|
||||
@@ -8,13 +8,21 @@
|
||||
material.material_code,
|
||||
material.material_name,
|
||||
sect.sect_name,
|
||||
attr.struct_name
|
||||
attr.struct_name,
|
||||
task.task_code,
|
||||
(
|
||||
CASE
|
||||
WHEN dtl.status > '20' THEN true
|
||||
ELSE false
|
||||
END
|
||||
) AS edit
|
||||
FROM
|
||||
st_ivt_checkdtl dtl
|
||||
LEFT JOIN st_ivt_checkmst ios ON ios.check_id = dtl.check_id
|
||||
LEFT JOIN md_me_materialbase material ON material.material_id = dtl.material_id
|
||||
LEFT JOIN st_ivt_sectattr sect ON sect.sect_code = dtl.sect_code
|
||||
LEFT JOIN st_ivt_structattr attr ON attr.struct_code = dtl.struct_code
|
||||
LEFT JOIN sch_base_task task ON task.task_id = dtl.task_id
|
||||
<where>
|
||||
ios.is_delete = '0'
|
||||
<if test="param.check_id != null and param.check_id != ''">
|
||||
|
||||
@@ -11,14 +11,19 @@ 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.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.basedata_manage.enums.BaseDataEnum;
|
||||
import org.nl.wms.sch_manage.service.util.tasks.CheckBackMoveTask;
|
||||
import org.nl.wms.sch_manage.service.util.tasks.CheckMoveTask;
|
||||
import org.nl.wms.warehouse_management.enums.IOSConstant;
|
||||
import org.nl.wms.warehouse_management.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_management.service.IMdPbGroupplateService;
|
||||
import org.nl.wms.warehouse_management.service.IStIvtCheckdtlService;
|
||||
import org.nl.wms.warehouse_management.service.IStIvtCheckmstService;
|
||||
import org.nl.wms.warehouse_management.service.dao.GroupPlate;
|
||||
import org.nl.wms.warehouse_management.service.dao.StIvtCheckdtl;
|
||||
import org.nl.wms.warehouse_management.service.dao.StIvtCheckmst;
|
||||
import org.nl.wms.warehouse_management.service.dao.mapper.StIvtCheckmstMapper;
|
||||
@@ -27,6 +32,7 @@ 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.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -42,9 +48,30 @@ import java.util.Set;
|
||||
@Service
|
||||
public class StIvtCheckmstServiceImpl extends ServiceImpl<StIvtCheckmstMapper, StIvtCheckmst> implements IStIvtCheckmstService {
|
||||
|
||||
/**
|
||||
* 盘点明细服务
|
||||
*/
|
||||
@Autowired
|
||||
private IStIvtCheckdtlService iStIvtCheckdtlService;
|
||||
|
||||
/**
|
||||
* 盘点移库任务类服务
|
||||
*/
|
||||
@Autowired
|
||||
private CheckMoveTask checkMoveTask;
|
||||
|
||||
/**
|
||||
* 盘点回库任务类服务
|
||||
*/
|
||||
@Autowired
|
||||
private CheckBackMoveTask checkBackMoveTask;
|
||||
|
||||
/**
|
||||
* 组盘记录服务
|
||||
*/
|
||||
@Autowired
|
||||
private IMdPbGroupplateService iMdPbGroupplateService;
|
||||
|
||||
@Override
|
||||
public IPage<StIvtCheckmst> queryAll(Map whereJson, PageQuery page) {
|
||||
String check_code = MapUtil.getStr(whereJson, "check_code");
|
||||
@@ -126,23 +153,56 @@ public class StIvtCheckmstServiceImpl extends ServiceImpl<StIvtCheckmstMapper, S
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void saveCheck(CheckInsertDto dto) {
|
||||
StIvtCheckmst mstDao = this.getById(dto.getCheck_id());
|
||||
mstDao.setStatus(IOSEnum.CHECK_MST_STATUS.code("盘点中"));
|
||||
this.updateById(mstDao);
|
||||
public void dtlCheckConfirm(StIvtCheckdtl dao) {
|
||||
StIvtCheckdtl dtlDao = iStIvtCheckdtlService.getById(dao.getCheckdtl_id());
|
||||
dtlDao.setFac_qty(dao.getFac_qty());
|
||||
// 是否异常 1-正常 2-异常
|
||||
dtlDao.setCheck_result(
|
||||
dtlDao.getBase_qty().doubleValue() == dtlDao.getFac_qty().doubleValue() ?
|
||||
IOSConstant.ONE : IOSConstant.TWO
|
||||
);
|
||||
dtlDao.setCheck_optid(SecurityUtils.getCurrentUserId());
|
||||
dtlDao.setCheck_optname(SecurityUtils.getCurrentNickName());
|
||||
dtlDao.setCheck_optname(DateUtil.now());
|
||||
|
||||
// 判断是否有任务: 有任务判断是否完成,没任务直接确认
|
||||
if (ObjectUtil.isNotEmpty(dao.getTask_id())) {
|
||||
if (!dao.getStatus().equals(IOSEnum.CHECK_DTL_STATUS.code("盘点中"))) {
|
||||
throw new BadRequestException("当前移库任务未完成或已在回库中,不允许确认操作!");
|
||||
}
|
||||
|
||||
// 生成回库任务
|
||||
JSONObject jsonTask = new JSONObject();
|
||||
jsonTask.put("point_code1", IOSConstant.CZW_POINT);
|
||||
jsonTask.put("point_code2", dtlDao.getStruct_code());
|
||||
jsonTask.put("vehicle_code", dtlDao.getStoragevehicle_code());
|
||||
jsonTask.put("contact_task", dtlDao.getTask_id());
|
||||
checkBackMoveTask.create(jsonTask);
|
||||
|
||||
dtlDao.setStatus(IOSEnum.CHECK_DTL_STATUS.code("回库中"));
|
||||
dtlDao.setIs_down(IOSConstant.ONE);
|
||||
} else {
|
||||
dtlDao.setStatus(IOSEnum.CHECK_DTL_STATUS.code("完成"));
|
||||
}
|
||||
// 生成损益单据
|
||||
List<StIvtCheckdtl> dtlDaoList = new ArrayList<>();
|
||||
dtlDaoList.add(dtlDao);
|
||||
iStIvtCheckdtlService.createMore(dtlDaoList,dtlDao.getCheck_id());
|
||||
|
||||
// 更新组盘记录表
|
||||
iMdPbGroupplateService.update(
|
||||
new UpdateWrapper<GroupPlate>().lambda()
|
||||
.set(GroupPlate::getQty, dtlDao.getFac_qty())
|
||||
.eq(GroupPlate::getMaterial_id, dtlDao.getMaterial_id())
|
||||
.eq(GroupPlate::getStoragevehicle_code, dtlDao.getStoragevehicle_code())
|
||||
.eq(GroupPlate::getPcsn, dtlDao.getPcsn())
|
||||
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("入库"))
|
||||
);
|
||||
|
||||
// 更新明细
|
||||
iStIvtCheckdtlService.remove(
|
||||
new QueryWrapper<StIvtCheckdtl>().lambda()
|
||||
.eq(StIvtCheckdtl::getCheck_id, mstDao.getCheck_id())
|
||||
.ne(StIvtCheckdtl::getStatus, IOSEnum.CHECK_DTL_STATUS.code("完成"))
|
||||
);
|
||||
iStIvtCheckdtlService.createCheckDtl(dto);
|
||||
iStIvtCheckdtlService.update(
|
||||
new UpdateWrapper<StIvtCheckdtl>().lambda()
|
||||
.eq(StIvtCheckdtl::getCheck_id, dto.getCheck_id())
|
||||
.ne(StIvtCheckdtl::getStatus, IOSEnum.CHECK_DTL_STATUS.code("完成"))
|
||||
.set(StIvtCheckdtl::getStatus, IOSEnum.CHECK_DTL_STATUS.code("盘点中"))
|
||||
);
|
||||
iStIvtCheckdtlService.updateById(dtlDao);
|
||||
// 更新主表状态
|
||||
updateMst(dao.getCheck_id());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,19 +230,66 @@ public class StIvtCheckmstServiceImpl extends ServiceImpl<StIvtCheckmstMapper, S
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateMst(String check_id) {
|
||||
StIvtCheckmst mstDao = this.getById(check_id);
|
||||
|
||||
List<StIvtCheckdtl> dtlDaoList = iStIvtCheckdtlService.list(
|
||||
new QueryWrapper<StIvtCheckdtl>().lambda()
|
||||
.eq(StIvtCheckdtl::getCheck_id, check_id)
|
||||
);
|
||||
|
||||
boolean is_create = dtlDaoList.stream()
|
||||
.allMatch(row -> row.getStatus().equals(IOSEnum.CHECK_DTL_STATUS.code("生成")));
|
||||
|
||||
boolean is_check = dtlDaoList.stream()
|
||||
.anyMatch(row -> row.getStatus().equals(IOSEnum.CHECK_DTL_STATUS.code("盘点中")));
|
||||
|
||||
boolean is_confirm = dtlDaoList.stream()
|
||||
.allMatch(row -> row.getStatus().equals(IOSEnum.CHECK_DTL_STATUS.code("完成")));
|
||||
|
||||
mstDao.setStatus(is_confirm ? IOSEnum.CHECK_MST_STATUS.code("完成") : IOSEnum.CHECK_MST_STATUS.code("盘点中"));
|
||||
mstDao.setConfirm_optid(SecurityUtils.getCurrentUserId());
|
||||
mstDao.setConfirm_optname(SecurityUtils.getCurrentNickName());
|
||||
mstDao.setConfirm_time(DateUtil.now());
|
||||
if (is_create) {
|
||||
mstDao.setStatus(IOSEnum.CHECK_MST_STATUS.code("生成"));
|
||||
} else if (is_check) {
|
||||
mstDao.setStatus(IOSEnum.CHECK_MST_STATUS.code("盘点中"));
|
||||
} else if (is_confirm) {
|
||||
mstDao.setStatus(IOSEnum.CHECK_MST_STATUS.code("完成"));
|
||||
mstDao.setConfirm_optid(SecurityUtils.getCurrentUserId());
|
||||
mstDao.setConfirm_optname(SecurityUtils.getCurrentNickName());
|
||||
mstDao.setConfirm_time(DateUtil.now());
|
||||
}
|
||||
|
||||
// 判断是否异常
|
||||
boolean is_result = dtlDaoList.stream()
|
||||
.filter(row -> ObjectUtil.isNotEmpty(row.getCheck_result()))
|
||||
.anyMatch(row -> row.getCheck_result().equals(IOSConstant.TWO));
|
||||
|
||||
mstDao.setIs_nok(is_result ? IOSConstant.TWO : IOSConstant.ONE);
|
||||
this.updateById(mstDao);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void sendMoveTask(CheckInsertDto dto) {
|
||||
// 查询所有生成的明细
|
||||
List<StIvtCheckdtl> dtlDaoList = iStIvtCheckdtlService.list(
|
||||
new QueryWrapper<StIvtCheckdtl>().lambda()
|
||||
.eq(StIvtCheckdtl::getCheck_id, dto.getCheck_id())
|
||||
.eq(StIvtCheckdtl::getStatus, IOSEnum.CHECK_DTL_STATUS.code("生成"))
|
||||
);
|
||||
|
||||
// 生成盘点移库任务
|
||||
for (StIvtCheckdtl dtlDao : dtlDaoList) {
|
||||
JSONObject jsonTask = new JSONObject();
|
||||
jsonTask.put("point_code1", dtlDao.getStruct_code());
|
||||
jsonTask.put("point_code2", IOSConstant.CZW_POINT);
|
||||
jsonTask.put("vehicle_code", dtlDao.getStoragevehicle_code());
|
||||
String task_id = checkMoveTask.create(jsonTask);
|
||||
|
||||
// 更新明细
|
||||
dtlDao.setTask_id(task_id);
|
||||
dtlDao.setStatus(IOSEnum.CHECK_DTL_STATUS.code("移库中"));
|
||||
}
|
||||
iStIvtCheckdtlService.updateBatchById(dtlDaoList);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user