diff --git a/zc-business/src/main/java/com/zc/business/controller/DcOrganizationController.java b/zc-business/src/main/java/com/zc/business/controller/DcOrganizationController.java index f9c05daf..3c13893c 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcOrganizationController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcOrganizationController.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.ruoyi.common.core.page.TableDataInfo; import com.zc.business.domain.DcOrganizationExport; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -47,10 +48,11 @@ public class DcOrganizationController extends BaseController @PreAuthorize("@ss.hasPermi('business:organization:list')") @GetMapping("/list") - public AjaxResult list(DcOrganization dcOrganization) + public TableDataInfo list(DcOrganization dcOrganization) { + startPage(); ArrayList hashMaps = dcOrganizationService.selectDcOrganizationList(dcOrganization); - return AjaxResult.success(hashMaps); + return getDataTable(hashMaps); } /** diff --git a/zc-business/src/main/java/com/zc/business/controller/DcShiftsController.java b/zc-business/src/main/java/com/zc/business/controller/DcShiftsController.java index 2f3662f7..3218544b 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcShiftsController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcShiftsController.java @@ -3,8 +3,14 @@ package com.zc.business.controller; import java.io.InputStream; import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.servlet.http.HttpServletResponse; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.google.gson.JsonElement; +import com.ruoyi.common.utils.StringUtils; import com.zc.business.domain.DcShiftsRecord; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -12,6 +18,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.Mapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; @@ -28,7 +35,8 @@ import com.zc.business.service.IDcShiftsService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; import org.springframework.web.multipart.MultipartFile; - +import springfox.documentation.spring.web.json.Json; +import com.google.gson.*; /** * 值班Controller * @@ -52,7 +60,7 @@ public class DcShiftsController extends BaseController public TableDataInfo list(DcShifts dcShifts) { startPage(); - List list = dcShiftsService.selectDcShiftsList(dcShifts); + List list = dcShiftsService.selectDcShiftsList(dcShifts); return getDataTable(list); } @@ -113,6 +121,15 @@ public class DcShiftsController extends BaseController public AjaxResult remove(@PathVariable Long[] ids) throws Exception{ return toAjax(dcShiftsService.deleteDcShiftsByIds(ids)); } + /** + * 删除值班,某个时间下驻点下的全部值班信息 + */ + @PreAuthorize("@ss.hasPermi('business:shifts:remove')") + @Log(title = "值班", businessType = BusinessType.DELETE) + @PostMapping("/delete") + public AjaxResult removeDelete(@RequestBody DcShifts shifts) throws Exception{ + return toAjax(dcShiftsService.deleteDcShiftsListId(shifts)); + } //导出模板 @ApiOperation("导出模板") @@ -145,11 +162,11 @@ public class DcShiftsController extends BaseController * 查询操作记录 */ @ApiOperation("查询操作记录") - @GetMapping("/recordList") - public TableDataInfo recordList() + @PostMapping("/recordList") + public TableDataInfo recordList(@RequestBody DcShifts dcShifts) { startPage(); - List list = dcShiftsService.selectDcShiftsRecord(); + List list = dcShiftsService.selectDcShiftsRecord(dcShifts); return getDataTable(list); } diff --git a/zc-business/src/main/java/com/zc/business/domain/DcShifts.java b/zc-business/src/main/java/com/zc/business/domain/DcShifts.java index 554c248b..f07b648a 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcShifts.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcShifts.java @@ -1,6 +1,10 @@ package com.zc.business.domain; import java.util.Date; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -8,6 +12,9 @@ import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; +import java.util.HashMap; +import java.util.List; + /** * 值班对象 dc_shifts * @@ -23,9 +30,6 @@ public class DcShifts extends BaseEntity private Long idBefore; - /** 所属路管驻点 */ - @Excel(name = "所属路管驻点") - private Long stationId; /** 当值人员ID */ @ApiModelProperty(value = "当值人员ID", required = true) @@ -72,16 +76,37 @@ public class DcShifts extends BaseEntity @ApiModelProperty("驻点id") @Excel(name = "驻点id") - private String station; + private Long station; + + private JSONArray employeesJson; + + public JSONArray getEmployeesJson() { + return employeesJson; + } + + public void setEmployeesJson(JSONArray employeesJson) { + this.employeesJson = employeesJson; + } + + private List shiftsList; + + public List getShiftsList() { + return shiftsList; + } + + public void setShiftsList(List shiftsList) { + this.shiftsList = shiftsList; + } + public String getScheduling() { return scheduling; } - public String getStation() { + public Long getStation() { return station; } - public void setStation(String station) { + public void setStation(Long station) { this.station = station; } @@ -138,15 +163,7 @@ public class DcShifts extends BaseEntity { return id; } - public void setStationId(Long stationId) - { - this.stationId = stationId; - } - public Long getStationId() - { - return stationId; - } public void setEmployeesId(Long employeesId) { this.employeesId = employeesId; @@ -188,7 +205,6 @@ public class DcShifts extends BaseEntity public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) - .append("stationId", getStationId()) .append("employeesId", getEmployeesId()) .append("date", getDate()) .append("startTime", getStartTime()) diff --git a/zc-business/src/main/java/com/zc/business/domain/DcShiftsList.java b/zc-business/src/main/java/com/zc/business/domain/DcShiftsList.java new file mode 100644 index 00000000..2f85f023 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/domain/DcShiftsList.java @@ -0,0 +1,120 @@ +package com.zc.business.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; +import java.util.List; + +/** + * @author 王思祥 + * @ClassName DcShiftsList + */ + +public class DcShiftsList { + private static final long serialVersionUID = 1L; + + /** */ + private Long id; + + /** 当值人员ID */ + @ApiModelProperty(value = "当值人员ID", required = true) + @Excel(name = "当值人员ID") + private Long employeesId; + + + + @Excel(name = "姓名") + private String name; + @Excel(name = "所属路管驻点名称") + private String organizationName; + @ApiModelProperty("排班 1-白班 2-夜班") + @Excel(name = "排班 1-白班 2-夜班") + private String scheduling; + @ApiModelProperty("驻点id") + @Excel(name = "驻点id") + private String station; + @Excel(name = "手机号") + private String contactNumber; + + + public String getContactNumber() { + return contactNumber; + } + + public void setContactNumber(String contactNumber) { + this.contactNumber = contactNumber; + } + + public String getScheduling() { + return scheduling; + } + + public String getStation() { + return station; + } + + public void setStation(String station) { + this.station = station; + } + + public void setScheduling(String scheduling) { + this.scheduling = scheduling; + } + + + + public String getOrganizationName() { + return organizationName; + } + + public void setOrganizationName(String organizationName) { + this.organizationName = organizationName; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setEmployeesId(Long employeesId) + { + this.employeesId = employeesId; + } + + public Long getEmployeesId() + { + return employeesId; + } + + + + + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("employeesId", getEmployeesId()) + .toString(); + } +} diff --git a/zc-business/src/main/java/com/zc/business/domain/DcShiftsRecord.java b/zc-business/src/main/java/com/zc/business/domain/DcShiftsRecord.java index 000b44cf..d59b2c2b 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcShiftsRecord.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcShiftsRecord.java @@ -29,7 +29,7 @@ public class DcShiftsRecord extends BaseEntity private String operationType; /** 操作时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") @Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd") private Date operationTime; @@ -44,6 +44,8 @@ public class DcShiftsRecord extends BaseEntity @Excel(name = "值班人员") private String nickName; + @Excel(name = "驻点id") + private Long station; public String getNickName() { return nickName; @@ -108,6 +110,14 @@ public class DcShiftsRecord extends BaseEntity return shiftsDate; } + public Long getStation() { + return station; + } + + public void setStation(Long station) { + this.station = station; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcShiftsMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcShiftsMapper.java index edd32b00..dff1b9d3 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcShiftsMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcShiftsMapper.java @@ -4,6 +4,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import com.zc.business.domain.DcShifts; +import com.zc.business.domain.DcShiftsList; import com.zc.business.domain.DcShiftsRecord; import org.apache.ibatis.annotations.Param; import org.apache.poi.hssf.record.DConRefRecord; @@ -80,7 +81,12 @@ public interface DcShiftsMapper */ public DcShifts selectDcShiftsByEmployeesId(Long id); //查询操作记录表 - public List selectDcShiftsRecord(); + public List selectDcShiftsRecord(DcShifts dcShifts); //根据驻点和时间查询人员 public List> selectStation(@Param("station") String station,@Param("date") Date date); + public List selectStationDate(@Param("station") Long station, @Param("date") Date date); + //新增时查看是否存在 + Long selectExist(DcShifts dcShifts); + //查看部分信息,删除使用 + List selectDcShiftsDeleteList(DcShifts dcShifts); } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcShiftsService.java b/zc-business/src/main/java/com/zc/business/service/IDcShiftsService.java index 14df2e1d..f75df56f 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcShiftsService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcShiftsService.java @@ -30,7 +30,8 @@ public interface IDcShiftsService * @param dcShifts 值班 * @return 值班集合 */ - List selectDcShiftsList(DcShifts dcShifts); + List selectDcShiftsList(DcShifts dcShifts); + List selectDcShiftsListExcel(DcShifts dcShifts); /** @@ -56,7 +57,7 @@ public interface IDcShiftsService * @return 结果 */ int deleteDcShiftsByIds(Long[] ids)throws Exception; - + int deleteDcShiftsListId(DcShifts dcShifts)throws Exception; /** * 删除值班信息 * @@ -68,5 +69,5 @@ public interface IDcShiftsService //导入文档数据 public AjaxResult importEquipment(MultipartFile file) throws Exception; //查询操作记录表 - public List selectDcShiftsRecord(); + public List selectDcShiftsRecord(DcShifts dcShifts); } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java index c6e18394..d2235c55 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java @@ -1,13 +1,19 @@ package com.zc.business.service.impl; +import com.alibaba.fastjson.JSON; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.bean.BeanValidators; import com.ruoyi.common.utils.poi.ExcelUtil; import com.zc.business.domain.DcEmployees; import com.zc.business.domain.DcShifts; +import com.zc.business.domain.DcShiftsList; import com.zc.business.domain.DcShiftsRecord; import com.zc.business.mapper.DcEmployeesMapper; import com.zc.business.mapper.DcShiftsMapper; @@ -19,13 +25,10 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.validation.Validator; -import java.lang.reflect.Array; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; -import java.util.stream.Collectors; /** * 值班Service业务层处理 @@ -62,23 +65,30 @@ public class DcShiftsServiceImpl implements IDcShiftsService * @return 值班 */ @Override - public List selectDcShiftsList(DcShifts dcShifts) + public List selectDcShiftsList(DcShifts dcShifts) { - List objects = new ArrayList<>(); +// ArrayList objects = new ArrayList<>(); + ArrayList objects = new ArrayList<>(); List list = dcShiftsMapper.selectDcShiftsList(dcShifts); - for (DcShifts shifts:list){ - HashMap map = new HashMap(); + for (DcShifts shifts:list ){ Date date = shifts.getDate(); - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); - String formattedDate = formatter.format(date); - String station = shifts.getStation(); - List> name = dcShiftsMapper.selectStation(station, date); - map.put("date",formattedDate); - map.put("organizationName",name); - - objects.add(map); + Long station = shifts.getStation(); + List organizationName = dcShiftsMapper.selectStationDate(station, date); + shifts.setShiftsList(organizationName); + objects.add(shifts); } - return objects; +// for (DcShifts shifts:list){ +// HashMap map = new HashMap(); +// Date date = shifts.getDate(); +// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); +// String formattedDate = formatter.format(date); +// String station = shifts.getStation(); +// List> name = dcShiftsMapper.selectStation(station, date); +// map.put("date",formattedDate); +// map.put("organizationName",name); +// objects.add(map); +// } + return list; } @Override @@ -95,27 +105,45 @@ public class DcShiftsServiceImpl implements IDcShiftsService @Override @Transactional(rollbackFor = ServiceException.class) public int insertDcShifts(DcShifts dcShifts) throws Exception{ - dcShifts.setCreateTime(DateUtils.getNowDate()); - int shifts = dcShiftsMapper.insertDcShifts(dcShifts); String msg = ""; - if (shifts==0){ - msg="新增用户信息失败"; - throw new ServiceException(msg); - } - DcShiftsRecord dcShiftsRecord = new DcShiftsRecord(); - dcShiftsRecord.setOperator(SecurityUtils.getUserId());//操作人员id - dcShiftsRecord.setOperationType("Add");//操作类型 - dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间 - dcShiftsRecord.setShiftsDate(dcShifts.getDate());//值班日期 - Long employeesId = dcShifts.getEmployeesId();//新增人员id - DcEmployees dcEmployees = dcEmployeesMapper.selectDcEmployeesById(employeesId); - String name = dcEmployees.getName();//新增人员名称 - dcShiftsRecord.setModifyContent("新增值班人员"+name); - dcShifts.setCreateTime(DateUtils.getNowDate()); - int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord); - if (shiftsRecord==0){ - msg="操作日志记录失败"; - throw new ServiceException(msg); + JSON employeesJson = dcShifts.getEmployeesJson(); + JsonElement jsonElement = new JsonParser().parse(String.valueOf(employeesJson)); + JsonArray jsonArray = jsonElement.getAsJsonArray(); + for (JsonElement element : jsonArray) { + Long employeesId = element.getAsJsonObject().get("employeesId").getAsLong(); + Long station = element.getAsJsonObject().get("station").getAsLong(); + String scheduling = element.getAsJsonObject().get("scheduling").getAsString(); + if (employeesId!=null&&station!=null&& StringUtils.isNotEmpty(scheduling)){ + dcShifts.setEmployeesId(employeesId); + dcShifts.setStation(station); + dcShifts.setScheduling(scheduling); + Long aLong = dcShiftsMapper.selectExist(dcShifts); + if (aLong!=0){ + continue; + } + } + dcShifts.setCreateTime(DateUtils.getNowDate()); + int shifts = dcShiftsMapper.insertDcShifts(dcShifts); + if (shifts==0){ + msg="新增用户信息失败"; + throw new ServiceException(msg); + } + DcShiftsRecord dcShiftsRecord = new DcShiftsRecord(); + dcShiftsRecord.setOperator(SecurityUtils.getUserId());//操作人员id + dcShiftsRecord.setOperationType("Add");//操作类型 + dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间 + dcShiftsRecord.setShiftsDate(dcShifts.getDate());//值班日期 + Long employeesIdS = dcShifts.getEmployeesId();//新增人员id + DcEmployees dcEmployees = dcEmployeesMapper.selectDcEmployeesById(employeesIdS); + String name = dcEmployees.getName();//新增人员名称 + dcShiftsRecord.setModifyContent("新增值班人员"+name); + dcShifts.setCreateTime(DateUtils.getNowDate()); + dcShiftsRecord.setStation(station);//驻点 + int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord); + if (shiftsRecord==0){ + msg="操作日志记录失败"; + throw new ServiceException(msg); + } } return 1; } @@ -153,6 +181,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间 dcShiftsRecord.setShiftsDate(dcShiftsById.getDate());//值班日期 dcShiftsRecord.setModifyContent("岗位" + postNameBefore + "姓名" + nameBefore + "修改为" + postName + name); + dcShiftsRecord.setStation(dcShiftsById.getStation());//驻点 int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord); if (shiftsRecord == 0) { msg = "操作日志记录失败"; @@ -186,6 +215,37 @@ public class DcShiftsServiceImpl implements IDcShiftsService dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间 dcShiftsRecord.setModifyContent("删除值班人员"+name); dcShiftsRecord.setShiftsDate(dcShifts.getDate());//值班日期 + dcShiftsRecord.setStation(dcShifts.getStation());//驻点 + int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord); + if (shiftsRecord==0){ + msg="操作日志记录失败"; + throw new ServiceException(msg); + } + } + return 1; + } + + @Override + @Transactional(rollbackFor = ServiceException.class) + public int deleteDcShiftsListId(DcShifts dcShifts) throws Exception { + List shiftsValue = dcShiftsMapper.selectDcShiftsDeleteList(dcShifts); + for (DcShifts shifts:shiftsValue){ + Long id = shifts.getId(); + DcShifts dcShiftsById = dcShiftsMapper.selectDcShiftsById(id); + String name = dcShiftsById.getName(); + String msg = ""; + int i = dcShiftsMapper.deleteDcShiftsById(id); + if (i==0){ + msg="删除用户信息失败"; + throw new ServiceException(msg); + } + DcShiftsRecord dcShiftsRecord = new DcShiftsRecord(); + dcShiftsRecord.setOperator(SecurityUtils.getUserId());//操作人员id + dcShiftsRecord.setOperationType("DELETE");//操作类型 + dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间 + dcShiftsRecord.setModifyContent("删除值班人员"+name); + dcShiftsRecord.setShiftsDate(dcShiftsById.getDate());//值班日期 + dcShiftsRecord.setStation(dcShiftsById.getStation());//驻点 int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord); if (shiftsRecord==0){ msg="操作日志记录失败"; @@ -195,6 +255,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService return 1; } + /** * 删除值班信息 * @@ -243,7 +304,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService //查询操作记录表 @Override - public List selectDcShiftsRecord() { - return dcShiftsMapper.selectDcShiftsRecord(); + public List selectDcShiftsRecord(DcShifts shifts) { + return dcShiftsMapper.selectDcShiftsRecord(shifts); } } diff --git a/zc-business/src/main/resources/mapper/business/DcShiftsMapper.xml b/zc-business/src/main/resources/mapper/business/DcShiftsMapper.xml index 8edda33d..e1ea10fa 100644 --- a/zc-business/src/main/resources/mapper/business/DcShiftsMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcShiftsMapper.xml @@ -30,9 +30,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + @@ -120,7 +138,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" operation_time, modify_content, shifts_date, - + station, #{id}, @@ -129,7 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{operationTime}, #{modifyContent}, #{shiftsDate}, - + #{station},