From be2c9ff8a393a0112d815b0e35e6fe3ad7537dbe Mon Sep 17 00:00:00 2001 From: mashuai Date: Wed, 13 Nov 2024 18:01:55 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E6=96=99=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/biz/domain/TypeTreeBuild.java | 77 ++++ .../bonus/common/biz/domain/TypeTreeNode.java | 37 ++ .../controller/BackApplyInfoController.java | 33 +- .../back/domain/BackApplyDetails.java | 50 ++- .../material/back/domain/BackApplyInfo.java | 64 ++- .../bonus/material/back/domain/MaCodeDto.java | 34 ++ .../back/domain/vo/BackApplyRequestVo.java | 28 ++ .../material/back/domain/vo/MaCodeVo.java | 27 ++ .../back/mapper/BackApplyInfoMapper.java | 98 ++++ .../back/service/IBackApplyInfoService.java | 22 +- .../impl/BackApplyInfoServiceImpl.java | 422 +++++++++++++++++- .../common/controller/SelectController.java | 7 + .../material/common/mapper/SelectMapper.java | 23 + .../common/service/SelectService.java | 7 + .../service/impl/SelectServiceImpl.java | 43 +- .../material/back/BackApplyInfoMapper.xml | 327 +++++++++++++- .../mapper/material/common/SelectMapper.xml | 77 ++++ 17 files changed, 1302 insertions(+), 74 deletions(-) create mode 100644 bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TypeTreeBuild.java create mode 100644 bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TypeTreeNode.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/MaCodeDto.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/vo/BackApplyRequestVo.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/vo/MaCodeVo.java diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TypeTreeBuild.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TypeTreeBuild.java new file mode 100644 index 00000000..9d72bc79 --- /dev/null +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TypeTreeBuild.java @@ -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 nodeList = new ArrayList<>(); + + /** + * 构造方法 + * @param nodeList 将数据集合赋值给nodeList,即所有数据作为所有节点。 + */ + public TypeTreeBuild(List nodeList){ + this.nodeList = nodeList; + } + + /** + * 获取需构建的所有根节点(顶级节点) "0" + * @return 所有根节点List集合 + */ + public List getRootNode(){ + // 保存所有根节点(所有根节点的数据) + List rootNodeList = new ArrayList<>(); + // treeNode:查询出的每一条数据(节点) + for (TypeTreeNode treeNode : nodeList){ + // 判断当前节点是否为根节点,此处注意:若parentId类型是String,则要采用equals()方法判断。 + if (0 == treeNode.getParentId()) { + // 是,添加 + rootNodeList.add(treeNode); + } + } + return rootNodeList; + } + + /** + * 根据每一个顶级节点(根节点)进行构建树形结构 + * @return 构建整棵树 + */ + public List buildTree(){ + // treeNodes:保存一个顶级节点所构建出来的完整树形 + List treeNodes = new ArrayList(); + // getRootNode():获取所有的根节点 + for (TypeTreeNode treeRootNode : getRootNode()) { + // 将顶级节点进行构建子树 + treeRootNode = buildChildTree(treeRootNode); + // 完成一个顶级节点所构建的树形,增加进来 + treeNodes.add(treeRootNode); + } + return treeNodes; + } + + /** + * 递归-----构建子树形结构 + * @param pNode 根节点(顶级节点) + * @return 整棵树 + */ + public TypeTreeNode buildChildTree(TypeTreeNode pNode){ + List childTree = new ArrayList(); + // nodeList:所有节点集合(所有数据) + for (TypeTreeNode treeNode : nodeList) { + // 判断当前节点的父节点ID是否等于根节点的ID,即当前节点为其下的子节点 + if (treeNode.getParentId() == pNode.getTypeId()) { + // 再递归进行判断当前节点的情况,调用自身方法 + childTree.add(buildChildTree(treeNode)); + } + } + // for循环结束,即节点下没有任何节点,树形构建结束,设置树结果 + pNode.setChildren(childTree); + return pNode; + } + +} diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TypeTreeNode.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TypeTreeNode.java new file mode 100644 index 00000000..5f5e443d --- /dev/null +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TypeTreeNode.java @@ -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 children = new ArrayList<>(); +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/controller/BackApplyInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/controller/BackApplyInfoController.java index 46a9e1e8..505ec15e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/controller/BackApplyInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/controller/BackApplyInfoController.java @@ -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); } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyDetails.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyDetails.java index 0aa10f25..cb0844c4 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyDetails.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyDetails.java @@ -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 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 bmFileInfos; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyInfo.java index a00b775c..5225d9f3 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/BackApplyInfo.java @@ -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; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/MaCodeDto.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/MaCodeDto.java new file mode 100644 index 00000000..8d076054 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/MaCodeDto.java @@ -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 bmFileInfos; +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/vo/BackApplyRequestVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/vo/BackApplyRequestVo.java new file mode 100644 index 00000000..2327ebcb --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/vo/BackApplyRequestVo.java @@ -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 backApplyDetailsList; +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/vo/MaCodeVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/vo/MaCodeVo.java new file mode 100644 index 00000000..9334e9a8 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/domain/vo/MaCodeVo.java @@ -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; +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/mapper/BackApplyInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/mapper/BackApplyInfoMapper.java index 339080b0..b47379f7 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/mapper/BackApplyInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/mapper/BackApplyInfoMapper.java @@ -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 getMachineById(BackApplyInfo dto); + + /** + * 根据任务id查询详情 + * @param id + * @return + */ + List selectBackApplyDetailsListByTaskId(Long id); + + /** + * 根据设备编码查询设备信息 + * @param id + * @return + */ + List 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); + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/IBackApplyInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/IBackApplyInfoService.java index ad063be6..d8cea68c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/IBackApplyInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/IBackApplyInfoService.java @@ -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); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java index 301f3d8e..41a4a5eb 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java @@ -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 backApplyDetailsList = backApplyInfoMapper.selectBackApplyDetailsListByTaskId(id); + if (CollectionUtils.isNotEmpty(backApplyDetailsList)) { + // 批量查询附件信息,减少数据库访问次数 + List bmFileInfos = fetchBmFileInfos(id, backApplyDetailsList); + // 查询编码设备信息 + List 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 fetchBmFileInfos(Long id, List backApplyDetailsList) { + List bmFileInfos = new ArrayList<>(); + for (BackApplyDetails details : backApplyDetailsList) { + BmFileInfo bmFileInfo = new BmFileInfo(); + bmFileInfo.setTaskId(id); + bmFileInfo.setTaskType(3); + bmFileInfo.setModelId(details.getId()); + List bmFileInfoList = bmFileInfoMapper.selectBmFileInfoList(bmFileInfo); + // 合并所有附件信息 + bmFileInfos.addAll(bmFileInfoList); + } + return bmFileInfos; + } + + /** + * 查询编码设备信息 + * @param id + * @return + */ + private List fetchMaCodeList(Long id) { + return backApplyInfoMapper.selectByCode(id); + } + + /** + * 为每个退料详情设置附件信息 + * @param details + * @param bmFileInfos + */ + private void setBmFileInfosForDetails(BackApplyDetails details, List bmFileInfos) { + // 为每个退料详情设置附件信息 + List 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 maCodeList) { + List maCodeDtos = new ArrayList<>(); + for (MaCodeVo maCodeVo : maCodeList) { + MaCodeDto maCodeDto = new MaCodeDto(); + maCodeDto.setMaCode(maCodeVo.getMaCode()); + maCodeDto.setMaId(maCodeVo.getMaId()); + maCodeDto.setApDetection(maCodeVo.getApDetection()); + // 查询并设置编码附件 + List 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 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); + //针对修改,先删除,后添加 + //对传入的手机号进行校验 + if (StringUtils.isNotBlank(dto.getBackApplyInfo().getPhone()) && !PhoneUtil.isMobile(dto.getBackApplyInfo().getPhone())) { + return AjaxResult.error("手机号格式不正确,请重新填写!"); + } + // 查询信息 + Long id = dto.getId(); + BackApplyInfo backApplyInfo = backApplyInfoMapper.selectBackApplyInfoById(id); + List backApplyDetailsList = backApplyInfoMapper.selectBackApplyDetailsListByTaskId(id); + List 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("错误信息描述"); + 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 backApplyDetailsList = backApplyInfoMapper.selectBackApplyDetailsListByTaskId(id); + List 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 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 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)); + } + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java index c549b584..735a1a84 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java @@ -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); + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java index 13a6baa1..6340dc38 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java @@ -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 */ List getPartTree(SelectDto dto); + + /** + * 在用设备类型树4级 + * @param bean + * @return + */ + List getUseTypeTreeL4(BackApplyInfo bean); + + /** + * 在用设备类型树3级 + * @param list + * @return + */ + List getUseTypeTreeL3(List list); + + /** + * 在用设备类型树2级 + * @param list + * @return + */ + List getUseTypeTreeL21(List list); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java index 5e63291f..d8aec26e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java @@ -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); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java index ad6f57c5..769ac569 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java @@ -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 groupList = new ArrayList<>(); + List list = new ArrayList<>(); + List listL4 = new ArrayList<>(); + List listL3 = new ArrayList<>(); + List listL21 = new ArrayList<>(); + try { + // 先查第四层类型 + listL4 = mapper.getUseTypeTreeL4(bean); + if (CollectionUtils.isNotEmpty(listL4)) { + List list4ParentIds = listL4.stream().map(o -> o.getParentId()).collect(Collectors.toList()); + // 根据第四层parentId 查第三层类型 + listL3 = mapper.getUseTypeTreeL3(list4ParentIds); + List 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 groupList = new ArrayList<>(); diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml index f0f4ac26..50b1d7f8 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/back/BackApplyInfoMapper.xml @@ -27,28 +27,174 @@ 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 - + 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 + + 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}, '%') + ) + + + + + + and bai.status = #{status} + + GROUP BY bai.`code` + ORDER BY bai.create_time desc - - + 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 - + + + + + + + + + insert into back_apply_info @@ -89,6 +235,125 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + insert into tm_task ( + task_type, + task_status, + code, + create_by, + remark, + company_id, + create_time + ) values ( + #{taskType}, + #{taskStatus}, + #{code}, + #{createBy}, + #{remark}, + #{companyId}, + NOW() + ) + + + + insert into tm_task_agreement + ( + + task_id, + + + agreement_id, + + + create_by, + + + remark, + + + company_id, + + create_time + ) values ( + + #{taskId}, + + + #{agreementId}, + + + #{createBy}, + + + #{remark}, + + + #{companyId}, + + NOW() + ) + + + + insert into back_apply_details + + code, + parent_id, + type_id, + pre_num, + audit_num, + use_num, + status, + create_by, + create_time, + ap_detection, + remark, + company_id, + + + #{code}, + #{parentId}, + #{typeId}, + #{preNum}, + #{auditNum}, + #{num}, + #{status}, + #{createBy}, + #{createTime}, + #{apDetection}, + #{remark}, + #{companyId}, + + + + + insert into back_check_details + + parent_id, + type_id, + back_num, + ma_id, + status, + create_by, + create_time, + remark, + ap_detection, + company_id, + + + #{parentId}, + #{typeId}, + #{preNum}, + #{maId}, + #{status}, + #{createBy}, + #{createTime}, + #{remark}, + #{apDetection}, + #{companyId}, + + + update back_apply_info @@ -99,8 +364,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" direct_audit_by = #{directAuditBy}, direct_audit_time = #{directAuditTime}, direct_audit_remark = #{directAuditRemark}, - create_by = #{createBy}, - create_time = #{createTime}, update_by = #{updateBy}, update_time = #{updateTime}, remark = #{remark}, @@ -122,4 +385,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} + + + update tm_task set status = 0 where task_id = #{taskId} + + + + delete from tm_task_agreement where task_id = #{taskId} + + + + delete from back_apply_info where id = #{id} + + + + delete from back_apply_details where parent_id = #{id} + + + + delete from back_check_details where parent_id = #{id} + \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml index 6b18ebed..f44d948e 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml @@ -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' + + + + + + \ No newline at end of file