From e34cd43d2480e73adc783a6a0f7a594c0defd3c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=AE=9C=E9=98=B3?= <1301318913@qq.com> Date: Thu, 28 Mar 2024 16:52:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8A=82=E5=81=87=E6=97=A5=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MesHolidaySettingController.java | 139 ++++++++++++++++++ .../vo/MesHolidaySettingBaseVO.java | 70 +++++++++ .../vo/MesHolidaySettingCreateReqVO.java | 14 ++ .../vo/MesHolidaySettingExcelVO.java | 72 +++++++++ .../vo/MesHolidaySettingExportReqVO.java | 67 +++++++++ .../vo/MesHolidaySettingPageReqVO.java | 69 +++++++++ .../vo/MesHolidaySettingRespVO.java | 19 +++ .../vo/MesHolidaySettingUpdateReqVO.java | 18 +++ .../MesHolidaySettingConvert.java | 34 +++++ .../MesHolidaySettingDO.java | 92 ++++++++++++ .../MesHolidaySettingMapper.java | 62 ++++++++ .../module/mes/enums/ErrorCodeConstants.java | 4 + .../MesHolidaySettingService.java | 79 ++++++++++ .../MesHolidaySettingServiceImpl.java | 107 ++++++++++++++ .../MesHolidaySettingMapper.xml | 12 ++ 15 files changed, 858 insertions(+) create mode 100644 win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/MesHolidaySettingController.java create mode 100644 win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingBaseVO.java create mode 100644 win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingCreateReqVO.java create mode 100644 win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingExcelVO.java create mode 100644 win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingExportReqVO.java create mode 100644 win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingPageReqVO.java create mode 100644 win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingRespVO.java create mode 100644 win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingUpdateReqVO.java create mode 100644 win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/convert/mesholidaysetting/MesHolidaySettingConvert.java create mode 100644 win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/dal/dataobject/mesholidaysetting/MesHolidaySettingDO.java create mode 100644 win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/dal/mysql/mesholidaysetting/MesHolidaySettingMapper.java create mode 100644 win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/service/mesholidaysetting/MesHolidaySettingService.java create mode 100644 win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/service/mesholidaysetting/MesHolidaySettingServiceImpl.java create mode 100644 win-module-mes/win-module-mes-biz/src/main/resources/mapper/mesholidaysetting/MesHolidaySettingMapper.xml diff --git a/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/MesHolidaySettingController.java b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/MesHolidaySettingController.java new file mode 100644 index 000000000..3aef0e30b --- /dev/null +++ b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/MesHolidaySettingController.java @@ -0,0 +1,139 @@ +package com.win.module.mes.controller.mesholidaysetting; + +import io.swagger.v3.oas.annotations.Parameters; +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.*; +import java.io.IOException; + +import com.win.framework.common.pojo.PageResult; +import com.win.framework.common.pojo.CommonResult; +import static com.win.framework.common.pojo.CommonResult.success; + +import com.win.framework.excel.core.util.ExcelUtils; + +import com.win.framework.operatelog.core.annotations.OperateLog; +import static com.win.framework.operatelog.core.enums.OperateTypeEnum.*; + +import com.win.module.mes.controller.mesholidaysetting.vo.*; +import com.win.module.mes.dal.dataobject.mesholidaysetting.MesHolidaySettingDO; +import com.win.module.mes.convert.mesholidaysetting.MesHolidaySettingConvert; +import com.win.module.mes.service.mesholidaysetting.MesHolidaySettingService; +import org.springframework.web.multipart.MultipartFile; + +@Tag(name = "管理后台 - 节假日设置") +@RestController +@RequestMapping("/mes/holidaySetting") +@Validated +public class MesHolidaySettingController { + + @Resource + private MesHolidaySettingService holidaySettingService; + + @PostMapping("/create") + @Operation(summary = "创建节假日设置") + @PreAuthorize("@ss.hasPermission('mes:holidaySetting:create')") + public CommonResult createHolidaySetting(@Valid @RequestBody MesHolidaySettingCreateReqVO createReqVO) { + return success(holidaySettingService.createHolidaySetting(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新节假日设置") + @PreAuthorize("@ss.hasPermission('mes:holidaySetting:update')") + public CommonResult updateHolidaySetting(@Valid @RequestBody MesHolidaySettingUpdateReqVO updateReqVO) { + int result = holidaySettingService.updateHolidaySetting(updateReqVO); + return success(result > 0); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除节假日设置") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:holidaySetting:delete')") + public CommonResult deleteHolidaySetting(@RequestParam("id") Long id) { + int result = holidaySettingService.deleteHolidaySetting(id); + return success(result > 0); + } + + @GetMapping("/get") + @Operation(summary = "获得节假日设置") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('mes:holidaySetting:query')") + public CommonResult getHolidaySetting(@RequestParam("id") Long id) { + MesHolidaySettingDO holidaySetting = holidaySettingService.getHolidaySetting(id); + return success(MesHolidaySettingConvert.INSTANCE.convert(holidaySetting)); + } + + @GetMapping("/list") + @Operation(summary = "获得节假日设置列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('mes:holidaySetting:query')") + public CommonResult> getHolidaySettingList(@RequestParam("ids") Collection ids) { + List list = holidaySettingService.getHolidaySettingList(ids); + return success(MesHolidaySettingConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得节假日设置分页") + @PreAuthorize("@ss.hasPermission('mes:holidaySetting:query')") + public CommonResult> getHolidaySettingPage(@Valid MesHolidaySettingPageReqVO pageVO) { + PageResult pageResult = holidaySettingService.getHolidaySettingPage(pageVO); + return success(MesHolidaySettingConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出节假日设置 Excel") + @PreAuthorize("@ss.hasPermission('mes:holidaySetting:export')") + @OperateLog(type = EXPORT) + public void exportHolidaySettingExcel(@Valid MesHolidaySettingExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = holidaySettingService.getHolidaySettingList(exportReqVO); + // 导出 Excel + List datas = MesHolidaySettingConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "节假日设置.xls", "数据", MesHolidaySettingExcelVO.class, datas); + } + + @GetMapping("/get-import-template") + @Operation(summary = "获得导入节假日设置模板") + public void importTemplate(HttpServletResponse response) throws IOException { + List list = Arrays.asList(); + // 输出 + ExcelUtils.write(response, "节假日设置基本信息导入模板.xls", "节假日设置基本信息列表", MesHolidaySettingExcelVO.class, list); + } + + @PostMapping("/import") + @Operation(summary = "导入节假日设置基本信息") + @Parameters({ + @Parameter(name = "file", description = "Excel 文件", required = true), + @Parameter(name = "mode", description = "导入模式1更新2追加3覆盖", example = "1"), + @Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true") + }) + @PreAuthorize("@ss.hasPermission('mes:holiday-setting:import')") + public CommonResult> importExcel(HttpServletResponse response, + @RequestParam("file") MultipartFile file, + @RequestParam(value = "mode") Integer mode, + @RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception { + + List list = ExcelUtils.read(file, MesHolidaySettingExcelVO.class); + List errorList = holidaySettingService.importMesHolidaySettingList(list, mode, updatePart); + + Map returnMap = new HashMap<>(); + returnMap.put("errorCount", errorList.size()); + if(!errorList.isEmpty()) { + String url = ExcelUtils.writeLocalFile("节假日设置基本信息导入错误数据" + LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")) + ".xlsx", "错误列表", errorList); + returnMap.put("errorFile", url); + } + + return success(returnMap); + } +} diff --git a/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingBaseVO.java b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingBaseVO.java new file mode 100644 index 000000000..2b38cccb1 --- /dev/null +++ b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingBaseVO.java @@ -0,0 +1,70 @@ +package com.win.module.mes.controller.mesholidaysetting.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; +import org.springframework.format.annotation.DateTimeFormat; + +import static com.win.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * 节假日设置 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class MesHolidaySettingBaseVO { + + @Schema(description = "备用字段一") + private String textOne; + + @Schema(description = "备用字段二") + private String textTwo; + + @Schema(description = "备用字段三") + private String textThree; + + @Schema(description = "备用字段四") + private String textFour; + + @Schema(description = "备用字段五") + private String textFive; + + @Schema(description = "删除时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime deleteTime; + + @Schema(description = "状态", example = "2") + private String status; + + @Schema(description = "并发乐观锁", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "并发乐观锁不能为空") + private Integer concurrencyStamp; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "删除用户名") + private String deleter; + + @Schema(description = "位置ID", example = "21742") + private Integer siteId; + + @Schema(description = "更改ID", example = "11261") + private Integer changeEmplId; + + @Schema(description = "节假日日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime holidayDate; + + @Schema(description = "节假日类型") + private String holidayFlag; + + @Schema(description = "节假日名称", example = "芋艿") + private String holidayName; + +} diff --git a/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingCreateReqVO.java b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingCreateReqVO.java new file mode 100644 index 000000000..b0f5ec178 --- /dev/null +++ b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingCreateReqVO.java @@ -0,0 +1,14 @@ +package com.win.module.mes.controller.mesholidaysetting.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 节假日设置创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class MesHolidaySettingCreateReqVO extends MesHolidaySettingBaseVO { + +} diff --git a/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingExcelVO.java b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingExcelVO.java new file mode 100644 index 000000000..57ae4187f --- /dev/null +++ b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingExcelVO.java @@ -0,0 +1,72 @@ +package com.win.module.mes.controller.mesholidaysetting.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * 节假日设置 Excel VO + * + * @author 超级管理员 + */ +@Data +public class MesHolidaySettingExcelVO { + + @ExcelProperty("id") + private Long id; + + @ExcelProperty("备用字段一") + private String textOne; + + @ExcelProperty("备用字段二") + private String textTwo; + + @ExcelProperty("备用字段三") + private String textThree; + + @ExcelProperty("备用字段四") + private String textFour; + + @ExcelProperty("备用字段五") + private String textFive; + + @ExcelProperty("删除时间") + private LocalDateTime deleteTime; + + @ExcelProperty("状态") + private String status; + + @ExcelProperty("并发乐观锁") + private Integer concurrencyStamp; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @ExcelProperty("删除用户名") + private String deleter; + + @ExcelProperty("位置ID") + private Integer siteId; + + @ExcelProperty("更改ID") + private Integer changeEmplId; + + @ExcelProperty("节假日日期") + private LocalDateTime holidayDate; + + @ExcelProperty("节假日类型") + private String holidayFlag; + + @ExcelProperty("节假日名称") + private String holidayName; + +} diff --git a/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingExportReqVO.java b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingExportReqVO.java new file mode 100644 index 000000000..8b4b5cba6 --- /dev/null +++ b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingExportReqVO.java @@ -0,0 +1,67 @@ +package com.win.module.mes.controller.mesholidaysetting.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import com.win.framework.common.pojo.PageParam; +import java.time.LocalDateTime; +import org.springframework.format.annotation.DateTimeFormat; + +import static com.win.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 节假日设置 Excel 导出 Request VO,参数和 MesHolidaySettingPageReqVO 是一致的") +@Data +public class MesHolidaySettingExportReqVO { + + @Schema(description = "备用字段一") + private String textOne; + + @Schema(description = "备用字段二") + private String textTwo; + + @Schema(description = "备用字段三") + private String textThree; + + @Schema(description = "备用字段四") + private String textFour; + + @Schema(description = "备用字段五") + private String textFive; + + @Schema(description = "删除时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] deleteTime; + + @Schema(description = "状态", example = "2") + private String status; + + @Schema(description = "并发乐观锁") + private Integer concurrencyStamp; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "删除用户名") + private String deleter; + + @Schema(description = "位置ID", example = "21742") + private Integer siteId; + + @Schema(description = "更改ID", example = "11261") + private Integer changeEmplId; + + @Schema(description = "节假日日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] holidayDate; + + @Schema(description = "节假日类型") + private String holidayFlag; + + @Schema(description = "节假日名称", example = "芋艿") + private String holidayName; + +} diff --git a/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingPageReqVO.java b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingPageReqVO.java new file mode 100644 index 000000000..d3aabafb6 --- /dev/null +++ b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingPageReqVO.java @@ -0,0 +1,69 @@ +package com.win.module.mes.controller.mesholidaysetting.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import com.win.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static com.win.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 节假日设置分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class MesHolidaySettingPageReqVO extends PageParam { + + @Schema(description = "备用字段一") + private String textOne; + + @Schema(description = "备用字段二") + private String textTwo; + + @Schema(description = "备用字段三") + private String textThree; + + @Schema(description = "备用字段四") + private String textFour; + + @Schema(description = "备用字段五") + private String textFive; + + @Schema(description = "删除时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] deleteTime; + + @Schema(description = "状态", example = "2") + private String status; + + @Schema(description = "并发乐观锁") + private Integer concurrencyStamp; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "删除用户名") + private String deleter; + + @Schema(description = "位置ID", example = "21742") + private Integer siteId; + + @Schema(description = "更改ID", example = "11261") + private Integer changeEmplId; + + @Schema(description = "节假日日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] holidayDate; + + @Schema(description = "节假日类型") + private String holidayFlag; + + @Schema(description = "节假日名称", example = "芋艿") + private String holidayName; + +} diff --git a/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingRespVO.java b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingRespVO.java new file mode 100644 index 000000000..d59654570 --- /dev/null +++ b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingRespVO.java @@ -0,0 +1,19 @@ +package com.win.module.mes.controller.mesholidaysetting.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 节假日设置 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class MesHolidaySettingRespVO extends MesHolidaySettingBaseVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29789") + private Long id; + + @Schema(description = "创建时间") + private LocalDateTime createTime; + +} diff --git a/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingUpdateReqVO.java b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingUpdateReqVO.java new file mode 100644 index 000000000..b37757b96 --- /dev/null +++ b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/controller/mesholidaysetting/vo/MesHolidaySettingUpdateReqVO.java @@ -0,0 +1,18 @@ +package com.win.module.mes.controller.mesholidaysetting.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 节假日设置更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class MesHolidaySettingUpdateReqVO extends MesHolidaySettingBaseVO { + + @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29789") + @NotNull(message = "id不能为空") + private Long id; + +} diff --git a/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/convert/mesholidaysetting/MesHolidaySettingConvert.java b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/convert/mesholidaysetting/MesHolidaySettingConvert.java new file mode 100644 index 000000000..a7d6e1a44 --- /dev/null +++ b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/convert/mesholidaysetting/MesHolidaySettingConvert.java @@ -0,0 +1,34 @@ +package com.win.module.mes.convert.mesholidaysetting; + +import java.util.*; + +import com.win.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import com.win.module.mes.controller.mesholidaysetting.vo.*; +import com.win.module.mes.dal.dataobject.mesholidaysetting.MesHolidaySettingDO; + +/** + * 节假日设置 Convert + * + * @author 超级管理员 + */ +@Mapper +public interface MesHolidaySettingConvert { + + MesHolidaySettingConvert INSTANCE = Mappers.getMapper(MesHolidaySettingConvert.class); + + MesHolidaySettingDO convert(MesHolidaySettingCreateReqVO bean); + + MesHolidaySettingDO convert(MesHolidaySettingUpdateReqVO bean); + + MesHolidaySettingRespVO convert(MesHolidaySettingDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/dal/dataobject/mesholidaysetting/MesHolidaySettingDO.java b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/dal/dataobject/mesholidaysetting/MesHolidaySettingDO.java new file mode 100644 index 000000000..9b04e4006 --- /dev/null +++ b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/dal/dataobject/mesholidaysetting/MesHolidaySettingDO.java @@ -0,0 +1,92 @@ +package com.win.module.mes.dal.dataobject.mesholidaysetting; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import com.win.framework.mybatis.core.dataobject.BaseDO; + +/** + * 节假日设置 DO + * + * @author 超级管理员 + */ +@TableName("system_mes_holiday_setting") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MesHolidaySettingDO extends BaseDO { + + /** + * id + */ + @TableId + private Long id; + /** + * 备用字段一 + */ + private String textOne; + /** + * 备用字段二 + */ + private String textTwo; + /** + * 备用字段三 + */ + private String textThree; + /** + * 备用字段四 + */ + private String textFour; + /** + * 备用字段五 + */ + private String textFive; + /** + * 删除时间 + */ + private LocalDateTime deleteTime; + /** + * 状态 + */ + private String status; + /** + * 并发乐观锁 + */ + private Integer concurrencyStamp; + /** + * 备注 + */ + private String remark; + /** + * 删除用户名 + */ + private String deleter; + /** + * 位置ID + */ + private Integer siteId; + /** + * 更改ID + */ + private Integer changeEmplId; + /** + * 节假日日期 + */ + private LocalDateTime holidayDate; + /** + * 节假日类型 + */ + private String holidayFlag; + /** + * 节假日名称 + */ + private String holidayName; + +} diff --git a/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/dal/mysql/mesholidaysetting/MesHolidaySettingMapper.java b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/dal/mysql/mesholidaysetting/MesHolidaySettingMapper.java new file mode 100644 index 000000000..da51d0147 --- /dev/null +++ b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/dal/mysql/mesholidaysetting/MesHolidaySettingMapper.java @@ -0,0 +1,62 @@ +package com.win.module.mes.dal.mysql.mesholidaysetting; + +import java.util.*; + +import com.win.framework.common.pojo.PageResult; +import com.win.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.win.framework.mybatis.core.mapper.BaseMapperX; +import com.win.module.mes.dal.dataobject.mesholidaysetting.MesHolidaySettingDO; +import org.apache.ibatis.annotations.Mapper; +import com.win.module.mes.controller.mesholidaysetting.vo.*; + +/** + * 节假日设置 Mapper + * + * @author 超级管理员 + */ +@Mapper +public interface MesHolidaySettingMapper extends BaseMapperX { + + default PageResult selectPage(MesHolidaySettingPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(MesHolidaySettingDO::getTextOne, reqVO.getTextOne()) + .eqIfPresent(MesHolidaySettingDO::getTextTwo, reqVO.getTextTwo()) + .eqIfPresent(MesHolidaySettingDO::getTextThree, reqVO.getTextThree()) + .eqIfPresent(MesHolidaySettingDO::getTextFour, reqVO.getTextFour()) + .eqIfPresent(MesHolidaySettingDO::getTextFive, reqVO.getTextFive()) + .betweenIfPresent(MesHolidaySettingDO::getDeleteTime, reqVO.getDeleteTime()) + .eqIfPresent(MesHolidaySettingDO::getStatus, reqVO.getStatus()) + .eqIfPresent(MesHolidaySettingDO::getConcurrencyStamp, reqVO.getConcurrencyStamp()) + .eqIfPresent(MesHolidaySettingDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(MesHolidaySettingDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(MesHolidaySettingDO::getDeleter, reqVO.getDeleter()) + .eqIfPresent(MesHolidaySettingDO::getSiteId, reqVO.getSiteId()) + .eqIfPresent(MesHolidaySettingDO::getChangeEmplId, reqVO.getChangeEmplId()) + .betweenIfPresent(MesHolidaySettingDO::getHolidayDate, reqVO.getHolidayDate()) + .eqIfPresent(MesHolidaySettingDO::getHolidayFlag, reqVO.getHolidayFlag()) + .likeIfPresent(MesHolidaySettingDO::getHolidayName, reqVO.getHolidayName()) + .orderByDesc(MesHolidaySettingDO::getId)); + } + + default List selectList(MesHolidaySettingExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(MesHolidaySettingDO::getTextOne, reqVO.getTextOne()) + .eqIfPresent(MesHolidaySettingDO::getTextTwo, reqVO.getTextTwo()) + .eqIfPresent(MesHolidaySettingDO::getTextThree, reqVO.getTextThree()) + .eqIfPresent(MesHolidaySettingDO::getTextFour, reqVO.getTextFour()) + .eqIfPresent(MesHolidaySettingDO::getTextFive, reqVO.getTextFive()) + .betweenIfPresent(MesHolidaySettingDO::getDeleteTime, reqVO.getDeleteTime()) + .eqIfPresent(MesHolidaySettingDO::getStatus, reqVO.getStatus()) + .eqIfPresent(MesHolidaySettingDO::getConcurrencyStamp, reqVO.getConcurrencyStamp()) + .eqIfPresent(MesHolidaySettingDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(MesHolidaySettingDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(MesHolidaySettingDO::getDeleter, reqVO.getDeleter()) + .eqIfPresent(MesHolidaySettingDO::getSiteId, reqVO.getSiteId()) + .eqIfPresent(MesHolidaySettingDO::getChangeEmplId, reqVO.getChangeEmplId()) + .betweenIfPresent(MesHolidaySettingDO::getHolidayDate, reqVO.getHolidayDate()) + .eqIfPresent(MesHolidaySettingDO::getHolidayFlag, reqVO.getHolidayFlag()) + .likeIfPresent(MesHolidaySettingDO::getHolidayName, reqVO.getHolidayName()) + .orderByDesc(MesHolidaySettingDO::getId)); + } + +} diff --git a/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/enums/ErrorCodeConstants.java b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/enums/ErrorCodeConstants.java index e23a551e0..6321c136e 100644 --- a/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/enums/ErrorCodeConstants.java +++ b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/enums/ErrorCodeConstants.java @@ -61,6 +61,10 @@ public interface ErrorCodeConstants { ErrorCode OPERSTEPS_TYPE_ERROR = new ErrorCode(2_002_000_020, "操作步骤类型异常!"); ErrorCode OPERSTEPS_TYPE_ERRORMODE = new ErrorCode(2_002_000_021, "未知的导入模式!"); + ErrorCode HOLIDAY_SETTING_NOT_EXISTS = new ErrorCode(2_001_000_013, "节假日不存在!"); + ErrorCode HOLIDAY_SETTING_IMPORT_LIST_IS_EMPTY = new ErrorCode(2_001_000_014, "节假日导入数据内容为空!"); + + } diff --git a/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/service/mesholidaysetting/MesHolidaySettingService.java b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/service/mesholidaysetting/MesHolidaySettingService.java new file mode 100644 index 000000000..e26e5716d --- /dev/null +++ b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/service/mesholidaysetting/MesHolidaySettingService.java @@ -0,0 +1,79 @@ +package com.win.module.mes.service.mesholidaysetting; + +import java.util.*; +import javax.validation.*; +import com.win.module.mes.controller.mesholidaysetting.vo.*; +import com.win.module.mes.dal.dataobject.mesholidaysetting.MesHolidaySettingDO; +import com.win.framework.common.pojo.PageResult; + +/** + * 节假日设置 Service 接口 + * + * @author 超级管理员 + */ +public interface MesHolidaySettingService { + + /** + * 创建节假日设置 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createHolidaySetting(@Valid MesHolidaySettingCreateReqVO createReqVO); + + /** + * 更新节假日设置 + * + * @param updateReqVO 更新信息 + */ + Integer updateHolidaySetting(@Valid MesHolidaySettingUpdateReqVO updateReqVO); + + /** + * 删除节假日设置 + * + * @param id 编号 + */ + Integer deleteHolidaySetting(Long id); + + /** + * 获得节假日设置 + * + * @param id 编号 + * @return 节假日设置 + */ + MesHolidaySettingDO getHolidaySetting(Long id); + + /** + * 获得节假日设置列表 + * + * @param ids 编号 + * @return 节假日设置列表 + */ + List getHolidaySettingList(Collection ids); + + /** + * 获得节假日设置分页 + * + * @param pageReqVO 分页查询 + * @return 节假日设置分页 + */ + PageResult getHolidaySettingPage(MesHolidaySettingPageReqVO pageReqVO); + + /** + * 获得节假日设置列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 节假日设置列表 + */ + List getHolidaySettingList(MesHolidaySettingExportReqVO exportReqVO); + + /** + * 导入节假日设置主信息 + * + * @param datas 导入节假日设置主信息列表 + * @param mode 导入模式1更新2追加3覆盖 + * @param updatePart 是否支持更新 + * @return 导入结果 + */ + public List importMesHolidaySettingList(List datas, Integer mode, boolean updatePart); +} diff --git a/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/service/mesholidaysetting/MesHolidaySettingServiceImpl.java b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/service/mesholidaysetting/MesHolidaySettingServiceImpl.java new file mode 100644 index 000000000..3861c4478 --- /dev/null +++ b/win-module-mes/win-module-mes-biz/src/main/java/com/win/module/mes/service/mesholidaysetting/MesHolidaySettingServiceImpl.java @@ -0,0 +1,107 @@ +package com.win.module.mes.service.mesholidaysetting; + +import cn.hutool.core.collection.CollUtil; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import com.win.module.mes.controller.mesholidaysetting.vo.*; +import com.win.module.mes.dal.dataobject.mesholidaysetting.MesHolidaySettingDO; +import com.win.framework.common.pojo.PageResult; + +import com.win.module.mes.convert.mesholidaysetting.MesHolidaySettingConvert; +import com.win.module.mes.dal.mysql.mesholidaysetting.MesHolidaySettingMapper; + +import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.win.module.mes.enums.ErrorCodeConstants.*; + +/** + * 节假日设置 Service 实现类 + * + * @author 超级管理员 + */ +@Service +@Validated +public class MesHolidaySettingServiceImpl implements MesHolidaySettingService { + + @Resource + private MesHolidaySettingMapper holidaySettingMapper; + + @Override + public Long createHolidaySetting(MesHolidaySettingCreateReqVO createReqVO) { + // 插入 + MesHolidaySettingDO holidaySetting = MesHolidaySettingConvert.INSTANCE.convert(createReqVO); + holidaySettingMapper.insert(holidaySetting); + // 返回 + return holidaySetting.getId(); + } + + @Override + public Integer updateHolidaySetting(MesHolidaySettingUpdateReqVO updateReqVO) { + // 校验存在 + validateHolidaySettingExists(updateReqVO.getId()); + // 更新 + MesHolidaySettingDO updateObj = MesHolidaySettingConvert.INSTANCE.convert(updateReqVO); + return holidaySettingMapper.updateById(updateObj); + } + + @Override + public Integer deleteHolidaySetting(Long id) { + // 校验存在 + validateHolidaySettingExists(id); + // 删除 + return holidaySettingMapper.deleteById(id); + } + + private void validateHolidaySettingExists(Long id) { + if (holidaySettingMapper.selectById(id) == null) { + throw exception(HOLIDAY_SETTING_NOT_EXISTS); + } + } + + @Override + public MesHolidaySettingDO getHolidaySetting(Long id) { + return holidaySettingMapper.selectById(id); + } + + @Override + public List getHolidaySettingList(Collection ids) { + return holidaySettingMapper.selectBatchIds(ids); + } + + @Override + public PageResult getHolidaySettingPage(MesHolidaySettingPageReqVO pageReqVO) { + return holidaySettingMapper.selectPage(pageReqVO); + } + + @Override + public List getHolidaySettingList(MesHolidaySettingExportReqVO exportReqVO) { + return holidaySettingMapper.selectList(exportReqVO); + } + + @Override + public List importMesHolidaySettingList(List datas, Integer mode, boolean updatePart) { + if (CollUtil.isEmpty(datas)) { + throw exception(HOLIDAY_SETTING_IMPORT_LIST_IS_EMPTY); + } + + List errorList = new ArrayList<>(); +// datas.forEach(item -> { +// if(errorList == null){ +// // 判断如果不存在,在进行插入 +// MesHolidaySettingDO obj = holidaySettingMapper.selectByCode(item.getCode()); +// if (obj == null&& mode != 3) { +// holidaySettingMapper.insert(MesHolidaySettingConvert.INSTANCE.convert(item)); +// } +// else if (obj != null && mode != 2) {// 如果存在,判断是否允许更新 +// MesHolidaySettingDO holidaySettingDO = MesHolidaySettingConvert.INSTANCE.convert(item); +// holidaySettingDO.setId(obj.getId()); +// holidaySettingMapper.updateById(obj); +// } +// } +// }); + + return errorList; + } +} diff --git a/win-module-mes/win-module-mes-biz/src/main/resources/mapper/mesholidaysetting/MesHolidaySettingMapper.xml b/win-module-mes/win-module-mes-biz/src/main/resources/mapper/mesholidaysetting/MesHolidaySettingMapper.xml new file mode 100644 index 000000000..e65e1b1eb --- /dev/null +++ b/win-module-mes/win-module-mes-biz/src/main/resources/mapper/mesholidaysetting/MesHolidaySettingMapper.xml @@ -0,0 +1,12 @@ + + + + + + +