Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
87541e54cd
|
|
@ -32,6 +32,8 @@ public class TypeTreeNode {
|
|||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private String typeName;
|
||||
|
||||
private String materialName;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<TypeTreeNode> children = new ArrayList<>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.validation.Valid;
|
||||
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.material.back.domain.MaCode;
|
||||
import com.bonus.material.back.domain.vo.BackAppRequestVo;
|
||||
import com.bonus.material.back.domain.vo.BackApplyRequestVo;
|
||||
import com.bonus.material.common.annotation.PreventRepeatSubmit;
|
||||
import io.swagger.annotations.Api;
|
||||
|
|
@ -52,13 +54,29 @@ public class BackApplyInfoController extends BaseController {
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据单位和工程id查询领料机具
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "根据单位和工程id查询领料机具")
|
||||
@GetMapping("/getMachineById")
|
||||
public AjaxResult getMachineById(BackApplyInfo dto){
|
||||
return backApplyInfoService.getMachineById(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* app根据设备编码去检索领料详情
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "app编码检索")
|
||||
@RequiresPermissions("back:info:list")
|
||||
@GetMapping("/getMachine")
|
||||
public AjaxResult getMachine(BackApplyInfo dto){
|
||||
return backApplyInfoService.getMachine(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出退料任务列表
|
||||
*/
|
||||
|
|
@ -110,7 +128,7 @@ public class BackApplyInfoController extends BaseController {
|
|||
@RequiresPermissions("back:info:add")
|
||||
@SysLog(title = "退料任务", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增退料任务app")
|
||||
@PostMapping("/insertApp")
|
||||
public AjaxResult insertApp(@RequestBody BackApplyRequestVo dto) {
|
||||
public AjaxResult insertApp(@RequestBody BackAppRequestVo dto) {
|
||||
try {
|
||||
return backApplyInfoService.insertApp(dto);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -170,9 +188,9 @@ public class BackApplyInfoController extends BaseController {
|
|||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("back:info:remove")
|
||||
@SysLog(title = "退料任务", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除退料任务")
|
||||
@DeleteMapping("/{id}")
|
||||
public AjaxResult remove(@PathVariable Long id) {
|
||||
return backApplyInfoService.deleteBackApplyInfoById(id);
|
||||
@PostMapping("/deleteById")
|
||||
public AjaxResult remove(@RequestBody BackApplyInfo backApplyInfo) {
|
||||
return backApplyInfoService.deleteBackApplyInfoById(backApplyInfo.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -186,4 +204,26 @@ public class BackApplyInfoController extends BaseController {
|
|||
public AjaxResult delete(@RequestBody BackApplyInfo backApplyInfo) {
|
||||
return backApplyInfoService.delete(backApplyInfo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "app查询单个类型设备编码")
|
||||
@RequiresPermissions("back:info:list")
|
||||
@SysLog(title = "退料任务", businessType = OperaType.QUERY, logType = 1,module = "仓储管理->app查询单个类型设备编码")
|
||||
@GetMapping("/getMaCodeList")
|
||||
public AjaxResult getMaCodeList(BackApplyInfo backApplyInfo) {
|
||||
return backApplyInfoService.getMaCodeList(backApplyInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* app编码查看保存
|
||||
* @param maCode
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "app编码查看保存")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("back:info:update")
|
||||
@SysLog(title = "退料任务", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->删除退料任务")
|
||||
@PostMapping("/updateMaCode")
|
||||
public AjaxResult updateMaCode(@RequestBody MaCode maCode) {
|
||||
return backApplyInfoService.updateMaCode(maCode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,16 @@ public class BackApplyDetails extends BaseEntity {
|
|||
@ApiModelProperty(value = "管理方式(0编号 1计数)")
|
||||
private String manageType;
|
||||
|
||||
/**
|
||||
* 机具编码
|
||||
*/
|
||||
@ApiModelProperty(value = "机具编码")
|
||||
private String maCode;
|
||||
|
||||
private String materialName;
|
||||
|
||||
private String maStatus;
|
||||
|
||||
/**
|
||||
* 机具编码集合(可能存在多个,数据库存储用逗号分割)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -153,4 +153,7 @@ public class BackApplyInfo {
|
|||
|
||||
@ApiModelProperty(value="关键字")
|
||||
private String keyWord;
|
||||
|
||||
@ApiModelProperty(value="设备编码")
|
||||
private String maCode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.bonus.material.back.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author ma_sh
|
||||
* @create 2024/11/21 17:14
|
||||
*/
|
||||
@Data
|
||||
public class MaCode {
|
||||
|
||||
/**
|
||||
* 编码设备列表传参
|
||||
*/
|
||||
private List<MaCodeDto> maCodeDtoList;
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.material.back.domain;
|
||||
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import com.bonus.material.basic.domain.BmFileInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
@ -12,11 +13,16 @@ import java.util.List;
|
|||
* @create 2024/11/11 15:57
|
||||
*/
|
||||
@Data
|
||||
public class MaCodeDto {
|
||||
public class MaCodeDto extends BaseEntity {
|
||||
|
||||
@ApiModelProperty(value = "主键id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "机具id")
|
||||
private Long maId;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 机具编码
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
package com.bonus.material.back.domain.vo;
|
||||
|
||||
import com.bonus.material.back.domain.BackApplyDetails;
|
||||
import com.bonus.material.back.domain.BackApplyInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 退料申请请求参数
|
||||
* @Author ma_sh
|
||||
* @create 2024/11/11 15:32
|
||||
*/
|
||||
@Data
|
||||
public class BackAppRequestVo {
|
||||
|
||||
/**
|
||||
* 退料申请信息
|
||||
*/
|
||||
private BackApplyInfo backApplyInfo;
|
||||
|
||||
/**
|
||||
* 编码退料申请明细
|
||||
*/
|
||||
private BackApplyDetails backApplyDetails;
|
||||
|
||||
/**
|
||||
* 数量退料申请明细
|
||||
*/
|
||||
private List<BackApplyDetails> backApplyDetailsList;
|
||||
}
|
||||
|
|
@ -16,6 +16,8 @@ public class MaCodeVo {
|
|||
|
||||
private String maStatus;
|
||||
|
||||
private String maStatusName;
|
||||
|
||||
private String typeId;
|
||||
|
||||
@ApiModelProperty(value = "物资类型")
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import com.bonus.material.back.domain.BackApplyDetails;
|
||||
import com.bonus.material.back.domain.BackApplyInfo;
|
||||
import com.bonus.material.back.domain.MaCodeDto;
|
||||
import com.bonus.material.back.domain.vo.MaCodeVo;
|
||||
import com.bonus.material.settlement.domain.SltAgreementInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -225,4 +226,60 @@ public interface BackApplyInfoMapper {
|
|||
* @return
|
||||
*/
|
||||
int deleteDetails(BackApplyInfo backApplyInfo);
|
||||
|
||||
/**
|
||||
* 查询机具
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<MaCodeVo> getMachine(BackApplyInfo dto);
|
||||
|
||||
/**
|
||||
* 查询机具数量
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
Integer getNum(BackApplyInfo dto);
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
* @param details
|
||||
* @return
|
||||
*/
|
||||
BackApplyDetails selectBackApplyDetailsById(BackApplyDetails details);
|
||||
|
||||
/**
|
||||
* 更新详情
|
||||
* @param details
|
||||
* @return
|
||||
*/
|
||||
int updateDetails(BackApplyDetails details);
|
||||
|
||||
/**
|
||||
* 查询机具详情
|
||||
* @param details
|
||||
* @return
|
||||
*/
|
||||
BackApplyDetails selectCheckDetails(BackApplyDetails details);
|
||||
|
||||
/**
|
||||
* 更新机具详情
|
||||
* @param checkDetails
|
||||
* @return
|
||||
*/
|
||||
int updateCheck(BackApplyDetails checkDetails);
|
||||
|
||||
/**
|
||||
* 根据类型查询机具
|
||||
* @param backApplyInfo
|
||||
* @return
|
||||
*/
|
||||
List<MaCodeVo> selectByTypeId(BackApplyInfo backApplyInfo);
|
||||
|
||||
/**
|
||||
* 更新机具外观状态
|
||||
* @param maCodeDto
|
||||
* @return
|
||||
*/
|
||||
int updateMaCode(MaCodeDto maCodeDto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import java.util.List;
|
|||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.back.domain.BackApplyInfo;
|
||||
import com.bonus.material.back.domain.MaCode;
|
||||
import com.bonus.material.back.domain.vo.BackAppRequestVo;
|
||||
import com.bonus.material.back.domain.vo.BackApplyRequestVo;
|
||||
|
||||
/**
|
||||
|
|
@ -79,7 +81,7 @@ public interface IBackApplyInfoService {
|
|||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
AjaxResult insertApp(BackApplyRequestVo dto);
|
||||
AjaxResult insertApp(BackAppRequestVo dto);
|
||||
|
||||
/**
|
||||
* app内层删除退料任务
|
||||
|
|
@ -87,4 +89,25 @@ public interface IBackApplyInfoService {
|
|||
* @return
|
||||
*/
|
||||
AjaxResult delete(BackApplyInfo backApplyInfo);
|
||||
|
||||
/**
|
||||
* app编码检索
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getMachine(BackApplyInfo dto);
|
||||
|
||||
/**
|
||||
* app查询单个类型设备编码
|
||||
* @param backApplyInfo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getMaCodeList(BackApplyInfo backApplyInfo);
|
||||
|
||||
/**
|
||||
* app编码查看保存
|
||||
* @param maCode
|
||||
* @return
|
||||
*/
|
||||
AjaxResult updateMaCode(MaCode maCode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import cn.hutool.core.util.PhoneUtil;
|
|||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.bonus.common.biz.enums.BackTaskStatusEnum;
|
||||
import com.bonus.common.biz.enums.HttpCodeEnum;
|
||||
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.utils.DateUtils;
|
||||
|
|
@ -15,11 +16,15 @@ import com.bonus.common.core.utils.StringUtils;
|
|||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.back.domain.BackApplyDetails;
|
||||
import com.bonus.material.back.domain.MaCode;
|
||||
import com.bonus.material.back.domain.MaCodeDto;
|
||||
import com.bonus.material.back.domain.vo.BackAppRequestVo;
|
||||
import com.bonus.material.back.domain.vo.BackApplyRequestVo;
|
||||
import com.bonus.material.back.domain.vo.MaCodeVo;
|
||||
import com.bonus.material.basic.domain.BmFileInfo;
|
||||
import com.bonus.material.basic.mapper.BmFileInfoMapper;
|
||||
import com.bonus.material.ma.mapper.MachineMapper;
|
||||
import com.bonus.material.purchase.config.RemoteConfig;
|
||||
import com.bonus.material.settlement.domain.SltAgreementInfo;
|
||||
import com.bonus.material.task.domain.TmTask;
|
||||
import com.bonus.material.task.domain.TmTaskAgreement;
|
||||
|
|
@ -56,6 +61,12 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
@Resource
|
||||
private TmTaskAgreementMapper taskAgreementMapper;
|
||||
|
||||
@Resource
|
||||
private MachineMapper machineMapper;
|
||||
|
||||
@Resource
|
||||
private RemoteConfig remoteConfig;
|
||||
|
||||
/**
|
||||
* 查询退料任务
|
||||
*
|
||||
|
|
@ -138,8 +149,9 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
* @param maCodeList
|
||||
*/
|
||||
private void setMaCodeDetails(BackApplyDetails details, List<MaCodeVo> maCodeList) {
|
||||
List<MaCodeVo> codeVos = maCodeList.stream().filter(maCodeVo -> StringUtils.isNotBlank(maCodeVo.getMaCode())).collect(Collectors.toList());
|
||||
List<MaCodeDto> maCodeDtos = new ArrayList<>();
|
||||
for (MaCodeVo maCodeVo : maCodeList) {
|
||||
for (MaCodeVo maCodeVo : codeVos) {
|
||||
MaCodeDto maCodeDto = new MaCodeDto();
|
||||
maCodeDto.setMaCode(maCodeVo.getMaCode());
|
||||
maCodeDto.setMaId(maCodeVo.getMaId());
|
||||
|
|
@ -228,7 +240,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
for (BackApplyDetails backApplyDetails : dto.getBackApplyDetailsList()) {
|
||||
if (backApplyDetails.getNum() != null && backApplyDetails.getPreNum() != null) {
|
||||
if (backApplyDetails.getNum() < backApplyDetails.getPreNum()) {
|
||||
return AjaxResult.error("退料数量不能大于预退数量,请重新填写!");
|
||||
return AjaxResult.error(backApplyDetails.getTypeName() + "退料数量不能大于预退数量,请重新填写!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -331,6 +343,8 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
details.setApDetection(maCodeDto.getApDetection());
|
||||
// 插入 CheckDetails
|
||||
result += backApplyInfoMapper.insertCheckDetails(details);
|
||||
//更新ma_machine表状态为3(退料检修)
|
||||
result += machineMapper.updateStatus(maCodeDto.getMaId(), MaMachineStatusEnum.BACK_REPAIR.getStatus());
|
||||
if (CollectionUtils.isNotEmpty(maCodeDto.getBmFileInfos())) {
|
||||
for (BmFileInfo bmFileInfo : maCodeDto.getBmFileInfos()) {
|
||||
bmFileInfo.setCreateBy(SecurityUtils.getUsername());
|
||||
|
|
@ -403,7 +417,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
for (BackApplyDetails backApplyDetails : dto.getBackApplyDetailsList()) {
|
||||
if (backApplyDetails.getNum() != null && backApplyDetails.getPreNum() != null) {
|
||||
if (backApplyDetails.getNum() < backApplyDetails.getPreNum()) {
|
||||
return AjaxResult.error("退料数量不能大于预退数量,请重新填写!");
|
||||
return AjaxResult.error(backApplyDetails.getTypeName() + "退料数量不能大于预退数量,请重新填写!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -415,10 +429,16 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
}
|
||||
// 查询信息
|
||||
Long id = dto.getBackApplyInfo().getId();
|
||||
BackApplyInfo backApplyInfo = backApplyInfoMapper.selectBackApplyInfoById(id);
|
||||
List<BackApplyDetails> backApplyDetailsList = backApplyInfoMapper.selectBackApplyDetailsListByTaskId(id);
|
||||
List<MaCodeVo> maCodeList = backApplyInfoMapper.selectByCode(id);
|
||||
// 删除相关任务信息
|
||||
int result = 0;
|
||||
if (CollectionUtils.isNotEmpty(maCodeList)) {
|
||||
for (MaCodeVo maCodeVo : maCodeList) {
|
||||
result += machineMapper.updateStatus(maCodeVo.getMaId(), MaMachineStatusEnum.IN_USE.getStatus());
|
||||
}
|
||||
}
|
||||
// 删除相关任务信息
|
||||
result += backApplyInfoMapper.deleteBackApplyDetails(id);
|
||||
result += backApplyInfoMapper.deleteCheckDetails(id);
|
||||
// 删除退料详情附件
|
||||
|
|
@ -428,9 +448,9 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
if (result > 0) {
|
||||
//执行新增操作
|
||||
BackApplyInfo info = dto.getBackApplyInfo();
|
||||
info.setId(id);
|
||||
info.setUpdateTime(DateUtils.getNowDate());
|
||||
info.setUpdateBy(SecurityUtils.getUsername());
|
||||
info.setCode(backApplyInfo.getCode());
|
||||
result += backApplyInfoMapper.updateBackApplyInfo(info);
|
||||
// 保存退料详情
|
||||
result = saveBackApplyDetails(dto, info, result);
|
||||
|
|
@ -624,55 +644,235 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult insertApp(BackApplyRequestVo dto) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult insertApp(BackAppRequestVo dto) {
|
||||
int result = 0;
|
||||
if (dto != null && dto.getBackApplyInfo() != null && CollectionUtils.isEmpty(dto.getBackApplyDetailsList())) {
|
||||
//只新增主任务单
|
||||
//对传入的手机号进行校验
|
||||
if (dto != null && dto.getBackApplyInfo() != null && dto.getBackApplyInfo().getId() == null) {
|
||||
//只新增主任务单
|
||||
//对传入的手机号进行校验
|
||||
if (StringUtils.isNotBlank(dto.getBackApplyInfo().getPhone()) && !PhoneUtil.isMobile(dto.getBackApplyInfo().getPhone())) {
|
||||
return AjaxResult.error("手机号格式不正确,请重新填写!");
|
||||
}
|
||||
//生成退料单号
|
||||
String code = getString();
|
||||
if (StringUtils.isBlank(code)) {
|
||||
return AjaxResult.error("后台退料编号生成异常,请重试!");
|
||||
return AjaxResult.error("后台退料编号生成异常,请重试!");
|
||||
}
|
||||
|
||||
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId());
|
||||
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(),
|
||||
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId());
|
||||
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(),
|
||||
BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus(),
|
||||
null,thisMonthMaxOrder + 1, code);
|
||||
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||
tmTask.setCreateBy(SecurityUtils.getUsername());
|
||||
BackApplyInfo backApplyInfo = dto.getBackApplyInfo();
|
||||
backApplyInfo.setCode(code);
|
||||
backApplyInfo.setCreateBy(SecurityUtils.getUsername());
|
||||
backApplyInfo.setCreateTime(DateUtils.getNowDate());
|
||||
// 保存退料信息到 tm_task 表中
|
||||
result += taskMapper.insertTmTask(tmTask);
|
||||
if (result > 0) {
|
||||
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask.getTaskId(), dto.getBackApplyInfo().getAgreementId());
|
||||
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
||||
tmTaskAgreement.setCreateBy(SecurityUtils.getUsername());
|
||||
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
||||
backApplyInfo.setTaskId(tmTask.getTaskId());
|
||||
result += backApplyInfoMapper.insertBackApplyInfo(backApplyInfo);
|
||||
}
|
||||
if (result > 0) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
} else if (dto != null && dto.getBackApplyInfo() != null && dto.getBackApplyInfo().getId() != null) {
|
||||
// 保存退料详情
|
||||
result = saveBackApplyDetails(dto, dto.getBackApplyInfo(), result);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
} else {
|
||||
return insertBackApplyInfo(dto);
|
||||
null, thisMonthMaxOrder + 1, code);
|
||||
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||
tmTask.setCreateBy(SecurityUtils.getUsername());
|
||||
BackApplyInfo backApplyInfo = dto.getBackApplyInfo();
|
||||
backApplyInfo.setCode(code);
|
||||
backApplyInfo.setCreateBy(SecurityUtils.getUsername());
|
||||
backApplyInfo.setCreateTime(DateUtils.getNowDate());
|
||||
result = getResultTask(dto, result, tmTask, backApplyInfo);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
} else if (dto != null && dto.getBackApplyInfo() != null && dto.getBackApplyInfo().getId() != null
|
||||
&& ((dto.getBackApplyDetails() != null) || CollectionUtils.isNotEmpty(dto.getBackApplyDetailsList()))) {
|
||||
if (dto.getBackApplyDetails() != null) {
|
||||
dto.getBackApplyInfo().setTypeId(String.valueOf(dto.getBackApplyDetails().getTypeId()));
|
||||
result = getResultMaCode(dto, result);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(dto.getBackApplyDetailsList())) {
|
||||
//数量退料入库
|
||||
for (BackApplyDetails details : dto.getBackApplyDetailsList()) {
|
||||
result = getResultNum(dto, result, details);
|
||||
}
|
||||
}
|
||||
if (result > 0) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
} else if (dto != null && dto.getBackApplyInfo() != null && dto.getBackApplyDetails() != null) {
|
||||
//对传入的手机号进行校验
|
||||
if (StringUtils.isNotBlank(dto.getBackApplyInfo().getPhone()) && !PhoneUtil.isMobile(dto.getBackApplyInfo().getPhone())) {
|
||||
return AjaxResult.error("手机号格式不正确,请重新填写!");
|
||||
}
|
||||
//生成退料单号
|
||||
String code = getString();
|
||||
if (StringUtils.isBlank(code)) {
|
||||
return AjaxResult.error("后台退料编号生成异常,请重试!");
|
||||
}
|
||||
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId());
|
||||
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(),
|
||||
BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus(),
|
||||
null, thisMonthMaxOrder + 1, code);
|
||||
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||
tmTask.setCreateBy(SecurityUtils.getUsername());
|
||||
BackApplyInfo backApplyInfo = dto.getBackApplyInfo();
|
||||
backApplyInfo.setCode(code);
|
||||
backApplyInfo.setCreateBy(SecurityUtils.getUsername());
|
||||
backApplyInfo.setCreateTime(DateUtils.getNowDate());
|
||||
// 保存退料信息到 tm_task 表中
|
||||
result = getResultTask(dto, result, tmTask, backApplyInfo);
|
||||
extractedMaCode(dto, result, code, backApplyInfo);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* app直接编码保存方法抽取
|
||||
* @param dto
|
||||
* @param result
|
||||
* @param code
|
||||
* @param backApplyInfo
|
||||
*/
|
||||
private void extractedMaCode(BackAppRequestVo dto, int result, String code, BackApplyInfo backApplyInfo) {
|
||||
//根据协议以及类型id查询领料数量
|
||||
Integer num = backApplyInfoMapper.getNum(backApplyInfo);
|
||||
//编码退料入库
|
||||
Long id = backApplyInfo.getId();
|
||||
BackApplyDetails details = dto.getBackApplyDetails();
|
||||
details.setCode(code);
|
||||
details.setParentId(id);
|
||||
details.setNum(num);
|
||||
details.setAuditNum(details.getPreNum());
|
||||
details.setStatus(String.valueOf(BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus()));
|
||||
details.setCreateBy(SecurityUtils.getUsername());
|
||||
details.setCreateTime(DateUtils.getNowDate());
|
||||
// 保存退料详情
|
||||
result += backApplyInfoMapper.insertBackApplyDetails(details);
|
||||
// 设置公共字段
|
||||
setCommonFields(details, id);
|
||||
details.setPreNum(1);
|
||||
// 插入 CheckDetails
|
||||
result += backApplyInfoMapper.insertCheckDetails(details);
|
||||
//更新ma_machine表状态为3(退料检修)
|
||||
result += machineMapper.updateStatus(details.getMaId(), MaMachineStatusEnum.BACK_REPAIR.getStatus());
|
||||
if (CollectionUtils.isNotEmpty(details.getBmFileInfos())) {
|
||||
for (BmFileInfo bmFileInfo : details.getBmFileInfos()) {
|
||||
bmFileInfo.setCreateBy(SecurityUtils.getUsername());
|
||||
bmFileInfo.setCreateTime(DateUtils.getNowDate());
|
||||
bmFileInfo.setTaskId(details.getId());
|
||||
bmFileInfo.setTaskType(3);
|
||||
bmFileInfo.setModelId(details.getMaId());
|
||||
result += bmFileInfoMapper.insertBmFileInfo(bmFileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存退料信息到任务及任务协议表
|
||||
* @param dto
|
||||
* @param result
|
||||
* @param tmTask
|
||||
* @param backApplyInfo
|
||||
* @return
|
||||
*/
|
||||
private int getResultTask(BackAppRequestVo dto, int result, TmTask tmTask, BackApplyInfo backApplyInfo) {
|
||||
// 保存退料信息到 tm_task 表中
|
||||
result += taskMapper.insertTmTask(tmTask);
|
||||
if (result > 0) {
|
||||
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask.getTaskId(), dto.getBackApplyInfo().getAgreementId());
|
||||
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
||||
tmTaskAgreement.setCreateBy(SecurityUtils.getUsername());
|
||||
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
||||
backApplyInfo.setTaskId(tmTask.getTaskId());
|
||||
result += backApplyInfoMapper.insertBackApplyInfo(backApplyInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数量退料入库
|
||||
* @param dto
|
||||
* @param result
|
||||
* @param details
|
||||
* @return
|
||||
*/
|
||||
private int getResultNum(BackAppRequestVo dto, int result, BackApplyDetails details) {
|
||||
details.setCode(dto.getBackApplyInfo().getCode());
|
||||
details.setParentId(dto.getBackApplyInfo().getId());
|
||||
details.setAuditNum(details.getPreNum());
|
||||
details.setStatus(String.valueOf(BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus()));
|
||||
details.setCreateBy(SecurityUtils.getUsername());
|
||||
details.setCreateTime(DateUtils.getNowDate());
|
||||
// 保存退料详情
|
||||
//现根据id查询back_apply_details表,看数据是否存在,存在则对数量进行更新,不存在则插入
|
||||
BackApplyDetails backApplyDetails = backApplyInfoMapper.selectBackApplyDetailsById(details);
|
||||
if (backApplyDetails != null) {
|
||||
details.setId(backApplyDetails.getId());
|
||||
result += backApplyInfoMapper.updateDetails(details);
|
||||
} else {
|
||||
result += backApplyInfoMapper.insertBackApplyDetails(details);
|
||||
}
|
||||
// 设置公共字段
|
||||
setCommonFields(details, dto.getBackApplyInfo().getId());
|
||||
// 插入 CheckDetails
|
||||
//根据id查询back_check_details表,看数据是否存在,存在则对数量进行更新,不存在则插入
|
||||
BackApplyDetails checkDetails = backApplyInfoMapper.selectCheckDetails(details);
|
||||
if (checkDetails != null) {
|
||||
details.setId(checkDetails.getId());
|
||||
result += backApplyInfoMapper.updateCheck(details);
|
||||
} else {
|
||||
result += backApplyInfoMapper.insertCheckDetails(details);
|
||||
}
|
||||
// 处理附件
|
||||
result = saveBmFileInfo(details, dto.getBackApplyInfo().getId(), result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码退料入库
|
||||
* @param dto
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
private int getResultMaCode(BackAppRequestVo dto, int result) {
|
||||
//根据协议以及类型id查询领料数量
|
||||
Integer num = backApplyInfoMapper.getNum(dto.getBackApplyInfo());
|
||||
//编码退料入库
|
||||
BackApplyDetails details = dto.getBackApplyDetails();
|
||||
details.setCode(dto.getBackApplyInfo().getCode());
|
||||
details.setParentId(dto.getBackApplyInfo().getId());
|
||||
details.setPreNum(1);
|
||||
details.setAuditNum(details.getPreNum());
|
||||
details.setNum(num);
|
||||
details.setStatus(String.valueOf(BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus()));
|
||||
details.setCreateBy(SecurityUtils.getUsername());
|
||||
details.setCreateTime(DateUtils.getNowDate());
|
||||
// 保存退料详情
|
||||
//现根据id查询back_apply_details表,看数据是否存在,存在则对数量进行更新,不存在则插入
|
||||
BackApplyDetails backApplyDetails = backApplyInfoMapper.selectBackApplyDetailsById(details);
|
||||
if (backApplyDetails != null) {
|
||||
details.setId(backApplyDetails.getId());
|
||||
result += backApplyInfoMapper.updateDetails(details);
|
||||
} else {
|
||||
result += backApplyInfoMapper.insertBackApplyDetails(details);
|
||||
}
|
||||
// 设置公共字段
|
||||
setCommonFields(details, dto.getBackApplyInfo().getId());
|
||||
// 插入 CheckDetails
|
||||
//根据id查询back_check_details表,看数据是否存在,存在则对数量进行更新,不存在则插入
|
||||
BackApplyDetails checkDetails = backApplyInfoMapper.selectCheckDetails(details);
|
||||
if (checkDetails != null) {
|
||||
checkDetails.setId(checkDetails.getId());
|
||||
result += backApplyInfoMapper.updateCheck(checkDetails);
|
||||
} else {
|
||||
result += backApplyInfoMapper.insertCheckDetails(details);
|
||||
}
|
||||
//更新ma_machine表状态为3(退料检修)
|
||||
result += machineMapper.updateStatus(details.getMaId(), MaMachineStatusEnum.BACK_REPAIR.getStatus());
|
||||
if (CollectionUtils.isNotEmpty(details.getBmFileInfos())) {
|
||||
for (BmFileInfo bmFileInfo : details.getBmFileInfos()) {
|
||||
bmFileInfo.setCreateBy(SecurityUtils.getUsername());
|
||||
bmFileInfo.setCreateTime(DateUtils.getNowDate());
|
||||
bmFileInfo.setTaskId(details.getId());
|
||||
bmFileInfo.setTaskType(3);
|
||||
bmFileInfo.setModelId(details.getMaId());
|
||||
result += bmFileInfoMapper.insertBmFileInfo(bmFileInfo);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* app内层删除退料任务
|
||||
* @param backApplyInfo
|
||||
|
|
@ -680,25 +880,33 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
*/
|
||||
@Override
|
||||
public AjaxResult delete(BackApplyInfo backApplyInfo) {
|
||||
//先查询相关编码信息
|
||||
List<MaCodeVo> maCodeVoList = backApplyInfoMapper.selectByCode(backApplyInfo.getParentId());
|
||||
//需要清除明细表以及可能存储的文件信息
|
||||
//清除back_apply_details表信息
|
||||
int result = backApplyInfoMapper.deleteApplyDetails(backApplyInfo);
|
||||
//删除back_check_details表信息
|
||||
result += backApplyInfoMapper.deleteDetails(backApplyInfo);
|
||||
//清除file文件表信息
|
||||
BmFileInfo fileInfo = new BmFileInfo();
|
||||
fileInfo.setTaskId(backApplyInfo.getParentId());
|
||||
fileInfo.setModelId(backApplyInfo.getId());
|
||||
result += bmFileInfoMapper.deleteBmFileInfoByBizInfo(fileInfo);
|
||||
if (CollectionUtils.isNotEmpty(maCodeVoList)) {
|
||||
for (MaCodeVo maCodeVo : maCodeVoList) {
|
||||
BmFileInfo bmFileInfo = new BmFileInfo();
|
||||
bmFileInfo.setTaskId(backApplyInfo.getId());
|
||||
bmFileInfo.setModelId(maCodeVo.getMaId());
|
||||
result += bmFileInfoMapper.deleteBmFileInfoByBizInfo(bmFileInfo);
|
||||
// 单个编码删除
|
||||
if (backApplyInfo.getMaId() != null) {
|
||||
// 先查询相关编码信息
|
||||
List<MaCodeVo> maCodeVoList = backApplyInfoMapper.selectByCode(backApplyInfo.getParentId());
|
||||
// 删除 back_check_details 表信息
|
||||
int result = deleteBackCheckDetails(backApplyInfo);
|
||||
//修改机具状态
|
||||
result += machineMapper.updateStatus(backApplyInfo.getMaId(), MaMachineStatusEnum.IN_USE.getStatus());
|
||||
// 删除相关文件信息
|
||||
if (CollectionUtils.isNotEmpty(maCodeVoList)) {
|
||||
result += deleteBmFileInfoForCodes(maCodeVoList, backApplyInfo.getId());
|
||||
}
|
||||
if (result > 0) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
// 查询相关编码信息
|
||||
List<MaCodeVo> maCodeVoList = backApplyInfoMapper.selectByCode(backApplyInfo.getParentId());
|
||||
// 清除明细表以及相关的文件信息
|
||||
int result = deleteApplyDetails(backApplyInfo);
|
||||
result += deleteBackCheckDetails(backApplyInfo);
|
||||
// 删除文件信息
|
||||
result += deleteBmFileInfoByParentId(backApplyInfo.getParentId(), backApplyInfo.getId());
|
||||
|
||||
// 删除与 MaCodeVo 相关的文件信息
|
||||
if (CollectionUtils.isNotEmpty(maCodeVoList)) {
|
||||
result += deleteBmFileInfoForCodes(maCodeVoList, backApplyInfo.getId());
|
||||
}
|
||||
if (result > 0) {
|
||||
return AjaxResult.success();
|
||||
|
|
@ -706,6 +914,156 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 back_check_details 表信息
|
||||
* @param backApplyInfo
|
||||
* @return
|
||||
*/
|
||||
private int deleteBackCheckDetails(BackApplyInfo backApplyInfo) {
|
||||
return backApplyInfoMapper.deleteDetails(backApplyInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 back_apply_details 表信息
|
||||
* @param backApplyInfo
|
||||
* @return
|
||||
*/
|
||||
private int deleteApplyDetails(BackApplyInfo backApplyInfo) {
|
||||
return backApplyInfoMapper.deleteApplyDetails(backApplyInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除与指定 parentId 和 modelId 相关的文件信息
|
||||
* @param parentId
|
||||
* @param modelId
|
||||
* @return
|
||||
*/
|
||||
private int deleteBmFileInfoByParentId(Long parentId, Long modelId) {
|
||||
BmFileInfo fileInfo = new BmFileInfo();
|
||||
fileInfo.setTaskId(parentId);
|
||||
fileInfo.setModelId(modelId);
|
||||
return bmFileInfoMapper.deleteBmFileInfoByBizInfo(fileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除与 maCodeVo 中的 maId 相关的文件信息
|
||||
* @param maCodeVoList
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
private int deleteBmFileInfoForCodes(List<MaCodeVo> maCodeVoList, Long taskId) {
|
||||
int result = 0;
|
||||
for (MaCodeVo maCodeVo : maCodeVoList) {
|
||||
BmFileInfo bmFileInfo = new BmFileInfo();
|
||||
bmFileInfo.setTaskId(taskId);
|
||||
bmFileInfo.setModelId(maCodeVo.getMaId());
|
||||
result += bmFileInfoMapper.deleteBmFileInfoByBizInfo(bmFileInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* app编码检索
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult getMachine(BackApplyInfo dto) {
|
||||
//判断输入或者编码识别或者二维码识别是否为领料工程和单位对应
|
||||
List<MaCodeVo> list = backApplyInfoMapper.getMachine(dto);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
for (MaCodeVo maCodeVo : list) {
|
||||
Map<String, String> maMachineMap = remoteConfig.getDictValue("ma_machine_status");
|
||||
String name = maMachineMap.get(maCodeVo.getMaStatus());
|
||||
maCodeVo.setMaStatusName(StringUtils.isBlank(name) ? "" : name);
|
||||
}
|
||||
}
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* app查询单个类型设备编码
|
||||
* @param backApplyInfo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult getMaCodeList(BackApplyInfo backApplyInfo) {
|
||||
// 查询相关编码信息
|
||||
List<MaCodeVo> maCodeVoList = backApplyInfoMapper.selectByTypeId(backApplyInfo);
|
||||
List<MaCodeDto> maCodeDtos = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(maCodeVoList)) {
|
||||
for (MaCodeVo maCodeVo : maCodeVoList) {
|
||||
MaCodeDto maCodeDto = new MaCodeDto();
|
||||
maCodeDto.setMaCode(maCodeVo.getMaCode());
|
||||
maCodeDto.setMaId(maCodeVo.getMaId());
|
||||
maCodeDto.setApDetection(maCodeVo.getApDetection());
|
||||
maCodeDto.setTypeName(maCodeVo.getTypeName());
|
||||
maCodeDto.setMaterialName(maCodeVo.getMaterialName());
|
||||
maCodeDto.setTypeId(maCodeVo.getTypeId());
|
||||
maCodeDto.setMaStatus(maCodeVo.getMaStatus());
|
||||
maCodeDto.setMaterialType(maCodeVo.getMaterialType());
|
||||
// 查询并设置编码附件
|
||||
List<BmFileInfo> bmFileInfoList = fetchBmFileInfos(backApplyInfo.getId(), maCodeVo.getMaId());
|
||||
if (CollectionUtils.isNotEmpty(bmFileInfoList)) {
|
||||
maCodeDto.setBmFileInfos(bmFileInfoList);
|
||||
}
|
||||
maCodeDtos.add(maCodeDto);
|
||||
}
|
||||
}
|
||||
return AjaxResult.success(maCodeDtos);
|
||||
}
|
||||
|
||||
/**
|
||||
* app编码查看保存
|
||||
* @param maCode
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult updateMaCode(MaCode maCode) {
|
||||
int result = 0;
|
||||
if (CollectionUtils.isNotEmpty(maCode.getMaCodeDtoList())) {
|
||||
// 遍历 maCodeDtoList
|
||||
for (MaCodeDto maCodeDto : maCode.getMaCodeDtoList()) {
|
||||
// 参数校验
|
||||
if (maCodeDto.getId() == null ||maCodeDto.getParentId() == null || maCodeDto.getMaId() == null) {
|
||||
return AjaxResult.error("参数错误");
|
||||
}
|
||||
// 更新 back_check_details 表
|
||||
maCodeDto.setUpdateBy(SecurityUtils.getUsername());
|
||||
maCodeDto.setUpdateTime(DateUtils.getNowDate());
|
||||
result += backApplyInfoMapper.updateMaCode(maCodeDto);
|
||||
// 获取 bmFileInfos
|
||||
List<BmFileInfo> bmFileInfos = maCodeDto.getBmFileInfos();
|
||||
if (CollectionUtils.isNotEmpty(bmFileInfos)) {
|
||||
// 准备删除的文件 ID 列表
|
||||
BmFileInfo fileInfo = new BmFileInfo();
|
||||
fileInfo.setTaskId(maCodeDto.getId());
|
||||
fileInfo.setModelId(maCodeDto.getMaId());
|
||||
// 获取现有的附件信息
|
||||
List<BmFileInfo> bmFileInfoList = bmFileInfoMapper.selectBmFileInfoList(fileInfo);
|
||||
// 如果已有附件记录,则删除
|
||||
if (CollectionUtils.isNotEmpty(bmFileInfoList)) {
|
||||
Long[] ids = bmFileInfoList.stream()
|
||||
.map(BmFileInfo::getId)
|
||||
.toArray(Long[]::new);
|
||||
result += bmFileInfoMapper.deleteBmFileInfoByIds(ids);
|
||||
}
|
||||
// 批量插入新的附件
|
||||
for (BmFileInfo bmFileInfo : bmFileInfos) {
|
||||
bmFileInfo.setTaskId(maCodeDto.getId());
|
||||
bmFileInfo.setModelId(maCodeDto.getMaId());
|
||||
result += bmFileInfoMapper.insertBmFileInfo(bmFileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果成功执行了至少一项操作,返回成功
|
||||
if (result > 0) {
|
||||
return AjaxResult.success("保存成功", result);
|
||||
}
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新任务表及退料申请表状态
|
||||
* @param backApplyInfo
|
||||
|
|
@ -802,7 +1160,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
Long newTask = null;
|
||||
// 生成维修单号
|
||||
String code = genCodeRule();
|
||||
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId());
|
||||
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId());
|
||||
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(), BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus(),
|
||||
null,thisMonthMaxOrder + 1, code);
|
||||
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||
|
|
|
|||
|
|
@ -131,4 +131,10 @@ public class SelectController {
|
|||
public AjaxResult getUseTypeTree(@RequestBody BackApplyInfo bean) {
|
||||
return service.getUseTypeTree(bean);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "在用设备类型")
|
||||
@PostMapping("/getUseType")
|
||||
public AjaxResult getUseType(@RequestBody BackApplyInfo bean) {
|
||||
return service.getUseType(bean);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,4 +151,11 @@ public interface SelectMapper {
|
|||
* @return
|
||||
*/
|
||||
List<BmProject> getProjectListApp(BmProject bmProject);
|
||||
|
||||
/**
|
||||
* 获取在用设备类型app
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<TypeTreeNode> getUseTypeTreeApp(BackApplyInfo bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -185,4 +185,11 @@ public interface SelectService {
|
|||
* @return
|
||||
*/
|
||||
AjaxResult getUseTypeTree(BackApplyInfo bean);
|
||||
|
||||
/**
|
||||
* 获取设备类型
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getUseType(BackApplyInfo bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -283,6 +283,35 @@ public class SelectServiceImpl implements SelectService {
|
|||
return AjaxResult.success(groupList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备类型 app用
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult getUseType(BackApplyInfo bean) {
|
||||
//四级类型只查询数量管理类型数据
|
||||
List<TypeTreeNode> listL4 = mapper.getUseTypeTreeApp(bean);
|
||||
if (CollectionUtils.isEmpty(listL4)) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
// 根据四级查询三级类型信息
|
||||
List<Long> list4ParentIds = listL4.stream()
|
||||
.map(TypeTreeNode::getParentId)
|
||||
.collect(Collectors.toList());
|
||||
// 根据第四层 parentId 查第三层类型
|
||||
List<TypeTreeNode> listL3 = mapper.getUseTypeTreeL3(list4ParentIds);
|
||||
// 如果 bean.getTypeId() 不为 null,筛选符合条件的 listL4 数据
|
||||
if (bean.getTypeId() != null) {
|
||||
List<TypeTreeNode> filteredListL4 = listL4.stream()
|
||||
.filter(node -> String.valueOf(node.getParentId()).equals(bean.getTypeId()))
|
||||
.collect(Collectors.toList());
|
||||
return AjaxResult.success(filteredListL4);
|
||||
}
|
||||
// 如果 bean.getTypeId() 为 null,则返回 listL3
|
||||
return AjaxResult.success(listL3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getGoodsShelvesCbx(SelectDto dto) {
|
||||
List<TreeNode> groupList = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -65,8 +65,9 @@ public class LeaseApplyInfoController extends BaseController {
|
|||
@ApiOperation(value = "获取领料任务详细信息")
|
||||
//@RequiresPermissions("lease:info:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@NotNull(message = "领料任务ID不能为空") @PathVariable("id") Long id) {
|
||||
return success(leaseApplyInfoService.selectLeaseApplyInfoById(id));
|
||||
public AjaxResult getInfo(@NotNull(message = "领料任务ID不能为空") @PathVariable("id") Long id,
|
||||
@RequestParam(value = "keyword", required = false) String keyword) {
|
||||
return success(leaseApplyInfoService.selectLeaseApplyInfoById(id, keyword));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@ public class LeaseApplyDetails extends BaseEntity {
|
|||
@ApiModelProperty(value = "数据所属组织")
|
||||
private Long companyId;
|
||||
|
||||
private String keyword;
|
||||
|
||||
public LeaseApplyDetails(Long id, Long parentId, Long typeId, Long preNum, Long auditNum, Long alNum, String status, Long companyId) {
|
||||
this.id = id;
|
||||
this.parentId = parentId;
|
||||
|
|
@ -96,7 +98,8 @@ public class LeaseApplyDetails extends BaseEntity {
|
|||
|
||||
public LeaseApplyDetails() {}
|
||||
|
||||
public LeaseApplyDetails(Long parentId) {
|
||||
public LeaseApplyDetails(Long parentId, String keyword) {
|
||||
this.parentId = parentId;
|
||||
this.keyword = keyword;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.bonus.material.lease.service;
|
|||
|
||||
import java.util.List;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.lease.domain.LeaseApplyDetails;
|
||||
import com.bonus.material.lease.domain.LeaseApplyInfo;
|
||||
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
|
||||
import com.bonus.material.lease.domain.vo.LeaseOutRequestVo;
|
||||
|
|
@ -18,9 +17,10 @@ public interface ILeaseApplyInfoService {
|
|||
* 查询领料任务
|
||||
*
|
||||
* @param id 领料任务主键
|
||||
* @param keyword keyword 关键字
|
||||
* @return 领料任务
|
||||
*/
|
||||
LeaseApplyRequestVo selectLeaseApplyInfoById(Long id);
|
||||
LeaseApplyRequestVo selectLeaseApplyInfoById(Long id, String keyword);
|
||||
|
||||
/**
|
||||
* 查询领料任务列表
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
* @return 领料任务
|
||||
*/
|
||||
@Override
|
||||
public LeaseApplyRequestVo selectLeaseApplyInfoById(Long id) {
|
||||
public LeaseApplyRequestVo selectLeaseApplyInfoById(Long id, String keyword) {
|
||||
try {
|
||||
Optional<LeaseApplyInfo> optionalInfo = Optional.ofNullable(leaseApplyInfoMapper.selectLeaseApplyInfoById(id));
|
||||
LeaseApplyRequestVo leaseApplyRequestVo = new LeaseApplyRequestVo();
|
||||
|
|
@ -69,7 +69,7 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
optionalInfo.ifPresent(info -> {
|
||||
leaseApplyRequestVo.setLeaseApplyInfo(info);
|
||||
// 获取领料单详情
|
||||
List<LeaseApplyDetails> details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId()));
|
||||
List<LeaseApplyDetails> details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId(), keyword));
|
||||
if (!CollectionUtils.isEmpty(details)) {
|
||||
leaseApplyRequestVo.setLeaseApplyDetailsList(details);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,4 +77,12 @@ public interface MachineMapper
|
|||
* 修改机具设备(ma_machine表)的状态为:在用
|
||||
*/
|
||||
int updateMaMachineStatus(@Param("record") LeaseOutDetails leaseOutDetails, @Param("status") Integer status);
|
||||
|
||||
/**
|
||||
* 修改机具设备(ma_machine表)的状态
|
||||
* @param maId
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
int updateStatus(@Param("maId") Long maId, @Param("status") Integer status);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -278,6 +278,87 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
order by start_time asc
|
||||
</select>
|
||||
|
||||
<select id="getMachine" resultType="com.bonus.material.back.domain.vo.MaCodeVo">
|
||||
SELECT
|
||||
mm.ma_id AS maId,
|
||||
mm.ma_code AS maCode,
|
||||
mm.ma_status AS maStatus,
|
||||
mt1.type_name AS typeName,
|
||||
mm.type_id AS typeId,
|
||||
mt.type_name AS materialName,
|
||||
mt2.type_name AS materialType
|
||||
FROM
|
||||
lease_out_details lod
|
||||
LEFT JOIN ma_machine mm ON lod.ma_id = mm.ma_id
|
||||
LEFT JOIN ma_type mt ON mm.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_type mt2 ON mt1.parent_id = mt2.type_id
|
||||
AND mt2.del_flag = '0'
|
||||
LEFT JOIN lease_apply_info lai ON lod.parent_id = lai.id
|
||||
LEFT JOIN tm_task_agreement tta ON lai.task_id = tta.task_id
|
||||
LEFT JOIN bm_agreement_info ba ON tta.agreement_id = ba.agreement_id
|
||||
WHERE
|
||||
mm.ma_status = '2' and mm.ma_code = #{maCode}
|
||||
AND ba.unit_id = #{unitId}
|
||||
AND ba.project_id = #{proId}
|
||||
</select>
|
||||
|
||||
<select id="getNum" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
SUM( CASE WHEN sai.agreement_id = #{agreementId} AND sai.STATUS = '0' THEN sai.num ELSE 0 END ) AS num
|
||||
FROM
|
||||
ma_type mt
|
||||
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
|
||||
WHERE
|
||||
EXISTS ( SELECT 1 FROM slt_agreement_info sai2 WHERE sai2.type_id = mt.type_id AND sai2.agreement_id = #{agreementId}
|
||||
AND sai2.STATUS = '0' and IFNULL(sai.lease_type,0) = 0 and sai2.num > 0)
|
||||
AND mt.type_id = #{typeId}
|
||||
</select>
|
||||
|
||||
<select id="selectBackApplyDetailsById" resultType="com.bonus.material.back.domain.BackApplyDetails">
|
||||
select id as id,
|
||||
code as code,
|
||||
parent_id as parentId,
|
||||
type_id as typeId,
|
||||
pre_num as preNum
|
||||
from back_apply_details
|
||||
where parent_id = #{parentId} and type_id = #{typeId}
|
||||
</select>
|
||||
|
||||
<select id="selectCheckDetails" resultType="com.bonus.material.back.domain.BackApplyDetails">
|
||||
SELECT
|
||||
id AS id,
|
||||
parent_id AS parentId,
|
||||
type_id AS typeId
|
||||
FROM
|
||||
back_check_details
|
||||
where parent_id = #{parentId} and type_id = #{typeId}
|
||||
<if test="maId != null">
|
||||
and ma_id = #{maId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectByTypeId" resultType="com.bonus.material.back.domain.vo.MaCodeVo">
|
||||
SELECT
|
||||
bcd.ma_id AS maId,
|
||||
mm.ma_code as maCode,
|
||||
bcd.type_id AS typeId,
|
||||
mt2.type_name AS materialType,
|
||||
mt.type_name AS materialName,
|
||||
mt1.type_name AS typeName,
|
||||
bcd.ap_detection AS apDetection,
|
||||
mm.ma_status AS maStatus
|
||||
FROM
|
||||
back_check_details bcd
|
||||
left join ma_machine mm on bcd.ma_id = mm.ma_id
|
||||
left join ma_type mt ON mt.type_id = mm.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_type mt2 ON mt1.parent_id = mt2.type_id and mt2.del_flag = 0
|
||||
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 into back_apply_info
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
|
@ -506,6 +587,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
update back_apply_details set use_num = use_num - COALESCE(#{preNum} ,0) where parent_id = #{parentId} and type_id = #{typeId}
|
||||
</update>
|
||||
|
||||
<update id="updateDetails">
|
||||
update back_apply_details set pre_num = pre_num + COALESCE(#{preNum} ,0) where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateCheck">
|
||||
update back_check_details set back_num = back_num + COALESCE(#{preNum} ,0) where parent_id = #{parentId} and type_id = #{typeId}
|
||||
<if test="maId != null">
|
||||
and ma_id = #{maId}
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<update id="updateMaCode">
|
||||
update back_check_details
|
||||
set
|
||||
<if test="updateBy != null">
|
||||
update_by = #{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
<if test="apDetection != null">
|
||||
ap_detection = #{apDetection}
|
||||
</if>
|
||||
where parent_id = #{parentId} and ma_id = #{maId}
|
||||
</update>
|
||||
|
||||
<insert id="insStlInfoTwo">
|
||||
insert into slt_agreement_info (agreement_id,type_id,ma_id,num,start_time,status,lease_id,lease_price,buy_price,is_slt,company_id,lease_type,create_time)
|
||||
values (#{info.agreementId},#{info.typeId},#{info.maId},#{many},#{info.startTime},#{info.status},#{info.leaseId},#{info.leasePrice},#{info.buyPrice},'0',#{info.companyId},#{info.leaseType},now());
|
||||
|
|
@ -528,6 +635,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</delete>
|
||||
|
||||
<delete id="deleteDetails">
|
||||
delete from back_apply_details where parent_id = #{parentId} and type_id = #{typeId}
|
||||
delete from back_check_details where parent_id = #{parentId} and type_id = #{typeId}
|
||||
<if test="maId != null">
|
||||
and ma_id = #{maId}
|
||||
</if>
|
||||
</delete>
|
||||
</mapper>
|
||||
|
|
@ -182,6 +182,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="getUseTypeTreeL4" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||||
SELECT
|
||||
mt.type_id as typeId,
|
||||
mt1.type_name as materialName,
|
||||
mt.type_name as typeName,
|
||||
mt.parent_id as parentId,
|
||||
mt.unit_name as unitName,
|
||||
|
|
@ -191,6 +192,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
FROM
|
||||
ma_type mt
|
||||
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
||||
WHERE
|
||||
EXISTS ( SELECT 1 FROM slt_agreement_info sai2 WHERE sai2.type_id = mt.type_id AND sai2.agreement_id = #{agreementId}
|
||||
AND sai2.STATUS = '0' and IFNULL(sai.lease_type,0) = 0 and sai2.num > 0)
|
||||
|
|
@ -201,6 +203,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="getUseTypeTreeL3" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||||
SELECT
|
||||
mt3.type_id as typeId,
|
||||
NULL as materialName,
|
||||
mt3.type_name as typeName,
|
||||
mt3.parent_id as parentId,
|
||||
mt3.unit_name as unitName,
|
||||
|
|
@ -217,6 +220,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="getUseTypeTreeL21" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||||
SELECT
|
||||
mt2.type_id as typeId,
|
||||
NULL as materialName,
|
||||
mt2.type_name as typeName,
|
||||
mt2.parent_id as parentId,
|
||||
mt2.unit_name as unitName,
|
||||
|
|
@ -233,6 +237,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
SELECT
|
||||
mt1.type_id as typeId,
|
||||
NULL as materialName,
|
||||
mt1.type_name as typeName,
|
||||
mt1.parent_id as parentId,
|
||||
mt1.unit_name as unitName,
|
||||
|
|
@ -243,6 +248,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
ma_type mt1 left join (
|
||||
SELECT
|
||||
mt2.type_id as typeId,
|
||||
NULL as materialName,
|
||||
mt2.type_name as typeName,
|
||||
mt2.parent_id as parentId,
|
||||
mt2.unit_name as unitName,
|
||||
|
|
@ -341,4 +347,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHERE del_flag = '0'
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getUseTypeTreeApp" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||||
SELECT
|
||||
mt.type_id as typeId,
|
||||
mt1.type_name as materialName,
|
||||
mt.type_name as typeName,
|
||||
mt.parent_id as parentId,
|
||||
mt.unit_name as unitName,
|
||||
mt.manage_type as manageType,
|
||||
SUM( CASE WHEN sai.agreement_id = #{agreementId} AND sai.STATUS = '0' THEN sai.num ELSE 0 END ) AS num,
|
||||
mt.LEVEL as level
|
||||
FROM
|
||||
ma_type mt
|
||||
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
||||
WHERE
|
||||
EXISTS ( SELECT 1 FROM slt_agreement_info sai2 WHERE sai2.type_id = mt.type_id AND sai2.agreement_id = #{agreementId}
|
||||
AND sai2.STATUS = '0' and IFNULL(sai.lease_type,0) = 0 and sai2.num > 0)
|
||||
and mt.manage_type = '1'
|
||||
GROUP BY
|
||||
mt.type_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -50,6 +50,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectLeaseApplyDetailsVo"/>
|
||||
<where>
|
||||
<if test="parentId != null "> and lad.parent_id = #{parentId}</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (mt.type_name LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR mt2.type_name LIKE CONCAT('%', #{keyword}, '%'))
|
||||
</if>
|
||||
<if test="typeId != null "> and lad.type_id = #{typeId}</if>
|
||||
<if test="preNum != null "> and lad.pre_num = #{preNum}</if>
|
||||
<if test="auditNum != null "> and lad.audit_num = #{auditNum}</if>
|
||||
|
|
|
|||
|
|
@ -98,6 +98,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="maStatus != null and maStatus != ''">
|
||||
and ma.ma_status = #{maStatus}
|
||||
</if>
|
||||
<if test="maCode != null and maCode != ''">
|
||||
and ma.ma_code like concat('%', #{maCode}, '%')
|
||||
</if>
|
||||
<if test="materialType != null and materialType != ''">
|
||||
and mt3.type_name like concat('%', #{materialType}, '%')
|
||||
</if>
|
||||
|
|
@ -312,4 +315,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</where>
|
||||
</update>
|
||||
<update id="updateStatus">
|
||||
UPDATE
|
||||
ma_machine
|
||||
SET
|
||||
ma_status = #{status}
|
||||
where
|
||||
ma_id = #{maId}
|
||||
</update>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue