退料管理

This commit is contained in:
mashuai 2024-11-13 18:01:55 +08:00
parent 1db9924f0d
commit be2c9ff8a3
17 changed files with 1302 additions and 74 deletions

View File

@ -0,0 +1,77 @@
package com.bonus.common.biz.domain;
import java.util.ArrayList;
import java.util.List;
/**
* BuildTree 构建树形结构
* @author 10488
*/
public class TypeTreeBuild {
public List<TypeTreeNode> nodeList = new ArrayList<>();
/**
* 构造方法
* @param nodeList 将数据集合赋值给nodeList即所有数据作为所有节点
*/
public TypeTreeBuild(List<TypeTreeNode> nodeList){
this.nodeList = nodeList;
}
/**
* 获取需构建的所有根节点顶级节点 "0"
* @return 所有根节点List集合
*/
public List<TypeTreeNode> getRootNode(){
// 保存所有根节点所有根节点的数据
List<TypeTreeNode> rootNodeList = new ArrayList<>();
// treeNode查询出的每一条数据节点
for (TypeTreeNode treeNode : nodeList){
// 判断当前节点是否为根节点此处注意若parentId类型是String则要采用equals()方法判断
if (0 == treeNode.getParentId()) {
// 添加
rootNodeList.add(treeNode);
}
}
return rootNodeList;
}
/**
* 根据每一个顶级节点根节点进行构建树形结构
* @return 构建整棵树
*/
public List<TypeTreeNode> buildTree(){
// treeNodes保存一个顶级节点所构建出来的完整树形
List<TypeTreeNode> treeNodes = new ArrayList<TypeTreeNode>();
// getRootNode()获取所有的根节点
for (TypeTreeNode treeRootNode : getRootNode()) {
// 将顶级节点进行构建子树
treeRootNode = buildChildTree(treeRootNode);
// 完成一个顶级节点所构建的树形增加进来
treeNodes.add(treeRootNode);
}
return treeNodes;
}
/**
* 递归-----构建子树形结构
* @param pNode 根节点顶级节点
* @return 整棵树
*/
public TypeTreeNode buildChildTree(TypeTreeNode pNode){
List<TypeTreeNode> childTree = new ArrayList<TypeTreeNode>();
// nodeList所有节点集合所有数据
for (TypeTreeNode treeNode : nodeList) {
// 判断当前节点的父节点ID是否等于根节点的ID即当前节点为其下的子节点
if (treeNode.getParentId() == pNode.getTypeId()) {
// 再递归进行判断当前节点的情况调用自身方法
childTree.add(buildChildTree(treeNode));
}
}
// for循环结束即节点下没有任何节点树形构建结束设置树结果
pNode.setChildren(childTree);
return pNode;
}
}

View File

@ -0,0 +1,37 @@
package com.bonus.common.biz.domain;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* 下拉树-实体类
* @Author 阮世耀
* @Create 2023/12/13 15:45
* @Version 1.0
*/
@Data
public class TypeTreeNode {
private long typeId;
private long parentId;
private int companyId;
private String num;
private String manageType;
private String unitName;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String level;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String typeName;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TypeTreeNode> children = new ArrayList<>();
}

View File

@ -3,13 +3,13 @@ package com.bonus.material.back.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.bonus.common.log.enums.OperaType;
import com.bonus.material.back.domain.vo.BackApplyRequestVo;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
@ -41,7 +41,7 @@ public class BackApplyInfoController extends BaseController {
* 查询退料任务列表
*/
@ApiOperation(value = "查询退料任务列表")
@RequiresPermissions("back:info:list")
//@RequiresPermissions("back:info:list")
@GetMapping("/list")
public TableDataInfo list(BackApplyInfo backApplyInfo) {
startPage();
@ -49,6 +49,13 @@ public class BackApplyInfoController extends BaseController {
return getDataTable(list);
}
@ApiOperation(value = "根据单位和工程id查询领料机具")
@GetMapping("/getMachineById")
public AjaxResult getMachineById(BackApplyInfo dto){
return backApplyInfoService.getMachineById(dto);
}
/**
* 导出退料任务列表
*/
@ -67,7 +74,7 @@ public class BackApplyInfoController extends BaseController {
* 获取退料任务详细信息
*/
@ApiOperation(value = "获取退料任务详细信息")
@RequiresPermissions("back:info:query")
//@RequiresPermissions("back:info:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(backApplyInfoService.selectBackApplyInfoById(id));
@ -81,9 +88,9 @@ public class BackApplyInfoController extends BaseController {
@RequiresPermissions("back:info:add")
@SysLog(title = "退料任务", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增退料任务")
@PostMapping
public AjaxResult add(@RequestBody BackApplyInfo backApplyInfo) {
public AjaxResult add(@RequestBody BackApplyRequestVo dto) {
try {
return toAjax(backApplyInfoService.insertBackApplyInfo(backApplyInfo));
return backApplyInfoService.insertBackApplyInfo(dto);
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}
@ -96,10 +103,10 @@ public class BackApplyInfoController extends BaseController {
@PreventRepeatSubmit
@RequiresPermissions("back:info:edit")
@SysLog(title = "退料任务", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改退料任务")
@PutMapping
public AjaxResult edit(@RequestBody BackApplyInfo backApplyInfo) {
@PostMapping("/edit")
public AjaxResult edit(@RequestBody BackApplyRequestVo dto) {
try {
return toAjax(backApplyInfoService.updateBackApplyInfo(backApplyInfo));
return backApplyInfoService.updateBackApplyInfo(dto);
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}
@ -109,11 +116,11 @@ public class BackApplyInfoController extends BaseController {
* 删除退料任务
*/
@ApiOperation(value = "删除退料任务")
@PreventRepeatSubmit
@RequiresPermissions("back:info:remove")
//@PreventRepeatSubmit
//@RequiresPermissions("back:info:remove")
@SysLog(title = "退料任务", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除退料任务")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(backApplyInfoService.deleteBackApplyInfoByIds(ids));
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id) {
return backApplyInfoService.deleteBackApplyInfoById(id);
}
}

View File

@ -1,11 +1,14 @@
package com.bonus.material.back.domain;
import com.bonus.common.core.annotation.Excel;
import com.bonus.material.basic.domain.BmFileInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import com.bonus.common.core.web.domain.BaseEntity;
import java.util.List;
/**
* 退料任务详细对象 back_apply_details
*
@ -27,6 +30,9 @@ public class BackApplyDetails extends BaseEntity {
@ApiModelProperty(value = "退料单号")
private String code;
@ApiModelProperty(value = "机具id")
private Long maId;
/** 任务ID */
@Excel(name = "任务ID")
@ApiModelProperty(value = "任务ID")
@ -37,25 +43,53 @@ public class BackApplyDetails extends BaseEntity {
@ApiModelProperty(value = "规格ID")
private Long typeId;
/** 申请数量 */
@Excel(name = "申请数量")
@ApiModelProperty(value = "申请数量")
private Long preNum;
@ApiModelProperty(value = "类型名称")
private String typeName;
@ApiModelProperty(value = "规格型号")
private String typeModel;
@ApiModelProperty(value = "单位名称")
private String unitName;
@ApiModelProperty(value = "管理方式(0编号 1计数)")
private String manageType;
/**
* 机具编码集合可能存在多个数据库存储用逗号分割
*/
private List<MaCodeDto> maCodeList;
@ApiModelProperty(value = "机具编码")
private String maCode;
/** 退料数量 */
@ApiModelProperty(value = "退料数量")
private Integer preNum;
/** 审批数量 */
@Excel(name = "审批数量")
@ApiModelProperty(value = "审批数量")
private Long auditNum;
private Integer auditNum;
/** 在用数量 */
@ApiModelProperty(value = "在用数量")
private Integer num;
/** 状态(0待审批1进行中2已出库3已驳回) */
@Excel(name = "状态(0待审批1进行中2已出库3已驳回)")
@ApiModelProperty(value = "状态(0待审批1进行中2已出库3已驳回)")
private String status;
@ApiModelProperty(value = "机具外观判断")
private String apDetection;
/** 数据所属组织 */
@Excel(name = "数据所属组织")
@ApiModelProperty(value = "数据所属组织")
private Long companyId;
/**
* 附件列表
*/
@ApiModelProperty(value = "附件列表")
List<BmFileInfo> bmFileInfos;
}

View File

@ -18,17 +18,44 @@ import com.bonus.common.core.web.domain.BaseEntity;
@Data
@ToString
public class BackApplyInfo extends BaseEntity {
public class BackApplyInfo {
private static final long serialVersionUID = 1L;
/** ID */
private Long id;
@ApiModelProperty(value = "协议id")
private Long agreementId;
@ApiModelProperty(value = "任务类型")
private Integer taskType;
@ApiModelProperty(value = "单位id")
private Long unitId;
@ApiModelProperty(value = "单位名称")
@Excel(name = "退料单位")
private String unitName;
@ApiModelProperty(value="工程id")
private Long proId;
@ApiModelProperty(value="工程名称")
@Excel(name = "工程名称")
private String proName;
/** 退料单号 */
@Excel(name = "退料单号")
@ApiModelProperty(value = "退料单号")
private String code;
@ApiModelProperty(value = "类型id")
private String typeId;
@ApiModelProperty(value = "类型名称")
@Excel(name = "物资类型")
private String typeName;
/** 任务ID */
@Excel(name = "任务ID")
@ApiModelProperty(value = "任务ID")
@ -40,7 +67,7 @@ public class BackApplyInfo extends BaseEntity {
private String backPerson;
/** 联系方式 */
@Excel(name = "联系方式")
@Excel(name = "退料人电话")
@ApiModelProperty(value = "联系方式")
private String phone;
@ -68,18 +95,45 @@ public class BackApplyInfo extends BaseEntity {
/** 预退料时间 */
@ApiModelProperty(value = "预退料时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "预退料时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date backTime;
@Excel(name = "创建人")
private String createBy;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "创建时间")
private Date createTime;
/** 1.机具分公司审核通过2.机具分公司审批不通过3.调试分公司审批通过4.调试分公司审批不通过5.出库进行中6.出库完成 */
@Excel(name = "1.机具分公司审核通过2.机具分公司审批不通过3.调试分公司审批通过4.调试分公司审批不通过5.出库进行中6.出库完成")
@Excel(name = "状态")
@ApiModelProperty(value = "1.机具分公司审核通过2.机具分公司审批不通过3.调试分公司审批通过4.调试分公司审批不通过5.出库进行中6.出库完成")
private String status;
@ApiModelProperty(value = "任务状态")
private Integer taskStatus;
private String updateBy;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
@ApiModelProperty(value = "打印状态")
@Excel(name = "打印状态")
private String printStatus;
@Excel(name = "备注")
private String remark;
/** 直转id */
@Excel(name = "直转id")
@ApiModelProperty(value = "直转id")
private Long directId;
@ApiModelProperty(value="开始时间")
private String startTime;
@ApiModelProperty(value="结束时间")
private String endTime;
@ApiModelProperty(value="关键字")
private String keyWord;
}

View File

@ -0,0 +1,34 @@
package com.bonus.material.back.domain;
import com.bonus.material.basic.domain.BmFileInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 机具编码及附件集合
* @Author ma_sh
* @create 2024/11/11 15:57
*/
@Data
public class MaCodeDto {
@ApiModelProperty(value = "机具id")
private Long maId;
/**
* 机具编码
*/
@ApiModelProperty(value = "机具编码")
private String maCode;
@ApiModelProperty(value = "机具外观判断")
private String apDetection;
/**
* 附件列表
*/
@ApiModelProperty(value = "附件列表")
List<BmFileInfo> bmFileInfos;
}

View File

@ -0,0 +1,28 @@
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 java.util.List;
/**
* 退料申请请求参数
* @Author ma_sh
* @create 2024/11/11 15:32
*/
@Data
public class BackApplyRequestVo {
private Long id;
/**
* 退料申请信息
*/
private BackApplyInfo backApplyInfo;
/**
* 退料申请明细
*/
private List<BackApplyDetails> backApplyDetailsList;
}

View File

@ -0,0 +1,27 @@
package com.bonus.material.back.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author ma_sh
* @create 2024/11/11 18:30
*/
@Data
public class MaCodeVo {
private Long maId;
private String maCode;
private String maStatus;
private String typeId;
private String materialName;
private String typeName;
@ApiModelProperty(value = "机具外观判断")
private String apDetection;
}

View File

@ -1,7 +1,12 @@
package com.bonus.material.back.mapper;
import java.util.Date;
import java.util.List;
import com.bonus.material.back.domain.BackApplyDetails;
import com.bonus.material.back.domain.BackApplyInfo;
import com.bonus.material.back.domain.vo.MaCodeVo;
import org.apache.ibatis.annotations.Param;
/**
* 退料任务Mapper接口
@ -57,4 +62,97 @@ public interface BackApplyInfoMapper {
* @return 结果
*/
public int deleteBackApplyInfoByIds(Long[] ids);
/**
* 查询任务编号
* @param date
* @param taskType
* @return
*/
String selectTaskNumByMonth(@Param("date") Date date, @Param("taskType") Integer taskType);
/**
* 新增任务
* @param backApplyInfo
* @return
*/
int insertTmTask(BackApplyInfo backApplyInfo);
/**
* 新增任务关联协议
* @param backApplyInfo
* @return
*/
int insertTaskAgreement(BackApplyInfo backApplyInfo);
/**
* 新增任务详情
* @param details
* @return
*/
int insertBackApplyDetails(BackApplyDetails details);
/**
* 根据机具编码和类型查询机具是否存在
* @param dto
* @return
*/
List<MaCodeVo> getMachineById(BackApplyInfo dto);
/**
* 根据任务id查询详情
* @param id
* @return
*/
List<BackApplyDetails> selectBackApplyDetailsListByTaskId(Long id);
/**
* 根据设备编码查询设备信息
* @param id
* @return
*/
List<MaCodeVo> selectByCode(Long id);
/**
* 新增机具退料详情
* @param details
* @return
*/
int insertCheckDetails(BackApplyDetails details);
/**
* 删除任务
* @param taskId
* @return
*/
int deleteTask(Long taskId);
/**
* 删除任务关联协议
* @param taskId
* @return
*/
int deleteTaskAgreement(Long taskId);
/**
* 删除退料主表
* @param id
* @return
*/
int deleteBackApply(Long id);
/**
* 删除退料详情
* @param id
* @return
*/
int deleteBackApplyDetails(Long id);
/**
* 删除机具退料详情
* @param id
* @return
*/
int deleteCheckDetails(Long id);
}

View File

@ -1,7 +1,10 @@
package com.bonus.material.back.service;
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.vo.BackApplyRequestVo;
/**
* 退料任务Service接口
@ -16,7 +19,7 @@ public interface IBackApplyInfoService {
* @param id 退料任务主键
* @return 退料任务
*/
public BackApplyInfo selectBackApplyInfoById(Long id);
public BackApplyRequestVo selectBackApplyInfoById(Long id);
/**
* 查询退料任务列表
@ -29,18 +32,18 @@ public interface IBackApplyInfoService {
/**
* 新增退料任务
*
* @param backApplyInfo 退料任务
* @param dto 退料任务
* @return 结果
*/
public int insertBackApplyInfo(BackApplyInfo backApplyInfo);
public AjaxResult insertBackApplyInfo(BackApplyRequestVo dto);
/**
* 修改退料任务
*
* @param backApplyInfo 退料任务
* @param dto 退料任务
* @return 结果
*/
public int updateBackApplyInfo(BackApplyInfo backApplyInfo);
public AjaxResult updateBackApplyInfo(BackApplyRequestVo dto);
/**
* 批量删除退料任务
@ -56,5 +59,12 @@ public interface IBackApplyInfoService {
* @param id 退料任务主键
* @return 结果
*/
public int deleteBackApplyInfoById(Long id);
public AjaxResult deleteBackApplyInfoById(Long id);
/**
* 根据机具编码和类型查询机具是否存在
* @param dto
* @return
*/
AjaxResult getMachineById(BackApplyInfo dto);
}

View File

@ -1,13 +1,31 @@
package com.bonus.material.back.service.impl;
import java.util.List;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.util.PhoneUtil;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.common.biz.enums.HttpCodeEnum;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
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.MaCodeDto;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.bonus.material.back.mapper.BackApplyInfoMapper;
import com.bonus.material.back.domain.BackApplyInfo;
import com.bonus.material.back.service.IBackApplyInfoService;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
/**
* 退料任务Service业务层处理
@ -16,10 +34,15 @@ import com.bonus.material.back.service.IBackApplyInfoService;
* @date 2024-10-16
*/
@Service
@Slf4j
public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
@Autowired
@Resource
private BackApplyInfoMapper backApplyInfoMapper;
@Resource
private BmFileInfoMapper bmFileInfoMapper;
/**
* 查询退料任务
*
@ -27,8 +50,109 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
* @return 退料任务
*/
@Override
public BackApplyInfo selectBackApplyInfoById(Long id) {
return backApplyInfoMapper.selectBackApplyInfoById(id);
public BackApplyRequestVo selectBackApplyInfoById(Long id) {
BackApplyRequestVo backApplyRequestVo = new BackApplyRequestVo();
//先根据外层id查询上层信息
BackApplyInfo backApplyInfo = backApplyInfoMapper.selectBackApplyInfoById(id);
backApplyRequestVo.setBackApplyInfo(backApplyInfo);
//查询退料详情信息
List<BackApplyDetails> backApplyDetailsList = backApplyInfoMapper.selectBackApplyDetailsListByTaskId(id);
if (CollectionUtils.isNotEmpty(backApplyDetailsList)) {
// 批量查询附件信息减少数据库访问次数
List<BmFileInfo> bmFileInfos = fetchBmFileInfos(id, backApplyDetailsList);
// 查询编码设备信息
List<MaCodeVo> maCodeList = fetchMaCodeList(id);
for (BackApplyDetails details : backApplyDetailsList) {
// 为每个退料详情设置附件信息
setBmFileInfosForDetails(details, bmFileInfos);
// 如果是编码设备查询并设置相关的编码信息和附件
if ("0".equals(details.getManageType())) {
setMaCodeDetails(details, maCodeList);
}
}
backApplyRequestVo.setBackApplyDetailsList(backApplyDetailsList);
}
return backApplyRequestVo;
}
/**
* 批量查询附件信息
* @param id
* @param backApplyDetailsList
* @return
*/
private List<BmFileInfo> fetchBmFileInfos(Long id, List<BackApplyDetails> backApplyDetailsList) {
List<BmFileInfo> bmFileInfos = new ArrayList<>();
for (BackApplyDetails details : backApplyDetailsList) {
BmFileInfo bmFileInfo = new BmFileInfo();
bmFileInfo.setTaskId(id);
bmFileInfo.setTaskType(3);
bmFileInfo.setModelId(details.getId());
List<BmFileInfo> bmFileInfoList = bmFileInfoMapper.selectBmFileInfoList(bmFileInfo);
// 合并所有附件信息
bmFileInfos.addAll(bmFileInfoList);
}
return bmFileInfos;
}
/**
* 查询编码设备信息
* @param id
* @return
*/
private List<MaCodeVo> fetchMaCodeList(Long id) {
return backApplyInfoMapper.selectByCode(id);
}
/**
* 为每个退料详情设置附件信息
* @param details
* @param bmFileInfos
*/
private void setBmFileInfosForDetails(BackApplyDetails details, List<BmFileInfo> bmFileInfos) {
// 为每个退料详情设置附件信息
List<BmFileInfo> relatedFileInfos = bmFileInfos.stream()
.filter(fileInfo -> fileInfo.getModelId().equals(details.getId()))
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(relatedFileInfos)) {
details.setBmFileInfos(relatedFileInfos);
}
}
/**
* 为编码设备详情设置编码信息和附件信息
* @param details
* @param maCodeList
*/
private void setMaCodeDetails(BackApplyDetails details, List<MaCodeVo> maCodeList) {
List<MaCodeDto> maCodeDtos = new ArrayList<>();
for (MaCodeVo maCodeVo : maCodeList) {
MaCodeDto maCodeDto = new MaCodeDto();
maCodeDto.setMaCode(maCodeVo.getMaCode());
maCodeDto.setMaId(maCodeVo.getMaId());
maCodeDto.setApDetection(maCodeVo.getApDetection());
// 查询并设置编码附件
List<BmFileInfo> bmFileInfoList = fetchBmFileInfos(details.getId(), maCodeVo.getMaId());
if (CollectionUtils.isNotEmpty(bmFileInfoList)) {
maCodeDto.setBmFileInfos(bmFileInfoList);
}
maCodeDtos.add(maCodeDto);
}
details.setMaCodeList(maCodeDtos);
}
/**
* 查询编码设备附件信息
* @param taskId
* @param modelId
* @return
*/
private List<BmFileInfo> fetchBmFileInfos(Long taskId, Long modelId) {
BmFileInfo fileInfo = new BmFileInfo();
fileInfo.setTaskId(taskId);
fileInfo.setTaskType(3);
fileInfo.setModelId(modelId);
return bmFileInfoMapper.selectBmFileInfoList(fileInfo);
}
/**
@ -45,33 +169,206 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
/**
* 新增退料任务
*
* @param backApplyInfo 退料任务
* @param dto 退料任务
* @return 结果
*/
@Override
public int insertBackApplyInfo(BackApplyInfo backApplyInfo) {
backApplyInfo.setCreateTime(DateUtils.getNowDate());
try {
return backApplyInfoMapper.insertBackApplyInfo(backApplyInfo);
} catch (Exception e) {
throw new ServiceException("错误信息描述");
@Transactional(rollbackFor = Exception.class)
public AjaxResult insertBackApplyInfo(BackApplyRequestVo dto) {
if (dto == null || dto.getBackApplyInfo() == null || CollectionUtils.isEmpty(dto.getBackApplyDetailsList())) {
return AjaxResult.error("参数为空,请重新选择后上传!");
}
//对传入的手机号进行校验
if (StringUtils.isNotBlank(dto.getBackApplyInfo().getPhone()) && !PhoneUtil.isMobile(dto.getBackApplyInfo().getPhone())) {
return AjaxResult.error("手机号格式不正确,请重新填写!");
}
//生成退料单号
String code = getString();
if (StringUtils.isBlank(code)) {
return AjaxResult.error("后台退料编号生成异常,请重试!");
}
BackApplyInfo backApplyInfo = dto.getBackApplyInfo();
backApplyInfo.setCode(code);
backApplyInfo.setCreateBy(SecurityUtils.getUsername());
backApplyInfo.setCreateTime(DateUtils.getNowDate());
backApplyInfo.setTaskType(3);
backApplyInfo.setTaskStatus(0);
backApplyInfo.setStatus("0");
int result = 0;
try {
// 保存退料信息到 tm_task 表中
result += backApplyInfoMapper.insertTmTask(backApplyInfo);
if (result > 0) {
Long taskId = backApplyInfo.getTaskId();
result += backApplyInfoMapper.insertTaskAgreement(backApplyInfo);
backApplyInfo.setTaskId(taskId);
result += backApplyInfoMapper.insertBackApplyInfo(backApplyInfo);
}
// 保存退料详情
result = saveBackApplyDetails(dto, backApplyInfo, result);
} catch (Exception e) {
log.error("保存退料信息时发生异常: ", e);
}
return result > 0 ? AjaxResult.success() : AjaxResult.error("保存失败,请重试!");
}
/**
* 保存退料详情
* @param dto
* @param backApplyInfo
* @param result
* @return
*/
private int saveBackApplyDetails(BackApplyRequestVo dto, BackApplyInfo backApplyInfo, int result) {
for (BackApplyDetails details : dto.getBackApplyDetailsList()) {
details.setCode(backApplyInfo.getCode());
details.setParentId(backApplyInfo.getId());
details.setAuditNum(details.getPreNum());
details.setStatus("0");
details.setCreateBy(SecurityUtils.getUsername());
details.setCreateTime(DateUtils.getNowDate());
// 保存退料详情
result += backApplyInfoMapper.insertBackApplyDetails(details);
// 处理附件
result = saveBmFileInfo(details, backApplyInfo.getId(), result);
// 判断是否为编码设备并处理附件
result = saveMaCodeBmFileInfo(details, backApplyInfo.getId(), result);
}
return result;
}
/**
* 保存附件
* @param details
* @param taskId
* @param result
* @return
*/
private int saveBmFileInfo(BackApplyDetails details, Long taskId, int result) {
if (CollectionUtils.isNotEmpty(details.getBmFileInfos())) {
for (BmFileInfo bmFileInfo : details.getBmFileInfos()) {
bmFileInfo.setCreateBy(SecurityUtils.getUsername());
bmFileInfo.setCreateTime(DateUtils.getNowDate());
bmFileInfo.setTaskId(taskId);
bmFileInfo.setTaskType(3);
bmFileInfo.setModelId(details.getId());
result += bmFileInfoMapper.insertBmFileInfo(bmFileInfo);
}
}
return result;
}
/**
* 保存编码设备附件
* @param details
* @param id
* @param result
* @return
*/
private int saveMaCodeBmFileInfo(BackApplyDetails details, Long id, int result) {
if (CollectionUtils.isNotEmpty(details.getMaCodeList())) {
for (MaCodeDto maCodeDto : details.getMaCodeList()) {
details.setMaId(maCodeDto.getMaId());
details.setParentId(id);
details.setCreateBy(SecurityUtils.getUsername());
details.setCreateTime(DateUtils.getNowDate());
details.setStatus("0");
result += backApplyInfoMapper.insertCheckDetails(details);
if (CollectionUtils.isNotEmpty(maCodeDto.getBmFileInfos())) {
for (BmFileInfo bmFileInfo : maCodeDto.getBmFileInfos()) {
bmFileInfo.setCreateBy(SecurityUtils.getUsername());
bmFileInfo.setCreateTime(DateUtils.getNowDate());
bmFileInfo.setTaskId(details.getId());
bmFileInfo.setTaskType(3);
bmFileInfo.setModelId(maCodeDto.getMaId());
result += bmFileInfoMapper.insertBmFileInfo(bmFileInfo);
}
}
}
}
return result;
}
/**
* 生成退料单号
* @return
*/
private String getString() {
//根据前台传过来的数据生成退料单号
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
Date nowDate = DateUtils.getNowDate();
String format = dateFormat.format(nowDate);
String taskNum = backApplyInfoMapper.selectTaskNumByMonth(nowDate, 3);
if (StringUtils.isNotBlank(taskNum)) {
// 将字符串转换为整数
int num = Integer.parseInt(taskNum);
// 执行加一操作
num++;
// 将结果转换回字符串格式并确保结果是2位数不足2位则在前面补0
taskNum = String.format("%02d", num);
} else {
taskNum = "01";
}
return "H" + format + "-" + taskNum;
}
/**
* 修改退料任务
*
* @param backApplyInfo 退料任务
* @param dto 退料任务
* @return 结果
*/
@Override
public int updateBackApplyInfo(BackApplyInfo backApplyInfo) {
backApplyInfo.setUpdateTime(DateUtils.getNowDate());
public AjaxResult updateBackApplyInfo(BackApplyRequestVo dto) {
try {
return backApplyInfoMapper.updateBackApplyInfo(backApplyInfo);
} catch (Exception e) {
throw new ServiceException("错误信息描述");
//针对修改先删除后添加
//对传入的手机号进行校验
if (StringUtils.isNotBlank(dto.getBackApplyInfo().getPhone()) && !PhoneUtil.isMobile(dto.getBackApplyInfo().getPhone())) {
return AjaxResult.error("手机号格式不正确,请重新填写!");
}
// 查询信息
Long id = dto.getId();
BackApplyInfo backApplyInfo = backApplyInfoMapper.selectBackApplyInfoById(id);
List<BackApplyDetails> backApplyDetailsList = backApplyInfoMapper.selectBackApplyDetailsListByTaskId(id);
List<MaCodeVo> maCodeList = backApplyInfoMapper.selectByCode(id);
// 删除相关任务信息
int result = 0;
result += backApplyInfoMapper.deleteTask(backApplyInfo.getTaskId());
result += backApplyInfoMapper.deleteTaskAgreement(backApplyInfo.getTaskId());
result += backApplyInfoMapper.deleteBackApplyDetails(backApplyInfo.getId());
result += backApplyInfoMapper.deleteCheckDetails(backApplyInfo.getId());
// 删除退料详情附件
result += deleteFileInfoForDetails(backApplyDetailsList, id);
// 删除编码设备附件
result += deleteFileInfoForMaCodes(maCodeList, id);
if (result > 0) {
//执行新增操作
backApplyInfo.setTaskType(3);
backApplyInfo.setTaskStatus(0);
backApplyInfo.setStatus("0");
backApplyInfo.setId(id);
backApplyInfo.setUpdateTime(DateUtils.getNowDate());
backApplyInfo.setUpdateBy(SecurityUtils.getUsername());
backApplyInfo.setBackPerson(dto.getBackApplyInfo().getBackPerson());
backApplyInfo.setPhone(dto.getBackApplyInfo().getPhone());
backApplyInfo.setRemark(dto.getBackApplyInfo().getRemark() == null ? backApplyInfo.getRemark() : dto.getBackApplyInfo().getRemark());
// 保存退料信息到 tm_task 表中
result += backApplyInfoMapper.insertTmTask(backApplyInfo);
if (result > 0) {
Long taskId = backApplyInfo.getTaskId();
result += backApplyInfoMapper.insertTaskAgreement(backApplyInfo);
backApplyInfo.setTaskId(taskId);
result += backApplyInfoMapper.updateBackApplyInfo(backApplyInfo);
}
// 保存退料详情
result = saveBackApplyDetails(dto, backApplyInfo, result);
return AjaxResult.success(result);
}
} catch (Exception e) {
throw new ServiceException("修改失败,请联系管理员");
}
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
}
/**
@ -92,7 +389,94 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
* @return 结果
*/
@Override
public int deleteBackApplyInfoById(Long id) {
return backApplyInfoMapper.deleteBackApplyInfoById(id);
@Transactional(rollbackFor = Exception.class)
public AjaxResult deleteBackApplyInfoById(Long id) {
try {
// 查询信息
BackApplyInfo backApplyInfo = backApplyInfoMapper.selectBackApplyInfoById(id);
List<BackApplyDetails> backApplyDetailsList = backApplyInfoMapper.selectBackApplyDetailsListByTaskId(id);
List<MaCodeVo> maCodeList = backApplyInfoMapper.selectByCode(id);
// 删除相关任务信息
int result = deleteTaskInfo(backApplyInfo);
// 删除退料详情附件
result += deleteFileInfoForDetails(backApplyDetailsList, id);
// 删除编码设备附件
result += deleteFileInfoForMaCodes(maCodeList, id);
if (result > 0) {
return AjaxResult.success(result);
}
} catch (Exception e) {
e.printStackTrace();
}
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
}
/**
* 删除任务信息
* @param backApplyInfo
* @return
*/
private int deleteTaskInfo(BackApplyInfo backApplyInfo) {
// 删除任务任务协议及相关信息
int result = 0;
result += backApplyInfoMapper.deleteTask(backApplyInfo.getTaskId());
result += backApplyInfoMapper.deleteTaskAgreement(backApplyInfo.getTaskId());
result += backApplyInfoMapper.deleteBackApply(backApplyInfo.getId());
result += backApplyInfoMapper.deleteBackApplyDetails(backApplyInfo.getId());
result += backApplyInfoMapper.deleteCheckDetails(backApplyInfo.getId());
return result;
}
/**
* 删除退料详情相关附件
* @param backApplyDetailsList
* @param taskId
* @return
*/
private int deleteFileInfoForDetails(List<BackApplyDetails> backApplyDetailsList, Long taskId) {
// 删除退料详情相关附件
int result = 0;
if (CollectionUtils.isNotEmpty(backApplyDetailsList)) {
for (BackApplyDetails details : backApplyDetailsList) {
BmFileInfo bmFileInfo = new BmFileInfo();
bmFileInfo.setModelId(details.getId());
bmFileInfo.setTaskId(taskId);
bmFileInfo.setTaskType(3);
result += bmFileInfoMapper.deleteBmFileInfoByBizInfo(bmFileInfo);
}
}
return result;
}
/**
* 删除编码设备相关附件
* @param maCodeList
* @param taskId
* @return
*/
private int deleteFileInfoForMaCodes(List<MaCodeVo> maCodeList, Long taskId) {
// 删除编码设备相关附件
int result = 0;
if (CollectionUtils.isNotEmpty(maCodeList)) {
for (MaCodeVo maCodeVo : maCodeList) {
BmFileInfo bmFileInfo = new BmFileInfo();
bmFileInfo.setModelId(maCodeVo.getMaId());
bmFileInfo.setTaskId(taskId);
bmFileInfo.setTaskType(3);
result += bmFileInfoMapper.deleteBmFileInfoByBizInfo(bmFileInfo);
}
}
return result;
}
/**
* 根据机具编码和类型查询机具是否存在
* @param dto
* @return
*/
@Override
public AjaxResult getMachineById(BackApplyInfo dto) {
return AjaxResult.success(backApplyInfoMapper.getMachineById(dto));
}
}

View File

@ -1,6 +1,7 @@
package com.bonus.material.common.controller;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.back.domain.BackApplyInfo;
import com.bonus.material.basic.domain.BmProject;
import com.bonus.material.basic.domain.BmUnit;
import com.bonus.material.common.domain.dto.SelectDto;
@ -124,4 +125,10 @@ public class SelectController {
public AjaxResult getAgreementInfoById(@RequestBody SelectDto dto){
return service.getAgreementInfoById(dto);
}
@ApiOperation(value = "在用设备类型树")
@PostMapping("/getUseTypeTree")
public AjaxResult getUseTypeTree(@RequestBody BackApplyInfo bean) {
return service.getUseTypeTree(bean);
}
}

View File

@ -1,6 +1,8 @@
package com.bonus.material.common.mapper;
import com.bonus.common.biz.domain.TreeNode;
import com.bonus.common.biz.domain.TypeTreeNode;
import com.bonus.material.back.domain.BackApplyInfo;
import com.bonus.material.basic.domain.BmProject;
import com.bonus.material.basic.domain.BmUnit;
import com.bonus.material.common.domain.dto.SelectDto;
@ -113,4 +115,25 @@ public interface SelectMapper {
* @return List<TreeNode>
*/
List<TreeNode> getPartTree(SelectDto dto);
/**
* 在用设备类型树4级
* @param bean
* @return
*/
List<TypeTreeNode> getUseTypeTreeL4(BackApplyInfo bean);
/**
* 在用设备类型树3级
* @param list
* @return
*/
List<TypeTreeNode> getUseTypeTreeL3(List<Long> list);
/**
* 在用设备类型树2级
* @param list
* @return
*/
List<TypeTreeNode> getUseTypeTreeL21(List<Long> list);
}

View File

@ -1,6 +1,7 @@
package com.bonus.material.common.service;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.back.domain.BackApplyInfo;
import com.bonus.material.basic.domain.BmProject;
import com.bonus.material.basic.domain.BmUnit;
import com.bonus.material.common.domain.dto.SelectDto;
@ -178,4 +179,10 @@ public interface SelectService {
*/
AjaxResult getPartTree(SelectDto dto);
/**
* 在用设备类型树
* @param bean
* @return
*/
AjaxResult getUseTypeTree(BackApplyInfo bean);
}

View File

@ -3,7 +3,10 @@ package com.bonus.material.common.service.impl;
import com.bonus.common.biz.constant.GlobalConstants;
import com.bonus.common.biz.domain.TreeBuild;
import com.bonus.common.biz.domain.TreeNode;
import com.bonus.common.biz.domain.TypeTreeBuild;
import com.bonus.common.biz.domain.TypeTreeNode;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.back.domain.BackApplyInfo;
import com.bonus.material.basic.domain.BmProject;
import com.bonus.material.basic.domain.BmUnit;
import com.bonus.material.common.domain.dto.SelectDto;
@ -17,7 +20,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author 10488
@ -213,6 +216,44 @@ public class SelectServiceImpl implements SelectService {
return AjaxResult.success(groupList);
}
/**
* 在用设备类型树
* @param bean
* @return
*/
@Override
public AjaxResult getUseTypeTree(BackApplyInfo bean) {
List<TypeTreeNode> groupList = new ArrayList<>();
List<TypeTreeNode> list = new ArrayList<>();
List<TypeTreeNode> listL4 = new ArrayList<>();
List<TypeTreeNode> listL3 = new ArrayList<>();
List<TypeTreeNode> listL21 = new ArrayList<>();
try {
// 先查第四层类型
listL4 = mapper.getUseTypeTreeL4(bean);
if (CollectionUtils.isNotEmpty(listL4)) {
List<Long> list4ParentIds = listL4.stream().map(o -> o.getParentId()).collect(Collectors.toList());
// 根据第四层parentId 查第三层类型
listL3 = mapper.getUseTypeTreeL3(list4ParentIds);
List<Long> list3ParentIds = listL3.stream().map(o -> o.getParentId()).collect(Collectors.toList());
// 根据第三层parentId 查第1.2层类型
listL21 = mapper.getUseTypeTreeL21(list3ParentIds);
list.addAll(listL4);
list.addAll(listL3);
list.addAll(listL21);
}
if (CollectionUtils.isNotEmpty(list)) {
// 创建树形结构数据集合作为参数
TypeTreeBuild treeBuild = new TypeTreeBuild(list);
// 原查询结果转换树形结构
groupList = treeBuild.buildTree();
}
} catch (Exception e) {
AjaxResult.error("类型树-查询失败", e);
}
return AjaxResult.success(groupList);
}
@Override
public AjaxResult getGoodsShelvesCbx(SelectDto dto) {
List<TreeNode> groupList = new ArrayList<>();

View File

@ -27,26 +27,172 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id, code, task_id, back_person, phone, direct_audit_by, direct_audit_time, direct_audit_remark, create_by, create_time, update_by, update_time, remark, company_id, back_time, status, direct_id from back_apply_info
</sql>
<select id="selectBackApplyInfoList" parameterType="com.bonus.material.back.domain.BackApplyInfo" resultMap="BackApplyInfoResult">
<include refid="selectBackApplyInfoVo"/>
<where>
<if test="code != null and code != ''"> and code = #{code}</if>
<if test="taskId != null "> and task_id = #{taskId}</if>
<if test="backPerson != null and backPerson != ''"> and back_person = #{backPerson}</if>
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
<if test="directAuditBy != null "> and direct_audit_by = #{directAuditBy}</if>
<if test="directAuditTime != null "> and direct_audit_time = #{directAuditTime}</if>
<if test="directAuditRemark != null and directAuditRemark != ''"> and direct_audit_remark = #{directAuditRemark}</if>
<if test="companyId != null "> and company_id = #{companyId}</if>
<if test="backTime != null "> and back_time = #{backTime}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="directId != null "> and direct_id = #{directId}</if>
</where>
<select id="selectBackApplyInfoList" resultType="com.bonus.material.back.domain.BackApplyInfo">
SELECT
bai.id as id,
bai.`code` as code,
bai.back_person as backPerson,
bai.phone as phone,
bp.pro_id as proId,
bai.remark as remark,
bp.pro_name as proName,
bu.unit_id as unitId,
bu.unit_name as unitName,
bai.back_time as backTime,
tt.task_status as taskStatus,
bai.create_by as createBy,
bai.create_time as createTime,
GROUP_CONCAT(DISTINCT mt2.type_id) as typeId,
GROUP_CONCAT(mt2.type_name) AS typeName,
bai.`status` AS status,
bai.print_status as printStatus
FROM
back_apply_info bai
LEFT JOIN back_apply_details bad on bad.parent_id = bai.id
LEFT JOIN tm_task tt on tt.task_id = bai.task_id and tt.status = '1'
LEFT JOIN tm_task_agreement tta on tta.task_id = tt.task_id
LEFT JOIN bm_agreement_info bagi on bagi.agreement_id = tta.agreement_id
AND bagi.`status` = '1'
LEFT JOIN bm_project bp on bp.pro_id = bagi.project_id
AND bp.del_flag = '0'
LEFT JOIN bm_unit bu on bu.unit_id = bagi.unit_id
AND bu.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt1.type_id = bad.type_id AND mt1.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id AND mt2.del_flag = '0'
WHERE
1=1
<if test="keyWord != null and keyWord != ''">
and (
bu.unit_name like concat('%', #{keyWord}, '%') or
bp.pro_name like concat('%', #{keyWord}, '%') or
bai.`code` like concat('%', #{keyWord}, '%') or
bai.back_person like concat('%', #{keyWord}, '%') or
bai.phone like concat('%', #{keyWord}, '%')
)
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
<![CDATA[and bai.create_time BETWEEN #{startTime} AND #{endTime} ]]>
</if>
<if test="status != null">
and bai.status = #{status}
</if>
GROUP BY bai.`code`
ORDER BY bai.create_time desc
</select>
<select id="selectBackApplyInfoById" parameterType="Long" resultMap="BackApplyInfoResult">
<include refid="selectBackApplyInfoVo"/>
where id = #{id}
<select id="selectTaskNumByMonth" resultType="java.lang.String">
SELECT SUBSTRING(`code`, - 2) as code
FROM tm_task
WHERE DATE_FORMAT(create_time, '%y%m') = DATE_FORMAT(#{date}, '%y%m')
AND task_type = #{taskType}
ORDER BY create_time DESC LIMIT 1
</select>
<select id="getMachineById" 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 materialName,
mm.type_id AS typeId,
mt.type_name AS typeName
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 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
1 = 1
<if test="unitId != null">
and ba.unit_id = #{unitId}
</if>
<if test="proId != null">
and ba.project_id = #{proId}
</if>
<if test="typeId != null">
and mm.type_id = #{typeId}
</if>
</select>
<select id="selectBackApplyInfoById" resultType="com.bonus.material.back.domain.BackApplyInfo">
SELECT
bai.id AS id,
bai.CODE AS CODE,
bai.task_id AS taskId,
bai.back_person AS backPerson,
bai.phone AS phone,
bai.create_by AS createBy,
bai.create_time AS createTime,
bai.update_by AS updateBy,
bai.update_time AS updateTime,
bai.remark AS remark,
bai.STATUS AS STATUS,
bai.print_status AS printStatus,
ba.agreement_id AS agreementId,
bu.unit_id AS unitId,
bu.unit_name AS unitName,
bp.pro_id AS proId,
bp.pro_name AS proName
FROM
back_apply_info bai
LEFT JOIN tm_task_agreement tta ON bai.task_id = tta.task_id
LEFT JOIN bm_agreement_info ba ON ba.agreement_id = tta.agreement_id
AND ba.`status` = 1
LEFT JOIN bm_unit bu ON ba.unit_id = bu.unit_id
AND bu.del_flag = '0'
LEFT JOIN bm_project bp ON ba.project_id = bp.pro_id
AND bp.del_flag = '0'
WHERE
bai.id = #{id}
</select>
<select id="selectBackApplyDetailsListByTaskId"
resultType="com.bonus.material.back.domain.BackApplyDetails">
SELECT
ba.id AS id,
ba.CODE AS CODE,
ba.parent_id AS parentId,
ba.type_id AS typeId,
mt.type_name AS typeModel,
mt1.type_name AS typeName,
mt.unit_name AS unitName,
mt.manage_type AS manageType,
ba.pre_num AS preNum,
ba.use_num AS num,
ba.STATUS AS STATUS,
ba.create_by AS createBy,
ba.create_time AS createTime,
ba.update_by AS updateBy,
ba.update_time AS updateTime,
ba.ma_code AS maCode,
ba.remark AS remark,
ba.ap_detection AS apDetection
FROM
back_apply_details ba
LEFT JOIN ma_type mt ON mt.type_id = ba.type_id and mt.del_flag = 0
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = 0
WHERE ba.parent_id = #{id}
</select>
<select id="selectByCode" resultType="com.bonus.material.back.domain.vo.MaCodeVo">
SELECT
bcd.ma_id AS maId,
mm.ma_code as maCode,
bcd.type_id AS typeId,
mt.type_name AS materialName,
mt1.type_name AS typeName,
bcd.ap_detection AS apDetection
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 mt.del_flag = 0
where bcd.parent_id = #{id}
</select>
<insert id="insertBackApplyInfo" parameterType="com.bonus.material.back.domain.BackApplyInfo" useGeneratedKeys="true" keyProperty="id">
@ -89,6 +235,125 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<insert id="insertTmTask" parameterType = "com.bonus.material.back.domain.BackApplyInfo" keyColumn="task_id" keyProperty="taskId" useGeneratedKeys="true">
insert into tm_task (
<if test="taskType != null">task_type, </if>
<if test="taskStatus != null">task_status, </if>
<if test="code != null and code != ''">code, </if>
<if test="createBy != null and createBy != ''">create_by, </if>
<if test="remark != null and remark != ''">remark, </if>
<if test="companyId != null">company_id, </if>
create_time
) values (
<if test="taskType != null">#{taskType}, </if>
<if test="taskStatus != null">#{taskStatus}, </if>
<if test="code != null and code != ''">#{code}, </if>
<if test="createBy != null and createBy != ''">#{createBy}, </if>
<if test="remark != null and remark != ''">#{remark}, </if>
<if test="companyId != null">#{companyId}, </if>
NOW()
)
</insert>
<insert id="insertTaskAgreement">
insert into tm_task_agreement
(
<if test="taskId != null">
task_id,
</if>
<if test="agreementId != null">
agreement_id,
</if>
<if test="createBy != null and createBy != ''">
create_by,
</if>
<if test="remark != null and remark != ''">
remark,
</if>
<if test="companyId != null">
company_id,
</if>
create_time
) values (
<if test="taskId != null">
#{taskId},
</if>
<if test="agreementId != null">
#{agreementId},
</if>
<if test="createBy != null and createBy != ''">
#{createBy},
</if>
<if test="remark != null and remark != ''">
#{remark},
</if>
<if test="companyId != null">
#{companyId},
</if>
NOW()
)
</insert>
<insert id="insertBackApplyDetails" useGeneratedKeys="true" keyProperty="id">
insert into back_apply_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="code != null">code,</if>
<if test="parentId != null">parent_id,</if>
<if test="typeId != null">type_id,</if>
<if test="preNum != null">pre_num,</if>
<if test="auditNum != null">audit_num,</if>
<if test="num != null">use_num,</if>
<if test="status != null">status,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="apDetection != null and apDetection != ''">ap_detection,</if>
<if test="remark != null">remark,</if>
<if test="companyId != null">company_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="code != null">#{code},</if>
<if test="parentId != null">#{parentId},</if>
<if test="typeId != null">#{typeId},</if>
<if test="preNum != null">#{preNum},</if>
<if test="auditNum != null">#{auditNum},</if>
<if test="num != null">#{num},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="apDetection != null and apDetection != ''">#{apDetection},</if>
<if test="remark != null">#{remark},</if>
<if test="companyId != null">#{companyId},</if>
</trim>
</insert>
<insert id="insertCheckDetails">
insert into back_check_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId != null">parent_id,</if>
<if test="typeId != null">type_id,</if>
<if test="preNum != null">back_num,</if>
<if test="maId != null">ma_id,</if>
<if test="status != null">status,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="remark != null">remark,</if>
<if test="apDetection != null and apDetection != ''">ap_detection,</if>
<if test="companyId != null">company_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null">#{parentId},</if>
<if test="typeId != null">#{typeId},</if>
<if test="preNum != null">#{preNum},</if>
<if test="maId != null">#{maId},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="remark != null">#{remark},</if>
<if test="apDetection != null and apDetection != ''">#{apDetection},</if>
<if test="companyId != null">#{companyId},</if>
</trim>
</insert>
<update id="updateBackApplyInfo" parameterType="com.bonus.material.back.domain.BackApplyInfo">
update back_apply_info
<trim prefix="SET" suffixOverrides=",">
@ -99,8 +364,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="directAuditBy != null">direct_audit_by = #{directAuditBy},</if>
<if test="directAuditTime != null">direct_audit_time = #{directAuditTime},</if>
<if test="directAuditRemark != null">direct_audit_remark = #{directAuditRemark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
@ -122,4 +385,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<delete id="deleteTask">
update tm_task set status = 0 where task_id = #{taskId}
</delete>
<delete id="deleteTaskAgreement">
delete from tm_task_agreement where task_id = #{taskId}
</delete>
<delete id="deleteBackApply">
delete from back_apply_info where id = #{id}
</delete>
<delete id="deleteBackApplyDetails">
delete from back_apply_details where parent_id = #{id}
</delete>
<delete id="deleteCheckDetails">
delete from back_check_details where parent_id = #{id}
</delete>
</mapper>

View File

@ -144,4 +144,81 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM bm_agreement_info
WHERE unit_id = #{unitId} AND project_id = #{projectId} AND status = '1'
</select>
<select id="getUseTypeTreeL4" resultType="com.bonus.common.biz.domain.TypeTreeNode">
SELECT
mt.type_id as typeId,
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
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 sai.lease_type = 0 and sai2.num > 0)
GROUP BY
mt.type_id
</select>
<select id="getUseTypeTreeL3" resultType="com.bonus.common.biz.domain.TypeTreeNode">
SELECT
mt3.type_id as typeId,
mt3.type_name as typeName,
mt3.parent_id as parentId,
mt3.unit_name as unitName,
NULL as manageType,
0 AS num,
mt3.LEVEL as level
FROM
ma_type mt3 where type_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getUseTypeTreeL21" resultType="com.bonus.common.biz.domain.TypeTreeNode">
SELECT
mt2.type_id as typeId,
mt2.type_name as typeName,
mt2.parent_id as parentId,
mt2.unit_name as unitName,
NULL as manageType,
0 AS num,
mt2.LEVEL as level
FROM
ma_type mt2 where type_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
union
SELECT
mt1.type_id as typeId,
mt1.type_name as typeName,
mt1.parent_id as parentId,
mt1.unit_name as unitName,
NULL as manageType,
0 AS num,
mt1.LEVEL as level
FROM
ma_type mt1 left join (
SELECT
mt2.type_id as typeId,
mt2.type_name as typeName,
mt2.parent_id as parentId,
mt2.unit_name as unitName,
NULL as manageType,
0 AS num,
mt2.LEVEL as level
FROM
ma_type mt2) mt2 on mt2.parentId = mt1.type_id where mt2.typeId in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>