This commit is contained in:
parent
79c0991698
commit
1b60cf6927
|
|
@ -73,6 +73,9 @@ public class MaterialConstants {
|
|||
/** 配件新购号的开头字母 */
|
||||
public final static String PART_TASK_TYPE_LABEL = "PJXG";
|
||||
|
||||
/** 配件领料单号的开头字母 */
|
||||
public static final String PART_LEASE_TASK_TYPE_LEASE = "LP";
|
||||
|
||||
/**
|
||||
* 内部单位协议
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.bonus.common.biz.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author : 阮世耀
|
||||
* @version : 1.0
|
||||
* 配件领料任务状态枚举
|
||||
*/
|
||||
@Getter
|
||||
public enum PartLeaseTaskStatusEnum {
|
||||
|
||||
LEASE_TASK_TO_PUBLISHED(0, "待审核"),
|
||||
LEASE_TASK_TO_AUDIT(1, "已审核"),
|
||||
LEASE_TASK_IN_PROGRESS(2, "已驳回");
|
||||
|
||||
private final Integer status;
|
||||
private final String statusName;
|
||||
|
||||
PartLeaseTaskStatusEnum(Integer status, String statusName) {
|
||||
this.status = status;
|
||||
this.statusName = statusName;
|
||||
}
|
||||
}
|
||||
|
|
@ -89,6 +89,7 @@ public class PartTypeServiceImpl implements IPartTypeService
|
|||
}
|
||||
// 检查 treeNode 是否已经存在于 newList 中
|
||||
if (!newList.contains(treeNode)) {
|
||||
treeNode.setStorageNum(type.getStorageNum());
|
||||
newList.add(treeNode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
package com.bonus.material.part.controller;
|
||||
|
||||
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.material.basic.domain.RetainedEquipmentInfo;
|
||||
import com.bonus.material.ma.domain.PartType;
|
||||
import com.bonus.material.part.domain.PartLeaseDetails;
|
||||
import com.bonus.material.part.domain.PartLeaseInfo;
|
||||
import com.bonus.material.part.service.PartLeaseService;
|
||||
|
|
@ -11,6 +14,7 @@ import io.swagger.annotations.ApiOperation;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -29,6 +33,28 @@ public class PartLeaseController extends BaseController {
|
|||
@Resource
|
||||
private PartLeaseService partLeaseService;
|
||||
|
||||
/**
|
||||
* 查询配件申请级别列表
|
||||
* @param partType
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "查询配件申请级别列表")
|
||||
@GetMapping("/selectPartTreeList")
|
||||
public AjaxResult selectPartTreeList(PartType partType) {
|
||||
return partLeaseService.selectPartTreeList(partType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据三级id查询一二级列表
|
||||
* @param partType
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "根据三级id查询一二级列表")
|
||||
@GetMapping("/selectPartTreeListByLevel")
|
||||
public AjaxResult selectPartTreeListByLevel(PartType partType) {
|
||||
return partLeaseService.selectPartTreeListByLevel(partType);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询配件领料任务列表")
|
||||
@GetMapping("/selectPartLeaseInfoList")
|
||||
public TableDataInfo selectPartLeaseInfoList(PartLeaseInfo partLeaseInfo) {
|
||||
|
|
@ -37,6 +63,20 @@ public class PartLeaseController extends BaseController {
|
|||
return getDataTable(partLeaseInfos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出配件列表
|
||||
* @param response
|
||||
* @param partLeaseInfo
|
||||
*/
|
||||
@ApiOperation("导出配件列表")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PartLeaseInfo partLeaseInfo)
|
||||
{
|
||||
List<PartLeaseInfo> list = partLeaseService.selectPartLeaseInfoList(partLeaseInfo);
|
||||
ExcelUtil<PartLeaseInfo> util = new ExcelUtil<>(PartLeaseInfo.class);
|
||||
util.exportExcel(response, list, "导出配件列表");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据任务id查询配件领料明细")
|
||||
@GetMapping("/selectPartLeaseByTaskId")
|
||||
public AjaxResult selectPartLeaseByTaskId(PartLeaseDetails partDto) {
|
||||
|
|
@ -49,27 +89,10 @@ public class PartLeaseController extends BaseController {
|
|||
return toAjax(partLeaseService.insertPartLeaseInfo(partLeaseInfo));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改配件领料任务")
|
||||
@PutMapping
|
||||
public AjaxResult edit(@NotNull(message = "领料任务不能为空") @RequestBody PartLeaseInfo partLeaseInfo) {
|
||||
return toAjax(partLeaseService.updatePartLeaseInfo(partLeaseInfo));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "审核领料任务")
|
||||
@PutMapping("/audit")
|
||||
@PostMapping("/audit")
|
||||
public AjaxResult audit(@NotNull(message = "领料任务不能为空") @RequestBody PartLeaseInfo partLeaseInfo) {
|
||||
return toAjax(partLeaseService.updatePartLeaseInfo(partLeaseInfo));
|
||||
return partLeaseService.auditPartLeaseInfo(partLeaseInfo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据taskId删除配件领料任务--支持批量")
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(partLeaseService.removePartLeaseInfoByIds(ids));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据id删除配件领料明细--支持批量")
|
||||
@DeleteMapping("/details/{ids}")
|
||||
public AjaxResult removeDetails(@PathVariable Long[] ids) {
|
||||
return toAjax(partLeaseService.removePartLeaseDetailsByIds(ids));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
package com.bonus.material.part.domain;
|
||||
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author : 阮世耀
|
||||
* @version : 1.0
|
||||
|
|
@ -10,19 +14,36 @@ import lombok.Data;
|
|||
* @Description: 描述
|
||||
*/
|
||||
@Data
|
||||
public class PartLeaseDetails implements java.io.Serializable {
|
||||
public class PartLeaseDetails extends BaseEntity implements java.io.Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long taskId;
|
||||
|
||||
@ApiModelProperty(value = "配件id")
|
||||
private Long partId;
|
||||
|
||||
@ApiModelProperty(value = "配件类型")
|
||||
private String partType;
|
||||
|
||||
@ApiModelProperty(value = "配件名称")
|
||||
private String partName;
|
||||
|
||||
private Integer preNum;
|
||||
@ApiModelProperty(value = "配件型号")
|
||||
private String partModel;
|
||||
|
||||
private Integer alNum;
|
||||
@ApiModelProperty(value = "申请数量")
|
||||
private BigDecimal preNum;
|
||||
|
||||
@ApiModelProperty(value = "原始数量")
|
||||
private BigDecimal storageNum;
|
||||
|
||||
@ApiModelProperty(value = "购买原值")
|
||||
private BigDecimal bugPrice;
|
||||
|
||||
private BigDecimal alNum;
|
||||
|
||||
private String remarks;
|
||||
|
||||
private Integer status;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.bonus.material.part.domain;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -22,28 +25,63 @@ public class PartLeaseInfo implements java.io.Serializable {
|
|||
@ApiModelProperty(value = "任务id")
|
||||
private Long taskId;
|
||||
|
||||
@ApiModelProperty(value = "任务编码")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "创建人")
|
||||
@ApiModelProperty(value = "申请人")
|
||||
@Excel(name = "申请人")
|
||||
private String creator;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
@Excel(name = "申请时间", width = 30, dateFormat = "yyyy-MM-dd hh:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "配件名称")
|
||||
@Excel(name = "申请配件")
|
||||
private String partName;
|
||||
|
||||
@ApiModelProperty(value = "任务编码")
|
||||
@Excel(name = "单号")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "审核人")
|
||||
@Excel(name = "审核人")
|
||||
private String auditor;
|
||||
|
||||
@ApiModelProperty(value = "审核时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime auditTime;
|
||||
@Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd hh:mm:ss")
|
||||
private Date auditTime;
|
||||
|
||||
@ApiModelProperty(value = "状态,0待审批 1通过 2驳回")
|
||||
private int status;
|
||||
private Integer taskStatus;
|
||||
|
||||
@ApiModelProperty(value = "状态,0 未审核 1已审核(包含通过和驳回)")
|
||||
private Integer appTaskStatus;
|
||||
|
||||
@ApiModelProperty(value = "状态,0待审批 1通过 2驳回")
|
||||
@Excel(name = "状态")
|
||||
private String taskStatusName;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remarks;
|
||||
|
||||
private String companyId;
|
||||
|
||||
@ApiModelProperty(value = "任务当月序号")
|
||||
private Integer monthOrder;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private String startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private String endTime;
|
||||
|
||||
@ApiModelProperty(value = "关键字")
|
||||
private String keyWord;
|
||||
|
||||
@ApiModelProperty(value = "申请数量")
|
||||
private BigDecimal preNum;
|
||||
|
||||
@ApiModelProperty(value = "明细")
|
||||
private List<PartLeaseDetails> partLeaseDetailsList;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package com.bonus.material.part.mapper;
|
||||
|
||||
import com.bonus.material.ma.domain.PartType;
|
||||
import com.bonus.material.part.domain.PartLeaseDetails;
|
||||
import com.bonus.material.part.domain.PartLeaseInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -69,4 +71,69 @@ public interface PartLeaseMapper {
|
|||
* @param ids 任务id
|
||||
*/
|
||||
int removePartLeaseDetailsByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 查询配件领用树结构列表
|
||||
* @param partType
|
||||
* @return
|
||||
*/
|
||||
List<PartType> selectPartTreeList(PartType partType);
|
||||
|
||||
/**
|
||||
* 根据当前年月获取当前任务的最大序号
|
||||
* @param currentYear
|
||||
* @param currentMonth
|
||||
* @return
|
||||
*/
|
||||
int getMonthMaxOrderByDate(@Param(value = "year") String currentYear,@Param(value = "month") String currentMonth);
|
||||
|
||||
/**
|
||||
* 修改领用详情
|
||||
* @param partLeaseDetails
|
||||
* @return
|
||||
*/
|
||||
int updatePartLeaseDetails(PartLeaseDetails partLeaseDetails);
|
||||
|
||||
/**
|
||||
* 根据等级查询领用详情
|
||||
* @param partType
|
||||
* @return
|
||||
*/
|
||||
PartType selectPartTreeListByLevel(PartType partType);
|
||||
|
||||
/**
|
||||
* 修改库存数量
|
||||
* @param partLeaseDetails
|
||||
* @return
|
||||
*/
|
||||
int updateMaTypeStockNum(PartLeaseDetails partLeaseDetails);
|
||||
|
||||
/**
|
||||
* 修改个人库存数量
|
||||
* @param partLeaseDetails
|
||||
* @return
|
||||
*/
|
||||
int updatePersonStockNum(PartLeaseDetails partLeaseDetails);
|
||||
|
||||
/**
|
||||
* 查询个人库存数量
|
||||
* @param partLeaseDetails
|
||||
* @return
|
||||
*/
|
||||
List<PartLeaseDetails> selectPerson(PartLeaseDetails partLeaseDetails);
|
||||
|
||||
/**
|
||||
* 新增个人库存数量
|
||||
* @param partLeaseDetails
|
||||
* @return
|
||||
*/
|
||||
int insertPersonStockNum(PartLeaseDetails partLeaseDetails);
|
||||
|
||||
/**
|
||||
* 修改领用任务状态
|
||||
* @param taskId
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
int updateTaskStatus(@Param("taskId") String taskId,@Param("status") Integer status);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.bonus.material.part.service;
|
||||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.ma.domain.PartType;
|
||||
import com.bonus.material.part.domain.PartLeaseDetails;
|
||||
import com.bonus.material.part.domain.PartLeaseInfo;
|
||||
|
||||
|
|
@ -13,57 +15,46 @@ import java.util.List;
|
|||
* @Description: 描述
|
||||
*/
|
||||
public interface PartLeaseService {
|
||||
/**
|
||||
* 查询配件领用信息
|
||||
* @param id 任务id
|
||||
*/
|
||||
PartLeaseInfo selectPartLeaseInfoById(Long id);
|
||||
|
||||
/**
|
||||
* 查询配件领用信息列表
|
||||
* @param partLeaseInfo 任务id
|
||||
* @param partLeaseInfo
|
||||
* @return
|
||||
*/
|
||||
List<PartLeaseInfo> selectPartLeaseInfoList(PartLeaseInfo partLeaseInfo);
|
||||
|
||||
/**
|
||||
* 新增配件领用信息
|
||||
* @param partLeaseInfo 任务id
|
||||
* @param partLeaseInfo
|
||||
* @return
|
||||
*/
|
||||
int insertPartLeaseInfo(PartLeaseInfo partLeaseInfo);
|
||||
|
||||
/**
|
||||
* 删除配件领用
|
||||
* @param ids 任务id
|
||||
*/
|
||||
int removePartLeaseInfoByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 修改配件领用信息
|
||||
* @param partLeaseInfo 任务id
|
||||
*/
|
||||
int updatePartLeaseInfo(PartLeaseInfo partLeaseInfo);
|
||||
|
||||
/**
|
||||
* 查询配件领用详情
|
||||
* @param partLeaseDetails 任务id
|
||||
* @param partLeaseDetails
|
||||
* @return
|
||||
*/
|
||||
List<PartLeaseDetails> selectPartLeaseDetailsList(PartLeaseDetails partLeaseDetails);
|
||||
|
||||
/**
|
||||
* 新增配件领用详情 -- 批量
|
||||
* @param partLeaseDetailsList 领用明细
|
||||
* 查询配件申请级别列表
|
||||
* @param partType
|
||||
* @return
|
||||
*/
|
||||
int batchPartLeaseDetails(List<PartLeaseDetails> partLeaseDetailsList);
|
||||
AjaxResult selectPartTreeList(PartType partType);
|
||||
|
||||
/**
|
||||
* 新增配件领用详情 -- 单条
|
||||
* @param leaseDetails 领用明细
|
||||
* 审核领料任务
|
||||
* @param partLeaseInfo
|
||||
* @return
|
||||
*/
|
||||
int insertPartLeaseDetails(PartLeaseDetails leaseDetails);
|
||||
AjaxResult auditPartLeaseInfo(PartLeaseInfo partLeaseInfo);
|
||||
|
||||
/**
|
||||
* 删除配件领用详情
|
||||
* @param ids 任务id
|
||||
* 根据三级id查询一二级列表
|
||||
* @param partType
|
||||
* @return
|
||||
*/
|
||||
int removePartLeaseDetailsByIds(Long[] ids);
|
||||
AjaxResult selectPartTreeListByLevel(PartType partType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,29 @@
|
|||
package com.bonus.material.part.service.impl;
|
||||
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.bonus.common.biz.constant.MaterialConstants;
|
||||
import com.bonus.common.biz.enums.PartLeaseTaskStatusEnum;
|
||||
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.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.ma.domain.PartType;
|
||||
import com.bonus.material.part.domain.PartLeaseDetails;
|
||||
import com.bonus.material.part.domain.PartLeaseInfo;
|
||||
import com.bonus.material.part.mapper.PartLeaseMapper;
|
||||
import com.bonus.material.part.service.PartLeaseService;
|
||||
import com.bonus.material.task.mapper.TmTaskMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author : 阮世耀
|
||||
|
|
@ -27,24 +33,12 @@ import java.util.List;
|
|||
* @Description: 描述
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PartLeaseServiceImpl implements PartLeaseService {
|
||||
|
||||
@Resource
|
||||
private PartLeaseMapper partLeaseMapper;
|
||||
|
||||
@Resource
|
||||
private TmTaskMapper tmTaskMapper;
|
||||
|
||||
/**
|
||||
* 查询配件领用信息
|
||||
*
|
||||
* @param id 任务id
|
||||
*/
|
||||
@Override
|
||||
public PartLeaseInfo selectPartLeaseInfoById(Long id) {
|
||||
return partLeaseMapper.selectPartLeaseInfoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配件领用信息列表
|
||||
*
|
||||
|
|
@ -66,12 +60,24 @@ public class PartLeaseServiceImpl implements PartLeaseService {
|
|||
if (null == partLeaseInfo || null == partLeaseInfo.getPartLeaseDetailsList()) {
|
||||
throw new ServiceException("领用信息不能为空");
|
||||
}
|
||||
final int thisMonthMaxOrder = tmTaskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_PART_LEASE.getTaskTypeId());
|
||||
for (PartLeaseDetails partLeaseDetails : partLeaseInfo.getPartLeaseDetailsList()) {
|
||||
if (null == partLeaseDetails.getPartId() || null == partLeaseDetails.getPreNum() || null == partLeaseDetails.getStorageNum()) {
|
||||
throw new ServiceException("领用明细信息不能为空");
|
||||
}
|
||||
if (partLeaseDetails.getPreNum().compareTo(partLeaseDetails.getStorageNum()) > 0) {
|
||||
throw new ServiceException("领用数量不能大于库存数量");
|
||||
}
|
||||
}
|
||||
int thisMonthMaxOrder = partLeaseMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth());
|
||||
final String taskCode = genderTaskCode(thisMonthMaxOrder);
|
||||
partLeaseInfo.setCode(taskCode).setCreator(SecurityUtils.getLoginUser().getUsername());
|
||||
partLeaseInfo.setCode(taskCode).setMonthOrder(thisMonthMaxOrder + 1).setCreator(SecurityUtils.getLoginUser().getUsername())
|
||||
.setCreateTime(DateUtils.getNowDate());
|
||||
final int insertPartLeaseInfo = partLeaseMapper.insertPartLeaseInfo(partLeaseInfo);
|
||||
final int batchDetailsNum;
|
||||
if (0 < insertPartLeaseInfo) {
|
||||
for (PartLeaseDetails partLeaseDetails : partLeaseInfo.getPartLeaseDetailsList()) {
|
||||
partLeaseDetails.setTaskId(partLeaseInfo.getTaskId());
|
||||
}
|
||||
batchDetailsNum = partLeaseMapper.batchPartLeaseDetails(partLeaseInfo.getPartLeaseDetailsList());
|
||||
} else {
|
||||
throw new ServiceException("领用信息新增失败");
|
||||
|
|
@ -92,44 +98,7 @@ public class PartLeaseServiceImpl implements PartLeaseService {
|
|||
final Date nowDate = DateUtils.getNowDate();
|
||||
final String format = dateFormat.format(nowDate);
|
||||
final String result = format.replace("-", "");
|
||||
return MaterialConstants.LEASE_TASK_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配件领用
|
||||
*
|
||||
* @param ids 任务id
|
||||
*/
|
||||
@Override
|
||||
public int removePartLeaseInfoByIds(Long[] ids) {
|
||||
return partLeaseMapper.removePartLeaseInfoByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改配件领用信息
|
||||
*
|
||||
* @param partLeaseInfo 任务id
|
||||
*/
|
||||
@Override
|
||||
public int updatePartLeaseInfo(PartLeaseInfo partLeaseInfo) {
|
||||
if (null == partLeaseInfo || null == partLeaseInfo.getTaskId()) {
|
||||
throw new ServiceException("领用信息或任务ID不能为空");
|
||||
}
|
||||
partLeaseInfo.setCode(null);
|
||||
switch (partLeaseInfo.getStatus()) {
|
||||
case 1:
|
||||
partLeaseInfo.setAuditor(SecurityUtils.getLoginUser().getUsername());
|
||||
partLeaseInfo.setAuditTime(LocalDateTime.now());
|
||||
break;
|
||||
case 2:
|
||||
partLeaseInfo.setAuditor(SecurityUtils.getLoginUser().getUsername());
|
||||
partLeaseInfo.setAuditTime(LocalDateTime.now());
|
||||
break;
|
||||
default:
|
||||
partLeaseInfo.setAuditor(null);
|
||||
partLeaseInfo.setAuditTime(null);
|
||||
}
|
||||
return partLeaseMapper.updatePartLeaseInfo(partLeaseInfo);
|
||||
return MaterialConstants.PART_LEASE_TASK_TYPE_LEASE + result + String.format("-%03d", thisMonthMaxOrder + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -143,32 +112,149 @@ public class PartLeaseServiceImpl implements PartLeaseService {
|
|||
}
|
||||
|
||||
/**
|
||||
* 新增配件领用详情 -- 批量
|
||||
*
|
||||
* @param partLeaseDetailsList 领用明细
|
||||
* 查询配件领用树结构列表
|
||||
* @param partType
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int batchPartLeaseDetails(List<PartLeaseDetails> partLeaseDetailsList) {
|
||||
return partLeaseMapper.batchPartLeaseDetails(partLeaseDetailsList);
|
||||
public AjaxResult selectPartTreeList(PartType partType) {
|
||||
List<PartType> list = new ArrayList<>();
|
||||
List<PartType> secondList = new ArrayList<>();
|
||||
List<PartType> thirdList = new ArrayList<>();
|
||||
HashMap<String, Object> map = new HashMap<>(2);
|
||||
List<PartType> partTypeList = partLeaseMapper.selectPartTreeList(partType);
|
||||
if (!CollectionUtils.isEmpty(partTypeList)) {
|
||||
if (partType.getId() != null) {
|
||||
list.addAll(partTypeList);
|
||||
partTypeList.forEach(partType1 -> {
|
||||
PartType type = new PartType();
|
||||
type.setId(partType1.getId());
|
||||
List<PartType> partTypeList1 = partLeaseMapper.selectPartTreeList(type);
|
||||
if (!CollectionUtils.isEmpty(partTypeList1)) {
|
||||
list.addAll(partTypeList1);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
for (PartType type : list) {
|
||||
if ("2".equals(type.getLevel())) {
|
||||
secondList.add(type);
|
||||
} else if ("3".equals(type.getLevel())) {
|
||||
thirdList.add(type);
|
||||
}
|
||||
}
|
||||
map.put("secondList", secondList);
|
||||
map.put("thirdList", thirdList);
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
}
|
||||
return AjaxResult.success(partTypeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增配件领用详情 -- 单条
|
||||
*
|
||||
* @param leaseDetails 领用明细
|
||||
* 审核配件领用任务
|
||||
* @param partLeaseInfo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int insertPartLeaseDetails(PartLeaseDetails leaseDetails) {
|
||||
return partLeaseMapper.insertPartLeaseDetails(leaseDetails);
|
||||
@Transactional
|
||||
public AjaxResult auditPartLeaseInfo(PartLeaseInfo partLeaseInfo) {
|
||||
if (partLeaseInfo == null || CollectionUtils.isEmpty(partLeaseInfo.getPartLeaseDetailsList()) ||
|
||||
partLeaseInfo.getTaskStatus() == null || partLeaseInfo.getTaskId() == null) {
|
||||
return AjaxResult.error("配件领用审核信息不能为空");
|
||||
}
|
||||
String userId = SecurityUtils.getUserId().toString();
|
||||
try {
|
||||
// 审核通过
|
||||
if (partLeaseInfo.getTaskStatus() == 1) {
|
||||
for (PartLeaseDetails partLeaseDetails : partLeaseInfo.getPartLeaseDetailsList()) {
|
||||
// 修改详情表的状态
|
||||
partLeaseDetails.setStatus(PartLeaseTaskStatusEnum.LEASE_TASK_TO_AUDIT.getStatus());
|
||||
partLeaseDetails.setUpdateBy(userId);
|
||||
partLeaseDetails.setUpdateTime(DateUtils.getNowDate());
|
||||
int res = partLeaseMapper.updatePartLeaseDetails(partLeaseDetails);
|
||||
if (res > 0) {
|
||||
// 审核通过,扣减ma_part_type表库存
|
||||
res = partLeaseMapper.updateMaTypeStockNum(partLeaseDetails);
|
||||
if (res == 0) {
|
||||
throw new ServiceException("配件库存不足");
|
||||
}
|
||||
// 增加个人库存
|
||||
// 现根据人员以及配件id去查询,存在则更新,不存在则新增
|
||||
partLeaseDetails.setCreateBy(userId);
|
||||
partLeaseDetails.setCreateTime(DateUtils.getNowDate());
|
||||
List<PartLeaseDetails> list = partLeaseMapper.selectPerson(partLeaseDetails);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
res = partLeaseMapper.insertPersonStockNum(partLeaseDetails);
|
||||
if (res == 0) {
|
||||
throw new ServiceException("个人库存新增失败");
|
||||
}
|
||||
} else {
|
||||
res = partLeaseMapper.updatePersonStockNum(partLeaseDetails);
|
||||
if (res == 0) {
|
||||
throw new ServiceException("个人库存更新失败");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new ServiceException("领用信息审核失败");
|
||||
}
|
||||
}
|
||||
} else if (partLeaseInfo.getTaskStatus() == 2) {
|
||||
for (PartLeaseDetails partLeaseDetails : partLeaseInfo.getPartLeaseDetailsList()) {
|
||||
// 修改详情表的状态
|
||||
partLeaseDetails.setStatus(PartLeaseTaskStatusEnum.LEASE_TASK_IN_PROGRESS.getStatus());
|
||||
partLeaseDetails.setUpdateBy(userId);
|
||||
int res = partLeaseMapper.updatePartLeaseDetails(partLeaseDetails);
|
||||
if (res == 0) {
|
||||
throw new ServiceException("领用信息审核失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 根据任务id查询详情状态,修改最外层任务状态
|
||||
PartLeaseDetails partLeaseDetails = new PartLeaseDetails();
|
||||
partLeaseDetails.setTaskId(partLeaseInfo.getTaskId());
|
||||
List<PartLeaseDetails> partLeaseDetailsByTaskId = partLeaseMapper.selectPartLeaseDetailsList(partLeaseDetails);
|
||||
// 将集合中的status取出
|
||||
List<Integer> statusList = partLeaseDetailsByTaskId.stream()
|
||||
.map(PartLeaseDetails::getStatus)
|
||||
.collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(statusList)) {
|
||||
int publishedStatus = PartLeaseTaskStatusEnum.LEASE_TASK_TO_PUBLISHED.getStatus();
|
||||
int inProgressStatus = PartLeaseTaskStatusEnum.LEASE_TASK_IN_PROGRESS.getStatus();
|
||||
boolean notContainsNoFinished =!statusList.contains(publishedStatus);
|
||||
boolean allReject = statusList.stream()
|
||||
.allMatch(status -> status.equals(inProgressStatus));
|
||||
if (notContainsNoFinished && !allReject) {
|
||||
partLeaseMapper.updateTaskStatus(partLeaseInfo.getTaskId().toString(), PartLeaseTaskStatusEnum.LEASE_TASK_TO_AUDIT.getStatus());
|
||||
} else if (notContainsNoFinished && allReject) {
|
||||
partLeaseMapper.updateTaskStatus(partLeaseInfo.getTaskId().toString(), PartLeaseTaskStatusEnum.LEASE_TASK_IN_PROGRESS.getStatus());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配件领用详情
|
||||
*
|
||||
* @param ids 任务id
|
||||
*/
|
||||
@Override
|
||||
public int removePartLeaseDetailsByIds(Long[] ids) {
|
||||
return partLeaseMapper.removePartLeaseDetailsByIds(ids);
|
||||
public AjaxResult selectPartTreeListByLevel(PartType partType) {
|
||||
if (partType == null || partType.getId() == null) {
|
||||
return AjaxResult.error("参数不能为空");
|
||||
}
|
||||
List<PartType> list = new ArrayList<>();
|
||||
PartType type = partLeaseMapper.selectPartTreeListByLevel(partType);
|
||||
if (type != null) {
|
||||
type.setId(type.getParentId());
|
||||
PartType type1 = partLeaseMapper.selectPartTreeListByLevel(type);
|
||||
if (type1 != null) {
|
||||
list.add(type1);
|
||||
type1.setId(type1.getParentId());
|
||||
PartType type2 = partLeaseMapper.selectPartTreeListByLevel(type1);
|
||||
if (type2 != null) {
|
||||
list.add(type2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -199,13 +199,6 @@ public interface RepairMapper {
|
|||
*/
|
||||
int updateStorageNum(RepairPartDetails partDetails);
|
||||
|
||||
/**
|
||||
* 扣减ma_part_type表库存
|
||||
* @param partDetails
|
||||
* @return
|
||||
*/
|
||||
int updateMaTypeStockNum(RepairPartDetails partDetails);
|
||||
|
||||
/**
|
||||
* 查询维修明细
|
||||
* @param bean
|
||||
|
|
|
|||
|
|
@ -729,13 +729,10 @@ public class RepairServiceImpl implements RepairService {
|
|||
repairMapper.addRecord(repairApplyRecord);
|
||||
// 扣减个人库配件库存数量
|
||||
int res = repairMapper.updateStorageNum(partDetails);
|
||||
if (res > 0) {
|
||||
// 扣减ma_part_type表库存
|
||||
res = repairMapper.updateMaTypeStockNum(partDetails);
|
||||
if (res == 0) {
|
||||
throw new ServiceException("配件库存不足");
|
||||
}
|
||||
if (res == 0) {
|
||||
throw new ServiceException("个人配件库存不足");
|
||||
}
|
||||
|
||||
} else {
|
||||
// 不选维修配件时, 只添加【维修记录表】
|
||||
repairMapper.addRecord(repairApplyRecord);
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ public class ScrapApplyDetails extends BaseEntity {
|
|||
@ApiModelProperty(value = "状态")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty(value = "app任务状态")
|
||||
private Integer appTaskStatus;
|
||||
|
||||
private String statusName;
|
||||
|
||||
@ApiModelProperty(value = "任务状态")
|
||||
|
|
|
|||
|
|
@ -8,25 +8,56 @@
|
|||
</select>
|
||||
|
||||
<select id="selectPartLeaseInfoList" resultType="com.bonus.material.part.domain.PartLeaseInfo">
|
||||
select task_id, code, creator, create_time, auditor, audit_time, status, remarks, company_id
|
||||
from pa_collar_apply
|
||||
SELECT
|
||||
p1.task_id as taskId,
|
||||
p1.creator as creator,
|
||||
p1.create_time as createTime,
|
||||
GROUP_CONCAT( mp.pa_name ) as partName,
|
||||
p1.`code` as code,
|
||||
GROUP_CONCAT(DISTINCT su.nick_name) as auditor,
|
||||
MAX(p2.audit_time) as auditTime,
|
||||
p1.task_status as taskStatus,
|
||||
case p1.task_status
|
||||
WHEN 0 THEN '待审核'
|
||||
WHEN 1 THEN '已审核'
|
||||
WHEN 2 THEN '已驳回'
|
||||
ELSE '未知'
|
||||
END as taskStatusName,
|
||||
SUM(p2.pre_num) as preNum
|
||||
FROM
|
||||
pa_collar_apply p1
|
||||
LEFT JOIN pa_collar_apply_details p2 ON p1.task_id = p2.task_id
|
||||
LEFT JOIN ma_part_type mp ON p2.part_id = mp.pa_id and mp.del_flag = '0'
|
||||
LEFT JOIN sys_user su on p2.auditor = su.user_id
|
||||
AND mp.del_flag = '0'
|
||||
<where>
|
||||
<if test="taskId != null ">
|
||||
and task_id = #{taskId}
|
||||
<if test="taskStatus != null">
|
||||
and p1.task_status = #{taskStatus}
|
||||
</if>
|
||||
<if test="code != null and code != ''">
|
||||
and `code` = #{code}
|
||||
<if test="appTaskStatus != null and appTaskStatus == 0">
|
||||
and p1.task_status = #{taskStatus}
|
||||
</if>
|
||||
<if test="creator != null and creator != ''">
|
||||
and creator = #{creator}
|
||||
<if test="appTaskStatus != null and appTaskStatus == 1">
|
||||
and (p1.task_status = 1 or p1.task_status = 2)
|
||||
</if>
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and (
|
||||
p1.creator like concat('%', #{keyWord}, '%') or
|
||||
p1.`code` like concat('%', #{keyWord}, '%') or
|
||||
p1.auditor like concat('%', #{keyWord}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||
<![CDATA[and DATE_FORMAT( p1.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
|
||||
</if>
|
||||
</where>
|
||||
orber by create_time desc
|
||||
GROUP BY p1.task_id
|
||||
ORDER BY p1.create_time desc
|
||||
</select>
|
||||
|
||||
<insert id="insertPartLeaseInfo">
|
||||
insert into pa_collar_apply(task_id, code, creator, create_time, status, remarks, company_id)
|
||||
values (#{taskId}, #{code}, #{creator}, now(), 0, #{remarks}, #{companyId})
|
||||
<insert id="insertPartLeaseInfo" useGeneratedKeys="true" keyProperty="taskId">
|
||||
insert into pa_collar_apply(code, month_order, creator, create_time, task_status, remarks, company_id)
|
||||
values (#{code}, #{monthOrder}, #{creator}, #{createTime}, 0, #{remarks}, #{companyId})
|
||||
</insert>
|
||||
|
||||
<delete id="removePartLeaseInfoByIds">
|
||||
|
|
@ -37,9 +68,24 @@
|
|||
</delete>
|
||||
|
||||
<select id="selectPartLeaseDetailsList" resultType="com.bonus.material.part.domain.PartLeaseDetails">
|
||||
select pcad.id, pcad.task_id, pcad.part_id, mpt.pa_name as partName, pcad.pre_num, pcad.al_num, pcad.remarks
|
||||
from pa_collar_apply_details pcad
|
||||
left join ma_part_type mpt on pcad.part_id = mpt.pa_id
|
||||
SELECT
|
||||
pcad.id as id,
|
||||
pcad.task_id as taskId,
|
||||
pcad.part_id as partId,
|
||||
mp3.pa_name as partType,
|
||||
mp2.pa_name as partName,
|
||||
mp1.pa_name as partModel,
|
||||
pcad.pre_num as preNum,
|
||||
pcad.status as status,
|
||||
mp1.buy_price as bugPrice
|
||||
FROM
|
||||
pa_collar_apply_details pcad
|
||||
LEFT JOIN ma_part_type mp1 ON pcad.part_id = mp1.pa_id
|
||||
AND mp1.del_flag = '0'
|
||||
LEFT JOIN ma_part_type mp2 ON mp1.parent_id = mp2.pa_id
|
||||
AND mp2.del_flag = '0'
|
||||
LEFT JOIN ma_part_type mp3 ON mp2.parent_id = mp3.pa_id
|
||||
AND mp3.del_flag = '0'
|
||||
<where>
|
||||
<if test="taskId != null ">
|
||||
and pcad.task_id = #{taskId}
|
||||
|
|
@ -47,25 +93,75 @@
|
|||
<if test="partId != null ">
|
||||
and pcad.part_id = #{partId}
|
||||
</if>
|
||||
<if test="partName != null and partName != ''">
|
||||
and pcad.part_name = #{partName}
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectPartTreeList" resultType="com.bonus.material.ma.domain.PartType">
|
||||
select pa_id as id, pa_name as paName, storage_num as storageNum,
|
||||
level as level,
|
||||
parent_id as parentId
|
||||
from ma_part_type
|
||||
<where>
|
||||
del_flag = '0'
|
||||
<if test="level != null and level != ''">
|
||||
and level = #{level}
|
||||
</if>
|
||||
<if test="id != null">
|
||||
and parent_id = #{id}
|
||||
</if>
|
||||
<if test="paName != null and paName != ''">
|
||||
and pa_name = #{partName}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getMonthMaxOrderByDate" resultType="java.lang.Integer">
|
||||
select COALESCE(max(month_order), 0) from pa_collar_apply
|
||||
where
|
||||
month(create_time) = #{month} and year(create_time) = #{year}
|
||||
</select>
|
||||
|
||||
<select id="selectPartTreeListByLevel" resultType="com.bonus.material.ma.domain.PartType">
|
||||
select pa_id as id, pa_name as paName, storage_num as storageNum,
|
||||
level as level,
|
||||
parent_id as parentId
|
||||
from ma_part_type
|
||||
<where>
|
||||
del_flag = '0'
|
||||
<if test="id != null">
|
||||
and pa_id = #{id}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectPerson" resultType="com.bonus.material.part.domain.PartLeaseDetails">
|
||||
SELECT
|
||||
part_id as partId,
|
||||
part_num as partNum
|
||||
FROM
|
||||
pa_person_storage
|
||||
WHERE
|
||||
part_id = #{partId}
|
||||
AND creator = #{createBy}
|
||||
</select>
|
||||
|
||||
<insert id="insertPartLeaseDetails">
|
||||
insert into pa_collar_apply_details(task_id, part_id, pre_num, al_num, remarks)
|
||||
values (#{taskId}, #{partId}, #{preNum}, #{alNum}, #{remarks})
|
||||
</insert>
|
||||
|
||||
<insert id="batchPartLeaseDetails">
|
||||
insert into pa_collar_apply_details(task_id, part_id, pre_num, al_num, remarks)
|
||||
insert into pa_collar_apply_details(task_id, part_id, pre_num, al_num, remarks, status)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.taskId}, #{item.partId}, #{item.preNum}, #{item.alNum}, #{item.remarks})
|
||||
(#{item.taskId}, #{item.partId}, #{item.preNum}, #{item.alNum}, #{item.remarks}, 0)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertPersonStockNum">
|
||||
insert into pa_person_storage(task_id, part_id, part_num, part_price, creator, create_time)
|
||||
values (#{taskId}, #{partId}, #{preNum}, #{bugPrice}, #{createBy}, #{createTime})
|
||||
</insert>
|
||||
|
||||
<update id="updatePartLeaseInfo">
|
||||
update pa_collar_apply
|
||||
<set>
|
||||
|
|
@ -94,4 +190,51 @@
|
|||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updatePartLeaseDetails">
|
||||
update pa_collar_apply_details
|
||||
<set>
|
||||
<if test="alNum != null">
|
||||
al_num = #{preNum},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status},
|
||||
</if>
|
||||
<if test="updateBy != null">
|
||||
auditor = #{updateBy},
|
||||
</if>
|
||||
audit_time = #{updateTime}
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateMaTypeStockNum">
|
||||
update
|
||||
ma_part_type
|
||||
set
|
||||
storage_num = storage_num - #{preNum},
|
||||
update_by = #{updateBy},
|
||||
update_time = #{updateTime}
|
||||
where
|
||||
pa_id = #{partId}
|
||||
</update>
|
||||
|
||||
<update id="updatePersonStockNum">
|
||||
update
|
||||
pa_person_storage
|
||||
set
|
||||
part_num = part_num + #{preNum}
|
||||
where
|
||||
part_id = #{partId}
|
||||
and creator = #{createBy}
|
||||
</update>
|
||||
|
||||
<update id="updateTaskStatus">
|
||||
update
|
||||
pa_collar_apply
|
||||
set
|
||||
task_status = #{status}
|
||||
where
|
||||
task_id = #{taskId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
@ -594,13 +594,4 @@
|
|||
part_id = #{partId}
|
||||
and creator = #{createBy}
|
||||
</update>
|
||||
<update id="updateMaTypeStockNum">
|
||||
update
|
||||
ma_part_type
|
||||
set
|
||||
storage_num = storage_num - #{partNum},
|
||||
update_time = now()
|
||||
where
|
||||
pa_id = #{partId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -64,10 +64,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
left join tm_task tt2 ON tt2.task_id = rad.task_id
|
||||
<where>
|
||||
<if test="typeId != null "> and type_id = #{typeId}</if>
|
||||
<if test="scrapNum != null "> and scrap_num = #{scrapNum}</if>
|
||||
<if test="scrapSource != null and scrapSource != ''"> and scrap_source = #{scrapSource}</if>
|
||||
<if test="scrapType != null and scrapType != ''"> and scrap_type = #{scrapType}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="appTaskStatus != null and appTaskStatus == 0">
|
||||
and tt.task_status = #{appTaskStatus}
|
||||
</if>
|
||||
<if test="appTaskStatus != null and appTaskStatus == 1">
|
||||
and (tt.task_status = 1 or tt.task_status = 2)
|
||||
</if>
|
||||
<if test="auditBy != null "> and audit_by = #{auditBy}</if>
|
||||
<if test="taskStatus != null "> and tt.task_status = #{taskStatus}</if>
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
|
|
|
|||
Loading…
Reference in New Issue