From 9a3cac240f1ad1b62a46dd862bcfc42bc0645bb5 Mon Sep 17 00:00:00 2001 From: skjia <106962133@qq.com> Date: Fri, 22 Mar 2024 18:38:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=80=BC=E7=8F=AD=E8=AE=A1=E5=88=92=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=BB=A3=E7=A0=81=E4=B8=8A=E4=BC=A0=20---=20jsk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/background/vo/DutyPlanVo.java | 63 ++++++++++++ .../controller/DutyPlanController.java | 58 +++++++++++ .../controller/ExportFileController.java | 36 +++++++ .../export/entity/DutyPlanExportVo.java | 40 ++++++++ .../background/mapper/DutyPlanMapper.java | 37 +++++++ .../background/service/DutyPlanService.java | 47 +++++++++ .../service/impl/DutyPlanServiceImpl.java | 96 +++++++++++++++++++ .../main/resources/mapper/DutyPlanMapper.xml | 69 +++++++++++++ 8 files changed, 446 insertions(+) create mode 100644 securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/DutyPlanVo.java create mode 100644 securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/controller/DutyPlanController.java create mode 100644 securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/export/entity/DutyPlanExportVo.java create mode 100644 securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/mapper/DutyPlanMapper.java create mode 100644 securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/DutyPlanService.java create mode 100644 securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/DutyPlanServiceImpl.java create mode 100644 securitycontrol-model/securitycontrol-background/src/main/resources/mapper/DutyPlanMapper.xml diff --git a/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/DutyPlanVo.java b/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/DutyPlanVo.java new file mode 100644 index 0000000..ccb75ab --- /dev/null +++ b/securitycontrol-commons/securitycontrol-commons-entity/src/main/java/com/securitycontrol/entity/background/vo/DutyPlanVo.java @@ -0,0 +1,63 @@ +package com.securitycontrol.entity.background.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; + +/** + * @author 10488 + * 值班计划VO + */ +@Data +public class DutyPlanVo { + + private String id; + + @ApiModelProperty(value = "日期") + @NotBlank(message = "日期不能为空", groups = {Query.class}) + @Length(max = 80, message = "日期字符长度不能超过80", groups = {Query.class}) + private String createDay; + + @ApiModelProperty(value = "类型") + @NotBlank(message = "类型不能为空", groups = {Query.class}) + private String type; + + @ApiModelProperty(value = "周一") + @Length(max = 180, message = "日期字符长度不能超过180", groups = {Query.class}) + private String mon; + + @ApiModelProperty(value = "周二") + @Length(max = 180, message = "日期字符长度不能超过180", groups = {Query.class}) + private String tue; + + @ApiModelProperty(value = "周三") + @Length(max = 180, message = "日期字符长度不能超过180", groups = {Query.class}) + private String wed; + + @ApiModelProperty(value = "周四") + @Length(max = 180, message = "日期字符长度不能超过180", groups = {Query.class}) + private String thu; + + @ApiModelProperty(value = "周五") + @Length(max = 180, message = "日期字符长度不能超过180", groups = {Query.class}) + private String fri; + + @ApiModelProperty(value = "周六") + @Length(max = 180, message = "日期字符长度不能超过180", groups = {Query.class}) + private String sat; + + @ApiModelProperty(value = "周日") + @Length(max = 180, message = "日期字符长度不能超过180", groups = {Query.class}) + private String sun; + + private String delFlag; + private String flage; + /** + * 查询条件限制 + */ + public interface Query { + } +} diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/controller/DutyPlanController.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/controller/DutyPlanController.java new file mode 100644 index 0000000..3d54fa5 --- /dev/null +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/controller/DutyPlanController.java @@ -0,0 +1,58 @@ +package com.securitycontrol.background.controller; + +import com.securitycontrol.background.service.DutyPlanService; +import com.securitycontrol.background.service.TeamService; +import com.securitycontrol.common.core.web.controller.BaseController; +import com.securitycontrol.common.core.web.domain.AjaxResult; +import com.securitycontrol.common.core.web.page.TableDataInfo; +import com.securitycontrol.common.log.annotation.Log; +import com.securitycontrol.common.log.enums.OperationType; +import com.securitycontrol.entity.background.dto.ParamDto; +import com.securitycontrol.entity.background.vo.DutyPlanVo; +import com.securitycontrol.entity.background.vo.TeamManageVo; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * 值班计划管理 + * + * @author jsk + */ +@RequestMapping(value = "/back/dutyPlan/") +@RestController +public class DutyPlanController extends BaseController { + + @Resource(name = "DutyPlanService") + private DutyPlanService service; + + @ApiOperation(value = "获取时间列表") + @GetMapping("getTimeLists") + @Log(title = "值班计划管理", menu = "风险值班管理->值班计划管理", grade = OperationType.QUERY_BUSINESS, details = "查询时间列表", type = "业务日志") + public Map getTeamLists() { + Map map =new HashMap<>(); + map = service.getTimeLists(); + return map; + } + + @ApiOperation(value = "新增修改值班计划") + @PostMapping("addOrUpdateDutyPlan") + @Log(title = "值班计划管理", menu = "风险值班管理->班组管理", grade = OperationType.ADD_BUSINESS, details = "新增修改值班计划", type = "业务日志") + public AjaxResult addDutyPlan(@RequestBody DutyPlanVo vo) { + return service.addOrUpdateDutyPlan(vo); + } + + @ApiOperation(value = "获取值班列表") + @GetMapping("getDutyPlanLists") + @Log(title = "值班计划管理", menu = "风险值班管理->值班计划管理", grade = OperationType.QUERY_BUSINESS, details = "查询值班计划", type = "业务日志") + public List getDutyPlanLists(@RequestBody DutyPlanVo vo) { + Map map =new HashMap<>(); + List list = service.getDutyPlan(vo); + return list; + } +} diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/controller/ExportFileController.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/controller/ExportFileController.java index 1322884..a6697ca 100644 --- a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/controller/ExportFileController.java +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/controller/ExportFileController.java @@ -3,10 +3,12 @@ package com.securitycontrol.background.controller; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; +import com.securitycontrol.background.export.entity.DutyPlanExportVo; import com.securitycontrol.background.export.entity.TeamExportVo; import com.securitycontrol.background.export.entity.TeamUserExportVo; import com.securitycontrol.background.export.entity.UserAccessExportVo; import com.securitycontrol.background.export.util.ExcelStyleUtil; +import com.securitycontrol.background.service.DutyPlanService; import com.securitycontrol.background.service.HumanService; import com.securitycontrol.background.service.TeamService; import com.securitycontrol.common.core.utils.StringUtils; @@ -14,6 +16,7 @@ import com.securitycontrol.common.core.utils.aes.DateTimeHelper; import com.securitycontrol.common.log.annotation.Log; import com.securitycontrol.common.log.enums.OperationType; import com.securitycontrol.entity.background.dto.ParamDto; +import com.securitycontrol.entity.background.vo.DutyPlanVo; import com.securitycontrol.entity.background.vo.HumanManageVo; import com.securitycontrol.entity.background.vo.TeamManageVo; import com.securitycontrol.entity.background.vo.UserAccessVo; @@ -50,6 +53,39 @@ public class ExportFileController { @Resource(name = "HumanService") private HumanService humanService; + @Resource(name = "DutyPlanService") + private DutyPlanService dutyPlanService; + + @GetMapping("exportDutyPlanData") + @Log(title = "值班计划管理", menu = "风险值班管理->值班计划管理", grade = OperationType.EXPORT_BUSINESS, details = "导出值班计划", type = "业务日志") + public void exportDutyPlanData(HttpServletRequest request, HttpServletResponse response, DutyPlanVo dto) { + try { + List teamExportVoList = new ArrayList<>(); + List teamLists = dutyPlanService.getDutyPlan(dto); + for (int i = 0; i < teamLists.size(); i++) { + if("1".equals(teamLists.get(i).getType())){ + teamLists.get(i).setType("上午"); + }else{ + teamLists.get(i).setType("下午"); + } + DutyPlanExportVo exportVo = new DutyPlanExportVo(); + BeanUtils.copyProperties(teamLists.get(i), exportVo); + teamExportVoList.add(exportVo); + } + ExportParams exportParams = new ExportParams("值班计划列表", "值班计划列表", ExcelType.XSSF); + exportParams.setStyle(ExcelStyleUtil.class); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, TeamExportVo.class, teamExportVoList); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode("班组列表" + ".xlsx", "UTF-8")); + ServletOutputStream outputStream = response.getOutputStream(); + workbook.write(outputStream); + outputStream.close(); + workbook.close(); + } catch (Exception e) { + log.error("导出值班计划", e); + } + } + @GetMapping("exportTeamData") @Log(title = "人车管理", menu = "人车管理->班组管理", grade = OperationType.EXPORT_BUSINESS, details = "导出班组", type = "业务日志") public void exportTeamData(HttpServletRequest request, HttpServletResponse response, ParamDto dto) { diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/export/entity/DutyPlanExportVo.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/export/entity/DutyPlanExportVo.java new file mode 100644 index 0000000..0498f05 --- /dev/null +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/export/entity/DutyPlanExportVo.java @@ -0,0 +1,40 @@ +package com.securitycontrol.background.export.entity; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + + +/** + * @author:cwchen + * @date:2024-03-12-14:21 + * @version:1.0 + * @description:班组导出-vo + */ +@Data +public class DutyPlanExportVo { + + @Excel(name = "--", width = 20.0, orderNum = "0") + private String type; + + @Excel(name = "周一", width = 20.0, orderNum = "1") + private String mon; + + @Excel(name = "周二", width = 20.0, orderNum = "2") + private String tue; + + @Excel(name = "周三", width = 20.0, orderNum = "3") + private String wed; + + @Excel(name = "周四", width = 20.0, orderNum = "4") + private String thu; + + @Excel(name = "周五", width = 20.0, orderNum = "5") + private String fri; + + @Excel(name = "周六", width = 20.0, orderNum = "6") + private String sat; + + @Excel(name = "周日", width = 20.0, orderNum = "7") + private String sun; + +} diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/mapper/DutyPlanMapper.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/mapper/DutyPlanMapper.java new file mode 100644 index 0000000..e5a642f --- /dev/null +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/mapper/DutyPlanMapper.java @@ -0,0 +1,37 @@ +package com.securitycontrol.background.mapper; + +import com.securitycontrol.entity.background.dto.ParamDto; +import com.securitycontrol.entity.background.vo.DutyPlanVo; +import com.securitycontrol.entity.background.vo.TeamManageVo; +import org.apache.ibatis.annotations.MapKey; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +/** + * 班组数据库访问层 + * + * @author 10488 + */ +@Repository(value = "DutyPlanMapper") +public interface DutyPlanMapper { + /** + * DD + * + * @param vo + * @return + */ + int addDutyPlan(DutyPlanVo vo); + + /** + * 获取班组列表 + * + * @param dto + * @return List + * @description + * @author cwchen + * @date 2024/3/21 9:45 + */ + List getDutyPlan(DutyPlanVo dto); +} diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/DutyPlanService.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/DutyPlanService.java new file mode 100644 index 0000000..8160129 --- /dev/null +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/DutyPlanService.java @@ -0,0 +1,47 @@ +package com.securitycontrol.background.service; + +import com.securitycontrol.common.core.web.domain.AjaxResult; +import com.securitycontrol.entity.background.dto.ParamDto; +import com.securitycontrol.entity.background.vo.DutyPlanVo; +import com.securitycontrol.entity.background.vo.TeamManageVo; + +import java.util.List; +import java.util.Map; + +/** + * @author 10488 + * 班组-业务层 + */ +public interface DutyPlanService { + /** + * 获取时间列表 + * + * @param + * @return Map + * @description + * @author jsk + * @date 2024/3/21 9:40 + */ + Map getTimeLists(); + /** + * 新增修改值班计划 + * + * @param + * @return AjaxResult + * @description + * @author jsk + * @date 2024/3/21 9:40 + */ + AjaxResult addOrUpdateDutyPlan(DutyPlanVo vo); + /** + * 值班计划 + * + * @param + * @return List + * @description + * @author jsk + * @date 2024/3/21 9:40 + */ + List getDutyPlan(DutyPlanVo vo); + +} diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/DutyPlanServiceImpl.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/DutyPlanServiceImpl.java new file mode 100644 index 0000000..ecc6f7f --- /dev/null +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/DutyPlanServiceImpl.java @@ -0,0 +1,96 @@ +package com.securitycontrol.background.service.impl; + +import com.securitycontrol.background.mapper.DutyPlanMapper; +import com.securitycontrol.background.service.DutyPlanService; +import com.securitycontrol.common.core.web.domain.AjaxResult; +import com.securitycontrol.entity.background.vo.DutyPlanVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.text.SimpleDateFormat; +import java.util.*; + +@Service(value = "DutyPlanService") +@Slf4j +public class DutyPlanServiceImpl implements DutyPlanService { + + @Resource(name = "DutyPlanMapper") + private DutyPlanMapper mapper; + + @Override + public Map getTimeLists() { + Map map=new HashMap<>(); + List dates=new ArrayList<>(); + try{ + for(int i=-4;i<=4;i++){ + + String monday= getWeekMon(new Date((System.currentTimeMillis())+(i*7*60*60*1000*24L))); + String sunday= getWeekSun(new Date((System.currentTimeMillis())+(i*7*60*60*1000*24L))); + dates.add(monday+"~"+sunday); + } + map.put("code",200); + map.put("data",dates); + }catch (Exception e){ + map.put("code",400); + } + return map; + } + + @Override + public AjaxResult addOrUpdateDutyPlan(DutyPlanVo vo) { + try{ + DutyPlanVo vod=new DutyPlanVo(); + vod.setCreateDay(vo.getCreateDay()); + vod.setType(vo.getType()); + List list=mapper.getDutyPlan(vod); + if(list!=null&&list.size()>0){ + vo.setFlage("2"); + mapper.addDutyPlan(vo); + }else{ + vo.setFlage("1"); + mapper.addDutyPlan(vo); + } + }catch (Exception e){ + AjaxResult.error(); + } + return AjaxResult.success(); + } + + @Override + public List getDutyPlan(DutyPlanVo vo) { + return mapper.getDutyPlan(vo); + } + + + /** + * 获取本周周日日期 + * @return + */ + public static String getWeekSun(Date date){ + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + Calendar c = Calendar.getInstance(); + c.setTime(date); + // 如果是周日直接返回 + if (c.get(Calendar.DAY_OF_WEEK) == 1) { + return sdf.format(date); + } + //System.out.println(c.get(Calendar.DAY_OF_WEEK)); + c.add(Calendar.DATE, 7 - c.get(Calendar.DAY_OF_WEEK) + 1); + return sdf.format(c.getTime()); + } + /** + * 获取本周周一日期 + * @return + */ + public static String getWeekMon(Date date) { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + Calendar c = Calendar.getInstance(); + c.setTime(date); + if (c.get(Calendar.DAY_OF_WEEK) == 1) { + c.add(Calendar.DAY_OF_MONTH, -1); + } + c.add(Calendar.DATE, c.getFirstDayOfWeek() - c.get(Calendar.DAY_OF_WEEK) + 1); + return sdf.format(c.getTime()); + } +} diff --git a/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/DutyPlanMapper.xml b/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/DutyPlanMapper.xml new file mode 100644 index 0000000..5793a81 --- /dev/null +++ b/securitycontrol-model/securitycontrol-background/src/main/resources/mapper/DutyPlanMapper.xml @@ -0,0 +1,69 @@ + + + + + + + + INSERT INTO tb_duty_plan + + create_day, + type, + mon, + tue, + wed, + thu, + fri, + sat, + sun, + + + #{createDay}, + #{type}, + #{mon}, + #{tue}, + #{wed}, + #{thu}, + #{fri}, + #{sun}, + + + + UPDATE tb_duty_plan + + mon = #{mon}, + tue = #{tue}, + wed = #{wed}, + thu = #{thu}, + fri = #{fri}, + sat = #{sat}, + sun = #{sun}, + + WHERE create_day = #{createDay} and type=#{type} + + + + + + \ No newline at end of file