Merge remote-tracking branch 'origin/branch_syruan'

# Conflicts:
#	bonus-modules/bonus-material/src/main/java/com/bonus/material/repair/service/impl/RepairAuditDetailsServiceImpl.java
This commit is contained in:
syruan 2024-11-19 18:29:57 +08:00
commit 293502daf0
20 changed files with 1007 additions and 144 deletions

View File

@ -0,0 +1,53 @@
package com.bonus.common.biz.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.Date;
/**
* @author : 阮世耀
* @version : 1.0
* @Description: 基础Base VO
*/
@Getter
@Setter
@ToString
public class BaseVO {
@ApiModelProperty(value = "关键字")
private String keyword;
@ApiModelProperty(value = "状态")
private String status;
@ApiModelProperty(value = "组织id")
private Long companyId;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "开始时间")
private String startTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
@ApiModelProperty(value = "创建人")
private String createBy;
@ApiModelProperty(value = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@ApiModelProperty(value = "更新人")
private String updateBy;
@ApiModelProperty(value = "更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
}

View File

@ -13,7 +13,7 @@ public enum RepairTaskStatusEnum {
TASK_STATUS_PROCESSING(0, "维修管理--进行中"),
TASK_STATUS_COMPLETE(1, "维修管理--已完成"),
TASK_STATUS_REJECT(2, "维修管理--驳回"),
TASK_STATUS_REJECT(2, "维修管理--驳回退料"),
TASK_STATUS_TO_EXAM(3, "修饰审核--待审核"),
TASK_STATUS_REVIEW(4, "修饰审核--审核通过"),
TASK_STATUS_NO_REVIEW(5, "修饰审核--审核不通过"),

View File

@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import com.bonus.common.core.web.domain.BaseEntity;
import lombok.experimental.Accessors;
/**
* 附件
@ -13,12 +14,11 @@ import com.bonus.common.core.web.domain.BaseEntity;
* @author xsheng
* @date 2024-09-26
*/
@Data
@ToString
public class BmFileInfo extends BaseEntity
{
@Accessors(chain = true)
public class BmFileInfo extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键id */

View File

@ -4,6 +4,8 @@ import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
import com.bonus.common.log.enums.OperaType;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.material.repair.domain.RepairPart;
@ -173,7 +175,7 @@ public class RepairAuditDetailsController extends BaseController {
/**
* 修改修试审核详细
*/
@ApiOperation(value = "修改修试审核详细")
@PreventRepeatSubmit
@RequiresPermissions("repair:details:edit")
@ -185,6 +187,18 @@ public class RepairAuditDetailsController extends BaseController {
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}
}*/
/**
* 批量修改修试审核详细
*/
@ApiOperation(value = "批量修改修试审核详细")
@PreventRepeatSubmit
@RequiresPermissions("repair:details:edit")
@SysLog(title = "批量修试审核详细", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->批量修改修试审核详细")
@PutMapping
public AjaxResult edit(@RequestBody @NotNull List<RepairAuditDetails> repairAuditDetails) {
return toAjax(repairAuditDetailsService.updateRepairAuditDetailsBatch(repairAuditDetails));
}
/**

View File

@ -10,6 +10,8 @@ import com.bonus.material.repair.domain.RepairApplyRecord;
import com.bonus.material.repair.domain.RepairPartDetails;
import com.bonus.material.repair.domain.RepairTask;
import com.bonus.material.repair.domain.RepairTaskDetails;
import com.bonus.material.repair.domain.vo.RepairDeviceListVo;
import com.bonus.material.repair.domain.vo.RepairDeviceVO;
import com.bonus.material.repair.service.RepairService;
import com.bonus.system.api.domain.SysUser;
import com.fasterxml.jackson.core.JsonProcessingException;
@ -17,13 +19,16 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
/**
* @author syruan
@ -44,7 +49,7 @@ public class RepairController extends BaseController {
/**
* 获取维修任务列表
*/
@ApiOperation(value = "获取维修任务列表")
@ApiOperation(value = "获取维修任务列表--分页")
@GetMapping("/getRepairTaskList")
@RequiresPermissions(value = "repair:manage:list")
public TableDataInfo getRepairTaskList(RepairTask bean) {
@ -54,21 +59,9 @@ public class RepairController extends BaseController {
}
/**
* 导出维修任务列表
* 获取维修任务列表--不分页--NO_PAGE
*/
@PostMapping("/export")
@RequiresPermissions("repair:manage:export")
@ApiOperation(value = "导出维修任务列表")
public void export(HttpServletResponse response, RepairTask bean) {
List<RepairTask> list = service.exportRepairTaskList(bean);
ExcelUtil<RepairTask> util = new ExcelUtil<>(RepairTask.class);
util.exportExcel(response, list, "维修任务列表");
}
/**
* 获取维修任务列表--APP
*/
@ApiOperation(value = "获取维修任务列表---APP")
@ApiOperation(value = "获取维修任务列表---不分页")
@GetMapping("/getAppRepairTaskList")
@RequiresPermissions("repair:manage:list")
public AjaxResult getAppRepairTaskList(RepairTask bean) {
@ -81,20 +74,20 @@ public class RepairController extends BaseController {
*/
@ApiOperation(value = "获取维修物资设备列表---分页")
@GetMapping("/getRepairMaTypeList")
@RequiresPermissions("repair:manage:preview")
// @RequiresPermissions("repair:manage:preview")
public TableDataInfo getRepairMaTypeList(RepairTaskDetails bean) {
startPage();
List<RepairTaskDetails> list = service.getRepairMaTypeList(bean);
List<RepairDeviceListVo> list = service.getRepairMaTypeList(bean);
return getDataTable(list);
}
/**
* 获取维修任务机具列表
* 获取维修任务机具列表--级页面详情列表
*/
@ApiOperation(value = "获取维修物资设备列表---不分页")
@GetMapping("/getAppRepairMaTypeList")
public AjaxResult getAppRepairMaTypeList(RepairTaskDetails bean) {
List<RepairTaskDetails> list = service.getRepairMaTypeList(bean);
List<RepairDeviceListVo> list = service.getRepairMaTypeList(bean);
return AjaxResult.success(list);
}
@ -106,8 +99,10 @@ public class RepairController extends BaseController {
public AjaxResult submitRepairApply(@RequestBody @NotNull RepairApplyRecord bean) {
try {
String partStrList = bean.getPartStrList();
List<RepairPartDetails> repairPartDetails = objectMapper.readValue(partStrList, new TypeReference<List<RepairPartDetails>>() {});
bean.setPartList(repairPartDetails);
if (StringUtils.isNoneBlank(partStrList)) {
List<RepairPartDetails> repairPartDetails = objectMapper.readValue(partStrList, new TypeReference<List<RepairPartDetails>>() {});
bean.setPartList(Optional.ofNullable(repairPartDetails).orElse(new ArrayList<>()));
}
return service.submitRepairApply(bean);
} catch (JsonProcessingException e) {
throw new ServiceException("Jackson反序列化异常:" + e.getMessage());
@ -115,32 +110,50 @@ public class RepairController extends BaseController {
}
/**
* 快捷维修记录
* 快捷维修 1.把维修都设置为内部维修增加维修配件明细
*/
@ApiOperation(value = "快捷维修记录")
@ApiOperation(value = "快捷维修--批量--默认内部维修")
@PostMapping("/fastRepairApply")
public AjaxResult fastRepairApply(@RequestBody List<RepairTaskDetails> list) {
return service.fastRepairApply(list);
}
/**
* 完成维修
* 批量维修 1.判断维修方式增加维修配件明细
*/
@ApiOperation(value = "完成维修")
@ApiOperation(value = "批量维修--批量--按照传参维修方式进行维修")
@PostMapping("/batchRepairApply")
public AjaxResult batchRepairApply(@RequestBody @NotNull List<RepairDeviceVO> list) {
return service.batchRepairApply(list);
}
/**
* 维修明细--批量审核--更新明细status
*/
@ApiOperation(value = "维修明细更新status--批量")
@PostMapping("/completeRepair")
public AjaxResult completeRepair(@RequestBody ArrayList<Long> ids) {
return toAjax(service.completeRepair(ids));
}
/**
* 提交审核
* 任务维修完成--提交修饰审核
*/
@ApiOperation(value = "提交审核")
@ApiOperation(value = "任务维修完成--提交至修饰审核")
@PostMapping("/endRepairTask")
public AjaxResult endRepairTask(@RequestBody ArrayList<RepairTask> taskList) {
return service.endRepairTask(taskList);
}
/**
* 驳回退料--批量
*/
@ApiOperation(value = "驳回退料--批量")
@DeleteMapping("/{ids}")
public AjaxResult rejectRepair(@PathVariable Long[] ids) {
return service.rejectRepair(Arrays.asList(ids));
}
/**
* 获取维修员下拉选
*/
@ -150,4 +163,17 @@ public class RepairController extends BaseController {
return AjaxResult.success(list);
}
/**
* 导出维修任务列表--外层--壹级列表
*/
@PostMapping("/export")
@RequiresPermissions("repair:manage:export")
@ApiOperation(value = "导出维修任务列表")
public void export(HttpServletResponse response, RepairTask bean) {
List<RepairTask> list = service.exportRepairTaskList(bean);
ExcelUtil<RepairTask> util = new ExcelUtil<>(RepairTask.class);
util.exportExcel(response, list, "维修任务列表");
}
}

View File

@ -7,20 +7,22 @@ import java.util.List;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import com.bonus.common.core.web.domain.BaseEntity;
import lombok.experimental.Accessors;
/**
* 维修记录对象 repair_apply_record
*
* @author xsheng
* @date 2024-10-16
* @author syruan
*/
@EqualsAndHashCode(callSuper = false)
@Data
@ToString
@Accessors(chain = true)
public class RepairApplyRecord extends BaseEntity {
private static final long serialVersionUID = 1L;
/** $column.columnComment */
@ -53,7 +55,7 @@ public class RepairApplyRecord extends BaseEntity {
/** 维修方式1内部2返厂3报废 */
@Excel(name = "维修方式", readConverterExp = "1=内部2返厂3报废")
private String repairType;
private Integer repairType;
/** 数据所属组织 */
@Excel(name = "数据所属组织")
@ -91,7 +93,7 @@ public class RepairApplyRecord extends BaseEntity {
/** 类型0不收费1收费 */
@Excel(name = "类型", readConverterExp = "0=不收费1收费")
private String partType;
private Integer partType;
/** 配件名称 */
@Excel(name = "配件名称")

View File

@ -91,7 +91,7 @@ public class RepairAuditDetails extends BaseEntity {
/** 0未审核1已审核2驳回 */
@Excel(name = "状态", readConverterExp = "0=未审核,1=已审核,2=驳回")
@ApiModelProperty(value = "0未审核1已审核2驳回")
private char status;
private String status;
/** 数据所属组织 */
@ApiModelProperty(value = "数据所属组织")

View File

@ -1,11 +1,15 @@
package com.bonus.material.repair.domain;
import java.math.BigDecimal;
import java.util.List;
import com.bonus.common.core.annotation.Excel;
import com.bonus.material.basic.domain.BmFileInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import com.bonus.common.core.web.domain.BaseEntity;
import lombok.experimental.Accessors;
/**
* 维修配件详细对象 repair_part_details
@ -13,10 +17,9 @@ import com.bonus.common.core.web.domain.BaseEntity;
* @author xsheng
* @date 2024-10-16
*/
@Data
@ToString
@Accessors(chain = true)
public class RepairPartDetails extends BaseEntity {
private static final long serialVersionUID = 1L;
@ -55,7 +58,7 @@ public class RepairPartDetails extends BaseEntity {
/** 类型0不收费1收费 */
@Excel(name = "类型", readConverterExp = "0=不收费1收费")
private String partType;
private Integer partType;
/** 数据所属组织 */
@Excel(name = "数据所属组织")
@ -68,9 +71,27 @@ public class RepairPartDetails extends BaseEntity {
private String repairContent;
/** 维修数量 */
@ApiModelProperty(value = "维修数量")
private Integer repairNum;
/** 报废数量 */
@ApiModelProperty(value = "报废数量")
private Integer scrapNum;
/** 报废原因 */
@ApiModelProperty(value = "报废原因")
private String scrapReason;
/** 报废原因类型0自然损坏1人为损坏 */
@Excel(name = "损坏原因类型", readConverterExp = "0=自然损坏1人为损坏")
private String scrapType;
/** 附件集合 */
@ApiModelProperty(value = "附件集合")
private List<BmFileInfo> fileList;
/** 维修人员 */
@ApiModelProperty(value = "维修人")
private String repairer;
@ApiModelProperty(value = "配件名称")

View File

@ -18,6 +18,13 @@ public class RepairTask {
*/
@ApiModelProperty(value = "任务id")
private String taskId;
@ApiModelProperty(value = "任务状态")
private Integer taskStatus;
@ApiModelProperty(value = "任务类型")
private Integer taskType;
/**
* 维修单号
*/

View File

@ -34,6 +34,13 @@ public class RepairTaskDetails extends BaseEntity {
*/
@ApiModelProperty(value = "类型名称")
private String typeName;
/**
* 规格类型id
*/
@ApiModelProperty(value = "规格型号id")
private String typeId;
/**
* 规格型号
*/
@ -49,13 +56,20 @@ public class RepairTaskDetails extends BaseEntity {
/**
* 编码
*/
@ApiModelProperty(value = "编码")
@ApiModelProperty(value = "设备编码")
private String code;
/**
* 维修总量
*/
@ApiModelProperty(value = "维修总量")
private int repairNum;
/**
* 维修方式: 1内部 2外部返厂 3报废
*/
@ApiModelProperty(value = "维修方式: 1内部 2外部 3报废")
private Integer repairType;
/**
* 维修合格数量
*/
@ -72,12 +86,6 @@ public class RepairTaskDetails extends BaseEntity {
@ApiModelProperty(value = "待修状态")
private String status;
/**
* 规格类型id
*/
@ApiModelProperty(value = "规格型号id")
private String typeId;
@ApiModelProperty(value = "组织id")
private Long companyId;

View File

@ -0,0 +1,65 @@
package com.bonus.material.repair.domain.vo;
import com.bonus.common.biz.domain.BaseVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.ArrayList;
import java.util.List;
/**
* @author : 阮世耀
* @version : 1.0
* @CreateTime: 2024-11-15 13:26
* @Description: 维修设备列表返回VO
*/
@EqualsAndHashCode(callSuper = false)
@Data
public class RepairDeviceListVo extends BaseVO {
@ApiModelProperty(value = "id")
private Long id;
@ApiModelProperty(value = "任务ID")
private Integer taskId;
@ApiModelProperty(value = "类型id")
private Long typeNameId;
@ApiModelProperty(value = "设备编码")
private String code;
@ApiModelProperty(value = "类型名称")
private String typeName;
@ApiModelProperty(value = "规格型号id")
private Long typeId;
@ApiModelProperty(value = "规格型号")
private String type;
@ApiModelProperty(value = "物资设备计量单位")
private String unitName;
@ApiModelProperty(value = "管理模式")
private Integer manageType;
@ApiModelProperty(value = "设备表主键id")
private Long maId;
@ApiModelProperty(value = "维修人员")
private String repairer;
@ApiModelProperty(value = "维修总量")
private int repairNum;
@ApiModelProperty(value = "已修数量")
private int repairedNum;
@ApiModelProperty(value = "维修报废数量")
private int scrapNum;
@ApiModelProperty(value = "内层物资类型集合")
private List<RepairDeviceVO> repairDeviceList = new ArrayList<>();
}

View File

@ -0,0 +1,137 @@
package com.bonus.material.repair.domain.vo;
import com.bonus.material.repair.domain.RepairPart;
import com.bonus.material.repair.domain.RepairPartDetails;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.ArrayList;
import java.util.List;
/**
* @author : 阮世耀
* @version : 1.0
* @CreateTime: 2024-11-15 14:35
* @Description: 维修设备VO
*/
@Data
@Accessors(chain = true)
public class RepairDeviceVO {
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "任务ID")
private Long taskId;
@ApiModelProperty(value = "设备表主键id")
private Long maId;
@ApiModelProperty(value = "设备类型")
private String typeName;
@ApiModelProperty(value = "规格型号")
private String type;
@ApiModelProperty(value = "规格型号ID")
private Long typeId;
@ApiModelProperty(value = "设备编码")
private String code;
@ApiModelProperty(value = "状态")
private String status;
@ApiModelProperty(value = "维修配件信息")
private String partInfo;
@ApiModelProperty(value = "维修方式: 1内部 2外部返厂 3报废")
private Integer repairType;
@ApiModelProperty(value = "维修人员")
private String repairer;
@ApiModelProperty(value = "管理模式")
private Integer manageType;
@ApiModelProperty(value = "附件")
private String fileUrl;
@ApiModelProperty(value = "维修数量")
private int repairNum;
@ApiModelProperty(value = "维修合格数量")
private int repairedNum;
@ApiModelProperty(value = "维修报废数量")
private int scrapNum;
@ApiModelProperty(value = "编码--内部维修配件集合")
private List<RepairPartDetails> codeInRepairPartList;
@ApiModelProperty(value = "编码--返厂维修配件集合")
private List<RepairPartDetails> codeOutRepairPartList;
@ApiModelProperty(value = "编码--报废维修配件集合")
private List<RepairPartDetails> codeScrapRepairPartList;
@ApiModelProperty(value = "数量--内部维修配件集合")
private List<RepairPartDetails> numberInRepairPartList;
@ApiModelProperty(value = "数量--返厂维修配件集合")
private List<RepairPartDetails> numberOutRepairPartList;
@ApiModelProperty(value = "数量--报废维修配件集合")
private List<RepairPartDetails> numberScrapRepairPartList;
// 手动覆盖 getter 方法确保 List 始终被初始化
public List<RepairPartDetails> getCodeInRepairPartList() {
if (this.codeInRepairPartList == null) {this.codeInRepairPartList = new ArrayList<>();}
return this.codeInRepairPartList;
}
public List<RepairPartDetails> getCodeOutRepairPartList() {
if (this.codeOutRepairPartList == null) {this.codeOutRepairPartList = new ArrayList<>();}
return this.codeOutRepairPartList;
}
public List<RepairPartDetails> getCodeScrapRepairPartList() {
if (this.codeScrapRepairPartList == null) {this.codeScrapRepairPartList = new ArrayList<>();}
return this.codeScrapRepairPartList;
}
public List<RepairPartDetails> getNumberInRepairPartList() {
if (this.numberInRepairPartList == null) {this.numberInRepairPartList = new ArrayList<>();}
return this.numberInRepairPartList;
}
public List<RepairPartDetails> getNumberOutRepairPartList() {
if (this.numberOutRepairPartList == null) {this.numberOutRepairPartList = new ArrayList<>();}
return this.numberOutRepairPartList;
}
public List<RepairPartDetails> getNumberScrapRepairPartList() {
if (this.numberScrapRepairPartList == null) {this.numberScrapRepairPartList = new ArrayList<>();}
return this.numberScrapRepairPartList;
}
// 自定义 clear 方法
public void clear() {
this.id = null;
this.taskId = null;
this.typeName = null;
this.type = null;
this.code = null;
this.status = null;
this.partInfo = null;
this.repairType = null;
this.fileUrl = null;
this.codeInRepairPartList.clear();
this.codeOutRepairPartList.clear();
this.codeScrapRepairPartList.clear();
this.numberInRepairPartList.clear();
this.numberOutRepairPartList.clear();
this.numberScrapRepairPartList.clear();
}
}

View File

@ -61,6 +61,14 @@ public interface RepairAuditDetailsMapper {
*/
int updateRepairAuditDetails(RepairAuditDetails repairAuditDetails);
/**
* 批量修改修试审核详细--批量
*
* @param ids 批量修试审核详细
* @return 结果
*/
int updateRepairAuditDetailsBatch(@Param("ids") List<Long> ids, @Param("status") String status);
/**
* 删除修试审核详细
*

View File

@ -4,6 +4,7 @@ import com.bonus.material.repair.domain.RepairApplyRecord;
import com.bonus.material.repair.domain.RepairPartDetails;
import com.bonus.material.repair.domain.RepairTask;
import com.bonus.material.repair.domain.RepairTaskDetails;
import com.bonus.material.repair.domain.vo.RepairDeviceListVo;
import com.bonus.system.api.domain.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -27,7 +28,7 @@ public interface RepairMapper {
* 获取维修详细列表
* @param bean 维修任务详情--查询条件
*/
List<RepairTaskDetails> getRepairMaTypeList(RepairTaskDetails bean);
List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean);
/**
* 新增维修记录
@ -81,7 +82,7 @@ public interface RepairMapper {
* @param taskList 任务列表集合
* @param userid 用户id
*/
int updateTaskStatus(@Param("taskList") List<RepairTask> taskList, @Param("userId") Long userid);
int updateTaskStatus(@Param("taskList") List<RepairTask> taskList, @Param("userId") Long userid, @Param("taskStatus") Integer taskStatus);
/**
* 新增任务
@ -107,7 +108,7 @@ public interface RepairMapper {
* @param repairNum 维修数量
* @param userid 用户id
*/
int updateRepairedNumTwo(@Param("id")Long id, @Param("repairNum")int repairNum, @Param("userId")Long userid);
int updateRepairedNumTwo(@Param("id") Long id, @Param("repairNum") int repairNum, @Param("userId") Long userid);
/**
* 查询是否存在未完成维修的
@ -122,7 +123,7 @@ public interface RepairMapper {
List<RepairTaskDetails> getDetailsListByTaskId(RepairTask task);
/**
* 新增实验建议审核数据
* 新增修饰审核审核数据
* @param details 数据详情
*/
int addAuditDetails(RepairTaskDetails details);
@ -135,7 +136,7 @@ public interface RepairMapper {
/**
* 新增维修费用
*/
int addRepairCost(@Param("bean") RepairApplyRecord bean, @Param("costs") BigDecimal costs,@Param("partType") String partType);
int addRepairCost(@Param("bean") RepairApplyRecord bean, @Param("costs") BigDecimal costs, @Param("partType") String partType);
/**
* 查询配件价格

View File

@ -80,6 +80,14 @@ public interface IRepairAuditDetailsService {
*/
int updateRepairAuditDetails(RepairAuditDetails repairAuditDetails);
/**
* 批量修改修试审核详细
*
* @param repairAuditDetails 修试审核详细集合
* @return 结果
*/
int updateRepairAuditDetailsBatch(List<RepairAuditDetails> repairAuditDetails);
/**
* 批量删除修试审核详细
*

View File

@ -5,6 +5,8 @@ import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.repair.domain.RepairApplyRecord;
import com.bonus.material.repair.domain.RepairTask;
import com.bonus.material.repair.domain.RepairTaskDetails;
import com.bonus.material.repair.domain.vo.RepairDeviceListVo;
import com.bonus.material.repair.domain.vo.RepairDeviceVO;
import com.bonus.system.api.domain.SysUser;
import java.util.ArrayList;
@ -24,15 +26,11 @@ public interface RepairService {
/**
* 获取维修详细列表
* @param bean
* @return
*/
List<RepairTaskDetails> getRepairMaTypeList(RepairTaskDetails bean);
List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean);
/**
* 新增维修记录
* @param bean
* @return
* 提交维修记录
*/
AjaxResult submitRepairApply(RepairApplyRecord bean);
@ -43,10 +41,10 @@ public interface RepairService {
*/
AjaxResult fastRepairApply(List<RepairTaskDetails> list);
AjaxResult batchRepairApply(List<RepairDeviceVO> repairDeviceVOList);
/**
* 完成维修
* @param ids
* @return
* 维修明细--批量审核--更新明细status
*/
int completeRepair(ArrayList<Long> ids);
@ -58,11 +56,12 @@ public interface RepairService {
/**
* 提交审核
* @param taskList
* @return
* @param taskList 任务信息集合
*/
AjaxResult endRepairTask(List<RepairTask> taskList);
AjaxResult rejectRepair(List<Long> taskList);
/**
* 导出维修列表

View File

@ -25,8 +25,8 @@ import com.bonus.material.task.mapper.TmTaskAgreementMapper;
import com.bonus.material.task.mapper.TmTaskMapper;
import com.bonus.material.task.domain.TmTask;
import javax.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import com.bonus.material.repair.mapper.RepairAuditDetailsMapper;
import com.bonus.material.repair.service.IRepairAuditDetailsService;
@ -72,8 +72,7 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
}
/**
* @param repairAuditDetails
* @return
* @param repairAuditDetails 查询参数
*/
@Override
public List<RepairAuditDetails> getRepairAuditList(RepairAuditDetails repairAuditDetails) {
@ -114,14 +113,14 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
.collect(Collectors.toList());
// 批量查询 typeName
List<KeyValueVO> keyValueList = repairAuditDetailsMapper.selectTypeNamesByTaskIds(taskIds);
Map<Long, String> typeNameMap = repairAuditDetailsMapper.selectTypeNamesByTaskIds(taskIds);
// 设置 itemType
if (CollectionUtil.isNotEmpty(keyValueList)) {
Map<String, String> keyValueMap = keyValueList.stream().collect(Collectors.toMap(KeyValueVO::getMapKey, KeyValueVO::getMapValue));
if (CollectionUtil.isNotEmpty(typeNameMap)) {
for (ScrapApplyDetailsVO scrapApplyDetailsVO : repairQuestList) {
Long taskId = scrapApplyDetailsVO.getTaskId();
if (taskId != null) {
String typeName = keyValueMap.get(String.valueOf(taskId));
String typeName = typeNameMap.get(taskId);
if (typeName != null) {
scrapApplyDetailsVO.setItemType(typeName);
}
@ -316,7 +315,7 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
if (CollectionUtil.isNotEmpty(auditDetailList)) {
for (RepairAuditDetails bean : auditDetailList) {
bean.setAuditBy(SecurityUtils.getLoginUser().getUserid());
bean.setStatus(status);
bean.setStatus(String.valueOf(status));
bean.setUpdateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid()));
bean.setAuditRemark(scrapAudit.getRemark());
repairAuditDetailsMapper.updateStatus(bean);
@ -326,7 +325,7 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
if (auditAllList != null) {
for (RepairAuditDetails bean : auditAllList) {
bean.setAuditBy(SecurityUtils.getLoginUser().getUserid());
bean.setStatus(status);
bean.setStatus(String.valueOf(status));
bean.setUpdateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid()));
bean.setAuditRemark(scrapAudit.getRemark());
repairAuditDetailsMapper.updateStatus(bean);
@ -449,6 +448,33 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
}
}
/**
* 批量修改修试审核详细
*
* @param repairAuditDetails 修试审核详细
* @return 结果
*/
@Override
public int updateRepairAuditDetailsBatch(@NotNull List<RepairAuditDetails> repairAuditDetails) {
// 提取所有需要更新的 ID
List<Long> ids = repairAuditDetails.stream()
.filter(Objects::nonNull)
.map(RepairAuditDetails::getId)
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (ids.isEmpty()) {
return 0;
}
try {
// 调用 Mapper 方法进行批量更新
return repairAuditDetailsMapper.updateRepairAuditDetailsBatch(ids,repairAuditDetails.get(0).getStatus());
} catch (Exception e) {
throw new ServiceException("错误信息描述");
}
}
/**
* 批量删除修试审核详细
*

View File

@ -1,23 +1,31 @@
package com.bonus.material.repair.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.bonus.common.biz.enums.RepairTaskStatusEnum;
import com.bonus.common.biz.enums.TmTaskTypeEnum;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.repair.domain.RepairApplyRecord;
import com.bonus.material.repair.domain.RepairPartDetails;
import com.bonus.material.repair.domain.RepairTask;
import com.bonus.material.repair.domain.RepairTaskDetails;
import com.bonus.material.basic.domain.BmFileInfo;
import com.bonus.material.basic.mapper.BmFileInfoMapper;
import com.bonus.material.repair.domain.*;
import com.bonus.material.repair.domain.vo.RepairDeviceListVo;
import com.bonus.material.repair.domain.vo.RepairDeviceVO;
import com.bonus.material.repair.mapper.RepairMapper;
import com.bonus.material.repair.service.RepairService;
import com.bonus.material.task.mapper.TmTaskMapper;
import com.bonus.system.api.domain.SysUser;
import com.bonus.system.api.model.LoginUser;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author syruan
@ -28,6 +36,17 @@ public class RepairServiceImpl implements RepairService {
@Resource
private RepairMapper repairMapper;
@Resource
private TmTaskMapper taskMapper;
@Resource
private BmFileInfoMapper bmFileInfoMapper;
// 1:内部维修 2:外部返厂维修 3:报废
private final int inRepairType = 1, outRepairType = 2, scrapRepairType = 3;
// 维修管理方式--0编码管理 1数量管理
private final int manageTypeByCode = 0, manageTypeByNumber = 1;
@Override
public List<RepairTask> getRepairTaskList(RepairTask bean) {
@ -40,69 +59,101 @@ public class RepairServiceImpl implements RepairService {
}
@Override
public List<RepairTaskDetails> getRepairMaTypeList(RepairTaskDetails bean) {
//Long companyId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
public List<RepairDeviceListVo> getRepairMaTypeList(RepairTaskDetails bean) {
bean.setCompanyId(null);
return repairMapper.getRepairMaTypeList(bean);
List<RepairDeviceListVo> repairMaTypeList = repairMapper.getRepairMaTypeList(bean);
if (repairMaTypeList.isEmpty()) {
return repairMaTypeList;
}
// 创建Map集合用于快速分组使用 ConcurrentHashMap 保证线程安全
Map<Long, RepairDeviceListVo> resultMap = new ConcurrentHashMap<>();
// 遍历处理把相同的父级对象拆分到子集合中
repairMaTypeList.forEach(item -> {
// 创建对象并复制字段value
RepairDeviceVO repairDeviceVO = new RepairDeviceVO();
try {
BeanUtil.copyProperties(item, repairDeviceVO);
} catch (Exception e) {
// 记录异常日志并提供更详细的错误信息
System.err.println("复制属性时发生错误: {}" + e.getMessage());
throw new RuntimeException("复制属性时发生错误", e);
}
if (item.getTypeNameId() == null) {
// 处理 typeNameId 为空的情况
System.err.println("typeNameId 为空,跳过当前项: " + item);
return;
}
// 使用 computeIfAbsent 方法如果 key 不存在则创建一个新对象并添加到 resultMap
resultMap.computeIfAbsent(item.getTypeNameId(), k -> item).getRepairDeviceList().add(repairDeviceVO);
});
return new ArrayList<>(resultMap.values());
}
/**
* 新增维修记录
* 提交维修记录
* @param bean repairApplyRecord
*/
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult submitRepairApply(RepairApplyRecord bean) {
public AjaxResult submitRepairApply(@NotNull(message = "参数不能为空") RepairApplyRecord bean) {
// 获取维修详情记录待维修已维修报废的数量
RepairTaskDetails details = repairMapper.getById(bean.getId());
LoginUser loginUser = SecurityUtils.getLoginUser();
bean.setCreateBy(String.valueOf(loginUser.getUserid()));
// 获取维修配件列表
List<RepairPartDetails> partList = bean.getPartList();
BigDecimal sfCosts = new BigDecimal("0");
String nbType = "1";
String fcType = "2";
// 收费配件
String sfPart = "1";
String bsfPart = "0";
if (partList != null && !partList.isEmpty()) {
if (CollectionUtil.isNotEmpty(partList)) {
bean.setRepairNum(partList.get(0).getRepairNum());
bean.setRepairer(partList.get(0).getRepairer());
}
// 根据维修类型更新维修数量报废数量
switch (bean.getRepairType()) {
case "1": {
int repairNum = (details.getRepairedNum() + bean.getRepairNum());
int num = repairNum + details.getScrapNum();
if (num > details.getRepairNum()) {
throw new ServiceException("维修数量大于维修总量");
}
repairMapper.updateRepairedNum(bean.getId(), repairNum, Long.valueOf(bean.getRepairer()), loginUser.getUserid());
case inRepairType: {
int repairNum = verifyRepairNum(bean, details);
// 更新维修数量并修改维修人员
repairMapper.updateRepairedNum(bean.getId(), repairNum, loginUser.getUserid(), loginUser.getUserid());
break;
}
case "2": {
int repairNum = (int) (details.getRepairedNum() + bean.getRepairNum());
int num = repairNum + details.getScrapNum();
if (num > details.getRepairNum()) {
throw new ServiceException("维修数量大于维修总量");
}
case outRepairType: {
int repairNum = verifyRepairNum(bean, details);
// 更新维修数量维修人员不变
repairMapper.updateRepairedNumTwo(bean.getId(), repairNum, loginUser.getUserid());
break;
}
case "3": {
int scrapNum = (int) (details.getScrapNum() + bean.getScrapNum());
case scrapRepairType: {
int scrapNum = details.getScrapNum() + bean.getScrapNum();
int num = scrapNum + details.getRepairedNum();
if (num > details.getRepairNum()) {
throw new ServiceException("维修数量大于维修总量");
}
// 更新报废数量
repairMapper.updateScrapNum(bean.getId(), scrapNum, loginUser.getUserid());
break;
}
default:
break;
}
if (partList != null && !partList.isEmpty()) {
if (nbType.equals(bean.getRepairType())) {
// 判断配件列表是否为空
if (CollectionUtil.isNotEmpty(partList)) {
// 内部维修
if (Objects.equals(inRepairType, bean.getRepairType())) {
// 遍历配件列表判断配件类型收费还是不收费
for (RepairPartDetails partDetails : partList) {
if (partDetails.getPartId() != null) {
// 有维修配件时
// 有维修配件时,如果价格为空设置为0
if (partDetails.getPartCost() == null) {
partDetails.setPartCost(new BigDecimal(0));
}
@ -111,23 +162,30 @@ public class RepairServiceImpl implements RepairService {
partDetails.setTypeId(bean.getTypeId());
partDetails.setCreateBy(String.valueOf(loginUser.getUserid()));
partDetails.setCompanyId(bean.getCompanyId());
// 根据partid 找到配件单价
// 根据 partId 找配件单价
BigDecimal partPrice = repairMapper.selectPartPrice(partDetails.getPartId());
// 设置配件费用
partDetails.setPartCost(partPrice);
// 添加维修配件明细表
repairMapper.addPart(partDetails);
bean.setPartPrice(partDetails.getPartCost());
bean.setPartId((long) partDetails.getPartId().intValue());
bean.setPartNum(partDetails.getPartNum());
bean.setRepairContent(partDetails.getRepairContent());
bean.setPartType(partDetails.getPartType());
// 添加维修记录表
repairMapper.addRecord(bean);
} else {
// 不选维修配件时
// 不选维修配件时, 只添加维修记录表
repairMapper.addRecord(bean);
}
}
}
if (fcType.equals(bean.getRepairType())) {
// 返厂维修
if (outRepairType == bean.getRepairType()) {
bean.setPartName(partList.get(0).getPartName());
bean.setPartType(partList.get(0).getPartType());
bean.setRepairContent(partList.get(0).getRepairContent());
@ -142,81 +200,499 @@ public class RepairServiceImpl implements RepairService {
bean.setPartPrice(partList.get(0).getPartPrice());
}
bean.setPartNum(partList.get(0).getPartNum());
// 新增维修记录表
repairMapper.addRecord(bean);
}
for (RepairPartDetails partDetails : partList) {
if (partDetails.getPartCost() != null) {
BigDecimal partCost = partDetails.getPartCost();
BigDecimal partNumber = new BigDecimal(partDetails.getPartNum());
sfCosts = sfCosts.add(partCost.multiply(partNumber));
}
}
if (!"0".equals(sfCosts.toString())) {
// 配件费用计算
sfCosts = countPartCosts(partList, sfCosts);
// 判断是否是收费配件
if (sfPart.equals(sfCosts.toString())) {
// SQL: 新增维修费用记录表
repairMapper.addRepairCost(bean, sfCosts, sfPart);
}
} else {
// 新增预报废记录
// 新增维修记录表--预报废
repairMapper.addRecord(bean);
}
return AjaxResult.success();
}
/**
* 校验维修数量
*/
private static int verifyRepairNum(RepairApplyRecord bean, RepairTaskDetails details) {
int repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + bean.getRepairNum();
if (repairNum + OptionalInt.of(details.getScrapNum()).orElse(0) > details.getRepairNum()) {
throw new ServiceException("维修数量大于维修总量");
}
return repairNum;
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult fastRepairApply(List<RepairTaskDetails> list) {
LoginUser loginUser = SecurityUtils.getLoginUser();
// 判断待维修数量是否大于0
for (RepairTaskDetails bean : list) {
int repairedNum = bean.getRepairNum() - bean.getRepairedNum() - bean.getScrapNum();
if (repairedNum <= 0) {
throw new ServiceException("选中的数据中包含待维修数量为0的机具请重新选择");
}
}
// 执行SQL 1.增加维修记录表 2.修改维修明细表的维修数量
for (RepairTaskDetails bean : list) {
int repairedNum = bean.getRepairNum() - bean.getRepairedNum() - bean.getScrapNum();
RepairApplyRecord partDetails = new RepairApplyRecord();
partDetails.setTaskId(Long.valueOf(bean.getTaskId()));
partDetails.setMaId(Long.valueOf(bean.getMaId()));
partDetails.setTypeId(Long.valueOf(bean.getTypeId()));
partDetails.setRepairNum(repairedNum);
partDetails.setRepairType("1");
partDetails.setCreateBy(String.valueOf(loginUser.getUserid()));
partDetails.setCompanyId(bean.getCompanyId());
repairMapper.addRecord(partDetails);
RepairApplyRecord repairRecord = new RepairApplyRecord();
repairRecord.setTaskId(Long.valueOf(bean.getTaskId()));
repairRecord.setMaId(Long.valueOf(bean.getMaId()));
repairRecord.setTypeId(Long.valueOf(bean.getTypeId()));
repairRecord.setRepairNum(repairedNum);
// 快捷维修设置为内部维修
repairRecord.setRepairType(inRepairType);
repairRecord.setCreateBy(String.valueOf(loginUser.getUserid()));
repairRecord.setCompanyId(bean.getCompanyId());
repairMapper.addRecord(repairRecord);
int i = repairedNum + bean.getRepairedNum();
repairMapper.updateRepairedNumTwo(bean.getId(), i, loginUser.getUserid());
}
// 执行完毕无异常返回至前端
return AjaxResult.success();
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult endRepairTask(List<RepairTask> taskList) {
public AjaxResult batchRepairApply(@NotNull List<RepairDeviceVO> repairDeviceVOList) {
// 准备业务逻辑数据
LoginUser loginUser = SecurityUtils.getLoginUser();
for (RepairTask task : taskList) {
int i = repairMapper.getUnFinish(task);
if (i > 0) {
throw new ServiceException("选中的数据中包含维修未完成的,请完成维修再进行提交审核");
// 配件集合
List<RepairPartDetails> partList = new ArrayList<>();
// 校验参数过滤空数据
repairDeviceVOList.removeIf(Objects::isNull);
for (RepairDeviceVO bean : repairDeviceVOList) {
if (bean.getManageType() == null) {
throw new ServiceException("请选择物资管理方式");
}
if (Objects.equals(manageTypeByCode, bean.getManageType())) {
// 物资管理方式--编码管理
// 根据维修方式更新维修数量报废数量
switch (bean.getRepairType()) {
case inRepairType: {
partList = bean.getCodeInRepairPartList();
// 更新维修数量并修改维修人员
repairMapper.updateRepairedNum(bean.getId(), 1, loginUser.getUserid(), loginUser.getUserid());
break;
}
case outRepairType: {
partList = bean.getCodeOutRepairPartList();
// 更新维修数量维修人员不变
repairMapper.updateRepairedNumTwo(bean.getId(), 1, loginUser.getUserid());
break;
}
case scrapRepairType: {
// 报废无需上传配件直接初始化空集合
partList = bean.getCodeScrapRepairPartList();
// 更新报废数量
repairMapper.updateScrapNum(bean.getId(), 1, loginUser.getUserid());
break;
}
default:
System.err.println("请输入正确的维修类型:" + bean.getRepairType());
break;
}
// 统一处理配件集合数据
copeNumberManageInList(bean, partList, loginUser, bean.getManageType());
} else if (Objects.equals(manageTypeByNumber, bean.getManageType())) {
// 物资管理方式--数量管理
if (bean.getId() == null) {
throw new ServiceException("请完善参数维修详情ID为空!");
}
// 处理配件--数量管理--内部维修
if (CollectionUtil.isNotEmpty(bean.getNumberInRepairPartList())) {
// 获取维修详情表中的维修详情记录待维修已维修已报废的数量
RepairTaskDetails details = repairMapper.getById(bean.getId());
if (Objects.isNull(details)) {
throw new ServiceException("此维修记录不存在,请检查后提交!");
}
partList = bean.getNumberInRepairPartList();
if (bean.getNumberInRepairPartList().get(0).getRepairNum() != null && bean.getNumberInRepairPartList().get(0).getRepairNum() != 0) {
// ---------------校验维修数量-----------------
// 统计已维修数量 + 本次维修数量
int repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + bean.getNumberInRepairPartList().get(0).getRepairNum();
// 统计报废数量 + 维修合计数量
int num = repairNum + details.getScrapNum();
if (num > details.getRepairNum()) {
throw new ServiceException("维修数量大于维修总量");
}
// ---------------校验维修数量-----------------
// 更新维修数量并修改维修人员
repairMapper.updateRepairedNum(bean.getId(), repairNum, loginUser.getUserid(), loginUser.getUserid());
// 处理配件集合数据
copeNumberManageInList(bean, partList, loginUser, bean.getManageType());
}
}
// 处理配件集合数据 -- 数量管理--外部返厂维修
if (CollectionUtil.isNotEmpty(bean.getNumberOutRepairPartList())) {
// 获取维修详情表中的维修详情记录待维修已维修已报废的数量
RepairTaskDetails details = repairMapper.getById(bean.getId());
if (Objects.isNull(details)) {
throw new ServiceException("此维修记录不存在,请检查后提交!");
}
BigDecimal sfCosts = new BigDecimal("0");
partList = bean.getNumberOutRepairPartList();
// 重新查询维修详情
details = repairMapper.getById(bean.getId());
// 判断外部维修配件数量是否为空
if (partList.get(0).getRepairNum() != null && partList.get(0).getRepairNum() != 0) {
// 统计已维修数量 + 本次维修数量
int repairNum = OptionalInt.of(details.getRepairedNum()).orElse(0) + partList.get(0).getRepairNum();
// 统计报废数量 + 维修合计数量
if ((repairNum + OptionalInt.of(details.getScrapNum()).orElse(0)) > details.getRepairNum()) {
throw new ServiceException("维修数量大于维修总量");
}
// 更新维修数量维修人员不变
repairMapper.updateRepairedNumTwo(bean.getId(), repairNum, loginUser.getUserid());
if (partList.get(0).getSupplierId() == null) {
throw new ServiceException("请选择返厂厂家");
}
// 数量管理--外部返厂维修 -- 记录表插入数据
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
for (RepairPartDetails repairPartDetails : partList) {
repairApplyRecord.setId(bean.getId()).setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId())
.setRepairType(outRepairType).setRepairNum(repairPartDetails.getRepairNum()).setScrapNum(0)
.setPartName(repairPartDetails.getPartName()).setPartType(repairPartDetails.getPartType())
.setRepairContent(repairPartDetails.getRepairContent()).setSupplierId(repairPartDetails.getSupplierId())
.setPartNum(repairPartDetails.getPartNum()).setRepairer(loginUser.getUsername())
.setPartPrice(Optional.ofNullable(repairPartDetails.getPartPrice()).orElse(new BigDecimal(0)))
.setCreateBy(loginUser.getUsername());
// 新增维修记录表
repairMapper.addRecord(repairApplyRecord);
}
sfCosts = countPartCosts(partList, sfCosts);
// TODO: 判断是否是收费配件因数据存在多条可能有些是免费配件 有些收费所以这里用价格统一做处理后续讨论
// SQL: 新增维修费用记录表
repairMapper.addRepairCost(repairApplyRecord, sfCosts, sfCosts.equals(new BigDecimal("0")) ? "0" : "1");
}
}
// 处理配件集合数据 -- 数量管理--报废维修
if (CollectionUtil.isNotEmpty(bean.getNumberScrapRepairPartList())) {
// 判断报废数量是否为空
if (bean.getNumberScrapRepairPartList().get(0).getScrapNum() != null && bean.getNumberScrapRepairPartList().get(0).getScrapNum() > 0) {
// 获取维修详情表中的维修详情记录待维修已维修已报废的数量
RepairTaskDetails details = repairMapper.getById(bean.getId());
if (Objects.isNull(details)) {
throw new ServiceException("此维修记录不存在,请检查后提交!");
}
// -------------校验维修数量开始----------------
// 统计历史已报废数量 + 本次报废数量 = 报废总数
int scrapNum = OptionalInt.of(details.getScrapNum()).orElse(0) + bean.getNumberScrapRepairPartList().get(0).getScrapNum();
// 统计 报废总数 + 历史已维修数量,
int num = scrapNum + details.getRepairedNum();
// 不能大与总的待维修数量
if (num > details.getRepairNum()) {
throw new ServiceException("报废数量大于维修总量! 本次报废数量:" + bean.getScrapNum() + ",已报废数量:" + details.getScrapNum() + ",维修总量:" + details.getRepairNum());
}
// -------------校验维修数量结束----------------
// 更新报废数量
repairMapper.updateScrapNum(bean.getId(), scrapNum, loginUser.getUserid());
if (CollectionUtil.isNotEmpty(bean.getNumberScrapRepairPartList().get(0).getFileList())) {
for (BmFileInfo fileInfo : bean.getNumberScrapRepairPartList().get(0).getFileList()) {
fileInfo.setTaskType(TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId())
.setTaskId(bean.getTaskId()).setModelId(bean.getId())
.setCreateBy(loginUser.getUsername());
bmFileInfoMapper.insertBmFileInfo(fileInfo);
// 报废类型无需配件所以配件为空添加维修记录表
// 维修记录表信息
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId())
.setRepairType(scrapRepairType).setStatus(0L).setIsSlt(0L).setPartNum(0)
.setFileIds(fileInfo.getId() == null ? "" : String.valueOf(fileInfo.getId()))
.setRepairNum(0).setScrapNum(bean.getNumberScrapRepairPartList().get(0).getScrapNum())
.setScrapReason(bean.getNumberScrapRepairPartList().get(0).getScrapReason())
.setScrapType(bean.getNumberScrapRepairPartList().get(0).getScrapType())
.setRepairer(loginUser.getUsername()).setCreateBy(loginUser.getUsername());
// 因报废操作无需配件, 只添加维修记录表
repairMapper.addRecord(repairApplyRecord);
}
} else {
// 报废类型无需配件所以配件为空添加维修记录表
// 维修记录表信息
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId())
.setRepairType(scrapRepairType).setStatus(0L).setIsSlt(0L).setPartNum(0)
.setRepairNum(0).setScrapNum(bean.getNumberScrapRepairPartList().get(0).getScrapNum())
.setScrapReason(bean.getNumberScrapRepairPartList().get(0).getScrapReason())
.setScrapType(bean.getNumberScrapRepairPartList().get(0).getScrapType())
.setRepairer(loginUser.getUsername()).setCreateBy(loginUser.getUsername());
// 因报废操作无需配件, 只添加维修记录表
repairMapper.addRecord(repairApplyRecord);
}
}
}
} else {
throw new ServiceException("请选择正确的维修类型");
}
}
int i = repairMapper.updateTaskStatus(taskList, loginUser.getUserid());
return AjaxResult.success("维修完成");
}
/**
* 配件列表价格合计
* @param partList 配件列表
* @param sfCosts 配件价格合计
* @return 配件合计后的价格
*/
private static BigDecimal countPartCosts(List<RepairPartDetails> partList, BigDecimal sfCosts) {
for (RepairPartDetails partDetails : partList) {
if (partDetails.getPartPrice() != null) {
BigDecimal partPrice = partDetails.getPartPrice();
BigDecimal partNumber = new BigDecimal(partDetails.getPartNum());
sfCosts = sfCosts.add(partPrice.multiply(partNumber));
}
}
return sfCosts;
}
/**
* 处理配件集合数据
* @param bean 维修申请单
* @param partList 配件列表
* @param loginUser 当前登录用户
* @param manageType 管理方式0编码管理 1数量管理
*/
private void copeNumberManageInList(RepairDeviceVO bean, List<RepairPartDetails> partList, LoginUser loginUser, Integer manageType) {
if (CollectionUtil.isNotEmpty(partList)) {
if (bean.getManageType() == null) {
throw new ServiceException("请选择物资管理方式");
}
// 如果是数量管理那么默认为内部维修
if (bean.getRepairType() == null && manageType == manageTypeByNumber) {
bean.setRepairType(inRepairType);
}
// 再检查还是null的话直接结束任务
if (bean.getRepairType() == null) {
return;
}
// 内部维修
if (bean.getRepairType() == inRepairType) {
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
// 遍历配件列表判断配件类型收费还是不收费
for (RepairPartDetails partDetails : partList) {
// 维修记录表信息
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId()).setRepairType(inRepairType);
if (manageType == manageTypeByCode) {
repairApplyRecord.setRepairNum(scrapRepairType != bean.getRepairType() ? 1 : 0);
repairApplyRecord.setScrapNum(scrapRepairType == bean.getRepairType() ? 1 : 0);
}
if (manageType == manageTypeByNumber) {
repairApplyRecord.setRepairNum(partDetails.getRepairNum());
}
repairApplyRecord.setCreateBy(loginUser.getUsername());
repairApplyRecord.setStatus(0L);
if (partDetails.getPartId() != null && partDetails.getPartNum() != null) {
// 有维修配件时,如果价格为空设置为0
if (partDetails.getPartCost() == null) {
partDetails.setPartCost(new BigDecimal(0));
}
partDetails.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId()).setCompanyId(null);
partDetails.setCreateBy(String.valueOf(loginUser.getUserid()));
// 根据 partId 找配件单价
BigDecimal partPrice = repairMapper.selectPartPrice(partDetails.getPartId());
// 设置配件单价费用
partDetails.setPartPrice(partPrice);
// 添加维修配件明细表
repairMapper.addPart(partDetails);
// 设置维修记录的配件费用
repairApplyRecord.setId(bean.getId()).setPartPrice(partPrice)
.setPartNum(partDetails.getPartNum())
.setRepairContent(partDetails.getRepairContent())
.setPartType(partDetails.getPartType())
.setPartId(partDetails.getPartId() == null ? 0L : partDetails.getPartId());
// 添加维修记录表
repairMapper.addRecord(repairApplyRecord);
} else {
// 不选维修配件时, 只添加维修记录表
repairMapper.addRecord(repairApplyRecord);
}
}
BigDecimal sfCosts = countPartCosts(partList, new BigDecimal(0));
// TODO: 判断是否是收费配件因数据存在多条可能有些是免费配件 有些收费所以这里用价格统一做处理后续讨论
// SQL: 新增维修费用记录表
repairMapper.addRepairCost(repairApplyRecord, sfCosts, sfCosts.equals(new BigDecimal("0")) ? "0" : "1");
}
// 外部维修
if (bean.getRepairType() == outRepairType) {
// ---------------校验维修数量-----------------
// 统计已维修数量 + 本次维修数量
int repairNum = OptionalInt.of(bean.getRepairedNum()).orElse(0) + bean.getRepairNum();
// 统计报废数量 + 维修合计数量 不能 大与> 总的待维修量
if (repairNum + OptionalInt.of(bean.getScrapNum()).orElse(0) > bean.getRepairNum()) {
throw new ServiceException("维修数量大于维修总量");
}
// 更新维修数量维修人员不变
repairMapper.updateRepairedNumTwo(bean.getId(), repairNum, loginUser.getUserid());
// 编码管理--外部返厂维修
RepairApplyRecord repairApplyRecord = new RepairApplyRecord().setId(bean.getId()).setTaskId(bean.getTaskId()).setMaId(bean.getMaId())
.setTypeId(bean.getTypeId()).setRepairType(outRepairType)
.setPartName(partList.get(0).getPartName())
.setPartType(partList.get(0).getPartType())
.setRepairContent(partList.get(0).getRepairContent()).setPartNum(partList.get(0).getPartNum());
if (partList.get(0).getSupplierId() == null) {
throw new ServiceException("请选择返厂厂家");
}
repairApplyRecord.setSupplierId(partList.get(0).getSupplierId());
repairApplyRecord.setPartPrice(Optional.ofNullable(partList.get(0).getPartPrice()).orElse(new BigDecimal(0)));
// 新增维修记录表
repairMapper.addRecord(repairApplyRecord);
// 配件费用计算
BigDecimal sfCosts = countPartCosts(partList, new BigDecimal(0));
// TODO: 判断是否是收费配件因数据存在多条可能有些是免费配件 有些收费所以这里用价格统一做处理后续讨论
// SQL: 新增维修费用记录表
repairMapper.addRepairCost(repairApplyRecord, sfCosts, sfCosts.equals(new BigDecimal("0")) ? "0" : "1");
}
// 如果是报废类型进行上传附件相关处理
if (scrapRepairType == bean.getRepairType()) {
if (CollectionUtil.isNotEmpty(partList.get(0).getFileList())) {
for (BmFileInfo fileInfo : partList.get(0).getFileList()) {
fileInfo.setTaskType(TmTaskTypeEnum.TM_TASK_REPAIR.getTaskTypeId())
.setTaskId(bean.getTaskId()).setModelId(bean.getId())
.setCreateBy(loginUser.getUsername());
bmFileInfoMapper.insertBmFileInfo(fileInfo);
// 配件为空添加维修记录表
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId())
.setRepairType(bean.getRepairType()).setStatus(0L).setFileIds(String.valueOf(fileInfo.getId()))
.setRepairNum(bean.getRepairType() != scrapRepairType ? 1 : 0)
.setScrapNum(bean.getRepairType() == scrapRepairType ? 1 : 0)
.setCreateBy(loginUser.getUsername());
// 不选维修配件时, 只添加维修记录表
repairMapper.addRecord(repairApplyRecord);
}
} else {
// 配件为空添加维修记录表
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId())
.setRepairType(bean.getRepairType()).setStatus(0L)
.setRepairNum(bean.getRepairType() != scrapRepairType ? 1 : 0)
.setScrapNum(bean.getRepairType() == scrapRepairType ? 1 : 0)
.setCreateBy(loginUser.getUsername());
// 不选维修配件时, 只添加维修记录表
repairMapper.addRecord(repairApplyRecord);
}
}
} else {
// 配件为空添加维修记录表
RepairApplyRecord repairApplyRecord = new RepairApplyRecord();
repairApplyRecord.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId())
.setRepairType(bean.getRepairType()).setStatus(0L)
.setRepairNum(bean.getRepairType() != scrapRepairType ? 1 : 0)
.setScrapNum(bean.getRepairType() == scrapRepairType ? 1 : 0)
.setCreateBy(loginUser.getUsername());
// 不选维修配件时, 只添加维修记录表
repairMapper.addRecord(repairApplyRecord);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult endRepairTask(@NotNull List<RepairTask> taskList) {
LoginUser loginUser = SecurityUtils.getLoginUser();
// 1.查询选择任务是否还有未完成维修的数据
for (RepairTask task : taskList) {
if (repairMapper.getUnFinish(task) > 0) {
return AjaxResult.error("选中的数据中包含维修未完成的,请完成维修再进行提交审核");
}
}
// 2.更新tm_task任务状态
repairMapper.updateTaskStatus(taskList, loginUser.getUserid(), RepairTaskStatusEnum.TASK_STATUS_COMPLETE.getStatus());
// 3.业务逻辑处理
for (RepairTask task : taskList) {
task.setCreateBy(loginUser.getUserid());
// 查询任务的协议id
Long agreementId = repairMapper.getAgreementId(task);
// 查询维修任务的详情表
List<RepairTaskDetails> detailsList = repairMapper.getDetailsListByTaskId(task);
// 新增tm_task表数据修饰审核任务状态是待审核
task.setTaskType(TmTaskTypeEnum.TM_TASK_REPAIR_STORAGE.getTaskTypeId());
task.setTaskStatus(RepairTaskStatusEnum.TASK_STATUS_TO_EXAM.getStatus());
repairMapper.addTask(task);
// 循环插入修饰审核明细表
for (RepairTaskDetails details : detailsList) {
details.setCreateBy(String.valueOf(loginUser.getUserid()));
details.setTaskId(task.getTaskId());
repairMapper.addAuditDetails(details);
}
// 新增协议任务表--关联修饰任务与协议
task.setAgreementId(agreementId);
repairMapper.createAgreementTask(task);
}
return AjaxResult.success();
}
@Override
public AjaxResult rejectRepair(@NotNull List<Long> taskList) {
try {
taskList.forEach(taskId -> taskMapper.updateTmTaskStatusByTaskId(taskId, RepairTaskStatusEnum.TASK_STATUS_REJECT.getStatus()));
} catch (DataAccessException e) {
System.err.println(e.getMessage());
return AjaxResult.error("数据库SQL修改执行失败" + e.getMessage());
}
return AjaxResult.success("执行完成");
}
/**
* 维修明细--批量审核--更新明细status
*/
@Override
public int completeRepair(ArrayList<Long> ids) {
LoginUser loginUser = SecurityUtils.getLoginUser();

View File

@ -474,4 +474,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) t
GROUP BY task_id
</select>
<update id="updateRepairAuditDetailsBatch">
update repair_audit_details
set status = #{status}, update_time = now()
where id in
<foreach item="id" index="index" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</update>
</mapper>

View File

@ -13,7 +13,7 @@
<insert id="addTask" useGeneratedKeys="true" keyProperty="taskId">
insert into tm_task (task_status,task_type,code,create_by,create_time,company_id)
values (46,45,#{repairCode},#{createBy},now(),#{companyId});
values (#{taskStatus},#{taskType},#{repairCode},#{createBy},now(),#{companyId});
</insert>
<insert id="createAgreementTask">
@ -22,13 +22,15 @@
</insert>
<insert id="addAuditDetails">
insert into repair_audit_details (task_id,repair_id,ma_id,type_id,repair_num,repaired_num,scrap_num,status,create_by,create_time,company_id)
values (#{taskId},#{id},#{maId},#{typeId},#{repairNum},#{repairedNum},#{scrapNum},'0',#{createBy},now(),#{companyId});
insert into repair_audit_details (task_id,repair_id,ma_id,type_id,repair_num,repaired_num,scrap_num,status,
create_by,create_time,company_id)
values (#{taskId},#{id},#{maId},#{typeId},#{repairNum},#{repairedNum},#{scrapNum},'0',#{createBy},now(),
#{companyId});
</insert>
<insert id="addRepairCost">
insert into repair_cost (task_id,repair_id,type_id,ma_id,repair_num,costs,part_type,status,company_id)
values (#{bean.taskId},#{bean.id},#{bean.typeId},#{bean.maId},#{bean.repairNum},#{costs},#{partType},'0',#{bean.companyId});
insert into repair_cost (task_id,repair_id,type_id,ma_id,repair_num,costs,part_type,status,repair_type)
values (#{bean.taskId},#{bean.id},#{bean.typeId},#{bean.maId},#{bean.repairNum},#{costs},#{partType},'0',#{bean.repairType});
</insert>
<update id="updateRepairedNum">
@ -61,7 +63,7 @@
<update id="updateTaskStatus">
update tm_task
set task_status = '44',
set task_status = #{taskStatus},
update_by = #{userId},
update_time = now()
where task_id in
@ -197,12 +199,13 @@
tt.create_time DESC
</select>
<select id="getRepairMaTypeList" resultType="com.bonus.material.repair.domain.RepairTaskDetails">
<select id="getRepairMaTypeList" resultType="com.bonus.material.repair.domain.vo.RepairDeviceListVo">
select
rad.id as id,
rad.task_id as taskId,
rad.ma_id as maId,
mt2.type_name as typeName,
mt2.type_id as typeNameId,
mt.type_name as type,
mt.unit_name as unitName,
mt.manage_type as manageType,