在库在用设备维保

This commit is contained in:
hongchao 2025-08-08 10:29:07 +08:00
parent 35a42eb301
commit f330f9be11
11 changed files with 1383 additions and 44 deletions

View File

@ -0,0 +1,125 @@
package com.bonus.sgzb.material.controller;
import com.alibaba.fastjson.JSONObject;
import com.bonus.sgzb.base.domain.RepairApplyRecord;
import com.bonus.sgzb.base.domain.RepairPartDetails;
import com.bonus.sgzb.base.domain.RepairTask;
import com.bonus.sgzb.base.domain.RepairTaskDetails;
import com.bonus.sgzb.base.domain.vo.DictVo;
import com.bonus.sgzb.base.service.RepairService;
import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
import com.bonus.sgzb.common.log.annotation.Log;
import com.bonus.sgzb.common.log.enums.BusinessType;
import com.bonus.sgzb.common.security.annotation.RequiresPermissions;
import com.bonus.sgzb.material.domain.*;
import com.bonus.sgzb.material.service.EquipmentToRepairService;
import com.bonus.sgzb.material.vo.RepairAuditDetailsNew;
import com.bonus.sgzb.system.api.domain.SysUser;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author c liu
* @date 2023/12/11
*/
@RestController
@RequestMapping("/equipmentToRepair")
public class EquipmentToRepairController extends BaseController {
@Autowired
private EquipmentToRepairService service;
/**
* 获取设备编号在库下拉
*/
@GetMapping("/getMaCodeSelect")
public AjaxResult getMaCodeSelect(equipmentMaCodeInfo info)
{
List<equipmentMaCodeInfo> list = service.getMaCodeSelect(info);
return AjaxResult.success(list);
}
/**
* 获取维保任务列表
*/
@ApiOperation(value = "获取维保任务列表")
@Log(title = "维修任务列表", businessType = BusinessType.QUERY)
@GetMapping("/getEquipmentList")
// @RequiresPermissions(value = "repair:manage:list")
public TableDataInfo getEquipmentList(EquipmentTask bean)
{
startPage();
List<EquipmentTask> list = service.getEquipmentList(bean);
return getDataTable(list);
}
/**
* 新增维保记录
*/
@ApiOperation(value = "新增维保记录")
@Log(title = "新增维保记录", businessType = BusinessType.INSERT)
@PostMapping("/submitEquipment")
public AjaxResult submitEquipment(@RequestBody EquipmentRecord bean) {
String partStrList = bean.getPartStrList();
List<EquipmentPartDetails> equipmentPartDetails = JSONObject.parseArray(partStrList, EquipmentPartDetails.class);
bean.setPartList(equipmentPartDetails);
AjaxResult ajaxResult = service.submitEquipment(bean);
return ajaxResult;
}
@ApiOperation("获取维保详细信息")
@GetMapping("/getEquipmentInfo")
public AjaxResult getEquipmentInfo(EquipmentRecord bean) {
EquipmentRecord vo = service.getEquipmentInfo(bean);
return AjaxResult.success(vo);
}
/**
* 编辑维保
*/
@ApiOperation(value = "编辑维保")
@Log(title = "编辑维保", businessType = BusinessType.INSERT)
@PostMapping("/editEquipmentInfo")
public AjaxResult editEquipmentInfo(@RequestBody EquipmentRecord bean) {
String partStrList = bean.getPartStrList();
List<EquipmentPartDetails> repairPartDetails = JSONObject.parseArray(partStrList, EquipmentPartDetails.class);
bean.setPartList(repairPartDetails);
AjaxResult ajaxResult = service.editEquipmentInfo(bean);
return ajaxResult;
}
/**
* 提交维保记录
*/
@ApiOperation(value = "提交维保记录")
@Log(title = "提交维保记录", businessType = BusinessType.INSERT)
@PostMapping("/submitStatusNew")
public AjaxResult submitStatusNew(@RequestBody EquipmentRecord bean) {
AjaxResult ajaxResult = service.submitStatusNew(bean);
return ajaxResult;
}
/**
* 查看保养记录表
*/
@ApiOperation("查看保养记录表")
@GetMapping("/getMaintenanceEquipment")
// @RequiresPermissions("service:auditing:list")
public AjaxResult getMaintenanceEquipment(EquipmentRecord bean) {
EquipmentRecord vo = service.getMaintenanceEquipment(bean);
return AjaxResult.success(vo);
}
}

View File

@ -4,10 +4,7 @@ import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.material.domain.SelectDto;
import com.bonus.sgzb.material.service.SelectService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -122,6 +119,12 @@ public class SelectController {
return service.getDeviceTypeTree(dto);
}
@ApiOperation(value = "设备类型树")
@GetMapping("getDeviceTypeTreeTwo")
public AjaxResult getDeviceTypeTreeTwo(SelectDto dto){
return service.getDeviceTypeTree(dto);
}
@ApiOperation(value = "资产属性")
@PostMapping("getAssetAttributesCbx")
public AjaxResult getAssetAttributesCbx(@RequestBody SelectDto dto){

View File

@ -0,0 +1,113 @@
package com.bonus.sgzb.material.domain;
import com.bonus.sgzb.base.api.domain.FileInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* @author c liu
* @date 2023/12/11
*/
@Data
@ApiModel(value="维修配件")
public class EquipmentPartDetails {
private Long id;
private long parentId;
/**
* 机具ID
*/
@ApiModelProperty(value = "机具ID")
private String maId;
/**
* 规格ID
*/
@ApiModelProperty(value = "规格ID")
private String typeId;
/**
* 配件ID
*/
@ApiModelProperty(value = "配件ID")
private Long partId;
/**
* 配件名称
*/
@ApiModelProperty(value = "配件名称")
private String partName;
/**
* 配件数量
*/
@ApiModelProperty(value = "配件数量")
private Integer partNum;
/**
* 配件费用
*/
@ApiModelProperty(value = "配件费用")
private BigDecimal partCost;
/**
* 配件单价
*/
@ApiModelProperty(value = "配件单价")
private BigDecimal partPrice;
/**
* 类型0不收费1收费
*/
@ApiModelProperty(value = "类型0不收费1收费")
private String partType;
/**
* 创建者
*/
@ApiModelProperty(value = "创建者")
private Long createBy;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private String createTime;
/**
* 更新者
*/
@ApiModelProperty(value = "更新者")
private String updateBy;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private String updateTime;
@ApiModelProperty(value = "技术鉴定")
private String repairRemark;
/**
* 维修处理情况
*/
@ApiModelProperty(value = "维修处理情况")
private String repairContent;
/**
* 维修前情况
*/
@ApiModelProperty(value = "维修前情况")
private String repairContentBefore;
private Long companyId;
private Long repairer;
private List<FileInfo> fileList;
@ApiModelProperty(value = "维修数量")
private Integer repairNum;
private String partChange;
private Integer partChangeNum;
}

View File

@ -0,0 +1,139 @@
package com.bonus.sgzb.material.domain;
import com.bonus.sgzb.base.api.domain.FileInfo;
import com.bonus.sgzb.base.domain.RepairPartDetails;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
* @author c liu
* @date 2023/12/11
*/
@Data
@ApiModel(value="维保任务详细")
public class EquipmentRecord implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
/**
* 机具ID
*/
@ApiModelProperty(value = "机具ID")
private String maId;
/**
* 规格ID
*/
@ApiModelProperty(value = "规格ID")
private String typeId;
private String typeName;
private String typeModelName;
private String maCode;
/**
* 维修数量
*/
@ApiModelProperty(value = "维修数量")
private Integer repairNum;
/**
* 创建者
*/
@ApiModelProperty(value = "创建者")
private Long createBy;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private String createTime;
/**
* 更新者
*/
@ApiModelProperty(value = "更新者")
private String updateBy;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private String updateTime;
/**
* 配件数量
*/
@ApiModelProperty(value = "配件数量")
private Integer partNum;
/**
* 配件单价
*/
@ApiModelProperty(value = "配件单价")
private BigDecimal partPrice;
/**
* 维修处理情况
*/
@ApiModelProperty(value = "维修处理情况")
private String repairContent;
/**
* 维修前情况
*/
@ApiModelProperty(value = "维修前情况")
private String repairContentBefore;
/**
* 类型0不收费1收费
*/
@ApiModelProperty(value = "类型0不收费1收费")
private String partType;
/**
* 配件名称
*/
@ApiModelProperty(value = "配件名称")
private String partName;
private String repairRemark;
/**
* 维修人
*/
@ApiModelProperty(value = "维修人")
private Long repairer;
private List<EquipmentPartDetails> partList;
private String partStrList;
private Long companyId;
private Integer partId;
/**
* 损坏照片id
*/
@ApiModelProperty(value = "损坏照片id")
private String fileIds;
private List<FileInfo> fileList;
private int manageType;
private String partChange;
private Integer partChangeNum;
private int parentId;
/**
* 维保状态
*/
@ApiModelProperty(value = "维保状态")
private Integer repairStatus;
@ApiModelProperty(value = "维修时间")
private String repairTime;
private long[] ids;
private String auditBy;
private String repairerName;
}

View File

@ -0,0 +1,127 @@
package com.bonus.sgzb.material.domain;
import com.bonus.sgzb.common.core.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author c liu
* @date 2023/12/11
*/
@Data
@ApiModel(value="维保任务")
public class EquipmentTask {
private long id;
/**
* 设备编号
*/
@ApiModelProperty(value = "设备编号")
private Long maId;
/**
* 编码
*/
@ApiModelProperty(value = "编码")
private String maCode;
/**
* 任务创建人
*/
@ApiModelProperty(value = "任务创建人")
private Long createBy;
/**
* 任务创建时间
*/
@ApiModelProperty(value = "任务创建时间")
private String createTime;
/**
* 维保时间
*/
@ApiModelProperty(value = "维保时间")
private String repairTime;
/**
* 维保状态
*/
@ApiModelProperty(value = "维保状态")
private Integer repairStatus;
/**
* 关键字
*/
private String keyword;
/**
* 开始时间
*/
private String startTime;
/**
* 结束时间
*/
private String endTime;
private Long companyId;
private Long agreementId;
/**
* 维修机具类型
*/
@ApiModelProperty(value = "维修规格型号")
@Excel(name = "维修规格型号",sort = 1)
private String typeModelName;
/**
* 规格型号
*/
@ApiModelProperty(value = "维修机具类型")
@Excel(name = "维修机具类型",sort = 2)
private String typeName;
/**
* 维修总量
*/
@ApiModelProperty(value = "维修总量")
@Excel(name = "维修总量",sort = 3)
private int repairNum;
/**
* 维修人员
*/
@ApiModelProperty(value = "维修人员")
private String repairer;
//类型ID
private Long typeId;
/**
* 技术鉴定
*/
@ApiModelProperty(value = "技术鉴定")
private String repairRemark;
/**
* 维修处理情况
*/
@ApiModelProperty(value = "维修处理情况")
private String repairContent;
/**
* 维修前情况
*/
@ApiModelProperty(value = "维修前情况")
private String repairContentBefore;
private int manageType;
/** 用户ID */
@ApiModelProperty(value = "userId")
private Long userId;
}

View File

@ -0,0 +1,31 @@
package com.bonus.sgzb.material.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author c liu
* @date 2023/12/11
*/
@Data
@ApiModel(value="设备编号")
public class equipmentMaCodeInfo {
/** 规格ID */
@ApiModelProperty(value = "规格ID")
private Long typeId;
@ApiModelProperty(value = "机具ID")
private Long maId;
@ApiModelProperty(value = "设备编码")
private String maCode;
@ApiModelProperty(value = "库存数量")
private BigDecimal storageNum;
@ApiModelProperty(value = "设备状态")
private Integer maStatus;
}

View File

@ -0,0 +1,51 @@
package com.bonus.sgzb.material.mapper;
import com.bonus.sgzb.base.api.domain.FileInfo;
import com.bonus.sgzb.base.domain.RepairApplyRecord;
import com.bonus.sgzb.base.domain.RepairPartDetails;
import com.bonus.sgzb.base.domain.RepairTask;
import com.bonus.sgzb.base.domain.RepairTaskDetails;
import com.bonus.sgzb.base.domain.vo.DictVo;
import com.bonus.sgzb.material.domain.*;
import com.bonus.sgzb.system.api.domain.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* @author c liu
* @date 2023/12/11
*/
@Mapper
public interface EquipmentToRepairMapper {
/**
* 获取设备编号在库下拉
* @return
*/
List<equipmentMaCodeInfo> getMaCodeSelect(equipmentMaCodeInfo info);
List<EquipmentTask> getEquipmentList(EquipmentTask bean);
int addEquipmentNew(EquipmentRecord beanTemp);
int addEquipmentDetailsNew(EquipmentPartDetails beanTempTwo);
EquipmentRecord getEquipmentInfo(EquipmentRecord bean);
List<EquipmentPartDetails> getPartList(EquipmentRecord record);
List<FileInfo> getFileEquipmentList(Long id);
void deleteEquipmentDetails(EquipmentRecord record);
void deleteFileEquipmentList(EquipmentRecord record);
int editEquipmentNew(EquipmentRecord beanTemp);
int submitStatusNew(long id);
EquipmentRecord getMaintenanceEquipment(EquipmentRecord bean);
}

View File

@ -0,0 +1,42 @@
package com.bonus.sgzb.material.service;
import com.bonus.sgzb.base.domain.RepairApplyRecord;
import com.bonus.sgzb.base.domain.RepairPartDetails;
import com.bonus.sgzb.base.domain.RepairTask;
import com.bonus.sgzb.base.domain.RepairTaskDetails;
import com.bonus.sgzb.base.domain.vo.DictVo;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.material.domain.EquipmentRecord;
import com.bonus.sgzb.material.domain.EquipmentTask;
import com.bonus.sgzb.material.domain.equipmentMaCodeInfo;
import com.bonus.sgzb.system.api.domain.SysUser;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* @author c liu
* @date 2023/12/11
*/
public interface EquipmentToRepairService {
/**
* 获取设备编号在库下拉
* @return
*/
List<equipmentMaCodeInfo> getMaCodeSelect(equipmentMaCodeInfo info);
List<EquipmentTask> getEquipmentList(EquipmentTask bean);
AjaxResult submitEquipment(EquipmentRecord bean);
EquipmentRecord getEquipmentInfo(EquipmentRecord bean);
AjaxResult editEquipmentInfo(EquipmentRecord bean);
AjaxResult submitStatusNew(EquipmentRecord bean);
EquipmentRecord getMaintenanceEquipment(EquipmentRecord bean);
}

View File

@ -0,0 +1,478 @@
package com.bonus.sgzb.material.service.impl;
import com.bonus.sgzb.app.mapper.BackReceiveMapper;
import com.bonus.sgzb.base.api.domain.FileInfo;
import com.bonus.sgzb.base.domain.RepairApplyRecord;
import com.bonus.sgzb.base.domain.RepairPartDetails;
import com.bonus.sgzb.base.domain.RepairTask;
import com.bonus.sgzb.base.domain.RepairTaskDetails;
import com.bonus.sgzb.base.mapper.RepairMapper;
import com.bonus.sgzb.base.service.RepairService;
import com.bonus.sgzb.common.core.exception.ServiceException;
import com.bonus.sgzb.common.core.utils.DateUtils;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.security.utils.SecurityUtils;
import com.bonus.sgzb.material.domain.*;
import com.bonus.sgzb.material.mapper.EquipmentToRepairMapper;
import com.bonus.sgzb.material.mapper.TaskMapper;
import com.bonus.sgzb.material.service.EquipmentToRepairService;
import com.bonus.sgzb.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
/**
* @author c liu
* @date 2023/12/11
*/
@Service("EquipmentToRepairService")
public class EquipmentToRepairServiceImpl implements EquipmentToRepairService {
@Autowired
private EquipmentToRepairMapper mapper;
@Autowired
private BackReceiveMapper backReceiveMapper;
private final static String STRING_ADMIN = "admin";
@Override
public List<equipmentMaCodeInfo> getMaCodeSelect(equipmentMaCodeInfo info) {
return mapper.getMaCodeSelect(info);
}
@Override
public List<EquipmentTask> getEquipmentList(EquipmentTask bean) {
Set<String> roles = SecurityUtils.getLoginUser().getRoles();
List<EquipmentTask> equipmentTaskList = new ArrayList<>();
if (roles.contains(STRING_ADMIN) || roles.contains("sysadmin")) {
equipmentTaskList = mapper.getEquipmentList(bean);
}else{
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
bean.setCompanyId(companyId);
bean.setUserId(SecurityUtils.getLoginUser().getUserid());
equipmentTaskList = mapper.getEquipmentList(bean);
}
return equipmentTaskList;
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult submitEquipment(EquipmentRecord bean) {
LoginUser loginUser = SecurityUtils.getLoginUser();
bean.setUpdateBy(loginUser.getUserid().toString());
bean.setCreateBy(loginUser.getUserid());
List<EquipmentPartDetails> partList = bean.getPartList();
if (partList != null && partList.size() > 0) {
if (partList.get(0).getRepairNum() == null){
throw new ServiceException("请输入维修数量");
}
bean.setRepairNum(partList.get(0).getRepairNum());
bean.setRepairer(partList.get(0).getRepairer());
if (partList.get(0).getUpdateTime() == null) {
// 获取当前时间并格式化为 "yyyy-MM-dd HH:mm:ss"
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
bean.setUpdateTime(sdf.format(new Date()));
} else {
// 如果已有日期但无时分秒补上 "00:00:00"
bean.setUpdateTime(partList.get(0).getUpdateTime() + " 00:00:00");
}
}else{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
bean.setUpdateTime(sdf.format(new Date()));
}
//如果是编码维修
if(bean.getManageType()==0){ //编码管理
//插入到equipment_record表
EquipmentRecord beanTemp = new EquipmentRecord();
beanTemp.setTypeId(bean.getTypeId());
beanTemp.setMaId(bean.getMaId());
beanTemp.setRepairNum(1);
beanTemp.setRepairStatus(0);
beanTemp.setCreateBy(bean.getRepairer());
beanTemp.setRepairer(bean.getRepairer());
beanTemp.setRepairTime(bean.getUpdateTime());
mapper.addEquipmentNew(beanTemp);
//插入到details表
if (partList != null && partList.size() > 0) {
for (EquipmentPartDetails partDetails : partList) {
if (partDetails.getPartId() != null) {
// 有维修配件时
if (partDetails.getPartCost() == null) {
partDetails.setPartCost(new BigDecimal(0));
}
partDetails.setMaId(bean.getMaId());
partDetails.setTypeId(bean.getTypeId());
partDetails.setCreateBy(loginUser.getUserid());
EquipmentPartDetails beanTempTwo = new EquipmentPartDetails();
beanTempTwo.setTypeId(bean.getTypeId());
beanTempTwo.setMaId(bean.getMaId());
beanTempTwo.setParentId(beanTemp.getId());
beanTempTwo.setPartId(partDetails.getPartId());
beanTempTwo.setPartPrice(partDetails.getPartCost());
beanTempTwo.setPartNum(partDetails.getPartNum());
beanTempTwo.setRepairContent(partDetails.getRepairContent());
beanTempTwo.setRepairContentBefore(partDetails.getRepairContentBefore());
beanTempTwo.setRepairRemark(partDetails.getRepairRemark());
beanTempTwo.setPartChange(partDetails.getPartChange());
beanTempTwo.setPartChangeNum(partDetails.getPartChangeNum());
beanTempTwo.setCreateBy(loginUser.getUserid());
mapper.addEquipmentDetailsNew(beanTempTwo);
//文件上传新增
if (partDetails.getFileList() != null){
for (FileInfo fileInfo : partDetails.getFileList()) {
fileInfo.setModelId(beanTempTwo.getId());
fileInfo.setTypeId(Integer.parseInt(bean.getTypeId()));
if (bean.getMaId() != null){
fileInfo.setMaId(Integer.parseInt(bean.getMaId()));
}
fileInfo.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
fileInfo.setCreateTime(DateUtils.getNowDate());
fileInfo.setRepairStatus(2);
backReceiveMapper.insertBmFileInfo(fileInfo);
}
}
}else{
partDetails.setMaId(bean.getMaId());
partDetails.setTypeId(bean.getTypeId());
partDetails.setCreateBy(loginUser.getUserid());
EquipmentPartDetails beanTempTwo = new EquipmentPartDetails();
beanTempTwo.setTypeId(bean.getTypeId());
beanTempTwo.setParentId(beanTemp.getId());
beanTempTwo.setPartId(null);
beanTempTwo.setPartPrice(null);
beanTempTwo.setPartNum(null);
beanTempTwo.setRepairContent(partDetails.getRepairContent());
beanTempTwo.setRepairContentBefore(partDetails.getRepairContentBefore());
beanTempTwo.setRepairRemark(partDetails.getRepairRemark());
beanTempTwo.setPartChange(null);
beanTempTwo.setPartChangeNum(null);
beanTempTwo.setCreateBy(loginUser.getUserid());
mapper.addEquipmentDetailsNew(beanTempTwo);
}
}
}
}else{ //数量管理
//插入到equipment_record表
EquipmentRecord beanTemp = new EquipmentRecord();
beanTemp.setTypeId(bean.getTypeId());
beanTemp.setRepairNum(bean.getRepairNum());
beanTemp.setRepairStatus(0);
beanTemp.setCreateBy(bean.getRepairer());
beanTemp.setRepairer(bean.getRepairer());
beanTemp.setRepairTime(bean.getUpdateTime());
mapper.addEquipmentNew(beanTemp);
//插入到details表
if (partList != null && partList.size() > 0) {
for (EquipmentPartDetails partDetails : partList) {
if (partDetails.getPartId() != null) {
// 有维修配件时
if (partDetails.getPartCost() == null) {
partDetails.setPartCost(new BigDecimal(0));
}
partDetails.setMaId(bean.getMaId());
partDetails.setTypeId(bean.getTypeId());
partDetails.setCreateBy(loginUser.getUserid());
EquipmentPartDetails beanTempTwo = new EquipmentPartDetails();
beanTempTwo.setTypeId(bean.getTypeId());
beanTempTwo.setParentId(beanTemp.getId());
beanTempTwo.setPartId(partDetails.getPartId());
beanTempTwo.setPartPrice(partDetails.getPartCost());
beanTempTwo.setPartNum(partDetails.getPartNum());
beanTempTwo.setRepairContent(partDetails.getRepairContent());
beanTempTwo.setRepairContentBefore(partDetails.getRepairContentBefore());
beanTempTwo.setRepairRemark(partDetails.getRepairRemark());
beanTempTwo.setPartChange(partDetails.getPartChange());
beanTempTwo.setPartChangeNum(partDetails.getPartChangeNum());
beanTempTwo.setCreateBy(loginUser.getUserid());
mapper.addEquipmentDetailsNew(beanTempTwo);
//文件上传新增
if (partDetails.getFileList() != null){
for (FileInfo fileInfo : partDetails.getFileList()) {
fileInfo.setModelId(beanTempTwo.getId());
fileInfo.setTypeId(Integer.parseInt(bean.getTypeId()));
if (bean.getMaId() != null){
fileInfo.setMaId(Integer.parseInt(bean.getMaId()));
}
fileInfo.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
fileInfo.setCreateTime(DateUtils.getNowDate());
fileInfo.setRepairStatus(2);
backReceiveMapper.insertBmFileInfo(fileInfo);
}
}
}else{
partDetails.setMaId(bean.getMaId());
partDetails.setTypeId(bean.getTypeId());
partDetails.setCreateBy(loginUser.getUserid());
EquipmentPartDetails beanTempTwo = new EquipmentPartDetails();
beanTempTwo.setTypeId(bean.getTypeId());
beanTempTwo.setParentId(beanTemp.getId());
beanTempTwo.setPartId(null);
beanTempTwo.setPartPrice(null);
beanTempTwo.setPartNum(null);
beanTempTwo.setRepairContent(partDetails.getRepairContent());
beanTempTwo.setRepairContentBefore(partDetails.getRepairContentBefore());
beanTempTwo.setRepairRemark(partDetails.getRepairRemark());
beanTempTwo.setPartChange(null);
beanTempTwo.setPartChangeNum(null);
beanTempTwo.setCreateBy(loginUser.getUserid());
mapper.addEquipmentDetailsNew(beanTempTwo);
}
}
}
}
return AjaxResult.success();
}
@Override
public EquipmentRecord getEquipmentInfo(EquipmentRecord bean) {
//获取维保信息
EquipmentRecord record = mapper.getEquipmentInfo(bean);
//获取配件信息
if(record != null){
List<EquipmentPartDetails> partList = mapper.getPartList(record);
if(partList != null){
for(int i=0; i<partList.size(); i++){
EquipmentPartDetails partDetails = partList.get(i);
if(i == 0){
partDetails.setRepairer(record.getRepairer());
partDetails.setRepairNum(record.getRepairNum());
partDetails.setUpdateTime(record.getRepairTime());
}
List<FileInfo> fileList = mapper.getFileEquipmentList(partDetails.getId());
partDetails.setFileList(fileList);
}
record.setPartList(partList);
}
}
return record;
}
@Override
public AjaxResult editEquipmentInfo(EquipmentRecord bean) {
//删除之前的配件和文件数据
EquipmentRecord record = mapper.getEquipmentInfo(bean);
if (record != null) {
//删除repair_equipment_details表
mapper.deleteEquipmentDetails(record);
//删除sys_file_info表
mapper.deleteFileEquipmentList(record);
}
LoginUser loginUser = SecurityUtils.getLoginUser();
bean.setUpdateBy(loginUser.getUserid().toString());
bean.setCreateBy(loginUser.getUserid());
List<EquipmentPartDetails> partList = bean.getPartList();
if (partList != null && partList.size() > 0) {
if (partList.get(0).getRepairNum() == null) {
throw new ServiceException("请输入维修数量");
}
bean.setRepairNum(partList.get(0).getRepairNum());
bean.setRepairer(partList.get(0).getRepairer());
if (partList.get(0).getUpdateTime() == null) {
// 获取当前时间并格式化为 "yyyy-MM-dd HH:mm:ss"
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
bean.setUpdateTime(sdf.format(new Date()));
} else {
// 如果已有日期但无时分秒补上 "00:00:00"
bean.setUpdateTime(partList.get(0).getUpdateTime() + " 00:00:00");
}
} else {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
bean.setUpdateTime(sdf.format(new Date()));
}
//如果是编码维修
if (bean.getManageType() == 0) { //编码管理
//插入到equipment_record表
EquipmentRecord beanTemp = new EquipmentRecord();
beanTemp.setId(bean.getId());
beanTemp.setTypeId(bean.getTypeId());
beanTemp.setMaId(bean.getMaId());
beanTemp.setRepairNum(1);
beanTemp.setRepairStatus(0);
beanTemp.setCreateBy(bean.getRepairer());
beanTemp.setRepairer(bean.getRepairer());
beanTemp.setRepairTime(bean.getUpdateTime());
mapper.editEquipmentNew(beanTemp);
//插入到details表
if (partList != null && partList.size() > 0) {
for (EquipmentPartDetails partDetails : partList) {
if (partDetails.getPartId() != null) {
// 有维修配件时
if (partDetails.getPartCost() == null) {
partDetails.setPartCost(new BigDecimal(0));
}
partDetails.setMaId(bean.getMaId());
partDetails.setTypeId(bean.getTypeId());
partDetails.setCreateBy(loginUser.getUserid());
EquipmentPartDetails beanTempTwo = new EquipmentPartDetails();
beanTempTwo.setTypeId(bean.getTypeId());
beanTempTwo.setParentId(beanTemp.getId());
beanTempTwo.setPartId(partDetails.getPartId());
beanTempTwo.setPartPrice(partDetails.getPartCost());
beanTempTwo.setPartNum(partDetails.getPartNum());
beanTempTwo.setRepairContent(partDetails.getRepairContent());
beanTempTwo.setRepairContentBefore(partDetails.getRepairContentBefore());
beanTempTwo.setRepairRemark(partDetails.getRepairRemark());
beanTempTwo.setPartChange(partDetails.getPartChange());
beanTempTwo.setPartChangeNum(partDetails.getPartChangeNum());
beanTempTwo.setCreateBy(loginUser.getUserid());
mapper.addEquipmentDetailsNew(beanTempTwo);
//文件上传新增
if (partDetails.getFileList() != null) {
for (FileInfo fileInfo : partDetails.getFileList()) {
fileInfo.setModelId(beanTempTwo.getId());
fileInfo.setTypeId(Integer.parseInt(bean.getTypeId()));
if (bean.getMaId() != null) {
fileInfo.setMaId(Integer.parseInt(bean.getMaId()));
}
fileInfo.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
fileInfo.setCreateTime(DateUtils.getNowDate());
fileInfo.setRepairStatus(2);
backReceiveMapper.insertBmFileInfo(fileInfo);
}
}
} else {
partDetails.setMaId(bean.getMaId());
partDetails.setTypeId(bean.getTypeId());
partDetails.setCreateBy(loginUser.getUserid());
EquipmentPartDetails beanTempTwo = new EquipmentPartDetails();
beanTempTwo.setTypeId(bean.getTypeId());
beanTempTwo.setParentId(beanTemp.getId());
beanTempTwo.setPartId(null);
beanTempTwo.setPartPrice(null);
beanTempTwo.setPartNum(null);
beanTempTwo.setRepairContent(partDetails.getRepairContent());
beanTempTwo.setRepairContentBefore(partDetails.getRepairContentBefore());
beanTempTwo.setRepairRemark(partDetails.getRepairRemark());
beanTempTwo.setPartChange(null);
beanTempTwo.setPartChangeNum(null);
beanTempTwo.setCreateBy(loginUser.getUserid());
mapper.addEquipmentDetailsNew(beanTempTwo);
}
}
}
} else { //数量管理
//插入到equipment_record表
EquipmentRecord beanTemp = new EquipmentRecord();
beanTemp.setId(bean.getId());
beanTemp.setTypeId(bean.getTypeId());
beanTemp.setRepairNum(bean.getRepairNum());
beanTemp.setRepairStatus(0);
beanTemp.setCreateBy(bean.getRepairer());
beanTemp.setRepairer(bean.getRepairer());
beanTemp.setRepairTime(bean.getUpdateTime());
mapper.editEquipmentNew(beanTemp);
//插入到details表
if (partList != null && partList.size() > 0) {
for (EquipmentPartDetails partDetails : partList) {
if (partDetails.getPartId() != null) {
// 有维修配件时
if (partDetails.getPartCost() == null) {
partDetails.setPartCost(new BigDecimal(0));
}
partDetails.setMaId(bean.getMaId());
partDetails.setTypeId(bean.getTypeId());
partDetails.setCreateBy(loginUser.getUserid());
EquipmentPartDetails beanTempTwo = new EquipmentPartDetails();
beanTempTwo.setTypeId(bean.getTypeId());
beanTempTwo.setParentId(beanTemp.getId());
beanTempTwo.setPartId(partDetails.getPartId());
beanTempTwo.setPartPrice(partDetails.getPartCost());
beanTempTwo.setPartNum(partDetails.getPartNum());
beanTempTwo.setRepairContent(partDetails.getRepairContent());
beanTempTwo.setRepairContentBefore(partDetails.getRepairContentBefore());
beanTempTwo.setRepairRemark(partDetails.getRepairRemark());
beanTempTwo.setPartChange(partDetails.getPartChange());
beanTempTwo.setPartChangeNum(partDetails.getPartChangeNum());
beanTempTwo.setCreateBy(loginUser.getUserid());
mapper.addEquipmentDetailsNew(beanTempTwo);
//文件上传新增
if (partDetails.getFileList() != null) {
for (FileInfo fileInfo : partDetails.getFileList()) {
fileInfo.setModelId(beanTempTwo.getId());
fileInfo.setTypeId(Integer.parseInt(bean.getTypeId()));
if (bean.getMaId() != null) {
fileInfo.setMaId(Integer.parseInt(bean.getMaId()));
}
fileInfo.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
fileInfo.setCreateTime(DateUtils.getNowDate());
fileInfo.setRepairStatus(2);
backReceiveMapper.insertBmFileInfo(fileInfo);
}
}
} else {
partDetails.setMaId(bean.getMaId());
partDetails.setTypeId(bean.getTypeId());
partDetails.setCreateBy(loginUser.getUserid());
EquipmentPartDetails beanTempTwo = new EquipmentPartDetails();
beanTempTwo.setTypeId(bean.getTypeId());
beanTempTwo.setParentId(beanTemp.getId());
beanTempTwo.setPartId(null);
beanTempTwo.setPartPrice(null);
beanTempTwo.setPartNum(null);
beanTempTwo.setRepairContent(partDetails.getRepairContent());
beanTempTwo.setRepairContentBefore(partDetails.getRepairContentBefore());
beanTempTwo.setRepairRemark(partDetails.getRepairRemark());
beanTempTwo.setPartChange(null);
beanTempTwo.setPartChangeNum(null);
beanTempTwo.setCreateBy(loginUser.getUserid());
mapper.addEquipmentDetailsNew(beanTempTwo);
}
}
}
}
return AjaxResult.success();
}
@Override
public AjaxResult submitStatusNew(EquipmentRecord bean) {
if(bean.getIds()!=null){
for (long id : bean.getIds()) {
int count = mapper.submitStatusNew(id);
if(count<=0){
return AjaxResult.error("提交失败");
}
}
}
return AjaxResult.success();
}
@Override
public EquipmentRecord getMaintenanceEquipment(EquipmentRecord bean) {
return mapper.getMaintenanceEquipment(bean);
}
}

View File

@ -272,22 +272,28 @@
<select id="getRepairTaskListNew" resultType="com.bonus.sgzb.base.domain.RepairTask">
select
mt.type_id as typeId,
sub.typeId,
mt2.type_name as type,
mt.type_name as typeName,
sum(rd.repair_num) as repairNum,
sum(rd.repaired_num + rd.scrap_num) as repairFinishNum,
sum(rd.repair_num) - sum(rd.repaired_num + rd.scrap_num) as repairNotFinishNum,
GROUP_CONCAT(DISTINCT rd.repair_remark SEPARATOR ',') as repairRemark,
sub.repairNum,
sub.repairFinishNum,
sub.repairNotFinishNum,
sub.repairRemark,
mt.manage_type as manageType,
IF(ras.type_id IS NOT NULL, 1, 0) as submitStatus,
ras.repair_type as repairType
from (
select
mt.type_id as typeId,
sum(rd.repair_num) as repairNum,
sum(rd.repaired_num + rd.scrap_num) as repairFinishNum,
sum(rd.repair_num) - sum(rd.repaired_num + rd.scrap_num) as repairNotFinishNum,
GROUP_CONCAT(DISTINCT rd.repair_remark SEPARATOR ',') as repairRemark
from
repair_apply_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 ma_type_repair mtr on mtr.type_id = rd.type_id
LEFT JOIN repair_apply_record_save ras ON rd.type_id = ras.type_id
where 1=1
<if test="type != null and type != ''">
AND mt.type_name like concat('%',#{type},'%')
@ -298,11 +304,13 @@
<if test="userId != null and userId != ''">
and mtr.user_id = #{userId}
</if>
<!-- <if test="companyId != null and companyId != ''">-->
<!-- and rd.company_id = #{companyId}-->
<!-- </if>-->
group by mt.type_id
order by mt.type_id
) sub
LEFT JOIN ma_type mt on sub.typeId = mt.type_id
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
LEFT JOIN repair_apply_record_save ras ON sub.typeId = ras.type_id
group by sub.typeId
order by sub.typeId
</select>
<select id="exportRepairTaskList" resultType="com.bonus.sgzb.base.domain.RepairTask">
@ -399,9 +407,9 @@
<if test="userId != null and userId != ''">
and mtr.user_id = #{userId}
</if>
<if test="companyId != null and companyId != ''">
and rad.company_id = #{companyId}
</if>
<!-- <if test="companyId != null and companyId != ''">-->
<!-- and rad.company_id = #{companyId}-->
<!-- </if>-->
<if test="keyword != null and keyword != ''">
AND (locate(#{keyword}, mm.ma_code) > 0
or locate(#{keyword}, su.nick_name) > 0
@ -409,10 +417,10 @@
or locate(#{keyword}, mt.type_name) > 0)
</if>
<if test="type != null and type != ''">
AND mt.type_id = #{type}
AND mt.type_name = #{type}
</if>
<if test="typeName != null and typeName != ''">
AND mt2.type_id = #{typeName}
AND mt2.type_name = #{typeName}
</if>
order by rad.create_time desc
</select>
@ -452,42 +460,62 @@
</select>
<select id="getRepairNew" resultType="com.bonus.sgzb.base.domain.RepairTaskDetails">
select rad.id as id,
rad.task_id as taskId,
rad.ma_id as maId,
select
sub.id as id,
sub.taskId as taskId,
sub.maId as maId,
mt2.type_name as typeName,
mt.type_name as type,
mm.ma_id as maId,
mm.ma_code as code,
sub.repairNum as repairNum,
sub.repairedNum as repairedNum,
sub.repairRemark as repairRemark,
sub.scrapNum as scrapNum,
sub.status as status,
su.nick_name as repairer,
sub.updateTime as updateTime,
sub.typeId as typeId,
mt.manage_type as manageType,
IF(ras.type_id IS NOT NULL, 1, 0) as submitStatus,
ras.repair_type as repairType
from (
select
rad.id as id,
rad.task_id as taskId,
rad.ma_id as maId,
rad.repair_num as repairNum,
rad.repaired_num as repairedNum,
rad.repair_remark as repairRemark,
rad.scrap_num as scrapNum,
rad.status as status,
su.nick_name as repairer,
rad.update_time as updateTime,
rad.type_id as typeId,
mt.manage_type as manageType,
IF(ras.type_id IS NOT NULL, 1, 0) as submitStatus,
ras.repair_type as repairType
from repair_apply_details rad
left join ma_type mt on rad.type_id = mt.type_id
left join ma_machine mm on mm.ma_id = rad.ma_id
left join sys_user su on rad.repairer = su.user_id
rad.repairer as repairer,
rad.create_time as createTime
from
repair_apply_details rad
where
rad.type_id = #{typeId} and (rad.status is null or rad.status = 0)
) sub
left join ma_type mt on sub.typeId = mt.type_id
left join ma_machine mm on mm.ma_id = sub.maId
left join sys_user su on sub.repairer = su.user_id
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
LEFT JOIN ma_type_repair mtr on mtr.type_id = rad.type_id
LEFT JOIN repair_apply_record_save ras ON rad.type_id = ras.type_id and mm.ma_id = ras.ma_id
where rad.type_id = #{typeId} and (rad.status is null or rad.status = 0)
<if test="userId != null and userId != ''">
and mtr.user_id = #{userId}
</if>
<!-- <if test="companyId != null and companyId != ''">-->
<!-- and rad.company_id = #{companyId}-->
<!-- </if>-->
<if test="code !=null and code != ''">
AND mm.ma_code like concat('%',#{code},'%')
</if>
order by rad.create_time desc
LEFT JOIN ma_type_repair mtr on mtr.type_id = sub.typeId
LEFT JOIN repair_apply_record_save ras ON sub.typeId = ras.type_id and mm.ma_id = ras.ma_id
<where>
<if test="userId != null and userId != ''">
and mtr.user_id = #{userId}
</if>
<!-- <if test="companyId != null and companyId != ''">
and rad.company_id = #{companyId}
</if>-->
<if test="code !=null and code != ''">
AND mm.ma_code like concat('%',#{code},'%')
</if>
</where>
order by
sub.createTime desc
</select>
<select id="getRepairPartListNew" resultType="com.bonus.sgzb.base.domain.RepairPartDetails">

View File

@ -0,0 +1,202 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.bonus.sgzb.material.mapper.EquipmentToRepairMapper">
<select id="getMaCodeSelect" resultType="com.bonus.sgzb.material.domain.equipmentMaCodeInfo">
select
ma_id as maId,
ma_code as maCode
from
ma_machine
where ma_status in (15,16)
and type_id = #{typeId}
</select>
<select id="getEquipmentList" resultType="com.bonus.sgzb.material.domain.EquipmentTask">
select
red.id as id,
red.type_id as typeId,
red.ma_id as maId,
mt2.type_name as typeName,
mt.type_name as typeModelName,
mm.ma_code as maCode,
red.repair_num as repairNum,
red.status as repairStatus,
su.nick_name as repairer,
DATE_FORMAT(red.repair_time,'%Y-%m-%d') as repairTime
from repair_equipment_record red
left join ma_type mt on red.type_id = mt.type_id
left join ma_machine mm on mm.ma_id = red.ma_id
left join sys_user su on red.repairer = su.user_id
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
LEFT JOIN ma_type_repair mtr on mtr.type_id = red.type_id
where 1=1
<if test="userId != null and userId != ''">
and mtr.user_id = #{userId}
</if>
<if test="keyword != null and keyword != ''">
AND (locate(#{keyword}, mm.ma_code) > 0
or locate(#{keyword}, su.nick_name) > 0
or locate(#{keyword}, mt2.type_name) > 0
or locate(#{keyword}, mt.type_name) > 0)
</if>
<if test="typeModelName != null and typeModelName != ''">
AND mt.type_name like concat('%',#{typeModelName},'%')
</if>
<if test="typeName != null and typeName != ''">
AND mt2.type_name like concat('%',#{typeName},'%')
</if>
<if test="repairStatus != null">
AND red.status = #{repairStatus}
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
<![CDATA[and DATE_FORMAT( red.repair_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
</if>
order by red.create_time desc
</select>
<insert id="addEquipmentNew" keyColumn="id" keyProperty="id" useGeneratedKeys="true" >
insert into repair_equipment_record (ma_id,type_id,repair_num,status,create_by,create_time,repairer,repair_time)
values (#{maId},#{typeId},#{repairNum},#{repairStatus},#{createBy},now(),#{repairer},#{repairTime});
</insert>
<insert id="addEquipmentDetailsNew" keyColumn="id" keyProperty="id" useGeneratedKeys="true" >
insert into repair_equipment_details (parent_id,type_id,ma_id,part_id,part_num,part_price,repair_remark,repair_content,repair_content_before,part_change,part_change_num,create_by,create_time)
values (#{parentId},#{typeId},#{maId},#{partId},#{partNum},#{partPrice},#{repairRemark},#{repairContent},#{repairContentBefore},#{partChange},#{partChangeNum},#{createBy},now());
</insert>
<select id="getEquipmentInfo" resultType="com.bonus.sgzb.material.domain.EquipmentRecord">
select
id,
ma_id as maId,
type_id as typeId,
repairer as repairer,
repair_num AS repairNum,
DATE_FORMAT(repair_time, '%Y-%m-%d') as repairTime
from repair_equipment_record rer
where rer.id = #{id}
</select>
<select id="getPartList" resultType="com.bonus.sgzb.material.domain.EquipmentPartDetails">
select
red.id as id,
red.parent_id as parentId,
red.ma_id as maId,
red.part_id as partId,
part_num as partNum,
part_price as partCost,
repair_content as repairContent,
repair_content_before as repairContentBefore,
repair_remark as repairRemark,
part_change as partChange,
part_change_num as partChangeNum
from repair_equipment_details red
left join ma_part_type mpt on red.part_id = mpt.pa_id
where red.parent_id = #{id}
order by red.create_time desc
</select>
<select id="getFileEquipmentList" resultType="com.bonus.sgzb.base.api.domain.FileInfo">
select
id,
model_id as modelId,
file_name as fileName,
file_url as fileUrl
from
sys_file_info sfi
where model_id = #{id} and repair_status = 2
</select>
<delete id="deleteEquipmentDetails">
delete from repair_equipment_details where parent_id = #{id}
</delete>
<delete id="deleteFileEquipmentList">
delete from sys_file_info
where type_id = #{typeId} and repair_status = 2
<if test="maId != null and maId != ''">
and ma_id = #{maId}
</if>
</delete>
<update id="editEquipmentNew">
update repair_equipment_record
<set>
<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="repairer != null and repairer != ''">
repairer = #{repairer},
</if>
<if test="repairTime != null">
repair_time = #{repairTime},
</if>
update_by = #{updateBy},
update_time = now()
</set>
where id = #{id}
</update>
<update id="submitStatusNew">
update repair_equipment_record
<set>
status = 1
</set>
where id = #{id}
</update>
<select id="getMaintenanceEquipment" resultType="com.bonus.sgzb.material.domain.EquipmentRecord">
select
red.parent_id as parentId,
red.create_time,
red.type_id,
mm.ma_id as maId,
mm.ma_code as maCode,
rer.repair_num as repairNum,
rer.status as repairStatus,
DATE_FORMAT(rer.repair_time, '%Y-%m-%d') as repairTime,
mt2.type_name as typeName,
mt.type_name as typeModelName,
su.nick_name as repairerName,
(
SELECT GROUP_CONCAT(DISTINCT red2.repair_remark SEPARATOR ';')
FROM repair_equipment_details red2
WHERE red2.parent_id = rer.id
) as repairRemark,
-- 使用子查询获取 repairRemarkBefore
(
SELECT GROUP_CONCAT(DISTINCT red3.repair_content_before SEPARATOR ';')
FROM repair_equipment_details red3
WHERE red3.parent_id = rer.id
) as repairContentBefore,
(
SELECT GROUP_CONCAT(
CASE
-- 当 part_id 存在时,关联表获取 pa_name
WHEN red4.part_id IS NOT NULL THEN CONCAT(mpt.pa_name, '','数量为',red4.part_num,' ', red4.repair_content)
WHEN red4.part_id IS NULL THEN CONCAT( red4.repair_content)
ELSE NULL
END
SEPARATOR '; '
)
FROM repair_equipment_details red4
LEFT JOIN ma_part_type mpt ON red4.part_id = mpt.pa_id
WHERE red4.parent_id = rer.id
) as repairContent
from
repair_equipment_details red
left join repair_equipment_record rer on red.parent_id = rer.id
left join ma_machine mm on mm.ma_id = rer.ma_id
left join ma_type mt on rer.type_id = mt.type_id
left join sys_user su on rer.repairer = su.user_id
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
where
red.parent_id = #{id}
group by red.parent_id,red.type_id
</select>
</mapper>