From 8d2181b7f76b6d7394c604760ffceeba3f0c3530 Mon Sep 17 00:00:00 2001 From: jiang Date: Thu, 31 Jul 2025 17:42:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=85=E5=A4=87=E9=85=8D=E7=BD=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bonus/material/device/domain/DevInfo.java | 118 +++++++++++++----- .../service/impl/DevInfoServiceImpl.java | 60 +++++++-- 2 files changed, 137 insertions(+), 41 deletions(-) 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 7e090e3..1cab687 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 @@ -34,21 +34,29 @@ public class DevInfo extends BaseEntity { @ApiModelProperty(value = "主键id") private Integer id; - /** 设备id */ + /** + * 设备id + */ @Excel(name = "设备id") @ApiModelProperty(value = "设备id") private Long maId; - /** 设备id数组 */ + /** + * 设备id数组 + */ @ApiModelProperty(value = "设备id数组") private List maIds; - /** 设备编码 */ + /** + * 设备编码 + */ @Excel(name = "设备编码") @ApiModelProperty(value = "设备编码") private String code; - /** 设备唯一标识符,用户输入,比如车架号 */ + /** + * 设备唯一标识符,用户输入,比如车架号 + */ @Excel(name = "设备唯一标识符") @ApiModelProperty(value = "设备唯一标识符") private String identifyCode; @@ -74,7 +82,9 @@ public class DevInfo extends BaseEntity { @NotBlank(message = "单位不能为空") private String unitName; - /** 类型id */ + /** + * 类型id + */ @Excel(name = "类型id") @ApiModelProperty(value = "类型id") @NotNull @@ -83,22 +93,30 @@ public class DevInfo extends BaseEntity { @ApiModelProperty(value = "装备类别") private String typeName; - /** 设备状态(自有,待上架,上架,在租,下架)考虑数据字典 */ + /** + * 设备状态(自有,待上架,上架,在租,下架)考虑数据字典 + */ @Excel(name = "设备状态(自有,待上架,上架,在租,下架)考虑数据字典") @ApiModelProperty(value = "设备状态(自有,待上架,上架,在租,下架)考虑数据字典") private Integer maStatus; - /** 设备状态(自有,待上架,上架,在租,下架)考虑数据字典 */ + /** + * 设备状态(自有,待上架,上架,在租,下架)考虑数据字典 + */ @Excel(name = "设备状态(自有,待上架,上架,在租,下架)考虑数据字典") @ApiModelProperty(value = "设备状态(自有,待上架,上架,在租,下架)考虑数据字典") private String maStatusName; - /** 租赁范围 */ + /** + * 租赁范围 + */ @Excel(name = "租赁范围") @ApiModelProperty(value = "租赁范围") private Long leaseScope; - /** 设备所在地 */ + /** + * 设备所在地 + */ @Excel(name = "设备所在地") @ApiModelProperty(value = "设备所在地") private String location; @@ -115,75 +133,103 @@ public class DevInfo extends BaseEntity { @ApiModelProperty(value = "设备所在区id") private Integer areaId; - /** 设备品牌 */ + /** + * 设备品牌 + */ @Excel(name = "设备品牌") @ApiModelProperty(value = "设备品牌") @NotBlank private String brand; - /** 设备型号 */ + /** + * 设备型号 + */ @Excel(name = "设备型号") @ApiModelProperty(value = "设备型号") private String modelName; - /** 出厂日期 */ + /** + * 出厂日期 + */ @Excel(name = "出厂日期") @ApiModelProperty(value = "出厂日期") @NotNull @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private Date productionDate; - /** 工作时长 */ + /** + * 工作时长 + */ @Excel(name = "工作时长") @ApiModelProperty(value = "工作时长") private String workingHours; - /** 整机序列号 */ + /** + * 整机序列号 + */ @Excel(name = "整机序列号") @ApiModelProperty(value = "整机序列号") private String serialNumber; - /** 设备月租价 */ + /** + * 设备月租价 + */ @Excel(name = "设备月租价") @ApiModelProperty(value = "设备月租价") private Float monthLeasePrice; - /** 设备天租价 */ + /** + * 设备天租价 + */ @Excel(name = "设备天租价") @ApiModelProperty(value = "设备天租价") @NotNull private Float dayLeasePrice; - /** 设备主照片 */ + /** + * 设备主照片 + */ @Excel(name = "设备主照片") @ApiModelProperty(value = "设备主照片") private String picUrl; - /** 机手月租金 */ + /** + * 机手月租金 + */ @Excel(name = "机手月租金") @ApiModelProperty(value = "机手月租金") private Float jsMonthPrice; - /** 机手天租金 */ + /** + * 机手天租金 + */ @Excel(name = "机手天租金") @ApiModelProperty(value = "机手天租金") private Float jsDayPrice; - /** 详细描述 */ + /** + * 详细描述 + */ @Excel(name = "详细描述") @ApiModelProperty(value = "详细描述") private String description; - /** gps编号 */ + /** + * gps编号 + */ @Excel(name = "gps编号") @ApiModelProperty(value = "gps编号") private String gpsCode; - /** 设备所属公司--废弃不用 */ + /** + * 设备所属公司--废弃不用 + */ @ApiModelProperty(value = "设备所属公司--废弃") private Long ownCo; - /** 创建人 */ + /** + * 创建人 + */ @Excel(name = "创建人") @ApiModelProperty(value = "创建人") private Long creator; @@ -197,32 +243,40 @@ public class DevInfo extends BaseEntity { @Size(min = 11, max = 11, message = "手机号长度不能超过11位") private String personPhone; - /** 设备规格 */ + /** + * 设备规格 + */ @Excel(name = "设备规格") @ApiModelProperty(value = "设备规格") private String specification; - /** 订金 */ + /** + * 订金 + */ @Excel(name = "订金") @ApiModelProperty(value = "订金") private BigDecimal deposit; - /** 是否删除 */ + /** + * 是否删除 + */ @Excel(name = "是否配备机手") @ApiModelProperty(value = "是否配备机手") private String isOperator; - /** 是否删除 */ + /** + * 是否删除 + */ @Excel(name = "是否删除") @ApiModelProperty(value = "是否删除") private String isActive; @ApiModelProperty(value = "主展示图") - @NotEmpty(message = "主展示图不能为空") + //@NotEmpty(message = "主展示图不能为空") private List mainFileList = new ArrayList<>(); @ApiModelProperty(value = "详情页展示图") - @NotEmpty(message = "详情页展示图不能为空") + //@NotEmpty(message = "详情页展示图不能为空") private List detailsFileList = new ArrayList<>(); @ApiModelProperty(value = "检测证明pdf") @@ -233,7 +287,9 @@ public class DevInfo extends BaseEntity { private List tableList; - /**文件附件*/ + /** + * 文件附件 + */ @ApiModelProperty(value = "文件附件") private List bmFileInfoList; @@ -305,4 +361,6 @@ public class DevInfo extends BaseEntity { @ApiModelProperty(value = "承租方联系人") private String lesseePerson; + + private String type; } 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 9b9c8ee..1dbd817 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 @@ -2,7 +2,9 @@ package com.bonus.material.device.service.impl; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.BooleanUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.PhoneUtil; +import com.alibaba.druid.sql.visitor.functions.If; import com.bonus.common.biz.constant.MaterialConstants; import com.bonus.common.biz.domain.*; import com.bonus.common.biz.enums.HttpCodeEnum; @@ -46,6 +48,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Validator; +import javax.validation.constraints.NotEmpty; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -210,6 +213,7 @@ public class DevInfoServiceImpl implements DevInfoService { /** * 根据文件名截取文件名 + * * @param fileName */ private String extracted(String fileName) { @@ -397,12 +401,22 @@ public class DevInfoServiceImpl implements DevInfoService { if (devInfo == null) { return AjaxResult.error("设备信息不能为空"); } + if (!"2".equals(devInfo.getType())) { + if (ObjectUtil.isEmpty(devInfo.getMainFileList())) { + return AjaxResult.error("主展示图不能为空"); + } + if (ObjectUtil.isEmpty(devInfo.getDetailsFileList())) { + return AjaxResult.error("详情页展示图不能为空"); + } + } String code = ""; for (int i = 0; i < devInfo.getTableList().size(); i++) { //获取用户信息 Long userId = SecurityUtils.getLoginUser().getUserid(); //保存用户信息 - devInfo.setCreator(userId).setMaStatus(ON_HIRE.getCode()).setOwnId(userId); + devInfo.setCreator(userId) + /*.setMaStatus(ON_HIRE.getCode())*/ + .setOwnId(userId); if (org.apache.commons.lang3.StringUtils.isBlank(code)) { code = getString(); } @@ -595,21 +609,35 @@ public class DevInfoServiceImpl implements DevInfoService { devInfo.setIdentifyCode(identifyCode); int i = devInfoMapper.updateDevInfo(devInfo); - Integer id = tableList.get(0).getId(); - if (id != null) { - MaDevQc maDevQc = new MaDevQc(); - maDevQc.setId(id).setQcUser(tableList.get(0).getCheckMan()).setQcTime(tableList.get(0).getCheckDate()).setNextCheckTime(tableList.get(0).getNextCheckDate()); - maDevQcMapper.updateById(maDevQc); - } if (i > 0) { BmFileInfo bmFileInfo = new BmFileInfo() .setTaskType(MaterialConstants.MATERIAL_FILE_TYPE_CODE) .setModelId(devInfo.getMaId()); bmFileInfoMapper.deleteBmFileInfoByBizInfo(bmFileInfo); + } + + Integer id = tableList.get(0).getId(); + if (id != null) { + MaDevQc maDevQc = new MaDevQc(); + maDevQc.setId(id).setQcUser(tableList.get(0).getCheckMan()).setQcTime(tableList.get(0).getCheckDate()).setNextCheckTime(tableList.get(0).getNextCheckDate()); + maDevQcMapper.updateById(maDevQc); Long userId = SecurityUtils.getLoginUser().getUserid(); Table table = tableList.get(0); uploadFile(table, devInfo, userId); + } else { + Long userId = SecurityUtils.getLoginUser().getUserid(); + //把文件保存到附件中 + Table table = devInfo.getTableList().get(0); + AjaxResult error = uploadFiles(table, devInfo, userId, 0); + if (error != null) { + return error; + } } + /* if (i > 0) { + Long userId = SecurityUtils.getLoginUser().getUserid(); + Table table = tableList.get(0); + uploadFile(table, devInfo, userId); + }*/ return i > 0 ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败"); } @@ -871,6 +899,7 @@ public class DevInfoServiceImpl implements DevInfoService { /** * 在租装备信息查询 + * * @param devInfo * @return */ @@ -881,6 +910,7 @@ public class DevInfoServiceImpl implements DevInfoService { /** * 设备批量导入模版下载 + * * @param response */ @Override @@ -888,7 +918,7 @@ public class DevInfoServiceImpl implements DevInfoService { //模板名称 String templateName = "MaDevTemplate.xlsx"; OutputStream out = null; - InputStream input =null; + InputStream input = null; try { input = this.getClass().getClassLoader().getResourceAsStream("template/MaDevTemplate.xlsx"); response.setCharacterEncoding("UTF-8"); @@ -914,6 +944,7 @@ public class DevInfoServiceImpl implements DevInfoService { /** * 设备信息导入 + * * @param file * @return */ @@ -987,7 +1018,7 @@ public class DevInfoServiceImpl implements DevInfoService { List devTemplateVos = entry.getValue(); for (DevTemplateVo templateVo : devTemplateVos) { if (StringUtils.isBlank(templateVo.getIdentifyCode()) && StringUtils.isBlank(templateVo.getCheckMan()) - && templateVo.getNextCheckDate() == null && templateVo.getCheckDate() == null) { + && templateVo.getNextCheckDate() == null && templateVo.getCheckDate() == null) { continue; } DevTemplateVo dto = new DevTemplateVo(); @@ -1015,6 +1046,7 @@ public class DevInfoServiceImpl implements DevInfoService { /** * 读取Excel表格数据,做非空判断 + * * @param sheet * @param totalRows * @param totalCells @@ -1062,8 +1094,8 @@ public class DevInfoServiceImpl implements DevInfoService { case 10: checkDate(cellValue, r, c); break; - default: - break; + default: + break; } } } @@ -1071,6 +1103,7 @@ public class DevInfoServiceImpl implements DevInfoService { /** * 检查数字格式是否为整数 + * * @param cellValue * @param r * @param c @@ -1088,6 +1121,7 @@ public class DevInfoServiceImpl implements DevInfoService { /** * 检查日期格式 + * * @param cellValue * @param rowIndex * @param colIndex @@ -1104,6 +1138,7 @@ public class DevInfoServiceImpl implements DevInfoService { /** * 判断日期格式是否正确 + * * @param dateStr * @return */ @@ -1150,6 +1185,7 @@ public class DevInfoServiceImpl implements DevInfoService { /** * 检查数据是否为空 + * * @param cellValue * @param rowIndex * @param colIndex @@ -1163,6 +1199,7 @@ public class DevInfoServiceImpl implements DevInfoService { /** * 检查电话号码格式 + * * @param cellValue * @param rowIndex * @param colIndex @@ -1178,6 +1215,7 @@ public class DevInfoServiceImpl implements DevInfoService { /** * 读取Excel表格数据,做非空及格式判断 + * * @param headerRow * @param totalCells */