From 36ceb1b34055787bafd26ef17f7ae101e7b84557 Mon Sep 17 00:00:00 2001 From: hayu <1604366271@qq.com> Date: Mon, 17 Feb 2025 17:43:58 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=86=E7=94=A8=E7=94=B3=E8=AF=B7,=E9=A2=86?= =?UTF-8?q?=E7=94=A8=E8=AE=B0=E5=BD=95=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/domain/lease/LeaseApplyInfo.java | 3 + .../common/biz/enums/TmTaskTypeEnum.java | 3 +- .../lease/controller/LeaseTaskController.java | 104 ++++++ .../lease/mapper/LeaseTaskMapper.java | 63 ++++ .../lease/service/ILeaseTaskService.java | 59 ++++ .../impl/LeaseApplyInfoServiceImpl.java | 16 +- .../service/impl/LeaseTaskServiceImpl.java | 320 ++++++++++++++++++ .../StandardConfigManageController.java | 10 + .../ma/domain/vo/StandardConfigDetailsVo.java | 17 + .../ma/mapper/StandardConfigManageMapper.java | 8 + .../service/StandardConfigManageService.java | 8 + .../impl/StandardConfigManageServiceImpl.java | 12 + .../material/lease/LeaseApplyInfoMapper.xml | 7 +- .../mapper/material/lease/LeaseTaskMapper.xml | 301 ++++++++++++++++ .../ma/StandardConfigManageMapper.xml | 30 ++ 15 files changed, 941 insertions(+), 20 deletions(-) create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseTaskController.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseTaskMapper.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseTaskService.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java create mode 100644 bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java index b1758e67..06b94543 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java @@ -250,4 +250,7 @@ public class LeaseApplyInfo extends BaseEntity{ */ @ApiModelProperty(value = "是否为领用申请") private Integer isLease; + + @ApiModelProperty(value = "采购申请编号") + private String applyCode; } diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/TmTaskTypeEnum.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/TmTaskTypeEnum.java index 9640cb9a..0cb71ff4 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/TmTaskTypeEnum.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/TmTaskTypeEnum.java @@ -19,8 +19,7 @@ public enum TmTaskTypeEnum { TM_TASK_REPAIR_INPUT(11, "修饰后入库任务"), TM_TASK_PART_LEASE(12, "配件领料任务"), TM_TASK_PART_TYPE(13, "配件新购"), - TM_TASK_REPAIR_NUM(14, "数量维修人员信息附件"), - TM_TASK_LEASE_INPUT(15, "领用任务"); + TM_TASK_REPAIR_NUM(14, "数量维修人员信息附件"); private final Integer taskTypeId; private final String taskTypeName; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseTaskController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseTaskController.java new file mode 100644 index 00000000..a0b1508a --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseTaskController.java @@ -0,0 +1,104 @@ +package com.bonus.material.lease.controller; + +import cn.hutool.core.convert.Convert; +import com.bonus.common.biz.config.ListPagingUtil; +import com.bonus.common.biz.domain.lease.LeaseApplyInfo; +import com.bonus.common.core.utils.ServletUtils; +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.log.annotation.SysLog; +import com.bonus.common.log.enums.OperaType; +import com.bonus.material.common.annotation.PreventRepeatSubmit; +import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo; +import com.bonus.material.lease.service.ILeaseApplyInfoService; +import com.bonus.material.lease.service.ILeaseTaskService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +/** + * @author hay + * @description 业务办理--领用任务 + * @date 2025/2/17 13:13 + */ +@Api(tags = "领用任务接口") +@RestController +@RequestMapping("/leaseTask") +public class LeaseTaskController extends BaseController { + + @Resource + private ILeaseTaskService service; + + /** + * 新增领用任务 + */ + @ApiOperation(value = "新增领用任务") + @PreventRepeatSubmit + @SysLog(title = "领用任务", businessType = OperaType.INSERT, logType = 1, module = "领用申请->新增领用任务") + @PostMapping + public AjaxResult add(@NotNull(message = "领用任务不能为空") @RequestBody LeaseApplyRequestVo leaseApplyRequestVo) { + try { + return service.insertLeaseApplyInfo(leaseApplyRequestVo); + } catch (Exception e) { + return error("系统错误, " + e.getMessage()); + } + } + + /** + * 领用记录查询 + */ + @ApiOperation(value = "领用记录列表查询") + @GetMapping("/list") + public AjaxResult list(LeaseApplyInfo leaseApplyInfo) { + Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1); + Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10); + try { + List list = service.selectLeaseApplyInfoList(leaseApplyInfo); + return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list)); + } catch (Exception e) { + return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, new ArrayList<>())); + } + } + + /** + * 领用记录详情查看 + */ + @ApiOperation(value = "领用记录详情查看") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@NotNull(message = "领用任务ID不能为空") @PathVariable("id") Long id, + @RequestParam(value = "keyWord", required = false) String keyWord) { + return success(service.selectLeaseApplyInfoById(id, keyWord)); + } + + /** + * 修改领用任务 + */ + @ApiOperation(value = "修改领用任务") + @PreventRepeatSubmit + @SysLog(title = "领用任务", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改领用任务") + @PutMapping + public AjaxResult edit(@RequestBody @NotNull LeaseApplyRequestVo leaseApplyRequestVo) { + try { + return toAjax(service.updateLeaseApplyInfo(leaseApplyRequestVo)); + } catch (Exception e) { + return error("系统错误, " + e.getMessage()); + } + } + + /** + * 删除领用任务 + */ + @ApiOperation(value = "删除领用任务") + @PreventRepeatSubmit + @SysLog(title = "领用任务", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除领用任务") + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + return toAjax(service.deleteLeaseApplyInfoByIds(ids)); + } + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseTaskMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseTaskMapper.java new file mode 100644 index 00000000..6285ead7 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseTaskMapper.java @@ -0,0 +1,63 @@ +package com.bonus.material.lease.mapper; + + +import com.bonus.common.biz.domain.lease.LeaseApplyInfo; +import com.bonus.material.lease.domain.LeaseApplyDetails; + +import java.util.List; + +/** +* @description 业务办理--领用任务 +* @author hay +* @date 2025/2/17 13:18 +*/ +public interface LeaseTaskMapper { + + /** + * 新增领用任务 + * + * @param leaseApplyInfo 领用任务 + * @return 结果 + */ + int insertLeaseApplyInfo(LeaseApplyInfo leaseApplyInfo); + + /** + * 插入详情数据 + * + * @param leaseApplyDetails 领用任务详情 + * @return 结果 + */ + int insertLeaseApplyDetailsList(List leaseApplyDetails); + + /** + * 领用记录列表查询 + * + * @param leaseApplyInfo 领用任务 + * @return 领用任务集合 + */ + List selectLeaseApplyInfoList(LeaseApplyInfo leaseApplyInfo); + + /** + * 查询领用任务详细列表 + * + * @param leaseApplyDetails 领用任务详细 + * @return 领用任务详细集合 + */ + List selectLeaseApplyDetailsList(LeaseApplyDetails leaseApplyDetails); + + /** + * 修改领用任务 + * + * @param leaseApplyInfo 领用任务 + * @return 结果 + */ + int updateLeaseApplyInfo(LeaseApplyInfo leaseApplyInfo); + + /** + * 查询领用任务 + * + * @param leaseApplyInfo + * @return 领用任务 + */ + LeaseApplyInfo selectLeaseApplyInfoById(LeaseApplyInfo leaseApplyInfo); +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseTaskService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseTaskService.java new file mode 100644 index 00000000..fc262c0e --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseTaskService.java @@ -0,0 +1,59 @@ +package com.bonus.material.lease.service; + + +import com.bonus.common.biz.domain.lease.LeaseApplyInfo; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo; + +import java.util.List; + +/** + * @author hay + * @description 业务办理--领用任务 + * @date 2025/2/17 13:15 + */ +public interface ILeaseTaskService { + + + /** + * 新增领用任务 + * + * @param leaseApplyRequestVo 领用任务 + * @return 结果 + */ + AjaxResult insertLeaseApplyInfo(LeaseApplyRequestVo leaseApplyRequestVo); + + /** + * 领用记录列表查询 + * + * @param leaseApplyInfo 领用任务 + * @return 领用任务集合 + */ + List selectLeaseApplyInfoList(LeaseApplyInfo leaseApplyInfo); + + /** + * 领用记录详情查看 + * + * @param id + * @param keyWord + * @return + */ + LeaseApplyRequestVo selectLeaseApplyInfoById(Long id, String keyWord); + + /** + * 修改领用任务 + * + * @param leaseApplyRequestVo 领用任务 + * @return 结果 + */ + boolean updateLeaseApplyInfo(LeaseApplyRequestVo leaseApplyRequestVo); + + /** + * 批量删除领用任务 + * + * @param ids 需要删除的领用任务主键集合 + * @return 结果 + */ + int deleteLeaseApplyInfoByIds(Long[] ids); +} + diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java index 398fa048..91d8d122 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java @@ -177,33 +177,25 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { /** * 新增领料任务 - * + * * @param leaseApplyRequestVo 领料任务 * @return 结果 */ @Override public AjaxResult insertLeaseApplyInfo(LeaseApplyRequestVo leaseApplyRequestVo) { if (null == leaseApplyRequestVo.getLeaseApplyInfo()) { - return AjaxResult.error("请先填写任务信息"); + return AjaxResult.error("请先填写领料任务信息"); } if (CollectionUtil.isEmpty(leaseApplyRequestVo.getLeaseApplyDetailsList())) { - return AjaxResult.error("请先添加任务物资明细"); + return AjaxResult.error("请先添加领料任务物资明细"); } leaseApplyRequestVo.getLeaseApplyInfo().setCreateTime(DateUtils.getNowDate()); leaseApplyRequestVo.getLeaseApplyInfo().setCreateBy(SecurityUtils.getUsername()); try { int thisMonthMaxOrder = tmTaskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId()); String taskCode = genderTaskCode(thisMonthMaxOrder); - Integer taskStatus; - if (leaseApplyRequestVo.getLeaseApplyInfo().getIsLease()!=null){ - //领用申请任务 - taskStatus=LeaseTaskStatusEnum.LEASE_TASK_ZERO.getStatus(); - } else { - //领料申请任务 - taskStatus=LeaseTaskStatusEnum.LEASE_TASK_TO_PUBLISHED.getStatus(); - } TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId(), - taskStatus, + LeaseTaskStatusEnum.LEASE_TASK_TO_PUBLISHED.getStatus(), leaseApplyRequestVo.getLeaseApplyInfo().getCompanyId(),thisMonthMaxOrder + 1, taskCode); tmTask.setCreateTime(DateUtils.getNowDate()); tmTask.setCreateBy(SecurityUtils.getUsername()); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java new file mode 100644 index 00000000..0dde8f9f --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java @@ -0,0 +1,320 @@ +package com.bonus.material.lease.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.bonus.common.biz.constant.MaterialConstants; +import com.bonus.common.biz.domain.BmFileInfo; +import com.bonus.common.biz.domain.lease.LeaseApplyInfo; +import com.bonus.common.biz.enums.LeaseTaskStatusEnum; +import com.bonus.common.biz.enums.TmTaskTypeEnum; +import com.bonus.common.core.exception.ServiceException; +import com.bonus.common.core.utils.DateUtils; +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.vo.MaCodeVo; +import com.bonus.material.basic.mapper.BmFileInfoMapper; +import com.bonus.material.lease.domain.LeaseApplyDetails; +import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo; +import com.bonus.material.lease.mapper.LeaseApplyDetailsMapper; +import com.bonus.material.lease.mapper.LeaseApplyInfoMapper; +import com.bonus.material.lease.mapper.LeaseTaskMapper; +import com.bonus.material.lease.service.ILeaseTaskService; +import com.bonus.material.task.domain.TmTask; +import com.bonus.material.task.domain.TmTaskAgreement; +import com.bonus.material.task.mapper.TmTaskAgreementMapper; +import com.bonus.material.task.mapper.TmTaskMapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.dao.DataAccessException; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * @author hay + * @description 业务办理--领用任务 + * @date 2025/2/17 13:16 + */ +@Service +@Slf4j +public class LeaseTaskServiceImpl implements ILeaseTaskService { + + @Resource + private LeaseTaskMapper mapper; + + @Resource + private LeaseApplyInfoMapper leaseApplyInfoMapper; + + @Resource + private LeaseApplyDetailsMapper leaseApplyDetailsMapper; + + @Resource + private TmTaskMapper tmTaskMapper; + + @Resource + TmTaskAgreementMapper tmTaskAgreementMapper; + + @Resource + private BmFileInfoMapper bmFileInfoMapper; + + + /** + * 新增领用任务 + * + * @param leaseApplyRequestVo 领用任务 + * @return 结果 + */ + @Override + public AjaxResult insertLeaseApplyInfo(LeaseApplyRequestVo leaseApplyRequestVo) { + if (null == leaseApplyRequestVo.getLeaseApplyInfo()) { + return AjaxResult.error("请先填写领用任务信息"); + } + if (CollectionUtil.isEmpty(leaseApplyRequestVo.getLeaseApplyDetailsList())) { + return AjaxResult.error("请先添加领用任务物资明细"); + } + leaseApplyRequestVo.getLeaseApplyInfo().setCreateTime(DateUtils.getNowDate()); + leaseApplyRequestVo.getLeaseApplyInfo().setCreateBy(SecurityUtils.getUsername()); + try { + int thisMonthMaxOrder = tmTaskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId()); + String taskCode = genderTaskCode(thisMonthMaxOrder); + TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId(), + LeaseTaskStatusEnum.LEASE_TASK_ZERO.getStatus(), + leaseApplyRequestVo.getLeaseApplyInfo().getCompanyId(),thisMonthMaxOrder + 1, taskCode); + tmTask.setCreateTime(DateUtils.getNowDate()); + tmTask.setCreateBy(SecurityUtils.getUsername()); + tmTaskMapper.insertTmTask(tmTask); + TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask.getTaskId(), leaseApplyRequestVo.getLeaseApplyInfo().getAgreementId()); + tmTaskAgreement.setCreateTime(DateUtils.getNowDate()); + tmTaskAgreement.setCreateBy(SecurityUtils.getUsername()); + tmTaskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement); + leaseApplyRequestVo.getLeaseApplyInfo().setTaskId(tmTask.getTaskId()); + leaseApplyRequestVo.getLeaseApplyInfo().setCode(taskCode); + + /** 设置审批人为默认的董班长 --防止代码冲突 **/ + Long peopleId = leaseApplyInfoMapper.getDirectAuditBy(); + leaseApplyRequestVo.getLeaseApplyInfo().setDirectAuditBy(peopleId); + /** 设置审批人为默认的董班长 --防止代码冲突 **/ + + int count = mapper.insertLeaseApplyInfo(leaseApplyRequestVo.getLeaseApplyInfo()); + if (!CollectionUtils.isEmpty(leaseApplyRequestVo.getLeaseApplyInfo().getBmFileInfos())) { + leaseApplyRequestVo.getLeaseApplyInfo().getBmFileInfos().forEach(bmFileInfo -> { + bmFileInfo.setTaskType(2); + bmFileInfo.setTaskId(tmTask.getTaskId()); + bmFileInfo.setModelId(leaseApplyRequestVo.getLeaseApplyInfo().getId()); + bmFileInfo.setFileType(5L); + bmFileInfo.setCreateBy(SecurityUtils.getUsername()); + bmFileInfo.setCreateTime(DateUtils.getNowDate()); + bmFileInfoMapper.insertBmFileInfo(bmFileInfo); + }); + } + if (count > 0) { + return insertPurchaseCheckDetails(leaseApplyRequestVo.getLeaseApplyDetailsList(), leaseApplyRequestVo.getLeaseApplyInfo().getId()); + } else { + return AjaxResult.error("新增任务失败,lease_apply_info表插入0条"); + } + } catch (DataAccessException e) { + return AjaxResult.error("数据库操作失败:" + e.getMessage()); + } catch (Exception e) { + return AjaxResult.error("新增任务失败:" + e.getMessage()); + } + } + + /** + * 领用记录列表查询 + * + * @param leaseApplyInfo 领用任务 + * @return 领用任务 + */ + @Override + public List selectLeaseApplyInfoList(LeaseApplyInfo leaseApplyInfo) { + Long userId = SecurityUtils.getUserId(); + leaseApplyInfo.setUserId(userId == 0 ? null : userId); + List list = mapper.selectLeaseApplyInfoList(leaseApplyInfo); + if (!CollectionUtils.isEmpty(list)) { + String keyWord = leaseApplyInfo.getKeyWord(); + // 如果关键字不为空,进行过滤 + if (!StringUtils.isBlank(keyWord)) { + list = list.stream() + .filter(item -> containsKeyword(item, keyWord)) + .collect(Collectors.toList()); + } + } + return list; + } + + /** + * 根据id查询领用任务 + * + * @param id 领用任务id + * @return 领用任务 + */ + @Override + public LeaseApplyRequestVo selectLeaseApplyInfoById(Long id, String keyWord) { + try { + LeaseApplyInfo leaseApplyInfo = new LeaseApplyInfo(); + leaseApplyInfo.setId(id); + Long userId = SecurityUtils.getUserId(); + leaseApplyInfo.setUserId(userId); + Optional optionalInfo = Optional.ofNullable(mapper.selectLeaseApplyInfoById(leaseApplyInfo)); + LeaseApplyRequestVo leaseApplyRequestVo = new LeaseApplyRequestVo(); + + optionalInfo.ifPresent(info -> { + BmFileInfo bmFileInfo = new BmFileInfo(); + bmFileInfo.setModelId(id); + bmFileInfo.setTaskType(2); + bmFileInfo.setFileType(5L); + List bmFileInfoList = bmFileInfoMapper.selectBmFileInfoList(bmFileInfo); + if (!CollectionUtils.isEmpty(bmFileInfoList)) { + info.setBmFileInfos(bmFileInfoList); + } + /** 设置审批人签名url 防止代码冲突 **/ + String directAuditUrl = leaseApplyInfoMapper.getDirectAuditUrl(info); + info.setDirectAuditSignUrl(directAuditUrl); + /** 设置审批人签名url 防止代码冲突 **/ + + /** 设置发料单位 防止代码冲突 **/ + if(info.getDirectAuditBy() != null){ + String sendUnit = leaseApplyInfoMapper.getSendUnit(info); + info.setSendUnit(sendUnit); + } + /** 设置发料单位 防止代码冲突 **/ + + leaseApplyRequestVo.setLeaseApplyInfo(info); + // 获取领料单详情 + List details = mapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId(), keyWord, userId)); + if (!CollectionUtils.isEmpty(details)) { + leaseApplyRequestVo.setLeaseApplyDetailsList(details); + for (LeaseApplyDetails detail : details) { + // 获取编码详情 + List maCodeVoList = leaseApplyDetailsMapper.getCodeList(id, detail.getTypeId()); + if (!CollectionUtils.isEmpty(maCodeVoList)) { + detail.setMaCodeVoList(maCodeVoList); + } + } + } + + }); + + return leaseApplyRequestVo; + } catch (Exception e) { + // 记录异常日志 + System.err.println("Error occurred while selecting lease apply info by ID: " + id + e.getMessage()); + throw new RuntimeException("Failed to select lease apply info", e); + } + } + + @Override + public boolean updateLeaseApplyInfo(LeaseApplyRequestVo leaseApplyRequestVo) { + try { + // 提取到局部变量中,减少重复代码 + LeaseApplyInfo leaseApplyInfo = leaseApplyRequestVo.getLeaseApplyInfo(); + if (leaseApplyInfo != null && leaseApplyInfo.getId() != null) { + leaseApplyInfo.setUpdateTime(DateUtils.getNowDate()); + leaseApplyInfo.setUpdateBy(SecurityUtils.getUsername()); + + // 去除创建一个新的数组对象,直接复用 + Long[] ids = {leaseApplyInfo.getId()}; + if (CollectionUtil.isNotEmpty(leaseApplyInfo.getBmFileInfos())) { + // 删除原有数据 + BmFileInfo bmFileInfo = new BmFileInfo(); + bmFileInfo.setTaskId(leaseApplyInfo.getTaskId()); + bmFileInfo.setModelId(leaseApplyInfo.getId()); + bmFileInfo.setTaskType(2); + bmFileInfo.setFileType(5L); + bmFileInfoMapper.deleteBmFileInfoByBizInfo(bmFileInfo); + for (BmFileInfo fileInfo : leaseApplyInfo.getBmFileInfos()) { + fileInfo.setTaskId(leaseApplyInfo.getTaskId()); + fileInfo.setModelId(leaseApplyInfo.getId()); + fileInfo.setTaskType(2); + fileInfo.setFileType(5L); + fileInfo.setCreateBy(SecurityUtils.getUsername()); + fileInfo.setCreateTime(DateUtils.getNowDate()); + bmFileInfoMapper.insertBmFileInfo(fileInfo); + } + } + if (CollectionUtil.isNotEmpty(leaseApplyRequestVo.getLeaseApplyDetailsList())) { + // 业务逻辑代码 + leaseApplyDetailsMapper.deleteLeaseApplyDetailsByParentIds(ids); + insertPurchaseCheckDetails(leaseApplyRequestVo.getLeaseApplyDetailsList(), leaseApplyInfo.getId()); + } + // 修改外层info + mapper.updateLeaseApplyInfo(leaseApplyInfo); + return true; + } + return false; + } catch (DataAccessException dae) { + throw new ServiceException("数据访问异常: " + dae.getMessage()); + } catch (IllegalArgumentException iae) { + throw new ServiceException("非法参数异常: " + iae.getMessage()); + } catch (Exception e) { + throw new ServiceException("未知异常: " + e.getMessage()); + } + } + + /** + * 批量删除领用任务 + * + * @param ids 需要删除的领用任务主键 + * @return 结果 + */ + @Override + public int deleteLeaseApplyInfoByIds(Long[] ids) { + return leaseApplyInfoMapper.deleteLeaseApplyInfoByIds(ids); + } + + /** + * 关键字搜索 + * @param item + * @param keyWord + * @return + */ + private boolean containsKeyword(LeaseApplyInfo item, String keyWord) { + return (item.getMaTypeNames() != null && item.getMaTypeNames().contains(keyWord)) || + (item.getUnitName() != null && item.getUnitName().contains(keyWord)) || + (item.getProjectName() != null && item.getProjectName().contains(keyWord)) || + (item.getCode() != null && item.getCode().contains(keyWord)) || + (item.getCreateBy() != null && item.getCreateBy().contains(keyWord)) || + (item.getLeasePerson() != null && item.getLeasePerson().contains(keyWord)) || + (item.getLeasePhone() != null && item.getLeasePhone().contains(keyWord)) || + (item.getContractPart() != null && item.getContractPart().contains(keyWord)) || + (item.getImpUnitName() != null && item.getImpUnitName().contains(keyWord)); + } + + + private AjaxResult insertPurchaseCheckDetails(List leaseApplyDetailsList, Long parentId) { + if (!CollectionUtils.isEmpty(leaseApplyDetailsList)) { + for (LeaseApplyDetails details : leaseApplyDetailsList) { + details.setParentId(parentId); + details.setCreateTime(DateUtils.getNowDate()); + details.setCreateBy(SecurityUtils.getUsername()); + } + // 批量插入详情数据 + int count = mapper.insertLeaseApplyDetailsList(leaseApplyDetailsList); + if (count > 0) { + return AjaxResult.success("新增任务成功"); + } else { + return AjaxResult.error("新增任务失败,lease_apply_detail详情表插入0条"); + } + } else { + return AjaxResult.success("新增任务成功"); + } + } + + /** + * 生成任务编号并构造Tm_Task任务对象 + * @param thisMonthMaxOrder 当月最大单号 + * @return 任务对象 + */ + private static String genderTaskCode(Integer thisMonthMaxOrder) { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date nowDate = DateUtils.getNowDate(); + String format = dateFormat.format(nowDate); + String result = format.replace("-", ""); + return MaterialConstants.LEASE_TASK_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + 1); + } +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/StandardConfigManageController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/StandardConfigManageController.java index 21ad07c2..00a23859 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/StandardConfigManageController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/StandardConfigManageController.java @@ -126,4 +126,14 @@ public class StandardConfigManageController extends BaseController { return service.delConfigDetails(bean); } + + /** + * 根据配置id查询配置明细 + * 返回参数和规格型号树参数一致 + */ + @ApiOperation(value = "根据配置id查询配置明细") + @GetMapping("/getListsByConfigId") + public AjaxResult getListsByConfigId(StandardConfigDetailsVo bean) { + return service.getListsByConfigId(bean); + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/vo/StandardConfigDetailsVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/vo/StandardConfigDetailsVo.java index fb054ad7..ee759784 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/vo/StandardConfigDetailsVo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/vo/StandardConfigDetailsVo.java @@ -44,6 +44,9 @@ public class StandardConfigDetailsVo extends Type { @ApiModelProperty(value = "物资名称") private String typeName; + @ApiModelProperty(value = "类型名称") + private String maTypeName; + @ApiModelProperty(value = "规格ID") private Long typeId; @@ -56,12 +59,26 @@ public class StandardConfigDetailsVo extends Type { @ApiModelProperty(value = "计量单位") private String unit; + @ApiModelProperty(value = "计量单位") + private String unitName; + @ApiModelProperty(value = "数量") private BigDecimal num; + @ApiModelProperty(value = "预领数量") + private BigDecimal preNum; + + /** 实时库存 */ + @ApiModelProperty(value = "实时库存") + private BigDecimal storageNum; + @ApiModelProperty(value = "备注") private String remark; + /** 管理方式(0编号 1计数) */ + @ApiModelProperty(value = "管理方式(0编号 1计数)") + private String manageType; + @ApiModelProperty(value = "创建者") private String createBy; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/StandardConfigManageMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/StandardConfigManageMapper.java index e1a2fb1a..548d0058 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/StandardConfigManageMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/StandardConfigManageMapper.java @@ -114,4 +114,12 @@ public interface StandardConfigManageMapper { * @return */ List getConfigLevelTwoList(StandardConfigBean bean); + + /** + * 根据配置id查询配置明细 + * 返回参数和规格型号树参数一致 + * @param configId + * @return + */ + List getListsByConfigId(Long configId); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/StandardConfigManageService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/StandardConfigManageService.java index 7dde2f9e..7898505c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/StandardConfigManageService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/StandardConfigManageService.java @@ -82,4 +82,12 @@ public interface StandardConfigManageService { * @return */ AjaxResult getConfigLevelTwoList(StandardConfigBean bean); + + /** + * 根据配置id查询配置明细 + * 返回参数和规格型号树参数一致 + * @param bean + * @return + */ + AjaxResult getListsByConfigId(StandardConfigDetailsVo bean); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/StandardConfigManageServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/StandardConfigManageServiceImpl.java index 5e238cea..9a9c666c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/StandardConfigManageServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/StandardConfigManageServiceImpl.java @@ -79,6 +79,18 @@ public class StandardConfigManageServiceImpl implements StandardConfigManageServ } } + @Override + public AjaxResult getListsByConfigId(StandardConfigDetailsVo bean) { + List list = new ArrayList<>(); + try { + list= mapper.getListsByConfigId(bean.getConfigId()); + return AjaxResult.success(list); + } catch (Exception e) { + e.printStackTrace(); + return AjaxResult.success(new ArrayList<>()); + } + } + @Override public int insertConfig(StandardConfigBean bean) { //根据类型名称判断,去重 diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyInfoMapper.xml index 03fa243e..3d95c663 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyInfoMapper.xml @@ -112,10 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and lai.lease_type = #{leaseType} and lai.estimate_lease_time = #{estimateLeaseTime} and lai.cost_bearing_party = #{costBearingParty} - and tt.task_status != '0' - - and lai.config_id is not null - + and tt.task_status != '0' GROUP BY lai.id ORDER BY tt.task_status,tt.create_time desc @@ -153,7 +150,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" lease_type, estimate_lease_time, cost_bearing_party, - config_id, #{code}, @@ -180,7 +176,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{leaseType}, #{estimateLeaseTime}, #{costBearingParty}, - #{configId}, diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml new file mode 100644 index 00000000..ac88cf0a --- /dev/null +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml @@ -0,0 +1,301 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + lai.id, lai.code, lai.task_id, lai.lease_person, lai.phone, lai.type, lai.company_audit_by,lai.apply_code, + lai.company_audit_time, lai.company_audit_remark, lai.dept_audit_by, lai.dept_audit_time, + lai.dept_audit_remark, lai.direct_audit_by, lai.direct_audit_time, lai.direct_audit_remark, + lai.create_by, lai.create_time, lai.update_by, lai.update_time, lai.remark, lai.company_id, + lai.direct_id, lai.lease_type, lai.estimate_lease_time, lai.cost_bearing_party, lai.lease_sign_url, lai.lease_sign_type, + bai.unit_id,bai.project_id,bu.unit_name, bp.pro_name, bai.agreement_code, tt.task_status as taskStatus, + sda.dict_label as taskStatusName, + IFNULL(sum(lad.pre_num),0) as preCountNum, + IFNULL(sum(lad.al_num),0) as alNum, + GROUP_CONCAT(DISTINCT mt1.type_name) AS maTypeNames, + bp.contract_part as contractPart, + sd.dept_name as impUnitName + from + lease_apply_info lai + left join tm_task tt on lai.task_id = tt.task_id + left join lease_apply_details lad on lai.id = lad.parent_id + left join tm_task_agreement tta on lai.task_id = tta.task_id + left join bm_agreement_info bai on tta.agreement_id = bai.agreement_id + left join bm_unit bu on bu.unit_id = bai.unit_id + left join bm_project bp on bp.pro_id = bai.project_id + left join sys_dept sd on sd.dept_id = bp.imp_unit + left join sys_dict_data sda on tt.task_status = sda.dict_value + and sda.dict_type = 'lease_task_status' + left join ma_type mt on lad.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' + + + + + + + select + lad.id, lad.parent_id, mt.type_id, mt.type_name, mt2.type_name as ma_type_name, + CASE mt.manage_type + WHEN 0 THEN + IFNULL(subquery0.num, 0) + ELSE + IFNULL(mt.storage_num, 0) + END as storage_num, + mt.manage_type as manageType, + (lad.pre_num - IF(lad.al_num IS NULL,'0',lad.al_num)) AS outNum, + IFNULL(lad.pre_num,0) as pre_num, + IFNULL(lad.audit_num,0) as audit_num, + IFNULL(lad.al_num,0) as al_num, + IFNULL(lad.status,0) as status, mt.unit_name,mt.unit_value, + lad.create_by, lad.create_time, lad.update_by, lad.update_time, lad.remark, lad.company_id + from + lease_apply_details lad + left join + ma_type mt on lad.type_id = mt.type_id and mt.`level` = '4' and mt.del_flag = '0' + left join + ma_type mt2 on mt2.type_id = mt.parent_id and mt2.`level` = '3' and mt2.del_flag = '0' + left join (SELECT mt.type_id, + mt2.type_name AS typeName, + mt.type_name AS typeModelName, + count(mm.ma_id) num + FROM ma_machine mm + LEFT JOIN ma_type mt ON mt.type_id = mm.type_id + LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id + WHERE mm.ma_code is not null and mm.ma_status in (1) + GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id + + + + + + + insert into lease_apply_info + + code, + task_id, + lease_person, + phone, + type, + company_audit_by, + company_audit_time, + company_audit_remark, + dept_audit_by, + dept_audit_time, + dept_audit_remark, + direct_audit_by, + direct_audit_time, + direct_audit_remark, + create_by, + create_time, + update_by, + update_time, + remark, + company_id, + direct_id, + lease_type, + estimate_lease_time, + cost_bearing_party, + apply_code, + + + #{code}, + #{taskId}, + #{leasePerson}, + #{phone}, + #{type}, + #{companyAuditBy}, + #{companyAuditTime}, + #{companyAuditRemark}, + #{deptAuditBy}, + #{deptAuditTime}, + #{deptAuditRemark}, + #{directAuditBy}, + #{directAuditTime}, + #{directAuditRemark}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{companyId}, + #{directId}, + #{leaseType}, + #{estimateLeaseTime}, + #{costBearingParty}, + #{applyCode}, + + + + + insert into lease_apply_details + (parent_id, type_id, pre_num, al_num, `status`, create_by, create_time, update_by, + update_time, remark, company_id) + values + + (#{item.parentId,jdbcType=INTEGER}, #{item.typeId,jdbcType=INTEGER}, #{item.preNum,jdbcType=INTEGER}, + #{item.alNum,jdbcType=INTEGER}, #{item.status,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR}, + NOW(), #{item.updateBy,jdbcType=VARCHAR}, NOW(), + #{item.remark,jdbcType=VARCHAR}, #{item.companyId,jdbcType=INTEGER}) + + + + + update lease_apply_info + + code = #{code}, + task_id = #{taskId}, + lease_person = #{leasePerson}, + phone = #{phone}, + `type` = #{type}, + company_audit_by = #{companyAuditBy}, + company_audit_time = #{companyAuditTime}, + company_audit_remark = #{companyAuditRemark}, + dept_audit_by = #{deptAuditBy}, + dept_audit_time = #{deptAuditTime}, + dept_audit_remark = #{deptAuditRemark}, + direct_audit_by = #{directAuditBy}, + direct_audit_time = #{directAuditTime}, + direct_audit_remark = #{directAuditRemark}, + update_by = #{updateBy}, + apply_code = #{applyCode}, + update_time = now(), + remark = #{remark}, + company_id = #{companyId}, + direct_id = #{directId}, + lease_type = #{leaseType}, + estimate_lease_time = #{estimateLeaseTime}, + cost_bearing_party = #{costBearingParty}, + + where id = #{id} + + + + + + + + \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/StandardConfigManageMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/StandardConfigManageMapper.xml index ef4e3e78..abb37a5c 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/StandardConfigManageMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/StandardConfigManageMapper.xml @@ -215,4 +215,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bsc.del_flag = 0 AND bsc.`level` = 2 +