修饰后入库
This commit is contained in:
parent
8cf748d179
commit
fcd224db8f
|
|
@ -0,0 +1,24 @@
|
|||
package com.bonus.common.biz.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author : mashuai
|
||||
* @version : 1.0
|
||||
* 退料任务状态枚举
|
||||
*/
|
||||
@Getter
|
||||
public enum RepairInputStatusEnum {
|
||||
|
||||
Input_TASK_NO_FINISHED(0, "入库进行中"),
|
||||
Input_TASK_IN_FINISHED(1, "入库完成"),
|
||||
Input_TASK_TO_REJECT(2, "入库驳回");
|
||||
|
||||
private final Integer status;
|
||||
private final String statusName;
|
||||
|
||||
RepairInputStatusEnum(Integer status, String statusName) {
|
||||
this.status = status;
|
||||
this.statusName = statusName;
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,8 @@ public class MaCodeVo {
|
|||
|
||||
private String typeId;
|
||||
|
||||
private String taskId;
|
||||
|
||||
@ApiModelProperty(value = "物资类型")
|
||||
private String materialType;
|
||||
|
||||
|
|
@ -29,4 +31,9 @@ public class MaCodeVo {
|
|||
|
||||
@ApiModelProperty(value = "机具外观判断")
|
||||
private String apDetection;
|
||||
|
||||
private String keyWord;
|
||||
|
||||
@ApiModelProperty(value = "驳回原因")
|
||||
private String rejectReason;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@ package com.bonus.material.repair.controller;
|
|||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.bonus.common.biz.annotation.StoreLog;
|
||||
import com.bonus.common.biz.domain.purchase.PurchaseDto;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.material.back.domain.vo.MaCodeVo;
|
||||
import com.bonus.material.common.annotation.PreventRepeatSubmit;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
|
@ -41,7 +45,7 @@ public class RepairInputDetailsController extends BaseController {
|
|||
* 查询修试后入库列表
|
||||
*/
|
||||
@ApiOperation(value = "查询修试后入库列表")
|
||||
@RequiresPermissions("repair:details:list")
|
||||
//@RequiresPermissions("repair:details:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(RepairInputDetails repairInputDetails) {
|
||||
startPage();
|
||||
|
|
@ -67,10 +71,10 @@ public class RepairInputDetailsController extends BaseController {
|
|||
* 获取修试后入库详细信息
|
||||
*/
|
||||
@ApiOperation(value = "获取修试后入库详细信息")
|
||||
@RequiresPermissions("repair:details:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return success(repairInputDetailsService.selectRepairInputDetailsById(id));
|
||||
//@RequiresPermissions("repair:details:query")
|
||||
@GetMapping(value = "/getById")
|
||||
public AjaxResult getInfo(RepairInputDetails repairInputDetails) {
|
||||
return success(repairInputDetailsService.selectRepairInputDetailsById(repairInputDetails));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -116,4 +120,44 @@ public class RepairInputDetailsController extends BaseController {
|
|||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(repairInputDetailsService.deleteRepairInputDetailsByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 入库或批量入库操作
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "入库或批量入库操作")
|
||||
@PreventRepeatSubmit
|
||||
// @RequiresPermissions("purchase:storage:add")
|
||||
@StoreLog(title = "修试后入库", module = "修试入库->修试后入库")
|
||||
@PostMapping("/warehouse")
|
||||
public AjaxResult warehouse(@RequestBody RepairInputDetails repairInputDetails) {
|
||||
return repairInputDetailsService.warehouse(repairInputDetails);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询修试待入库机具编码
|
||||
* @param mdCodeVo
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "查询修试待入库机具编码")
|
||||
@PreventRepeatSubmit
|
||||
// @RequiresPermissions("purchase:storage:add")
|
||||
@GetMapping("/getCodeList")
|
||||
public AjaxResult getCodeList(MaCodeVo mdCodeVo) {
|
||||
return repairInputDetailsService.getCodeList(mdCodeVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修试入库驳回或批量驳回
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "修试入库驳回或批量驳回")
|
||||
@PreventRepeatSubmit
|
||||
// @RequiresPermissions("purchase:storage:reject")
|
||||
@PostMapping("/reject")
|
||||
public AjaxResult reject(@RequestBody RepairInputDetails repairInputDetails) {
|
||||
return repairInputDetailsService.reject(repairInputDetails);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package com.bonus.material.repair.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 修饰入库最外层驳回入参
|
||||
* @Author ma_sh
|
||||
* @create 2024/12/13 14:17
|
||||
*/
|
||||
@Data
|
||||
public class RePairDto {
|
||||
|
||||
@ApiModelProperty(value = "任务id")
|
||||
private Long taskId;
|
||||
|
||||
@ApiModelProperty(value = "协议号")
|
||||
private Integer agreementId;
|
||||
}
|
||||
|
|
@ -1,12 +1,17 @@
|
|||
package com.bonus.material.repair.domain;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.bonus.material.back.domain.MaCode;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 修试后入库对象 repair_input_details
|
||||
|
|
@ -29,6 +34,12 @@ public class RepairInputDetails extends BaseEntity {
|
|||
@ApiModelProperty(value = "任务ID")
|
||||
private Long taskId;
|
||||
|
||||
@ApiModelProperty(value = "任务ID集合")
|
||||
private List<Long> taskIdList;
|
||||
|
||||
@ApiModelProperty(value = "外层任务ID集合")
|
||||
private List<RePairDto> outTaskList;
|
||||
|
||||
/** 维修审核ID */
|
||||
@Excel(name = "维修审核ID")
|
||||
@ApiModelProperty(value = "维修审核ID")
|
||||
|
|
@ -49,25 +60,96 @@ public class RepairInputDetails extends BaseEntity {
|
|||
@ApiModelProperty(value = "规格ID")
|
||||
private Long typeId;
|
||||
|
||||
/**
|
||||
* 退料单位名称
|
||||
*/
|
||||
@ApiModelProperty(value = "退料单位名称")
|
||||
@Excel(name = "退料单位名称",sort = 1)
|
||||
private String backUnit;
|
||||
/**
|
||||
* 退料工程名称
|
||||
*/
|
||||
@ApiModelProperty(value = "退料工程名称")
|
||||
@Excel(name = "退料工程名称",sort = 2)
|
||||
private String backPro;
|
||||
|
||||
@ApiModelProperty(value = "修饰入库编码")
|
||||
@Excel(name = "入库单号",sort = 3)
|
||||
private String inputCode;
|
||||
|
||||
@ApiModelProperty(value = "物资类型")
|
||||
@Excel(name = "物资类型",sort = 4)
|
||||
private String materialType;
|
||||
|
||||
@ApiModelProperty(value = "修饰入库编码")
|
||||
@Excel(name = "维修单号",sort = 5)
|
||||
private String repairCode;
|
||||
|
||||
@Excel(name = "创建人")
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/** 0未审核,1已入库,2驳回 */
|
||||
@Excel(name = "状态")
|
||||
private String statusName;
|
||||
|
||||
//@Excel(name = "备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "驳回原因")
|
||||
private String rejectReason;
|
||||
|
||||
@ApiModelProperty(value = "任务状态")
|
||||
private Integer taskStatus;
|
||||
|
||||
/** 维修合格数量 */
|
||||
@Excel(name = "维修合格数量")
|
||||
@ApiModelProperty(value = "维修合格数量")
|
||||
private BigDecimal repairNum;
|
||||
|
||||
@ApiModelProperty(value = "待入库数量")
|
||||
private BigDecimal pendingInputNum;
|
||||
|
||||
@ApiModelProperty(value = "驳回数量")
|
||||
private BigDecimal rejectNum;
|
||||
|
||||
/** 入库数量 */
|
||||
@Excel(name = "入库数量")
|
||||
@ApiModelProperty(value = "入库数量")
|
||||
private BigDecimal inputNum;
|
||||
|
||||
/** 0未审核,1已入库,2驳回 */
|
||||
@Excel(name = "0未审核,1已入库,2驳回")
|
||||
@ApiModelProperty(value = "0未审核,1已入库,2驳回")
|
||||
private String status;
|
||||
|
||||
/** 数据所属组织 */
|
||||
@Excel(name = "数据所属组织")
|
||||
@ApiModelProperty(value = "数据所属组织")
|
||||
private Long companyId;
|
||||
|
||||
@ApiModelProperty(value = "协议号")
|
||||
private Integer agreementId;
|
||||
|
||||
/**
|
||||
* 关键字
|
||||
*/
|
||||
private String keyword;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private String startTime;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private String endTime;
|
||||
|
||||
@ApiModelProperty(value = "操作前库存数量")
|
||||
private BigDecimal preStoreNum;
|
||||
|
||||
@ApiModelProperty(value = "操作后库存数量")
|
||||
private BigDecimal postStoreNum;
|
||||
|
||||
@ApiModelProperty(value = "编码列表")
|
||||
private List<RepairInputDetails> maCodeList;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
package com.bonus.material.repair.domain;
|
||||
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Author ma_sh
|
||||
* @create 2024/12/12 14:42
|
||||
*/
|
||||
@Data
|
||||
public class RepairInputInfo extends BaseEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "任务id")
|
||||
private Long taskId;
|
||||
|
||||
@ApiModelProperty(value = "物资id")
|
||||
private Long maId;
|
||||
|
||||
@ApiModelProperty(value = "类型id")
|
||||
private Long typeId;
|
||||
|
||||
@ApiModelProperty(value = "物资名称")
|
||||
private String typeName;
|
||||
|
||||
@ApiModelProperty(value = "规格型号")
|
||||
private String typeModelName;
|
||||
|
||||
@ApiModelProperty(value = "单位")
|
||||
private String unitName;
|
||||
|
||||
@ApiModelProperty(value = "单位")
|
||||
private String unitValue;
|
||||
|
||||
@ApiModelProperty(value = "预入库数量")
|
||||
private BigDecimal repairNum;
|
||||
|
||||
@ApiModelProperty(value = "待入库数量")
|
||||
private BigDecimal pendingInputNum;
|
||||
|
||||
@ApiModelProperty(value = "已入库数量")
|
||||
private BigDecimal inputNum;
|
||||
|
||||
@ApiModelProperty(value = "驳回数量")
|
||||
private BigDecimal rejectNum;
|
||||
|
||||
@ApiModelProperty(value = "管理模式")
|
||||
private String manageType;
|
||||
|
||||
@ApiModelProperty(value = "0 入库进行中,1 入库完成,2 入库驳回")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty(value = "入库状态名称")
|
||||
private String statusName;
|
||||
|
||||
@ApiModelProperty(value = "协议号")
|
||||
private Integer agreementId;
|
||||
|
||||
@ApiModelProperty(value = "驳回原因")
|
||||
private String rejectReason;
|
||||
}
|
||||
|
|
@ -1,7 +1,11 @@
|
|||
package com.bonus.material.repair.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.back.domain.vo.MaCodeVo;
|
||||
import com.bonus.material.repair.domain.RepairInputDetails;
|
||||
import com.bonus.material.repair.domain.RepairInputInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
|
|
@ -14,10 +18,10 @@ public interface RepairInputDetailsMapper {
|
|||
/**
|
||||
* 查询修试后入库
|
||||
*
|
||||
* @param id 修试后入库主键
|
||||
* @param repairInputDetails 修试后入库主键
|
||||
* @return 修试后入库
|
||||
*/
|
||||
public RepairInputDetails selectRepairInputDetailsById(Long id);
|
||||
public List<RepairInputInfo> selectRepairInputDetailsById(RepairInputDetails repairInputDetails);
|
||||
|
||||
/**
|
||||
* 查询修试后入库列表
|
||||
|
|
@ -63,4 +67,47 @@ public interface RepairInputDetailsMapper {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteRepairInputDetailsByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 根据任务id查询状态
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
List<String> selectStatusByTaskId(Long taskId);
|
||||
|
||||
/**
|
||||
* 修改库存数量
|
||||
* @param repairInputInfo
|
||||
* @return
|
||||
*/
|
||||
int updateNum(RepairInputInfo repairInputInfo);
|
||||
|
||||
/**
|
||||
* 修改物资状态
|
||||
* @param repairInputInfo
|
||||
* @return
|
||||
*/
|
||||
int updateMaStatus(RepairInputInfo repairInputInfo);
|
||||
|
||||
/**
|
||||
* 查询物资编码
|
||||
* @param mdCodeVo
|
||||
* @return
|
||||
*/
|
||||
List<MaCodeVo> getCodeList(MaCodeVo mdCodeVo);
|
||||
|
||||
/**
|
||||
* 查询入库详情信息
|
||||
* @param repairInputDetails1
|
||||
* @return
|
||||
*/
|
||||
List<RepairInputInfo> selectRepairDetailsById(RepairInputDetails repairInputDetails1);
|
||||
|
||||
/**
|
||||
* 维修记录单
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
int insertRad(RepairInputDetails repairInputDetails);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
package com.bonus.material.repair.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.back.domain.vo.MaCodeVo;
|
||||
import com.bonus.material.repair.domain.RepairInputDetails;
|
||||
import com.bonus.material.repair.domain.RepairInputInfo;
|
||||
|
||||
/**
|
||||
* 修试后入库Service接口
|
||||
|
|
@ -13,10 +17,10 @@ public interface IRepairInputDetailsService {
|
|||
/**
|
||||
* 查询修试后入库
|
||||
*
|
||||
* @param id 修试后入库主键
|
||||
* @param repairInputDetails 修试后入库主键
|
||||
* @return 修试后入库
|
||||
*/
|
||||
public RepairInputDetails selectRepairInputDetailsById(Long id);
|
||||
public List<RepairInputInfo> selectRepairInputDetailsById(RepairInputDetails repairInputDetails);
|
||||
|
||||
/**
|
||||
* 查询修试后入库列表
|
||||
|
|
@ -57,4 +61,25 @@ public interface IRepairInputDetailsService {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteRepairInputDetailsById(Long id);
|
||||
|
||||
/**
|
||||
* 入库或批量入库操作
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
AjaxResult warehouse(RepairInputDetails repairInputDetails);
|
||||
|
||||
/**
|
||||
* 查询入库编码
|
||||
* @param mdCodeVo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getCodeList(MaCodeVo mdCodeVo);
|
||||
|
||||
/**
|
||||
* 修试入库驳回或批量驳回
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
AjaxResult reject(RepairInputDetails repairInputDetails);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
|
|||
companyId = repairInputList.get(0).getCompanyId();
|
||||
}
|
||||
|
||||
taskCode = purchaseCodeRule("R", 50);
|
||||
taskCode = purchaseCodeRule("R", 5);
|
||||
taskStatus = 53;
|
||||
taskType = 50;
|
||||
long inputTaskId = genTask(taskCode, taskType, taskStatus, tmTaskAgreement, companyId);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,34 @@
|
|||
package com.bonus.material.repair.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.bonus.common.biz.constant.MaterialConstants;
|
||||
import com.bonus.common.biz.enums.*;
|
||||
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.back.domain.vo.MaCodeVo;
|
||||
import com.bonus.material.repair.domain.RePairDto;
|
||||
import com.bonus.material.repair.domain.RepairInputInfo;
|
||||
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 org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.bonus.material.repair.mapper.RepairInputDetailsMapper;
|
||||
import com.bonus.material.repair.domain.RepairInputDetails;
|
||||
import com.bonus.material.repair.service.IRepairInputDetailsService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 修试后入库Service业务层处理
|
||||
|
|
@ -17,18 +38,53 @@ import com.bonus.material.repair.service.IRepairInputDetailsService;
|
|||
*/
|
||||
@Service
|
||||
public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService {
|
||||
@Autowired
|
||||
@Resource
|
||||
private RepairInputDetailsMapper repairInputDetailsMapper;
|
||||
|
||||
@Resource
|
||||
private TmTaskMapper taskMapper;
|
||||
|
||||
@Resource
|
||||
private TmTaskAgreementMapper taskAgreementMapper;
|
||||
|
||||
/**
|
||||
* 查询修试后入库
|
||||
*
|
||||
* @param id 修试后入库主键
|
||||
* @param repairInputDetails 修试后入库主键
|
||||
* @return 修试后入库
|
||||
*/
|
||||
@Override
|
||||
public RepairInputDetails selectRepairInputDetailsById(Long id) {
|
||||
return repairInputDetailsMapper.selectRepairInputDetailsById(id);
|
||||
public List<RepairInputInfo> selectRepairInputDetailsById(RepairInputDetails repairInputDetails) {
|
||||
List<RepairInputInfo> inputInfos = repairInputDetailsMapper.selectRepairInputDetailsById(repairInputDetails);
|
||||
if (CollectionUtils.isNotEmpty(inputInfos)) {
|
||||
for (RepairInputInfo inputInfo : inputInfos) {
|
||||
RepairInputDetails inputDetails = new RepairInputDetails();
|
||||
inputDetails.setTaskId(inputInfo.getTaskId());
|
||||
inputDetails.setTypeId(inputInfo.getTypeId());
|
||||
List<RepairInputInfo> list = repairInputDetailsMapper.selectRepairDetailsById(inputDetails);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
List<Integer> statusList = list.stream()
|
||||
.map(info -> Integer.parseInt(info.getStatus()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(statusList)) {
|
||||
if (!statusList.contains(RepairInputStatusEnum.Input_TASK_NO_FINISHED.getStatus()) &&
|
||||
statusList.contains(RepairInputStatusEnum.Input_TASK_TO_REJECT.getStatus())) {
|
||||
inputInfo.setStatus(String.valueOf(RepairInputStatusEnum.Input_TASK_TO_REJECT.getStatus()));
|
||||
inputInfo.setStatusName(String.valueOf(RepairInputStatusEnum.Input_TASK_TO_REJECT.getStatusName()));
|
||||
} else if (!statusList.contains(RepairInputStatusEnum.Input_TASK_NO_FINISHED.getStatus()) &&
|
||||
!statusList.contains(RepairInputStatusEnum.Input_TASK_TO_REJECT.getStatus()) &&
|
||||
statusList.stream().allMatch(status -> status.equals(RepairInputStatusEnum.Input_TASK_IN_FINISHED.getStatus()))) {
|
||||
inputInfo.setStatus(String.valueOf(RepairInputStatusEnum.Input_TASK_IN_FINISHED.getStatus()));
|
||||
inputInfo.setStatusName(String.valueOf(RepairInputStatusEnum.Input_TASK_IN_FINISHED.getStatusName()));
|
||||
} else {
|
||||
inputInfo.setStatus(String.valueOf(RepairInputStatusEnum.Input_TASK_NO_FINISHED.getStatus()));
|
||||
inputInfo.setStatusName(String.valueOf(RepairInputStatusEnum.Input_TASK_NO_FINISHED.getStatusName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return inputInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -95,4 +151,445 @@ public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService
|
|||
public int deleteRepairInputDetailsById(Long id) {
|
||||
return repairInputDetailsMapper.deleteRepairInputDetailsById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 入库或批量入库操作
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult warehouse(RepairInputDetails repairInputDetails) {
|
||||
int result = 0;
|
||||
|
||||
// 检查条件,确保修试入库条件有效
|
||||
if (repairInputDetails.getTaskId() != null && repairInputDetails.getTypeId() != null && CollectionUtils.isEmpty(repairInputDetails.getTaskIdList())) {
|
||||
// 内层入库
|
||||
result += processInnerStorage(repairInputDetails);
|
||||
} else if (CollectionUtils.isNotEmpty(repairInputDetails.getTaskIdList())) {
|
||||
// 外层入库
|
||||
result += processOuterStorage(repairInputDetails);
|
||||
}
|
||||
|
||||
if (result > 0) {
|
||||
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg());
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取编码列表
|
||||
* @param mdCodeVo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult getCodeList(MaCodeVo mdCodeVo) {
|
||||
List<MaCodeVo> list = repairInputDetailsMapper.getCodeList(mdCodeVo);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修试入库驳回或批量驳回
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult reject(RepairInputDetails repairInputDetails) {
|
||||
int result = 0;
|
||||
// 检查条件,确保修试驳回条件有效
|
||||
if (repairInputDetails.getTaskId() != null && repairInputDetails.getTypeId() != null && CollectionUtils.isEmpty(repairInputDetails.getOutTaskList())) {
|
||||
// 内层驳回
|
||||
result += processInnerReject(repairInputDetails);
|
||||
} else if (CollectionUtils.isNotEmpty(repairInputDetails.getOutTaskList())) {
|
||||
// 外层驳回
|
||||
result += processOuterReject(repairInputDetails);
|
||||
}
|
||||
|
||||
if (result > 0) {
|
||||
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg());
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 外部驳回
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
private int processOuterReject(RepairInputDetails repairInputDetails) {
|
||||
int result = 0;
|
||||
for (RePairDto rePairDto : repairInputDetails.getOutTaskList()) {
|
||||
result += processRepairRejectTask(rePairDto);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 外部驳回
|
||||
* @param rePairDto
|
||||
* @return
|
||||
*/
|
||||
private int processRepairRejectTask(RePairDto rePairDto) {
|
||||
int result = 0;
|
||||
RepairInputDetails repairInputDetails1 = new RepairInputDetails();
|
||||
repairInputDetails1.setTaskId(rePairDto.getTaskId());
|
||||
repairInputDetails1.setAgreementId(rePairDto.getAgreementId());
|
||||
List<RepairInputInfo> list = repairInputDetailsMapper.selectRepairDetailsById(repairInputDetails1);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
//插入任务表
|
||||
Long newTaskId = insertTt();
|
||||
result += insertTta(newTaskId, repairInputDetails1);
|
||||
for (RepairInputInfo repairInputInfo : list) {
|
||||
if (repairInputInfo.getStatus().equals(RepairInputStatusEnum.Input_TASK_IN_FINISHED.getStatus().toString())
|
||||
|| repairInputInfo.getStatus().equals(RepairInputStatusEnum.Input_TASK_TO_REJECT.getStatus().toString())
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
result += updateRepairRejectDetails(repairInputInfo);
|
||||
//插入协议表
|
||||
repairInputDetails1.setTypeId(repairInputInfo.getTypeId());
|
||||
repairInputDetails1.setCreateBy(SecurityUtils.getUsername());
|
||||
repairInputDetails1.setTaskId(newTaskId);
|
||||
repairInputDetails1.setMaId(repairInputInfo.getMaId());
|
||||
repairInputDetails1.setRejectNum(repairInputInfo.getPendingInputNum());
|
||||
result += insertWxTask(newTaskId, repairInputDetails1);
|
||||
}
|
||||
if (result > 0) {
|
||||
result += taskMapper.updateTaskStatus(rePairDto.getTaskId().toString(), RepairInputStatusEnum.Input_TASK_TO_REJECT.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新状态为已驳回
|
||||
* @param repairInputInfo
|
||||
* @return
|
||||
*/
|
||||
private int updateRepairRejectDetails(RepairInputInfo repairInputInfo) {
|
||||
int result = 0;
|
||||
RepairInputDetails inputDetails = new RepairInputDetails();
|
||||
inputDetails.setStatus(RepairInputStatusEnum.Input_TASK_TO_REJECT.getStatus().toString());
|
||||
inputDetails.setRejectNum(repairInputInfo.getPendingInputNum());
|
||||
inputDetails.setMaId(repairInputInfo.getMaId() == null ? null : repairInputInfo.getMaId());
|
||||
inputDetails.setTaskId(repairInputInfo.getTaskId());
|
||||
inputDetails.setTypeId(repairInputInfo.getTypeId());
|
||||
inputDetails.setUpdateBy(SecurityUtils.getUsername());
|
||||
inputDetails.setUpdateTime(DateUtils.getNowDate());
|
||||
result += repairInputDetailsMapper.updateRepairInputDetails(inputDetails);
|
||||
|
||||
if ("0".equals(repairInputInfo.getManageType())) {
|
||||
repairInputInfo.setStatus(MaMachineStatusEnum.BACK_REPAIR.getStatus().toString());
|
||||
result += repairInputDetailsMapper.updateMaStatus(repairInputInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 内部驳回
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
private int processInnerReject(RepairInputDetails repairInputDetails) {
|
||||
int result = 0;
|
||||
// 入库数量不能大于预入库数量
|
||||
if (repairInputDetails.getRejectNum() != null && repairInputDetails.getPendingInputNum() != null) {
|
||||
if (repairInputDetails.getRejectNum().compareTo(repairInputDetails.getPendingInputNum()) > 0) {
|
||||
throw new ServiceException("驳回数量不能大于预入库数量");
|
||||
}
|
||||
}
|
||||
repairInputDetails.setCreateBy(SecurityUtils.getUsername());
|
||||
repairInputDetails.setUpdateBy(SecurityUtils.getUsername());
|
||||
repairInputDetails.setUpdateTime(DateUtils.getNowDate());
|
||||
// 编码类型驳回
|
||||
if (CollectionUtils.isNotEmpty(repairInputDetails.getMaCodeList())) {
|
||||
result += processCodeTypeReject(repairInputDetails);
|
||||
} else {
|
||||
// 数量类型驳回
|
||||
result += processQuantityTypeReject(repairInputDetails);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码类型驳回
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
private int processCodeTypeReject(RepairInputDetails repairInputDetails) {
|
||||
int result = 0;
|
||||
for (RepairInputDetails inputDetails : repairInputDetails.getMaCodeList()) {
|
||||
inputDetails.setStatus(RepairInputStatusEnum.Input_TASK_TO_REJECT.getStatus().toString());
|
||||
inputDetails.setTaskId(repairInputDetails.getTaskId());
|
||||
inputDetails.setTypeId(repairInputDetails.getTypeId());
|
||||
inputDetails.setRejectNum(BigDecimal.valueOf(1));
|
||||
inputDetails.setUpdateBy(SecurityUtils.getUsername());
|
||||
inputDetails.setUpdateTime(DateUtils.getNowDate());
|
||||
inputDetails.setCreateBy(SecurityUtils.getUsername());
|
||||
inputDetails.setRejectReason(repairInputDetails.getRejectReason());
|
||||
result += repairInputDetailsMapper.updateRepairInputDetails(inputDetails);
|
||||
inputDetails.setStatus(MaMachineStatusEnum.BACK_REPAIR.getStatus().toString());
|
||||
updateRepairInputInfo(inputDetails);
|
||||
//插入任务表
|
||||
Long newTaskId = insertTt();
|
||||
result += insertTta(newTaskId, repairInputDetails);
|
||||
result += insertWxTask(newTaskId, inputDetails);
|
||||
}
|
||||
if (result > 0) {
|
||||
updateTaskStatus(repairInputDetails);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数量类型驳回
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
private int processQuantityTypeReject(RepairInputDetails repairInputDetails) {
|
||||
int result = 0;
|
||||
repairInputDetails.setStatus(repairInputDetails.getRejectNum().equals(repairInputDetails.getPendingInputNum()) ? "2" : "0");
|
||||
result += repairInputDetailsMapper.updateRepairInputDetails(repairInputDetails);
|
||||
if (result > 0) {
|
||||
updateTaskStatus(repairInputDetails);
|
||||
RepairInputInfo repairInputInfo = new RepairInputInfo();
|
||||
repairInputInfo.setTypeId(repairInputDetails.getTypeId());
|
||||
repairInputInfo.setInputNum(repairInputDetails.getInputNum());
|
||||
repairInputDetailsMapper.updateNum(repairInputInfo);
|
||||
Long newTaskId = insertTt();
|
||||
result += insertTta(newTaskId, repairInputDetails);
|
||||
result += insertWxTask(newTaskId, repairInputDetails);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入维修工单表
|
||||
* @param newTaskId
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
private int insertWxTask(Long newTaskId, RepairInputDetails repairInputDetails) {
|
||||
repairInputDetails.setTaskId(newTaskId);
|
||||
return repairInputDetailsMapper.insertRad(repairInputDetails);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入协议任务表
|
||||
* @param newTaskId
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
private int insertTta(Long newTaskId, RepairInputDetails repairInputDetails) {
|
||||
int res;
|
||||
String agreementId = String.valueOf(repairInputDetails.getAgreementId());
|
||||
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(newTaskId, Long.parseLong(agreementId));
|
||||
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
||||
tmTaskAgreement.setCreateBy(SecurityUtils.getUsername());
|
||||
res = taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 驳回后重新生成维修单 插入任务表
|
||||
* @return
|
||||
*/
|
||||
private Long insertTt() {
|
||||
Long newTask = null;
|
||||
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId());
|
||||
// 生成维修单号
|
||||
String code = genderWxTaskCode(thisMonthMaxOrder);
|
||||
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId(), BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus(),
|
||||
null,thisMonthMaxOrder + 1, code);
|
||||
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||
tmTask.setCreateBy(SecurityUtils.getUsername());
|
||||
// 插入任务
|
||||
int taskId = taskMapper.insertTmTask(tmTask);
|
||||
// 如果插入成功且返回的 taskId 大于 0
|
||||
if (taskId > 0 && tmTask.getTaskId() > 0) {
|
||||
newTask = tmTask.getTaskId();
|
||||
}
|
||||
return newTask;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成维修单号
|
||||
* @param thisMonthMaxOrder
|
||||
* @return
|
||||
*/
|
||||
private String genderWxTaskCode(int thisMonthMaxOrder) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date nowDate = DateUtils.getNowDate();
|
||||
String format = dateFormat.format(nowDate);
|
||||
String result = format.replace("-", "");
|
||||
return MaterialConstants.REPAIR_TASK_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 内部入库
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
private int processInnerStorage(RepairInputDetails repairInputDetails) {
|
||||
int result = 0;
|
||||
// 入库数量不能大于预入库数量
|
||||
if (repairInputDetails.getInputNum() != null && repairInputDetails.getPendingInputNum() != null) {
|
||||
if (repairInputDetails.getInputNum().compareTo(repairInputDetails.getPendingInputNum()) > 0) {
|
||||
throw new ServiceException("入库数量不能大于预入库数量");
|
||||
}
|
||||
}
|
||||
repairInputDetails.setUpdateBy(SecurityUtils.getUsername());
|
||||
repairInputDetails.setUpdateTime(DateUtils.getNowDate());
|
||||
|
||||
// 编码类型入库
|
||||
if (CollectionUtils.isNotEmpty(repairInputDetails.getMaCodeList())) {
|
||||
result += processCodeTypeStorage(repairInputDetails);
|
||||
} else {
|
||||
// 数量类型入库
|
||||
result += processQuantityTypeStorage(repairInputDetails);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码类型入库
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
private int processCodeTypeStorage(RepairInputDetails repairInputDetails) {
|
||||
int result = 0;
|
||||
for (RepairInputDetails inputDetails : repairInputDetails.getMaCodeList()) {
|
||||
inputDetails.setStatus(RepairInputStatusEnum.Input_TASK_IN_FINISHED.getStatus().toString());
|
||||
inputDetails.setTaskId(repairInputDetails.getTaskId());
|
||||
inputDetails.setTypeId(repairInputDetails.getTypeId());
|
||||
inputDetails.setInputNum(BigDecimal.valueOf(1));
|
||||
inputDetails.setUpdateBy(SecurityUtils.getUsername());
|
||||
inputDetails.setUpdateTime(DateUtils.getNowDate());
|
||||
result += repairInputDetailsMapper.updateRepairInputDetails(inputDetails);
|
||||
inputDetails.setStatus(MaMachineStatusEnum.IN_STORE.getStatus().toString());
|
||||
updateRepairInputInfo(inputDetails);
|
||||
}
|
||||
if (result > 0) {
|
||||
updateTaskStatus(repairInputDetails);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数量类型入库
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
private int processQuantityTypeStorage(RepairInputDetails repairInputDetails) {
|
||||
int result = 0;
|
||||
repairInputDetails.setStatus(repairInputDetails.getInputNum().equals(repairInputDetails.getPendingInputNum()) ? "1" : "0");
|
||||
result += repairInputDetailsMapper.updateRepairInputDetails(repairInputDetails);
|
||||
if (result > 0) {
|
||||
updateTaskStatus(repairInputDetails);
|
||||
RepairInputInfo repairInputInfo = new RepairInputInfo();
|
||||
repairInputInfo.setTypeId(repairInputDetails.getTypeId());
|
||||
repairInputInfo.setInputNum(repairInputDetails.getInputNum());
|
||||
repairInputDetailsMapper.updateNum(repairInputInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新修试入库信息
|
||||
* @param inputDetails
|
||||
*/
|
||||
private void updateRepairInputInfo(RepairInputDetails inputDetails) {
|
||||
RepairInputInfo repairInputInfo = new RepairInputInfo();
|
||||
repairInputInfo.setMaId(inputDetails.getMaId());
|
||||
repairInputInfo.setStatus(inputDetails.getStatus());
|
||||
repairInputDetailsMapper.updateMaStatus(repairInputInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新修试入库状态
|
||||
* @param repairInputDetails
|
||||
*/
|
||||
private void updateTaskStatus(RepairInputDetails repairInputDetails) {
|
||||
List<String> list = repairInputDetailsMapper.selectStatusByTaskId(repairInputDetails.getTaskId());
|
||||
List<Integer> statusList = list.stream().map(Integer::parseInt).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(statusList)) {
|
||||
if (!statusList.contains(RepairInputStatusEnum.Input_TASK_NO_FINISHED.getStatus()) &&
|
||||
statusList.contains(RepairInputStatusEnum.Input_TASK_TO_REJECT.getStatus())) {
|
||||
taskMapper.updateTaskStatus(repairInputDetails.getTaskId().toString(), RepairInputStatusEnum.Input_TASK_TO_REJECT.getStatus());
|
||||
} else if (!statusList.contains(RepairInputStatusEnum.Input_TASK_NO_FINISHED.getStatus()) &&
|
||||
!statusList.contains(RepairInputStatusEnum.Input_TASK_TO_REJECT.getStatus()) &&
|
||||
statusList.stream().allMatch(status -> status.equals(RepairInputStatusEnum.Input_TASK_IN_FINISHED.getStatus()))) {
|
||||
taskMapper.updateTaskStatus(repairInputDetails.getTaskId().toString(), RepairInputStatusEnum.Input_TASK_IN_FINISHED.getStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 外部入库
|
||||
* @param repairInputDetails
|
||||
* @return
|
||||
*/
|
||||
private int processOuterStorage(RepairInputDetails repairInputDetails) {
|
||||
int result = 0;
|
||||
for (Long taskId : repairInputDetails.getTaskIdList()) {
|
||||
result += processRepairTask(taskId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修试入库
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
private int processRepairTask(Long taskId) {
|
||||
int result = 0;
|
||||
RepairInputDetails repairInputDetails1 = new RepairInputDetails();
|
||||
repairInputDetails1.setTaskId(taskId);
|
||||
List<RepairInputInfo> list = repairInputDetailsMapper.selectRepairDetailsById(repairInputDetails1);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
for (RepairInputInfo repairInputInfo : list) {
|
||||
if (repairInputInfo.getStatus().equals(RepairInputStatusEnum.Input_TASK_IN_FINISHED.getStatus().toString())
|
||||
|| repairInputInfo.getStatus().equals(RepairInputStatusEnum.Input_TASK_TO_REJECT.getStatus().toString())
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
result += updateRepairInputDetails(repairInputInfo);
|
||||
}
|
||||
if (result > 0) {
|
||||
result += taskMapper.updateTaskStatus(taskId.toString(), RepairInputStatusEnum.Input_TASK_IN_FINISHED.getStatus());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新修试入库明细
|
||||
* @param repairInputInfo
|
||||
* @return
|
||||
*/
|
||||
private int updateRepairInputDetails(RepairInputInfo repairInputInfo) {
|
||||
int result = 0;
|
||||
RepairInputDetails inputDetails = new RepairInputDetails();
|
||||
inputDetails.setStatus(RepairInputStatusEnum.Input_TASK_IN_FINISHED.getStatus().toString());
|
||||
inputDetails.setInputNum(repairInputInfo.getPendingInputNum());
|
||||
inputDetails.setMaId(repairInputInfo.getMaId() == null ? null : repairInputInfo.getMaId());
|
||||
inputDetails.setTaskId(repairInputInfo.getTaskId());
|
||||
inputDetails.setTypeId(repairInputInfo.getTypeId());
|
||||
result += repairInputDetailsMapper.updateRepairInputDetails(inputDetails);
|
||||
|
||||
if ("1".equals(repairInputInfo.getManageType())) {
|
||||
repairInputInfo.setInputNum(repairInputInfo.getPendingInputNum());
|
||||
result += repairInputDetailsMapper.updateNum(repairInputInfo);
|
||||
} else if ("0".equals(repairInputInfo.getManageType())) {
|
||||
result += repairInputDetailsMapper.updateMaStatus(repairInputInfo);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,24 +25,158 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select id, task_id, audit_id, repair_id, ma_id, type_id, repair_num, input_num, create_by, create_time, update_by, update_time, status, remark, company_id from repair_input_details
|
||||
</sql>
|
||||
|
||||
<select id="selectRepairInputDetailsList" parameterType="com.bonus.material.repair.domain.RepairInputDetails" resultMap="RepairInputDetailsResult">
|
||||
<include refid="selectRepairInputDetailsVo"/>
|
||||
<where>
|
||||
<if test="taskId != null "> and task_id = #{taskId}</if>
|
||||
<if test="auditId != null "> and audit_id = #{auditId}</if>
|
||||
<if test="repairId != null "> and repair_id = #{repairId}</if>
|
||||
<if test="maId != null "> and ma_id = #{maId}</if>
|
||||
<if test="typeId != null "> and type_id = #{typeId}</if>
|
||||
<if test="repairNum != null "> and repair_num = #{repairNum}</if>
|
||||
<if test="inputNum != null "> and input_num = #{inputNum}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="companyId != null "> and company_id = #{companyId}</if>
|
||||
|
||||
|
||||
<select id="selectRepairInputDetailsList" resultType="com.bonus.material.repair.domain.RepairInputDetails">
|
||||
SELECT
|
||||
rd.task_id AS taskId,
|
||||
tt1.CODE AS repairCode,
|
||||
rd.create_time AS createTime,
|
||||
tt.task_status AS taskStatus,
|
||||
CASE tt.task_status
|
||||
WHEN '0' THEN '入库进行中'
|
||||
WHEN '1' THEN '入库完成'
|
||||
WHEN '2' THEN '入库驳回'
|
||||
ELSE '未知状态'
|
||||
END AS statusName,
|
||||
rd.remark AS remark,
|
||||
bui.unit_name AS backUnit,
|
||||
bpi.pro_name AS backPro,
|
||||
su.nick_name AS createBy,
|
||||
tt.CODE AS inputCode,
|
||||
GROUP_CONCAT(DISTINCT mt2.type_name) AS materialType,
|
||||
tta.agreement_id as agreementId
|
||||
FROM
|
||||
repair_input_details rd
|
||||
LEFT JOIN ma_type mt on rd.type_id = mt.type_id
|
||||
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
|
||||
LEFT JOIN tm_task tt on rd.task_id = tt.task_id
|
||||
LEFT JOIN repair_apply_details rad ON rad.id = rd.repair_id
|
||||
LEFT JOIN tm_task tt1 on rad.task_id = tt1.task_id
|
||||
LEFT JOIN tm_task_agreement tta ON rd.task_id = tta.task_id
|
||||
LEFT JOIN bm_agreement_info bai2 ON tta.agreement_id = bai2.agreement_id
|
||||
LEFT JOIN bm_unit bui ON bai2.unit_id = bui.unit_id
|
||||
LEFT JOIN bm_project bpi ON bai2.project_id = bpi.pro_id and bpi.del_flag = '0'
|
||||
left join sys_user su on rd.create_by = su.user_id
|
||||
<where>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (
|
||||
locate(#{keyword}, su.nick_name) > 0
|
||||
or locate(#{keyword}, tt.CODE) > 0
|
||||
or locate(#{keyword}, tt1.CODE) > 0
|
||||
or locate(#{keyword}, bui.unit_name) > 0
|
||||
or locate(#{keyword}, bpi.pro_name) > 0
|
||||
or locate(#{keyword}, su.nick_name) > 0
|
||||
)
|
||||
</if>
|
||||
<if test="taskStatus != null ">
|
||||
AND tt.task_status = #{taskStatus}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||
AND rd.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY rd.task_id
|
||||
order by rd.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectRepairInputDetailsById" parameterType="Long" resultMap="RepairInputDetailsResult">
|
||||
<include refid="selectRepairInputDetailsVo"/>
|
||||
where id = #{id}
|
||||
|
||||
<select id="selectRepairInputDetailsById" resultType="com.bonus.material.repair.domain.RepairInputInfo">
|
||||
select
|
||||
rid.id as id,
|
||||
rid.task_id as taskId,
|
||||
rid.ma_id as maId,
|
||||
rid.type_id as typeId,
|
||||
SUM(IFNULL(rid.repair_num, 0)) as repairNum,
|
||||
SUM(IFNULL(rid.input_num, 0)) as inputNum,
|
||||
(SUM(IFNULL(rid.repair_num, 0)) - SUM(IFNULL(rid.input_num, 0)) - SUM(IFNULL(rid.reject_num, 0)))
|
||||
AS pendingInputNum,
|
||||
SUM(IFNULL(rid.reject_num, 0)) as rejectNum,
|
||||
rid.create_by as createBy,
|
||||
rid.create_time as createTime,
|
||||
rid.remark as remark,
|
||||
mt1.type_name AS typeName,
|
||||
mt.type_name AS typeModelName,
|
||||
mt.unit_name AS unitName,
|
||||
mt.unit_value AS unitValue,
|
||||
mt.manage_type AS manageType,
|
||||
tta.agreement_id as agreementId,
|
||||
rid.reject_reason as rejectReason
|
||||
from repair_input_details rid
|
||||
LEFT JOIN ma_type mt on rid.type_id = mt.type_id and mt.del_flag = '0'
|
||||
LEFT JOIN ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
||||
LEFT JOIN tm_task_agreement tta ON rid.task_id = tta.task_id
|
||||
where rid.task_id = #{taskId}
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (
|
||||
locate(#{keyword}, mt1.type_name) > 0
|
||||
or locate(#{keyword}, mt.type_name) > 0
|
||||
or locate(#{keyword}, mt.unit_name) > 0
|
||||
)
|
||||
</if>
|
||||
GROUP BY rid.type_id
|
||||
</select>
|
||||
|
||||
<select id="selectStatusByTaskId" resultType="java.lang.String">
|
||||
select status from repair_input_details where task_id = #{taskId}
|
||||
</select>
|
||||
|
||||
<select id="getCodeList" resultType="com.bonus.material.back.domain.vo.MaCodeVo">
|
||||
SELECT
|
||||
rid.ma_id as maId,
|
||||
mt1.type_name as typeName,
|
||||
mt.type_name as materialName,
|
||||
mm.ma_code as maCode,
|
||||
mm.ma_status as maStatus,
|
||||
rid.reject_reason as rejectReason
|
||||
FROM
|
||||
repair_input_details rid
|
||||
LEFT JOIN ma_machine mm ON rid.ma_id = mm.ma_id
|
||||
LEFT JOIN ma_type mt ON rid.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'
|
||||
WHERE
|
||||
rid.task_id = #{taskId}
|
||||
AND rid.type_id = #{typeId}
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
AND (
|
||||
locate(#{keyWord}, mt1.type_name) > 0
|
||||
or locate(#{keyWord}, mt.type_name) > 0
|
||||
or locate(#{keyWord}, mm.ma_code) > 0
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectRepairDetailsById" resultType="com.bonus.material.repair.domain.RepairInputInfo">
|
||||
SELECT
|
||||
rd.id as id,
|
||||
rd.task_id as taskId,
|
||||
rd.repair_id as repairId,
|
||||
rd.ma_id as maId,
|
||||
rd.type_id as typeId,
|
||||
rd.repair_num as repairNum,
|
||||
rd.input_num as inputNum,
|
||||
(IFNULL(rd.repair_num, 0) - IFNULL(rd.input_num, 0) - IFNULL(rd.reject_num, 0))
|
||||
AS pendingInputNum,
|
||||
rd.reject_num as rejectNum,
|
||||
rd.create_by as createBy,
|
||||
rd.create_time as createTime,
|
||||
rd.status as status,
|
||||
rd.remark as remark,
|
||||
mt1.type_name AS typeName,
|
||||
mt.type_name AS typeModelName,
|
||||
mt.unit_name AS unitName,
|
||||
mt.unit_value AS unitValue,
|
||||
mt.manage_type AS manageType
|
||||
FROM
|
||||
repair_input_details rd
|
||||
LEFT JOIN ma_type mt on rd.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'
|
||||
WHERE
|
||||
rd.task_id = #{taskId}
|
||||
<if test="typeId != null">
|
||||
and rd.type_id = #{typeId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="batchInsertRepairInputDetails" parameterType="com.bonus.material.repair.domain.RepairInputDetails">
|
||||
|
|
@ -91,25 +225,88 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="insertRad">
|
||||
insert into repair_apply_details
|
||||
(
|
||||
<if test="taskId != null">
|
||||
task_id,
|
||||
</if>
|
||||
<if test="maId != null">
|
||||
ma_id,
|
||||
</if>
|
||||
<if test="typeId != null">
|
||||
type_id,
|
||||
</if>
|
||||
<if test="rejectNum != null">
|
||||
repair_num,
|
||||
</if>
|
||||
status,
|
||||
<if test="createBy != null and createBy != ''">
|
||||
create_by,
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
remark,
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
company_id,
|
||||
</if>
|
||||
create_time
|
||||
)
|
||||
values (
|
||||
<if test="taskId != null">
|
||||
#{taskId},
|
||||
</if>
|
||||
<if test="maId != null">
|
||||
#{maId},
|
||||
</if>
|
||||
<if test="typeId != null">
|
||||
#{typeId},
|
||||
</if>
|
||||
<if test="rejectNum != null">
|
||||
#{rejectNum},
|
||||
</if>
|
||||
0,
|
||||
<if test="createBy != null and createBy != ''">
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
#{remark},
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
#{companyId},
|
||||
</if>
|
||||
NOW()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateRepairInputDetails" parameterType="com.bonus.material.repair.domain.RepairInputDetails">
|
||||
update repair_input_details
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="taskId != null">task_id = #{taskId},</if>
|
||||
<if test="auditId != null">audit_id = #{auditId},</if>
|
||||
<if test="repairId != null">repair_id = #{repairId},</if>
|
||||
<if test="maId != null">ma_id = #{maId},</if>
|
||||
<if test="typeId != null">type_id = #{typeId},</if>
|
||||
<if test="repairNum != null">repair_num = #{repairNum},</if>
|
||||
<if test="inputNum != null">input_num = #{inputNum},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="companyId != null">company_id = #{companyId},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
UPDATE repair_input_details
|
||||
SET
|
||||
<if test="inputNum != null">input_num = IFNULL(input_num, 0) + #{inputNum},</if>
|
||||
<if test="rejectNum != null">reject_num = IFNULL(reject_num, 0) + #{rejectNum},</if>
|
||||
<if test="rejectReason != null and rejectReason != ''">reject_reason = #{rejectReason},</if>
|
||||
update_by = #{updateBy},
|
||||
update_time = #{updateTime},
|
||||
status = #{status}
|
||||
WHERE task_id = #{taskId}
|
||||
and type_id = #{typeId}
|
||||
<if test="maId != null">
|
||||
and ma_id = #{maId}
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<update id="updateNum">
|
||||
UPDATE ma_type
|
||||
SET storage_num = #{inputNum} + IFNULL(storage_num, 0)
|
||||
WHERE
|
||||
type_id = #{typeId}
|
||||
</update>
|
||||
|
||||
<update id="updateMaStatus">
|
||||
UPDATE ma_machine
|
||||
SET ma_status = #{status}
|
||||
WHERE
|
||||
ma_id = #{maId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteRepairInputDetailsById" parameterType="Long">
|
||||
|
|
|
|||
Loading…
Reference in New Issue