diff --git a/zt-module-qms/zt-module-qms-api/src/main/java/com/zt/plat/module/qms/enums/ErrorCodeConstants.java b/zt-module-qms/zt-module-qms-api/src/main/java/com/zt/plat/module/qms/enums/ErrorCodeConstants.java index 5e6806e..02cbff4 100644 --- a/zt-module-qms/zt-module-qms-api/src/main/java/com/zt/plat/module/qms/enums/ErrorCodeConstants.java +++ b/zt-module-qms/zt-module-qms-api/src/main/java/com/zt/plat/module/qms/enums/ErrorCodeConstants.java @@ -160,6 +160,7 @@ public interface ErrorCodeConstants { ErrorCode MATERIAL_INVENTORY_INBOUND_DETAIL_NOT_EXISTS = new ErrorCode(1_032_150_000, "入库明细,出库明细等不存在"); + ErrorCode SYSTEM_VERSION_MANAGEMENT_NOT_EXISTS = new ErrorCode(1_032_150_000, "客户端版本管理不存在"); /*================================= tx 1_032_200_000 ~ 1_032_249_999 ==================================*/ diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/controller/admin/SystemVersionManagementController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/controller/admin/SystemVersionManagementController.java new file mode 100644 index 0000000..8f56c6a --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/controller/admin/SystemVersionManagementController.java @@ -0,0 +1,142 @@ +package com.zt.plat.module.qms.resource.clientManage.controller.admin; + +import com.zt.plat.module.qms.resource.clientManage.controller.vo.SystemVersionManagementPageReqVO; +import com.zt.plat.module.qms.resource.clientManage.controller.vo.SystemVersionManagementRespVO; +import com.zt.plat.module.qms.resource.clientManage.controller.vo.SystemVersionManagementSaveReqVO; +import org.springframework.web.bind.annotation.*; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import com.zt.plat.framework.business.interceptor.BusinessControllerMarker; +import com.zt.plat.framework.business.annotation.FileUploadController; +import com.zt.plat.framework.business.controller.AbstractFileUploadController; + +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import jakarta.validation.*; +import jakarta.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO; +import com.zt.plat.framework.common.pojo.PageParam; +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.framework.common.pojo.CommonResult; +import com.zt.plat.framework.common.util.object.BeanUtils; +import static com.zt.plat.framework.common.pojo.CommonResult.success; + +import com.zt.plat.framework.excel.core.util.ExcelUtils; + +import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog; +import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*; + +import com.zt.plat.module.qms.resource.clientManage.dal.dataobject.SystemVersionManagementDO; +import com.zt.plat.module.qms.resource.clientManage.service.SystemVersionManagementService; + +@Tag(name = "管理后台 - 客户端版本管理") +@RestController +@RequestMapping("/qms/system-version-management") +@Validated +@FileUploadController(source = "qms.systemversionmanagement") +public class SystemVersionManagementController extends AbstractFileUploadController implements BusinessControllerMarker{ + + static { + FileUploadController annotation = SystemVersionManagementController.class.getAnnotation(FileUploadController.class); + if (annotation != null) { + setFileUploadInfo(annotation); + } + } + + @Resource + private SystemVersionManagementService systemVersionManagementService; + + @PostMapping("/create") + @Operation(summary = "创建客户端版本管理") + @PreAuthorize("@ss.hasPermission('qms:system-version-management:create')") + public CommonResult createSystemVersionManagement(@Valid @RequestBody SystemVersionManagementSaveReqVO createReqVO) { + return success(systemVersionManagementService.createSystemVersionManagement(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新客户端版本管理") + @PreAuthorize("@ss.hasPermission('qms:system-version-management:update')") + public CommonResult updateSystemVersionManagement(@Valid @RequestBody SystemVersionManagementSaveReqVO updateReqVO) { + systemVersionManagementService.updateSystemVersionManagement(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除客户端版本管理") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('qms:system-version-management:delete')") + public CommonResult deleteSystemVersionManagement(@RequestParam("id") Long id) { + systemVersionManagementService.deleteSystemVersionManagement(id); + return success(true); + } + + @DeleteMapping("/delete-list") + @Parameter(name = "ids", description = "编号", required = true) + @Operation(summary = "批量删除客户端版本管理") + @PreAuthorize("@ss.hasPermission('qms:system-version-management:delete')") + public CommonResult deleteSystemVersionManagementList(@RequestBody BatchDeleteReqVO req) { + systemVersionManagementService.deleteSystemVersionManagementListByIds(req.getIds()); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得客户端版本管理") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('qms:system-version-management:query')") + public CommonResult getSystemVersionManagement(@RequestParam("id") Long id) { + SystemVersionManagementDO systemVersionManagement = systemVersionManagementService.getSystemVersionManagement(id); + return success(BeanUtils.toBean(systemVersionManagement, SystemVersionManagementRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得客户端版本管理分页") + @PreAuthorize("@ss.hasPermission('qms:system-version-management:query')") + public CommonResult> getSystemVersionManagementPage(@Valid SystemVersionManagementPageReqVO pageReqVO) { + PageResult pageResult = systemVersionManagementService.getSystemVersionManagementPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, SystemVersionManagementRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出客户端版本管理 Excel") + @PreAuthorize("@ss.hasPermission('qms:system-version-management:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportSystemVersionManagementExcel(@Valid SystemVersionManagementPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = systemVersionManagementService.getSystemVersionManagementPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "客户端版本管理.xls", "数据", SystemVersionManagementRespVO.class, + BeanUtils.toBean(list, SystemVersionManagementRespVO.class)); + } + + + @GetMapping("/get-by-platform") + @Operation(summary = "根据更新平台和安装包类型获取最新客户端版本管理信息") + //@PreAuthorize("@ss.hasPermission('qms:system-version-management:query')") + public CommonResult> getSystemVersionManagementByPlatformAndType(@Valid SystemVersionManagementPageReqVO pageReqVO) { + + if (pageReqVO.getCustDeviceId() == null ) { + return CommonResult.error(400, "客户端编号"); + } + if (pageReqVO.getUpdatePlatform() == null ) { + return CommonResult.error(400, "更新平台不能同时为空"); + } + if (pageReqVO.getUpdateType() == null) { + return CommonResult.error(400, "安装包类型不能同时为空"); + } + PageResult pageResult = systemVersionManagementService.getLts(pageReqVO); + return success(BeanUtils.toBean(pageResult, SystemVersionManagementRespVO.class)); + } + + @GetMapping("/publish") + CommonResult publish(@RequestParam("id") Long id) { + systemVersionManagementService.publish(id); + return success(true); + } +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/controller/vo/SystemVersionManagementPageReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/controller/vo/SystemVersionManagementPageReqVO.java new file mode 100644 index 0000000..c8fb26e --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/controller/vo/SystemVersionManagementPageReqVO.java @@ -0,0 +1,46 @@ +package com.zt.plat.module.qms.resource.clientManage.controller.vo; + +import lombok.*; +import io.swagger.v3.oas.annotations.media.Schema; +import com.zt.plat.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 客户端版本管理分页 Request VO") +@Data +public class SystemVersionManagementPageReqVO extends PageParam { + + @Schema(description = "客户端id", example = "赵六") + private String custDeviceId; + + @Schema(description = "客户端名称", example = "赵六") + private String custDeviceName; + + @Schema(description = "更新标题") + private String updateTitle; + + @Schema(description = "更新内容") + private String updateContent; + + @Schema(description = "更新平台") + private String updatePlatform; + + @Schema(description = "安装包类型") + private String updateType; + + @Schema(description = "上线发行") + private Integer issuanceFlag; + + @Schema(description = "所属部门") + private String systemDepartmentCode; + + @Schema(description = "创建人") + private String creator; + + @Schema(description = "创建日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/controller/vo/SystemVersionManagementRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/controller/vo/SystemVersionManagementRespVO.java new file mode 100644 index 0000000..7a4d22f --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/controller/vo/SystemVersionManagementRespVO.java @@ -0,0 +1,100 @@ +package com.zt.plat.module.qms.resource.clientManage.controller.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import com.zt.plat.framework.excel.core.annotations.DictFormat; +import com.zt.plat.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 客户端版本管理 Response VO") +@Data +@ExcelIgnoreUnannotated +public class SystemVersionManagementRespVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "18365") + @ExcelProperty("主键") + private Long id; + + @Schema(description = "客户端id", requiredMode = Schema.RequiredMode.REQUIRED, example = "20524") + @ExcelProperty(value = "客户端id", converter = DictConvert.class) + @DictFormat("T_SYS_VER_MNGT_CUST_DEV") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private String custDeviceId; + + @Schema(description = "客户端名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") + @ExcelProperty(value = "客户端名称", converter = DictConvert.class) + @DictFormat("T_SYS_VER_MNGT_CUST_DEV") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private String custDeviceName; + + @Schema(description = "更新标题") + @ExcelProperty("更新标题") + private String updateTitle; + + @Schema(description = "更新内容") + @ExcelProperty("更新内容") + private String updateContent; + + @Schema(description = "更新平台", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty(value = "更新平台", converter = DictConvert.class) + @DictFormat("T_SYSVER_MNGT_UPD_PLTF") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private String updatePlatform; + + @Schema(description = "安装包类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @ExcelProperty(value = "安装包类型", converter = DictConvert.class) + @DictFormat("T_SYSVER_MNGT_UPD_TP") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private String updateType; + + @Schema(description = "当前版本,必须大于当前线上发行版本号") + @ExcelProperty("当前版本,必须大于当前线上发行版本号") + private String currentVersion; + + @Schema(description = "最低版本") + @ExcelProperty("最低版本") + private String minimumVersion; + + @Schema(description = "下载地址", example = "https://www.iocoder.cn") + @ExcelProperty("下载地址") + private String downloadUrl; + + @Schema(description = "下载文件id", example = "11223344") + @ExcelProperty("下载文件id") + private String downloadId; + + @Schema(description = "文件md5值") + @ExcelProperty("文件md5值") + private String fileMd5; + + @Schema(description = "文件sha1值") + @ExcelProperty("文件sha1值") + private String fileEncryptAlgorithm; + + @Schema(description = "上线发行", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("上线发行") + private Integer issuanceFlag; + + @Schema(description = "是否静默更新") + @ExcelProperty("是否静默更新") + private Integer noneAdviceFlag; + + @Schema(description = "是否强制更新") + @ExcelProperty("是否强制更新") + private Integer mustUpdateFlag; + + @Schema(description = "所属部门") + @ExcelProperty("所属部门") + private String systemDepartmentCode; + + @Schema(description = "创建日期") + @ExcelProperty("创建日期") + private LocalDateTime createTime; + + @Schema(description = "备注") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "创建者") + @ExcelProperty("创建者") + private String creator; + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/controller/vo/SystemVersionManagementSaveReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/controller/vo/SystemVersionManagementSaveReqVO.java new file mode 100644 index 0000000..e5ff4f1 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/controller/vo/SystemVersionManagementSaveReqVO.java @@ -0,0 +1,83 @@ +package com.zt.plat.module.qms.resource.clientManage.controller.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import jakarta.validation.constraints.*; + +import java.util.List; + +@Schema(description = "管理后台 - 客户端版本管理新增/修改 Request VO") +@Data +public class SystemVersionManagementSaveReqVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "18365") + private Long id; + + // @Schema(description = "客户端id", requiredMode = Schema.RequiredMode.REQUIRED, example = "20524") +// @NotEmpty(message = "客户端id不能为空") + // private String custDeviceId; + + // @Schema(description = "客户端名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") +// @NotEmpty(message = "客户端名称不能为空") + // private String custDeviceName; + @Schema(description = "客户端id", requiredMode = Schema.RequiredMode.REQUIRED, example = "20524") + @NotEmpty(message = "客户端名称不能为空") + private String custDeviceId; + + @Schema(description = "客户端名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") + @NotEmpty(message = "客户端名称不能为空") + private String custDeviceName; + + @Schema(description = "更新标题") + private String updateTitle; + + @Schema(description = "更新内容") + private String updateContent; + + @Schema(description = "更新平台", requiredMode = Schema.RequiredMode.REQUIRED) +// @NotEmpty(message = "更新平台不能为空") + private String updatePlatform; + + @Schema(description = "安装包类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") +// @NotEmpty(message = "安装包类型不能为空") + private String updateType; + + @Schema(description = "当前版本,必须大于当前线上发行版本号") + private String currentVersion; + + @Schema(description = "最低版本") + private String minimumVersion; + + @Schema(description = "下载地址", example = "https://www.iocoder.cn") + private String downloadUrl; + + @Schema(description = "文件md5值") + private String fileMd5; + + @Schema(description = "文件sha1值") + private String fileEncryptAlgorithm; + + @Schema(description = "上线发行", requiredMode = Schema.RequiredMode.REQUIRED) +// @NotNull(message = "上线发行不能为空") + private Integer issuanceFlag; + + @Schema(description = "是否静默更新") + private Integer noneAdviceFlag; + + @Schema(description = "是否强制更新") + private Integer mustUpdateFlag; + + @Schema(description = "所属部门") + private String systemDepartmentCode; + + @Schema(description = "备注") + private String remark; + + + @Schema(description = "上传文件列表") + private List files; + + @Schema(description = "上传文件Uid") + private String downloadId; + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/controller/vo/uploadFileVo.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/controller/vo/uploadFileVo.java new file mode 100644 index 0000000..751a45e --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/controller/vo/uploadFileVo.java @@ -0,0 +1,23 @@ +package com.zt.plat.module.qms.resource.clientManage.controller.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "附件实例") +@Data +public class uploadFileVo { + private String id; + + private String url; + + private String name; + + private String uid; + + private String status; + + private String md5; + + private String sha1; + +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/dal/dataobject/SystemVersionManagementDO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/dal/dataobject/SystemVersionManagementDO.java new file mode 100644 index 0000000..288833d --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/dal/dataobject/SystemVersionManagementDO.java @@ -0,0 +1,126 @@ +package com.zt.plat.module.qms.resource.clientManage.dal.dataobject; + +import lombok.*; +import com.baomidou.mybatisplus.annotation.*; +import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO; +/** +* 客户端版本管理 DO +* +* @author 后台管理 +*/ +@TableName("t_sys_ver_mngt") +@KeySequence("t_sys_ver_mngt_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +/** +* 支持业务基类继承:isBusiness=true 时继承 BusinessBaseDO,否则继承 BaseDO +*/ +public class SystemVersionManagementDO extends BusinessBaseDO { + + + + /** + * 主键 + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + /** + * 客户端id + * + * 枚举 {@link TODO T_SYS_VER_MNGT_CUST_DEV 对应的类} + */ + @TableField("CUST_DEV_ID") + private String custDeviceId; + /** + * 客户端名称 + * + * 枚举 {@link TODO T_SYS_VER_MNGT_CUST_DEV 对应的类} + */ + @TableField("CUST_DEV_NAME") + private String custDeviceName; + /** + * 更新标题 + */ + @TableField("UPD_TTL") + private String updateTitle; + /** + * 更新内容 + */ + @TableField("UPD_CNTT") + private String updateContent; + /** + * 更新平台 + * + * 枚举 {@link TODO T_SYSVER_MNGT_UPD_PLTF 对应的类} + */ + @TableField("UPD_PLTF") + private String updatePlatform; + /** + * 安装包类型 + * + * 枚举 {@link TODO T_SYSVER_MNGT_UPD_TP 对应的类} + */ + @TableField("UPD_TP") + private String updateType; + /** + * 当前版本,必须大于当前线上发行版本号 + */ + @TableField("CRNT_VER") + private String currentVersion; + /** + * 最低版本 + */ + @TableField("MIN_VER") + private String minimumVersion; + /** + * 下载地址 + */ + @TableField("DL_URL") + private String downloadUrl; + /** + * 文件md5值 + */ + @TableField("FILE_MD5") + private String fileMd5; + /** + * 文件sha1值 + */ + @TableField("FILE_ENCR_ALG") + private String fileEncryptAlgorithm; + /** + * 上线发行 + */ + @TableField("ISSC_FLG") + private Integer issuanceFlag; + /** + * 是否静默更新 + */ + @TableField("NNE_ADV_FLG") + private Integer noneAdviceFlag; + /** + * 是否强制更新 + */ + @TableField("MUST_UPD_FLG") + private Integer mustUpdateFlag; + /** + * 所属部门 + */ + @TableField("SYS_DEPT_CD") + private String systemDepartmentCode; + /** + * 备注 + */ + @TableField("RMK") + private String remark; + + @TableField("CREATOR") + private String creator; + + @TableField("DL_ID") + private String downloadId; + +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/dal/mapper/SystemVersionManagementMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/dal/mapper/SystemVersionManagementMapper.java new file mode 100644 index 0000000..0636952 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/dal/mapper/SystemVersionManagementMapper.java @@ -0,0 +1,60 @@ +package com.zt.plat.module.qms.resource.clientManage.dal.mapper; + +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX; +import com.zt.plat.module.qms.resource.clientManage.dal.dataobject.SystemVersionManagementDO; +import com.zt.plat.module.qms.resource.clientManage.controller.vo.SystemVersionManagementPageReqVO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.Collections; +import java.util.List; + +/** + * 客户端版本管理 Mapper + * + * @author 后台管理 + */ +@Mapper +public interface SystemVersionManagementMapper extends BaseMapperX { + + default PageResult selectPage(SystemVersionManagementPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(SystemVersionManagementDO::getCustDeviceId, reqVO.getCustDeviceId()) + .eqIfPresent(SystemVersionManagementDO::getCustDeviceName, reqVO.getCustDeviceName()) + .eqIfPresent(SystemVersionManagementDO::getUpdateTitle, reqVO.getUpdateTitle()) + .eqIfPresent(SystemVersionManagementDO::getUpdateContent, reqVO.getUpdateContent()) + .eqIfPresent(SystemVersionManagementDO::getUpdatePlatform, reqVO.getUpdatePlatform()) + .eqIfPresent(SystemVersionManagementDO::getIssuanceFlag, reqVO.getIssuanceFlag()) + .eqIfPresent(SystemVersionManagementDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode()) + .eqIfPresent(SystemVersionManagementDO::getCreator, reqVO.getCreator()) + .betweenIfPresent(SystemVersionManagementDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(SystemVersionManagementDO::getId)); + } + + + default PageResult selectLts(SystemVersionManagementPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(SystemVersionManagementDO::getUpdatePlatform, reqVO.getUpdatePlatform()) + .eqIfPresent(SystemVersionManagementDO::getUpdateType, reqVO.getUpdateType()) + .eqIfPresent(SystemVersionManagementDO::getCustDeviceId, reqVO.getCustDeviceId()) + .eq(SystemVersionManagementDO::getIssuanceFlag,1) + .orderByDesc(SystemVersionManagementDO::getCreateTime) +// .last("LIMIT 1") + ); + } + + default List selectBySameCustDeviceId(Long id) { + // 先根据id查询出目标记录的custDeviceId + SystemVersionManagementDO target = selectById(id); + if (target == null) { + return Collections.emptyList(); + } + + // 查询相同custDeviceId的所有记录 + return selectList(new LambdaQueryWrapperX() + .eq(SystemVersionManagementDO::getCustDeviceId, target.getCustDeviceId()) + .eq(SystemVersionManagementDO::getIssuanceFlag, 1) + .orderByDesc(SystemVersionManagementDO::getCreateTime)); + } +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/service/SystemVersionManagementService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/service/SystemVersionManagementService.java new file mode 100644 index 0000000..fa2b14b --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/service/SystemVersionManagementService.java @@ -0,0 +1,78 @@ +package com.zt.plat.module.qms.resource.clientManage.service; + +import java.util.*; + +import com.zt.plat.module.qms.resource.clientManage.controller.vo.SystemVersionManagementPageReqVO; +import com.zt.plat.module.qms.resource.clientManage.controller.vo.SystemVersionManagementRespVO; +import com.zt.plat.module.qms.resource.clientManage.controller.vo.SystemVersionManagementSaveReqVO; +import jakarta.validation.*; +import com.zt.plat.module.qms.resource.clientManage.dal.dataobject.SystemVersionManagementDO; +import com.zt.plat.framework.common.pojo.PageResult; + +/** + * 客户端版本管理 Service 接口 + * + * @author 后台管理 + */ +public interface SystemVersionManagementService { + + /** + * 创建客户端版本管理 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + SystemVersionManagementRespVO createSystemVersionManagement(@Valid SystemVersionManagementSaveReqVO createReqVO); + + /** + * 更新客户端版本管理 + * + * @param updateReqVO 更新信息 + */ + void updateSystemVersionManagement(@Valid SystemVersionManagementSaveReqVO updateReqVO); + + /** + * 删除客户端版本管理 + * + * @param id 编号 + */ + void deleteSystemVersionManagement(Long id); + + /** + * 批量删除客户端版本管理 + * + * @param ids 编号 + */ + void deleteSystemVersionManagementListByIds(List ids); + + /** + * 获得客户端版本管理 + * + * @param id 编号 + * @return 客户端版本管理 + */ + SystemVersionManagementDO getSystemVersionManagement(Long id); + + /** + * 获得客户端版本管理分页 + * + * @param pageReqVO 分页查询 + * @return 客户端版本管理分页 + */ + PageResult getSystemVersionManagementPage(SystemVersionManagementPageReqVO pageReqVO); + + + /** + * 获得客户端版本管理接口方法 + * + * @param pageReqVO 分页查询 + * @return 客户端版本管理分页 + */ + PageResult getLts(SystemVersionManagementPageReqVO pageReqVO); + + /** + * 版本发布 + * @param id + */ + void publish (Long id); +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/service/SystemVersionManagementServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/service/SystemVersionManagementServiceImpl.java new file mode 100644 index 0000000..239636b --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/clientManage/service/SystemVersionManagementServiceImpl.java @@ -0,0 +1,151 @@ +package com.zt.plat.module.qms.resource.clientManage.service; + +import cn.hutool.core.collection.CollUtil; +import com.zt.plat.framework.security.core.LoginUser; +import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils; +import com.zt.plat.module.qms.resource.clientManage.controller.vo.SystemVersionManagementPageReqVO; +import com.zt.plat.module.qms.resource.clientManage.controller.vo.SystemVersionManagementRespVO; +import com.zt.plat.module.qms.resource.clientManage.controller.vo.SystemVersionManagementSaveReqVO; +import com.zt.plat.module.qms.resource.clientManage.controller.vo.uploadFileVo; +import org.springframework.stereotype.Service; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; + +import com.zt.plat.module.qms.resource.clientManage.dal.dataobject.SystemVersionManagementDO; +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.framework.common.util.object.BeanUtils; + +import com.zt.plat.module.qms.resource.clientManage.dal.mapper.SystemVersionManagementMapper; + +import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList; +import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*; + +/** + * 客户端版本管理 Service 实现类 + * + * @author 后台管理 + */ +@Service +@Validated +public class SystemVersionManagementServiceImpl implements SystemVersionManagementService { + + @Resource + private SystemVersionManagementMapper systemVersionManagementMapper; + + @Override + public SystemVersionManagementRespVO createSystemVersionManagement(SystemVersionManagementSaveReqVO createReqVO) { + //多条数据取第一条 + if (createReqVO.getFiles().size() > 0) { + uploadFileVo uploadFileVo = createReqVO.getFiles().get(0); + createReqVO.setDownloadUrl(uploadFileVo.getUrl()); + createReqVO.setFileMd5(uploadFileVo.getMd5()); + createReqVO.setFileEncryptAlgorithm(uploadFileVo.getSha1()); + createReqVO.setDownloadId(uploadFileVo.getId()); + } + + // 插入 + SystemVersionManagementDO systemVersionManagement = BeanUtils.toBean(createReqVO, SystemVersionManagementDO.class); + + // LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();//获取当前登录人通用方法 + systemVersionManagement.setCreator(String.valueOf(SecurityFrameworkUtils.getLoginUser().getId())); + + systemVersionManagementMapper.insert(systemVersionManagement); + // 返回 + return BeanUtils.toBean(systemVersionManagement, SystemVersionManagementRespVO.class); + } + + @Override + public void updateSystemVersionManagement(SystemVersionManagementSaveReqVO updateReqVO) { + // 校验存在 + validateSystemVersionManagementExists(updateReqVO.getId()); + + //多条数据取第一条 + if (updateReqVO.getFiles().size() > 0) { + uploadFileVo uploadFileVo = updateReqVO.getFiles().get(0); + updateReqVO.setDownloadUrl(uploadFileVo.getUrl()); + updateReqVO.setFileMd5(uploadFileVo.getMd5()); + updateReqVO.setFileEncryptAlgorithm(uploadFileVo.getSha1()); + updateReqVO.setDownloadId(uploadFileVo.getId()); + } + + // 更新 + SystemVersionManagementDO updateObj = BeanUtils.toBean(updateReqVO, SystemVersionManagementDO.class); + + updateObj.setUpdater(String.valueOf(SecurityFrameworkUtils.getLoginUser().getId())); + + systemVersionManagementMapper.updateById(updateObj); + } + + @Override + public void deleteSystemVersionManagement(Long id) { + // 校验存在 + validateSystemVersionManagementExists(id); + // 删除 + systemVersionManagementMapper.deleteById(id); + } + + @Override + public void deleteSystemVersionManagementListByIds(List ids) { + // 校验存在 + validateSystemVersionManagementExists(ids); + // 删除 + systemVersionManagementMapper.deleteByIds(ids); + } + + private void validateSystemVersionManagementExists(List ids) { + List list = systemVersionManagementMapper.selectByIds(ids); + if (CollUtil.isEmpty(list) || list.size() != ids.size()) { + throw exception(SYSTEM_VERSION_MANAGEMENT_NOT_EXISTS); + } + } + + private void validateSystemVersionManagementExists(Long id) { + if (systemVersionManagementMapper.selectById(id) == null) { + throw exception(SYSTEM_VERSION_MANAGEMENT_NOT_EXISTS); + } + } + + @Override + public SystemVersionManagementDO getSystemVersionManagement(Long id) { + return systemVersionManagementMapper.selectById(id); + } + + @Override + public PageResult getSystemVersionManagementPage(SystemVersionManagementPageReqVO pageReqVO) { + return systemVersionManagementMapper.selectPage(pageReqVO); + } + + @Override + public PageResult getLts(SystemVersionManagementPageReqVO pageReqVO) { + + + return systemVersionManagementMapper.selectLts(pageReqVO); + } + + @Override + public void publish(Long id) { + // 校验存在 + validateSystemVersionManagementExists(id); + + // 下线当前发布的版本 + List systemVersionManagementDOS = systemVersionManagementMapper.selectBySameCustDeviceId(id); + + if (systemVersionManagementDOS.size() > 0) { + + SystemVersionManagementDO systemVersionManagementDO = systemVersionManagementDOS.get(0); + SystemVersionManagementDO offlineVO = new SystemVersionManagementDO(); + offlineVO.setId(systemVersionManagementDO.getId()); + offlineVO.setIssuanceFlag(2); + systemVersionManagementMapper.updateById(offlineVO); + } + + + SystemVersionManagementDO onlineVO = new SystemVersionManagementDO(); + onlineVO.setId(id); + onlineVO.setIssuanceFlag(1); + systemVersionManagementMapper.updateById(onlineVO); + } +} \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/clientManage/data/dal/mapper/SystemVersionManagementMapper.xml b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/clientManage/data/dal/mapper/SystemVersionManagementMapper.xml new file mode 100644 index 0000000..6cc78e5 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/resources/com/zt/plat/module/qms/resource/clientManage/data/dal/mapper/SystemVersionManagementMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file