Compare commits

..

2 Commits

Author SHA1 Message Date
skjia 309b559896 Merge branch 'master' of http://192.168.0.56:3000/haozq/ah_jjzhgd_service 2024-03-22 18:42:27 +08:00
skjia 9a3cac240f 值班计划管理代码上传 --- jsk 2024-03-22 18:38:01 +08:00
8 changed files with 446 additions and 0 deletions

View File

@ -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 {
}
}

View File

@ -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<String, Object> getTeamLists() {
Map<String, Object> 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<DutyPlanVo> getDutyPlanLists(@RequestBody DutyPlanVo vo) {
Map<String, Object> map =new HashMap<>();
List<DutyPlanVo> list = service.getDutyPlan(vo);
return list;
}
}

View File

@ -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<DutyPlanExportVo> teamExportVoList = new ArrayList<>();
List<DutyPlanVo> 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) {

View File

@ -0,0 +1,40 @@
package com.securitycontrol.background.export.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
/**
* @authorcwchen
* @date2024-03-12-14:21
* @version1.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;
}

View File

@ -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<TeamManageVo>
* @description
* @author cwchen
* @date 2024/3/21 9:45
*/
List<DutyPlanVo> getDutyPlan(DutyPlanVo dto);
}

View File

@ -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<String, Object>
* @description
* @author jsk
* @date 2024/3/21 9:40
*/
Map<String, Object> getTimeLists();
/**
* 新增修改值班计划
*
* @param
* @return AjaxResult
* @description
* @author jsk
* @date 2024/3/21 9:40
*/
AjaxResult addOrUpdateDutyPlan(DutyPlanVo vo);
/**
* 值班计划
*
* @param
* @return List<DutyPlanVo>
* @description
* @author jsk
* @date 2024/3/21 9:40
*/
List<DutyPlanVo> getDutyPlan(DutyPlanVo vo);
}

View File

@ -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<String, Object> getTimeLists() {
Map<String, Object> map=new HashMap<>();
List<String> 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<DutyPlanVo> 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<DutyPlanVo> 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());
}
}

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.securitycontrol.background.mapper.DutyPlanMapper">
<!--新增/修改值班计划-->
<insert id="addDutyPlan">
<if test="flage == 1">
INSERT INTO tb_duty_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="teamId != null and teamId != ''">create_day,</if>
<if test="teamName != null and teamName != ''">type,</if>
<if test="teamLeader != null and teamLeader != ''">mon,</if>
<if test="bidCode != null and bidCode!=''">tue,</if>
<if test="teamLeaderPhone != null and teamLeaderPhone!=''">wed,</if>
<if test="idNumber != null and idNumber!=''">thu,</if>
<if test="status != null and status!=''">fri,</if>
<if test="status != null and status!=''">sat,</if>
<if test="status != null and status!=''">sun,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="createDay != null and createDay != ''">#{createDay},</if>
<if test="type != null and type != ''">#{type},</if>
<if test="mon != null and mon != ''">#{mon},</if>
<if test="tue != null and tue!=''">#{tue},</if>
<if test="wed != null and wed!=''">#{wed},</if>
<if test="thu != null and thu!=''">#{thu},</if>
<if test="fri != null and fri!=''">#{fri},</if>
<if test="sun != null and sun!=''">#{sun},</if>
</trim>
</if>
<if test="flage == 2">
UPDATE tb_duty_plan
<set>
<if test="mon != null and mon != ''">mon = #{mon},</if>
<if test="tue != null and tue != ''">tue = #{tue},</if>
<if test="wed != null and wed != ''">wed = #{wed},</if>
<if test="thu != null and thu != ''">thu = #{thu},</if>
<if test="fri != null and fri != ''">fri = #{fri},</if>
<if test="sat != null and sat != ''">sat = #{sat},</if>
<if test="sun != null and sun != ''">sun = #{sun},</if>
</set>
WHERE create_day = #{createDay} and type=#{type}
</if>
</insert>
<!--获取值班计划列表-->
<select id="getDutyPlan" resultType="com.securitycontrol.entity.background.vo.DutyPlanVo">
SELECT
tdp.create_day as createDay,
tdp.type as type,
tdp.mon as mon,
tdp.tue as tue,
tdp.wed as wed,
tdp.thu as thu,
tdp.fri as fri,
tdp.sat as sat,
tdp.sun as sun
FROM tb_duty_plan tdp
<where>
<if test="createDay !=null and createDay!=''">
AND tdp.create_day=#{createDay}
</if>
<if test="type !=null and type!=''">
AND tdp.type=#{type}
</if>
</where>
oreder by create_time
</select>
</mapper>