功能修改
This commit is contained in:
parent
129550fa13
commit
7cbac2f99e
|
|
@ -3,8 +3,10 @@ package com.bonus.material.back.controller;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
import com.bonus.common.log.enums.OperaType;
|
import com.bonus.common.log.enums.OperaType;
|
||||||
|
import com.bonus.material.back.domain.BackApplyDetails;
|
||||||
import com.bonus.material.back.domain.MaCode;
|
import com.bonus.material.back.domain.MaCode;
|
||||||
import com.bonus.material.back.domain.vo.BackAppRequestVo;
|
import com.bonus.material.back.domain.vo.BackAppRequestVo;
|
||||||
import com.bonus.material.back.domain.vo.BackApplyRequestVo;
|
import com.bonus.material.back.domain.vo.BackApplyRequestVo;
|
||||||
|
|
@ -14,7 +16,6 @@ import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
@ -102,6 +103,18 @@ public class BackApplyInfoController extends BaseController {
|
||||||
return success(backApplyInfoService.selectBackApplyInfoById(id));
|
return success(backApplyInfoService.selectBackApplyInfoById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询退料任务详情信息
|
||||||
|
* @param backApplyDetails
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "查询退料任务详情信息")
|
||||||
|
// @RequiresPermissions("back:info:query")
|
||||||
|
@GetMapping(value = "/getDetailsById")
|
||||||
|
public AjaxResult getDetailsById(BackApplyDetails backApplyDetails) {
|
||||||
|
return success(backApplyInfoService.getDetailsById(backApplyDetails));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增退料任务
|
* 新增退料任务
|
||||||
*/
|
*/
|
||||||
|
|
@ -227,7 +240,7 @@ public class BackApplyInfoController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "app内层删除退料任务")
|
@ApiOperation(value = "app内层删除退料任务")
|
||||||
@PreventRepeatSubmit
|
@PreventRepeatSubmit
|
||||||
@RequiresPermissions("back:info:remove")
|
//@RequiresPermissions("back:info:remove")
|
||||||
@SysLog(title = "退料任务", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除退料任务")
|
@SysLog(title = "退料任务", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除退料任务")
|
||||||
@PostMapping("/delete")
|
@PostMapping("/delete")
|
||||||
public AjaxResult delete(@RequestBody BackApplyInfo backApplyInfo) {
|
public AjaxResult delete(@RequestBody BackApplyInfo backApplyInfo) {
|
||||||
|
|
@ -255,4 +268,31 @@ public class BackApplyInfoController extends BaseController {
|
||||||
public AjaxResult updateMaCode(@RequestBody MaCode maCode) {
|
public AjaxResult updateMaCode(@RequestBody MaCode maCode) {
|
||||||
return backApplyInfoService.updateMaCode(maCode);
|
return backApplyInfoService.updateMaCode(maCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询工程是否结算
|
||||||
|
* @param backApplyInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "查询工程是否结算")
|
||||||
|
@PostMapping("/selectIsSltById")
|
||||||
|
public AjaxResult selectIsSltById(@RequestBody BackApplyInfo backApplyInfo) {
|
||||||
|
return backApplyInfoService.selectIsSltById(backApplyInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* app退料退回
|
||||||
|
* @param backApplyDetails
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "app退料退回")
|
||||||
|
@PreventRepeatSubmit
|
||||||
|
@PostMapping("/backOutBack")
|
||||||
|
public AjaxResult backOutBack(@NotNull(message = "领料出库信息不能为空") @RequestBody BackApplyDetails backApplyDetails) {
|
||||||
|
try {
|
||||||
|
return backApplyInfoService.backOutBack(backApplyDetails);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return error("系统错误, " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,9 @@ public class BackApplyDetails extends BaseEntity {
|
||||||
@ApiModelProperty(value = "机具id")
|
@ApiModelProperty(value = "机具id")
|
||||||
private Long maId;
|
private Long maId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "机具id")
|
||||||
|
private Long taskId;
|
||||||
|
|
||||||
/** 任务ID */
|
/** 任务ID */
|
||||||
@Excel(name = "任务ID")
|
@Excel(name = "任务ID")
|
||||||
@ApiModelProperty(value = "任务ID")
|
@ApiModelProperty(value = "任务ID")
|
||||||
|
|
|
||||||
|
|
@ -305,4 +305,25 @@ public interface BackApplyInfoMapper {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<MaCodeVo> getMachineByQrCode(BackApplyInfo dto);
|
List<MaCodeVo> getMachineByQrCode(BackApplyInfo dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据任务id查询详情
|
||||||
|
* @param backApplyDetails
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<BackApplyDetails> getDetailsById(BackApplyDetails backApplyDetails);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据任务id删除详情
|
||||||
|
* @param backApplyDetails
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int deleteBackApplyDetailsById(BackApplyDetails backApplyDetails);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新详情
|
||||||
|
* @param backApplyDetails
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int update(BackApplyDetails backApplyDetails);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.bonus.material.back.service;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.material.back.domain.BackApplyDetails;
|
||||||
import com.bonus.material.back.domain.BackApplyInfo;
|
import com.bonus.material.back.domain.BackApplyInfo;
|
||||||
import com.bonus.material.back.domain.MaCode;
|
import com.bonus.material.back.domain.MaCode;
|
||||||
import com.bonus.material.back.domain.vo.BackAppRequestVo;
|
import com.bonus.material.back.domain.vo.BackAppRequestVo;
|
||||||
|
|
@ -113,4 +114,25 @@ public interface IBackApplyInfoService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AjaxResult updateMaCode(MaCode maCode);
|
AjaxResult updateMaCode(MaCode maCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询工程是否结算
|
||||||
|
* @param backApplyInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult selectIsSltById(BackApplyInfo backApplyInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据退料任务id查询退料详情
|
||||||
|
* @param backApplyDetails
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<BackApplyDetails> getDetailsById(BackApplyDetails backApplyDetails);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* app退料退回
|
||||||
|
* @param backApplyDetails
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult backOutBack(BackApplyDetails backApplyDetails);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,8 @@ import java.util.stream.Collectors;
|
||||||
import cn.hutool.core.util.PhoneUtil;
|
import cn.hutool.core.util.PhoneUtil;
|
||||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||||
import com.bonus.common.biz.constant.MaterialConstants;
|
import com.bonus.common.biz.constant.MaterialConstants;
|
||||||
import com.bonus.common.biz.enums.BackTaskStatusEnum;
|
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
|
||||||
import com.bonus.common.biz.enums.HttpCodeEnum;
|
import com.bonus.common.biz.enums.*;
|
||||||
import com.bonus.common.biz.enums.MaMachineStatusEnum;
|
|
||||||
import com.bonus.common.biz.enums.TmTaskTypeEnum;
|
|
||||||
import com.bonus.common.core.exception.ServiceException;
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
import com.bonus.common.core.utils.DateUtils;
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
import com.bonus.common.core.utils.StringUtils;
|
import com.bonus.common.core.utils.StringUtils;
|
||||||
|
|
@ -28,11 +26,13 @@ import com.bonus.material.basic.mapper.BmFileInfoMapper;
|
||||||
import com.bonus.material.ma.mapper.MachineMapper;
|
import com.bonus.material.ma.mapper.MachineMapper;
|
||||||
import com.bonus.material.purchase.config.RemoteConfig;
|
import com.bonus.material.purchase.config.RemoteConfig;
|
||||||
import com.bonus.material.settlement.domain.SltAgreementInfo;
|
import com.bonus.material.settlement.domain.SltAgreementInfo;
|
||||||
|
import com.bonus.material.settlement.mapper.SltAgreementInfoMapper;
|
||||||
import com.bonus.material.task.domain.TmTask;
|
import com.bonus.material.task.domain.TmTask;
|
||||||
import com.bonus.material.task.domain.TmTaskAgreement;
|
import com.bonus.material.task.domain.TmTaskAgreement;
|
||||||
import com.bonus.material.task.mapper.TmTaskAgreementMapper;
|
import com.bonus.material.task.mapper.TmTaskAgreementMapper;
|
||||||
import com.bonus.material.task.mapper.TmTaskMapper;
|
import com.bonus.material.task.mapper.TmTaskMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.bonus.material.back.mapper.BackApplyInfoMapper;
|
import com.bonus.material.back.mapper.BackApplyInfoMapper;
|
||||||
import com.bonus.material.back.domain.BackApplyInfo;
|
import com.bonus.material.back.domain.BackApplyInfo;
|
||||||
|
|
@ -69,6 +69,9 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
@Resource
|
@Resource
|
||||||
private RemoteConfig remoteConfig;
|
private RemoteConfig remoteConfig;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SltAgreementInfoMapper sltAgreementInfoMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询退料任务
|
* 查询退料任务
|
||||||
*
|
*
|
||||||
|
|
@ -887,8 +890,14 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
if (backApplyInfo.getMaId() != null) {
|
if (backApplyInfo.getMaId() != null) {
|
||||||
// 先查询相关编码信息
|
// 先查询相关编码信息
|
||||||
List<MaCodeVo> maCodeVoList = backApplyInfoMapper.selectByCode(backApplyInfo.getParentId());
|
List<MaCodeVo> maCodeVoList = backApplyInfoMapper.selectByCode(backApplyInfo.getParentId());
|
||||||
|
// 更新 back_apply_details 表信息
|
||||||
|
BackApplyDetails backApplyDetails = new BackApplyDetails();
|
||||||
|
backApplyDetails.setParentId(backApplyInfo.getParentId());
|
||||||
|
backApplyDetails.setTypeId(Long.valueOf(backApplyInfo.getTypeId()));
|
||||||
|
backApplyDetails.setPreNum(BigDecimal.valueOf(1));
|
||||||
|
int result = backApplyInfoMapper.update(backApplyDetails);
|
||||||
// 删除 back_check_details 表信息
|
// 删除 back_check_details 表信息
|
||||||
int result = deleteBackCheckDetails(backApplyInfo);
|
result = deleteBackCheckDetails(backApplyInfo);
|
||||||
//修改机具状态
|
//修改机具状态
|
||||||
result += machineMapper.updateStatus(backApplyInfo.getMaId(), MaMachineStatusEnum.IN_USE.getStatus());
|
result += machineMapper.updateStatus(backApplyInfo.getMaId(), MaMachineStatusEnum.IN_USE.getStatus());
|
||||||
// 删除相关文件信息
|
// 删除相关文件信息
|
||||||
|
|
@ -1073,6 +1082,96 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询工程是否结算
|
||||||
|
* @param backApplyInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult selectIsSltById(BackApplyInfo backApplyInfo) {
|
||||||
|
SltAgreementInfo info = new SltAgreementInfo();
|
||||||
|
info.setAgreementId(backApplyInfo.getAgreementId());
|
||||||
|
List<SltAgreementInfo> list = sltAgreementInfoMapper.selectSltAgreementInfoList(info);
|
||||||
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
// 查看list中的isSlt字段是否包含1,如果包含,说明此工程已结算,无法再建立退料任务
|
||||||
|
for (SltAgreementInfo sltAgreementInfo : list) {
|
||||||
|
if ("1".equals(sltAgreementInfo.getIsSlt())) {
|
||||||
|
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "工程已结算,无法再建立退料任务");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询退料详情
|
||||||
|
* @param backApplyDetails
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<BackApplyDetails> getDetailsById(BackApplyDetails backApplyDetails) {
|
||||||
|
return backApplyInfoMapper.getDetailsById(backApplyDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* app退料退回
|
||||||
|
* @param backApplyDetails
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public AjaxResult backOutBack(BackApplyDetails backApplyDetails) {
|
||||||
|
int result = 0;
|
||||||
|
TmTask tmTask = taskMapper.selectTmTaskByTaskId(backApplyDetails.getTaskId());
|
||||||
|
if (tmTask != null && tmTask.getTaskStatus().equals(BackTaskStatusEnum.BACK_TASK_IN_FINISHED.getStatus())) {
|
||||||
|
return AjaxResult.error("该任务已完成,不能进行退回操作");
|
||||||
|
}
|
||||||
|
BackApplyDetails info = backApplyInfoMapper.selectBackApplyDetailsById(backApplyDetails);
|
||||||
|
// 针对于数量退回的设备,进行file文件的删除
|
||||||
|
if (backApplyDetails.getMaId() == null) {
|
||||||
|
BmFileInfo bmFileInfo = new BmFileInfo();
|
||||||
|
bmFileInfo.setTaskId(backApplyDetails.getTaskId());
|
||||||
|
bmFileInfo.setModelId(info.getId());
|
||||||
|
bmFileInfo.setTaskType(3);
|
||||||
|
result += bmFileInfoMapper.deleteBmFileInfoByBizInfo(bmFileInfo);
|
||||||
|
if (result > 0) {
|
||||||
|
// 删除back_apply_details的数据
|
||||||
|
result += backApplyInfoMapper.deleteBackApplyDetailsById(backApplyDetails);
|
||||||
|
// 删除back_check_details的数据
|
||||||
|
BackApplyInfo backApplyInfo = new BackApplyInfo();
|
||||||
|
backApplyInfo.setParentId(backApplyDetails.getParentId());
|
||||||
|
backApplyInfo.setTypeId(backApplyDetails.getTypeId().toString());
|
||||||
|
result += backApplyInfoMapper.deleteDetails(backApplyInfo);
|
||||||
|
}
|
||||||
|
if (result > 0) {
|
||||||
|
return AjaxResult.success("退料退回成功");
|
||||||
|
}
|
||||||
|
} else if (backApplyDetails.getMaId() != null) {
|
||||||
|
BmFileInfo bmFileInfo = new BmFileInfo();
|
||||||
|
bmFileInfo.setTaskId(info.getId());
|
||||||
|
bmFileInfo.setModelId(backApplyDetails.getMaId());
|
||||||
|
bmFileInfo.setTaskType(3);
|
||||||
|
result += bmFileInfoMapper.deleteBmFileInfoByBizInfo(bmFileInfo);
|
||||||
|
if (result > 0) {
|
||||||
|
// 更新back_apply_details的数据
|
||||||
|
result += backApplyInfoMapper.update(backApplyDetails);
|
||||||
|
// 删除back_check_details的数据
|
||||||
|
BackApplyInfo backApplyInfo = new BackApplyInfo();
|
||||||
|
backApplyInfo.setParentId(backApplyDetails.getParentId());
|
||||||
|
backApplyInfo.setTypeId(backApplyDetails.getTypeId().toString());
|
||||||
|
result += backApplyInfoMapper.deleteDetails(backApplyInfo);
|
||||||
|
// 更新ma_machine表的状态
|
||||||
|
LeaseOutDetails leaseOutDetails = new LeaseOutDetails();
|
||||||
|
leaseOutDetails.setTypeId(backApplyDetails.getTypeId());
|
||||||
|
result += machineMapper.updateMaMachineStatus(leaseOutDetails, MaMachineStatusEnum.IN_USE.getStatus());
|
||||||
|
}
|
||||||
|
if (result > 0) {
|
||||||
|
return AjaxResult.success("退料退回成功");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AjaxResult.error("退料退回失败");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新任务表及退料申请表状态
|
* 更新任务表及退料申请表状态
|
||||||
* @param backApplyInfo
|
* @param backApplyInfo
|
||||||
|
|
@ -1171,7 +1270,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId());
|
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId());
|
||||||
// 生成维修单号
|
// 生成维修单号
|
||||||
String code = genderWxTaskCode(thisMonthMaxOrder);
|
String code = genderWxTaskCode(thisMonthMaxOrder);
|
||||||
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId(), BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus(),
|
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId(), RepairTaskStatusEnum.TASK_STATUS_PROCESSING.getStatus(),
|
||||||
null,thisMonthMaxOrder + 1, code);
|
null,thisMonthMaxOrder + 1, code);
|
||||||
tmTask.setCreateTime(DateUtils.getNowDate());
|
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||||
tmTask.setRemark(remark);
|
tmTask.setRemark(remark);
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@ public class LeaseApplyDetails extends BaseEntity {
|
||||||
@ApiModelProperty(value = "任务ID")
|
@ApiModelProperty(value = "任务ID")
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "机具ID")
|
||||||
|
private Long maId;
|
||||||
|
|
||||||
/** 物资类型 */
|
/** 物资类型 */
|
||||||
@ApiModelProperty(value = "物资类型名称")
|
@ApiModelProperty(value = "物资类型名称")
|
||||||
@Excel(name = "类型名称")
|
@Excel(name = "类型名称")
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public AjaxResult leaseOutBack(LeaseOutDetails leaseOutDetails) {
|
public AjaxResult leaseOutBack(LeaseOutDetails leaseOutDetails) {
|
||||||
int res = 0;
|
int res = 0;
|
||||||
try {
|
try {
|
||||||
|
|
@ -225,17 +226,17 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
||||||
if (tmTask != null && tmTask.getTaskStatus().equals(LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus())) {
|
if (tmTask != null && tmTask.getTaskStatus().equals(LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus())) {
|
||||||
return AjaxResult.error("该任务已完成,不能进行退库操作");
|
return AjaxResult.error("该任务已完成,不能进行退库操作");
|
||||||
}
|
}
|
||||||
// 3、插入出库记录,修改库存,修改机具状态
|
// 2、插入出库记录,修改库存,修改机具状态
|
||||||
res = updateRecords(leaseOutDetails);
|
res = updateRecords(leaseOutDetails);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
throw new RuntimeException("出库退回失败,更新设备规格库存数量时出错!");
|
throw new RuntimeException("出库退回失败,更新设备规格库存数量时出错!");
|
||||||
}
|
}
|
||||||
// 4、修改任务状态(tm_task)
|
// 3、修改任务状态(tm_task)
|
||||||
res = editTaskStatus(leaseOutDetails);
|
res = editTaskStatus(leaseOutDetails);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
throw new RuntimeException("出库退回失败,修改任务状态失败");
|
throw new RuntimeException("出库退回失败,修改任务状态失败");
|
||||||
}
|
}
|
||||||
// 5、删除结算记录
|
// 4、删除结算记录
|
||||||
res = deleteSltInfo(leaseOutDetails);
|
res = deleteSltInfo(leaseOutDetails);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
throw new RuntimeException("出库失败,插入结算记录失败");
|
throw new RuntimeException("出库失败,插入结算记录失败");
|
||||||
|
|
@ -281,7 +282,9 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
||||||
// 普通机具减少 (ma_type 设备规格表)的库存数量
|
// 普通机具减少 (ma_type 设备规格表)的库存数量
|
||||||
res = typeMapper.addMaTypeStockNum(leaseOutDetails);
|
res = typeMapper.addMaTypeStockNum(leaseOutDetails);
|
||||||
// 更新 (ma_machine 设备表)的状态
|
// 更新 (ma_machine 设备表)的状态
|
||||||
machineMapper.updateMaMachineStatus(leaseOutDetails, MaMachineStatusEnum.IN_STORE.getStatus());
|
if (leaseOutDetails.getMaId() != null) {
|
||||||
|
machineMapper.updateMaMachineStatus(leaseOutDetails, MaMachineStatusEnum.IN_STORE.getStatus());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ public class ScheduledTasks {
|
||||||
*/
|
*/
|
||||||
private String getCronFromDatabase() {
|
private String getCronFromDatabase() {
|
||||||
// 这里假设从数据库中获取 cron 表达式
|
// 这里假设从数据库中获取 cron 表达式
|
||||||
return "0 0 9 */2 * ?";
|
//return "0 */1 * * * ?";
|
||||||
|
return "0 0 9 */3 * ?";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,119 @@
|
||||||
|
package com.bonus.material.warning;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||||
|
import com.bonus.common.biz.enums.PurchaseTaskStatusEnum;
|
||||||
|
import com.bonus.common.biz.enums.RepairInputStatusEnum;
|
||||||
|
import com.bonus.common.biz.enums.TmTaskTypeEnum;
|
||||||
|
import com.bonus.common.core.utils.StringUtils;
|
||||||
|
import com.bonus.common.core.utils.sms.SmsUtils;
|
||||||
|
import com.bonus.material.task.domain.TmTask;
|
||||||
|
import com.bonus.material.task.service.ITmTaskService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||||
|
import org.springframework.scheduling.support.CronTrigger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 待入库定时任务
|
||||||
|
* @Author ma_sh
|
||||||
|
* @create 2025/1/13 18:11
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class WashHouseScheduledTasks {
|
||||||
|
|
||||||
|
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ITmTaskService tmTaskService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ScheduledTaskRegistrar scheduledTaskRegistrar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时任务执行频率,每3天上午9点执行一次
|
||||||
|
*/
|
||||||
|
private String cronExpression = "0 0 9 */3 * ?";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化定时任务
|
||||||
|
*/
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
cronExpression = getCronFromDatabase();
|
||||||
|
updateCronTask();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新定时任务
|
||||||
|
*/
|
||||||
|
private void updateCronTask() {
|
||||||
|
scheduledTaskRegistrar.getScheduler().schedule(() -> {
|
||||||
|
taskWithWashHouse();
|
||||||
|
}, new CronTrigger(cronExpression));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从数据库中获取 cron 表达式
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getCronFromDatabase() {
|
||||||
|
// 这里假设从数据库中获取 cron 表达式
|
||||||
|
//return "0/30 * * * * ?";
|
||||||
|
return "0 0 9 */2 * ?";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void taskWithWashHouse() {
|
||||||
|
log.info("开始执行未入库定时推送任务");
|
||||||
|
boolean hasNullTask = false;
|
||||||
|
TmTask info = new TmTask();
|
||||||
|
List<TmTask> list = tmTaskService.selectTmTaskList(info);
|
||||||
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
for (TmTask tmTask : list) {
|
||||||
|
if (tmTask.getTaskType().equals(TmTaskTypeEnum.TM_TASK_PURCHASE.getTaskTypeId())) {
|
||||||
|
if (tmTask.getTaskStatus().equals(PurchaseTaskStatusEnum.TASK_IN_PROGRESS.getStatus())) {
|
||||||
|
hasNullTask = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (tmTask.getTaskType().equals(TmTaskTypeEnum.TM_TASK_REPAIR_INPUT.getTaskTypeId())) {
|
||||||
|
if (tmTask.getTaskStatus().equals(RepairInputStatusEnum.INPUT_TASK_NO_FINISHED.getStatus())) {
|
||||||
|
hasNullTask = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasNullTask) {
|
||||||
|
sendSms("15527030643", "您好!您还有待入库任务需要进行处理,请及时登录系统查看处理,感谢配合!");
|
||||||
|
} else {
|
||||||
|
log.info("没有待入库的单子");
|
||||||
|
System.out.println("没有待入库的单子");
|
||||||
|
}
|
||||||
|
// 记录任务执行时间
|
||||||
|
System.out.println("待入库定时任务执行时间:" + LocalDateTime.now().format(FORMATTER));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送短信
|
||||||
|
* @param phoneNumber 手机号码
|
||||||
|
* @param content 短信内容
|
||||||
|
*/
|
||||||
|
private void sendSms(String phoneNumber, String content) {
|
||||||
|
try {
|
||||||
|
String sendResult = SmsUtils.smsToken(phoneNumber, content, "");
|
||||||
|
if (StringUtils.isNotBlank(sendResult)) {
|
||||||
|
log.info("短信发送成功: {}", sendResult);
|
||||||
|
} else {
|
||||||
|
log.error("短信发送失败,发送结果为空!");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("短信发送过程中发生异常", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -405,6 +405,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
mm.ma_status = '2' and mm.qr_code = #{qrCode}
|
mm.ma_status = '2' and mm.qr_code = #{qrCode}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getDetailsById" resultType="com.bonus.material.back.domain.BackApplyDetails">
|
||||||
|
SELECT
|
||||||
|
mt1.type_name as typeName,
|
||||||
|
mt.type_name as typeModel,
|
||||||
|
bcd.type_id as typeId,
|
||||||
|
bcd.back_num as preNum,
|
||||||
|
bcd.ma_id as maId,
|
||||||
|
mm.ma_code as maCode,
|
||||||
|
bcd.parent_id as parentId,
|
||||||
|
bcd.create_by as createBy,
|
||||||
|
bcd.create_time as createTime,
|
||||||
|
bai.task_id as taskId
|
||||||
|
FROM
|
||||||
|
back_check_details bcd
|
||||||
|
LEFT JOIN ma_type mt ON bcd.type_id = mt.type_id
|
||||||
|
AND mt.del_flag = '0'
|
||||||
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||||
|
AND mt1.del_flag = '0'
|
||||||
|
LEFT JOIN ma_machine mm ON bcd.ma_id = mm.ma_id
|
||||||
|
LEFT JOIN back_apply_info bai ON bcd.parent_id = bai.id
|
||||||
|
WHERE
|
||||||
|
bcd.parent_id = #{parentId} and bcd.type_id = #{typeId}
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertBackApplyInfo" parameterType="com.bonus.material.back.domain.BackApplyInfo" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertBackApplyInfo" parameterType="com.bonus.material.back.domain.BackApplyInfo" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into back_apply_info
|
insert into back_apply_info
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
|
@ -704,7 +728,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
WHERE bai.task_id = #{taskId};
|
WHERE bai.task_id = #{taskId};
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="update">
|
||||||
|
update back_apply_details
|
||||||
|
set pre_num = pre_num - COALESCE(#{preNum} ,0),
|
||||||
|
audit_num = audit_num - COALESCE(#{preNum} ,0),
|
||||||
|
use_num = use_num + COALESCE(#{preNum} ,0),
|
||||||
|
status = '1',
|
||||||
|
update_time = now()
|
||||||
|
where
|
||||||
|
parent_id = #{parentId} and type_id = #{typeId}
|
||||||
|
</update>
|
||||||
|
|
||||||
<delete id="removeBackApplyDetails">
|
<delete id="removeBackApplyDetails">
|
||||||
delete from back_apply_details where code = #{code} and status = '2'
|
delete from back_apply_details where code = #{code} and status = '2'
|
||||||
</delete>
|
</delete>
|
||||||
|
<delete id="deleteBackApplyDetailsById">
|
||||||
|
delete from back_apply_details where parent_id = #{parentId} and type_id = #{typeId}
|
||||||
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
lease_apply_details
|
lease_apply_details
|
||||||
SET
|
SET
|
||||||
al_num = al_num - #{outNum},
|
al_num = al_num - #{outNum},
|
||||||
<if test="record.updateBy != null and record.updateBy!= '' ">
|
<if test="updateBy != null and updateBy!= '' ">
|
||||||
update_by = #{updateBy},
|
update_by = #{updateBy},
|
||||||
</if>
|
</if>
|
||||||
update_time = now(),
|
update_time = now(),
|
||||||
|
|
@ -369,7 +369,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
mt.type_name as typeName,
|
mt.type_name as typeName,
|
||||||
mm.ma_code as maCode,
|
mm.ma_code as maCode,
|
||||||
lod.create_by as createBy,
|
lod.create_by as createBy,
|
||||||
lod.create_time as createTime
|
lod.create_time as createTime,
|
||||||
|
lod.ma_id as maId
|
||||||
FROM
|
FROM
|
||||||
lease_out_details lod
|
lease_out_details lod
|
||||||
LEFT JOIN ma_type mt ON lod.type_id = mt.type_id
|
LEFT JOIN ma_type mt ON lod.type_id = mt.type_id
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue