diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java index 49243fd..f54c6ec 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java @@ -186,11 +186,11 @@ public class DevInfoController extends BaseController { /** * 设备信息录入--保存草稿--不校验必填 */ - @ApiOperation(value = "草稿新增(该接口已废弃)") +/* @ApiOperation(value = "草稿新增(该接口已废弃)") @PostMapping("/insertDraft") public AjaxResult insertDraft(@NotNull @RequestBody DevInfo devInfo) { return devInfoService.insertDraft(devInfo); - } + }*/ /** * 统计装备 diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/DevInfo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/DevInfo.java index ad5d858..3fe168c 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/DevInfo.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/DevInfo.java @@ -218,21 +218,14 @@ public class DevInfo extends BaseEntity { @NotEmpty(message = "详情页展示图不能为空") private List detailsFileList = new ArrayList<>(); - @ApiModelProperty(value = "检测证明pdf") - private List> examinationPdfs = new ArrayList<>(); - @ApiModelProperty(value = "检测证明pdf") private List examinationPdf = new ArrayList<>(); - @ApiModelProperty(value = "唯一标识符列表") - private List identifyCodes = new ArrayList<>(); - - @ApiModelProperty(value = "合格证pdf") - private List> insurancePdfs = new ArrayList<>(); - @ApiModelProperty(value = "合格证pdf") private List insurancePdf = new ArrayList<>(); + private List tableList; + /**文件附件*/ @ApiModelProperty(value = "文件附件") private List bmFileInfoList; diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/MaDevQc.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/MaDevQc.java index 3a2b237..688ca7c 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/MaDevQc.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/MaDevQc.java @@ -5,6 +5,7 @@ import com.bonus.common.core.web.domain.BaseEntity; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.experimental.Accessors; import java.util.Date; import java.io.Serializable; @@ -17,6 +18,7 @@ import java.util.List; * @since 2024-12-05 15:51:33 */ @Data +@Accessors(chain = true) public class MaDevQc extends BaseEntity implements Serializable { private static final long serialVersionUID = 810056154627295208L; diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/Table.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/Table.java new file mode 100644 index 0000000..3ab073f --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/Table.java @@ -0,0 +1,34 @@ +package com.bonus.material.device.domain; + +import com.bonus.common.biz.domain.BmFileInfo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * @Author:liang.chao + * @Date:2024/12/20 - 14:14 + */ +@Data +public class Table { + + @ApiModelProperty(value = "唯一标识符") + private String identifyCode; + + @ApiModelProperty(value = "检测人") + private String checkMan; + + @ApiModelProperty(value = "检测日期") + private String checkDate; + + @ApiModelProperty(value = "下次检测日期") + private String nextCheckDate; + + @ApiModelProperty(value = "检测证明pdf") + private List examinationPdf = new ArrayList<>(); + + @ApiModelProperty(value = "合格证pdf") + private List insurancePdf = new ArrayList<>(); +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/DevInfoService.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/DevInfoService.java index 99c38c7..118149e 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/DevInfoService.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/DevInfoService.java @@ -85,11 +85,6 @@ public interface DevInfoService { */ AjaxResult insertDevInfo(DevInfo devInfo); - /** - * 新增装备 -- 保存草稿 -- 不校验 - */ - AjaxResult insertDraft(DevInfo devInfo); - Map sumType(); List selectDevInfoLists(DevInfoVo devInfo); diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/MaDevQcService.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/MaDevQcService.java index 70e9614..03c9842 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/MaDevQcService.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/MaDevQcService.java @@ -24,6 +24,7 @@ public interface MaDevQcService { * @return */ AjaxResult insertDevQc(MaDevQc maDevQc); + AjaxResult addDev(MaDevQc maDevQc); /** * 删除装备质检 diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java index 91d9de8..237313b 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java @@ -24,6 +24,7 @@ import com.bonus.material.device.mapper.BmFileInfoMapper; import com.bonus.material.device.mapper.DevInfoMapper; import com.bonus.material.device.mapper.MaDevQcMapper; import com.bonus.material.device.service.DevInfoService; +import com.bonus.material.device.service.MaDevQcService; import com.bonus.system.api.model.LoginUser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; @@ -73,6 +74,9 @@ public class DevInfoServiceImpl implements DevInfoService { @Resource private BmFileInfoMapper bmFileInfoMapper; + @Resource + private MaDevQcService maDevQcService; + @Resource protected Validator validator; @@ -313,7 +317,7 @@ public class DevInfoServiceImpl implements DevInfoService { return AjaxResult.error("设备信息不能为空"); } String code = ""; - for (int i = 0; i < devInfo.getExaminationPdfs().size(); i++) { + for (int i = 0; i < devInfo.getTableList().size(); i++) { //获取用户信息 Long userId = SecurityUtils.getLoginUser().getUserid(); //保存用户信息 @@ -324,7 +328,7 @@ public class DevInfoServiceImpl implements DevInfoService { devInfo.setCode(code); devInfo.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId().toString()); devInfo.setDeviceCount(1); - devInfo.setIdentifyCode(devInfo.getIdentifyCodes().get(i)); + devInfo.setIdentifyCode(devInfo.getTableList().get(i).getIdentifyCode()); int saveSuccessNum = devInfoMapper.insertDevInfo(devInfo); code = ""; if (saveSuccessNum == 0) { @@ -343,46 +347,6 @@ public class DevInfoServiceImpl implements DevInfoService { return AjaxResult.success("保存成功"); } - /** - * 新增设备--草稿状态 - * - * @param devInfo 设备信息 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public AjaxResult insertDraft(DevInfo devInfo) { - //获取用户信息 - Long userId = SecurityUtils.getLoginUser().getUserid(); - //保存用户信息 - devInfo.setCreator(userId).setMaStatus(TO_BE_LISTED.getCode()).setOwnId(userId); - try { - if (devInfo.getMaId() != null) { - devInfoMapper.deleteDevInfoByMaId(devInfo.getMaId(), MaStatusEnum.UNDER_RENT.getCode()); - } - for (int i = 0; i < devInfo.getExaminationPdfs().size(); i++) { - String code = getString(); - devInfo.setCode(code); - devInfo.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId().toString()); - int insertedDraft = devInfoMapper.insertDraft(devInfo); - if (insertedDraft == 0) { - return AjaxResult.error("装备草稿保存失败,请修改后重试"); - } - //保存自定义属性值 - if (!CollectionUtils.isEmpty(devInfo.getDevInfoProperties())) { - devInfoMapper.insertDevInfoProperties(devInfo.getMaId(), devInfo.getDevInfoProperties()); - } - //把文件保存到附件中 - AjaxResult error = uploadFiles(devInfo, userId, i); - if (error != null) { - return error; - } - } - } catch (Exception e) { - return AjaxResult.error("装备草稿保存失败,执行异常:" + e.getMessage()); - } - return AjaxResult.success("装备草稿保存成功"); - } - /** * 物资设备文件处理并上传 * @@ -416,21 +380,27 @@ public class DevInfoServiceImpl implements DevInfoService { }); fileInfoList.addAll(devInfo.getDetailsFileList()); } - if (CollectionUtil.isNotEmpty(devInfo.getInsurancePdfs().get(i))) { - devInfo.getInsurancePdfs().get(i).removeIf(Objects::isNull); - devInfo.getInsurancePdfs().get(i).forEach(item -> { + if (CollectionUtil.isNotEmpty(devInfo.getTableList().get(i).getInsurancePdf())) { + devInfo.getTableList().get(i).getInsurancePdf().removeIf(Objects::isNull); + devInfo.getTableList().get(i).getInsurancePdf().forEach(item -> { item.setTaskType(MaterialConstants.MATERIAL_FILE_TYPE_CODE); item.setFileType(Long.valueOf(INSURANCE_PDF)); }); - fileInfoList.addAll(devInfo.getInsurancePdfs().get(i)); + fileInfoList.addAll(devInfo.getTableList().get(i).getInsurancePdf()); } - if (CollectionUtil.isNotEmpty(devInfo.getExaminationPdfs().get(i))) { - devInfo.getExaminationPdfs().get(i).removeIf(Objects::isNull); - devInfo.getExaminationPdfs().get(i).forEach(item -> { + if (CollectionUtil.isNotEmpty(devInfo.getTableList().get(i).getExaminationPdf())) { + devInfo.getTableList().get(i).getExaminationPdf().removeIf(Objects::isNull); + devInfo.getTableList().get(i).getExaminationPdf().forEach(item -> { item.setTaskType(MaterialConstants.MATERIAL_FILE_TYPE_CODE); item.setFileType(Long.valueOf(EXAMINATION_PDF)); }); - fileInfoList.addAll(devInfo.getExaminationPdfs().get(i)); + fileInfoList.addAll(devInfo.getTableList().get(i).getExaminationPdf()); + + // 新增检测证明 + MaDevQc maDevQc = new MaDevQc(); + maDevQc.setMaId(devInfo.getMaId().intValue()); + maDevQc.setFileInfoList(devInfo.getTableList().get(i).getExaminationPdf()); + maDevQcService.addDev(maDevQc); } // 上传处理后的附件列表 diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/MaDevQcServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/MaDevQcServiceImpl.java index e6f1d2c..f75a679 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/MaDevQcServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/MaDevQcServiceImpl.java @@ -82,6 +82,34 @@ public class MaDevQcServiceImpl implements MaDevQcService { return result > 0 ? AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg()) : AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg()); } + @Override + public AjaxResult addDev(MaDevQc maDevQc) { + if (maDevQc == null) { + return AjaxResult.error(HttpCodeEnum.TO_PARAM_NULL.getCode(), HttpCodeEnum.TO_PARAM_NULL.getMsg()); + } + String code = getString(); + maDevQc.setQcCode(code); + maDevQc.setCreateBy(String.valueOf(SecurityUtils.getUserId())); + maDevQc.setCreateTime(DateUtils.getNowDate()); + maDevQc.setQcCom(SecurityUtils.getLoginUser().getSysUser().getCompanyId().toString()); + int result = maDevQcMapper.insertDevQc(maDevQc); + devInfoMapper.updateDevInfoIsQc(maDevQc); + if (result > 0 && maDevQc.getId() != null) { + if (CollectionUtils.isNotEmpty(maDevQc.getFileInfoList())) { + for (BmFileInfo bmFileInfo : maDevQc.getFileInfoList()) { + bmFileInfo.setTaskId(Long.valueOf(maDevQc.getId())); + bmFileInfo.setModelId(Long.valueOf(maDevQc.getMaId())); + bmFileInfo.setTaskType(MaterialConstants.MATERIAL_FILE_TYPE_CODE); + // 质检附件 + bmFileInfo.setFileType(4L); + bmFileInfo.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString()); + bmFileInfoMapper.insertBmFileInfo(bmFileInfo); + } + } + } + return result > 0 ? AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg()) : AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg()); + } + /** * 生成需求编号 *