关注台站管理增加接口注解

新增台站关注信息接口增加返回内容
删除台站关注信息接口增加返回内容
导出导入模板接口增加数据示例
导出接口修改台站名称列宽
This commit is contained in:
qiaoqinzheng 2023-05-29 09:53:00 +08:00
parent 9d5196d431
commit 1c232a645e
9 changed files with 67 additions and 26 deletions

View File

@ -1,5 +1,8 @@
package org.jeecg.modules.controller; package org.jeecg.modules.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.config.valid.InsertGroup; import org.jeecg.config.valid.InsertGroup;
import org.jeecg.modules.entity.SysUserFocusStation; import org.jeecg.modules.entity.SysUserFocusStation;
import org.jeecg.modules.service.ISysUserFocusStationService; import org.jeecg.modules.service.ISysUserFocusStationService;
@ -11,25 +14,29 @@ import java.util.List;
@RestController @RestController
@RequestMapping("sysUserFocusStation") @RequestMapping("sysUserFocusStation")
@Api(value = "关注台站管理", tags = "关注台站管理")
public class SysUserFocusStationController { public class SysUserFocusStationController {
@Autowired @Autowired
private ISysUserFocusStationService sysUserFocusStationService; private ISysUserFocusStationService sysUserFocusStationService;
@GetMapping("findList") @GetMapping("findList")
@ApiOperation(value = "查询关注台站列表", notes = "查询关注台站列表")
public List<SysUserFocusStation> findList(){ public List<SysUserFocusStation> findList(){
List<SysUserFocusStation> result = sysUserFocusStationService.findList(); List<SysUserFocusStation> result = sysUserFocusStationService.findList();
return result; return result;
} }
@PostMapping("create") @PostMapping("create")
public void create(@RequestBody @Validated(value = InsertGroup.class) SysUserFocusStation sysUserFocusStation){ @ApiOperation(value = "新增关注", notes = "新增关注")
sysUserFocusStationService.create(sysUserFocusStation); public Result create(@RequestBody @Validated(value = InsertGroup.class) SysUserFocusStation sysUserFocusStation){
return sysUserFocusStationService.create(sysUserFocusStation);
} }
@DeleteMapping("deleteById") @DeleteMapping("deleteById")
public void deleteById(String stationId){ @ApiOperation(value = "取消关注", notes = "取消关注")
sysUserFocusStationService.deleteById(stationId); public Result deleteById(String stationId){
return sysUserFocusStationService.deleteById(stationId);
} }
} }

View File

@ -10,6 +10,7 @@ import org.jeecg.config.valid.UpdateGroup;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
@ -18,11 +19,10 @@ import java.util.Date;
public class SysUserFocusStation implements Serializable { public class SysUserFocusStation implements Serializable {
@TableId(value = "id", type = IdType.ASSIGN_ID) @TableId(value = "id", type = IdType.ASSIGN_ID)
@NotNull(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class}) @NotBlank(message = "不能为空", groups = UpdateGroup.class)
private Integer id; private String id;
@TableField(value = "user_id") @TableField(value = "user_id")
@NotBlank(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
private String userId; private String userId;
@TableField(value = "station_id") @TableField(value = "station_id")

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.service; package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.entity.SysUserFocusStation; import org.jeecg.modules.entity.SysUserFocusStation;
import java.util.List; import java.util.List;
@ -17,12 +18,12 @@ public interface ISysUserFocusStationService extends IService<SysUserFocusStatio
* 新增关注的台站核设施信息 * 新增关注的台站核设施信息
* @param sysUserFocusStation * @param sysUserFocusStation
*/ */
void create(SysUserFocusStation sysUserFocusStation); Result create(SysUserFocusStation sysUserFocusStation);
/** /**
* 取消关注 * 取消关注
* @param stationId * @param stationId
*/ */
void deleteById(String stationId); Result deleteById(String stationId);
} }

View File

@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.util.JwtUtil; import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.SpringContextUtils; import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.modules.entity.GardsStations;
import org.jeecg.modules.entity.SysUser; import org.jeecg.modules.entity.SysUser;
import org.jeecg.modules.entity.SysUserFocusStation; import org.jeecg.modules.entity.SysUserFocusStation;
import org.jeecg.modules.mapper.SysUserFocusStationMapper; import org.jeecg.modules.mapper.SysUserFocusStationMapper;
@ -38,7 +40,8 @@ public class SysUserFocusStationServiceImpl extends ServiceImpl<SysUserFocusStat
@Override @Override
@Transactional @Transactional
public void create(SysUserFocusStation sysUserFocusStation) { public Result create(SysUserFocusStation sysUserFocusStation) {
Result result = new Result();
//获取request //获取request
HttpServletRequest request = SpringContextUtils.getHttpServletRequest(); HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
//获取当前操作人用户名 //获取当前操作人用户名
@ -48,19 +51,23 @@ public class SysUserFocusStationServiceImpl extends ServiceImpl<SysUserFocusStat
userQueryWrapper.eq(SysUser::getUsername, username); userQueryWrapper.eq(SysUser::getUsername, username);
SysUser sysUser = sysUserMapper.selectOne(userQueryWrapper); SysUser sysUser = sysUserMapper.selectOne(userQueryWrapper);
if (Objects.isNull(sysUser)){ if (Objects.isNull(sysUser)){
throw new RuntimeException("当前用户不存在!"); result.error500("当前用户不存在!");
return result;
} }
Long id = IdWorker.getId(); Long id = IdWorker.getId();
sysUserFocusStation.setId(Integer.valueOf(id.toString())); sysUserFocusStation.setId(String.valueOf(id));
sysUserFocusStation.setUserId(sysUser.getId()); sysUserFocusStation.setUserId(sysUser.getId());
sysUserFocusStation.setCreateTime(new Date()); sysUserFocusStation.setCreateTime(new Date());
sysUserFocusStation.setCreateBy(username); sysUserFocusStation.setCreateBy(username);
this.baseMapper.insert(sysUserFocusStation); this.baseMapper.insert(sysUserFocusStation);
result.success("新增成功");
return result;
} }
@Override @Override
@Transactional @Transactional
public void deleteById(String stationId) { public Result deleteById(String stationId) {
Result result = new Result<>();
//获取request //获取request
HttpServletRequest request = SpringContextUtils.getHttpServletRequest(); HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
//获取当前操作人用户名 //获取当前操作人用户名
@ -70,12 +77,15 @@ public class SysUserFocusStationServiceImpl extends ServiceImpl<SysUserFocusStat
userQueryWrapper.eq(SysUser::getUsername, username); userQueryWrapper.eq(SysUser::getUsername, username);
SysUser sysUser = sysUserMapper.selectOne(userQueryWrapper); SysUser sysUser = sysUserMapper.selectOne(userQueryWrapper);
if (Objects.isNull(sysUser)){ if (Objects.isNull(sysUser)){
throw new RuntimeException("当前用户不存在!"); result.error500("当前用户不存在!");
return result;
} }
LambdaQueryWrapper<SysUserFocusStation> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SysUserFocusStation> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysUserFocusStation::getUserId, sysUser.getId()); queryWrapper.eq(SysUserFocusStation::getUserId, sysUser.getId());
queryWrapper.eq(SysUserFocusStation::getStationId, stationId); queryWrapper.eq(SysUserFocusStation::getStationId, stationId);
this.baseMapper.delete(queryWrapper); this.baseMapper.delete(queryWrapper);
result.success("删除成功");
return result;
} }
} }

View File

@ -12,7 +12,7 @@ public class SysTaskExportVo {
@ExcelField(title = "用户名称", width = 15, sort = 2) @ExcelField(title = "用户名称", width = 15, sort = 2)
private String userName; private String userName;
@ExcelField(title = "台站名称", width = 15, sort = 3) @ExcelField(title = "台站名称", width = 90, sort = 3)
private String stationName; private String stationName;
} }

View File

@ -92,7 +92,8 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
queryWrapper.eq(GardsDetectors::getDetectorCode, gardsDetectors.getDetectorCode()); queryWrapper.eq(GardsDetectors::getDetectorCode, gardsDetectors.getDetectorCode());
GardsDetectors detectors = this.baseMapper.selectOne(queryWrapper); GardsDetectors detectors = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(detectors)) { if (Objects.nonNull(detectors)) {
throw new RuntimeException("当前数据已存在,新增失败!"); result.error500("当前数据已存在,新增失败!");
return result;
} }
} }
this.baseMapper.insert(gardsDetectors); this.baseMapper.insert(gardsDetectors);
@ -107,14 +108,16 @@ public class GardsDetectorsServiceImpl extends ServiceImpl<GardsDetectorsMapper,
wrapper.eq(GardsDetectors::getDetectorId, gardsDetectors.getDetectorId()); wrapper.eq(GardsDetectors::getDetectorId, gardsDetectors.getDetectorId());
GardsDetectors stations = this.baseMapper.selectOne(wrapper); GardsDetectors stations = this.baseMapper.selectOne(wrapper);
if (Objects.isNull(stations)) { if (Objects.isNull(stations)) {
throw new RuntimeException("当前数据不存在,修改失败"); result.error500("当前数据不存在,修改失败");
return result;
} }
if (StringUtils.isNotBlank(gardsDetectors.getDetectorCode())){ if (StringUtils.isNotBlank(gardsDetectors.getDetectorCode())){
LambdaQueryWrapper<GardsDetectors> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GardsDetectors> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsDetectors::getDetectorCode, gardsDetectors.getDetectorCode()); queryWrapper.eq(GardsDetectors::getDetectorCode, gardsDetectors.getDetectorCode());
GardsDetectors detectors = this.baseMapper.selectOne(queryWrapper); GardsDetectors detectors = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(detectors) && !detectors.getDetectorId().equals(gardsDetectors.getDetectorId())) { if (Objects.nonNull(detectors) && !detectors.getDetectorId().equals(gardsDetectors.getDetectorId())) {
throw new RuntimeException("当前数据"+gardsDetectors.getDetectorCode()+"已存在,修改失败!"); result.error500("当前数据"+gardsDetectors.getDetectorCode()+"已存在,修改失败!");
return result;
} }
} }
LambdaQueryWrapper<GardsDetectors> detectorsQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GardsDetectors> detectorsQueryWrapper = new LambdaQueryWrapper<>();

View File

@ -70,7 +70,8 @@ public class GardsNuclearfacilityServiceImpl extends ServiceImpl<GardsNuclearfac
queryWrapper.eq(GardsNuclearfacility::getFacilityName, gardsNuclearfacility.getFacilityName()); queryWrapper.eq(GardsNuclearfacility::getFacilityName, gardsNuclearfacility.getFacilityName());
GardsNuclearfacility nuclearfacility = this.baseMapper.selectOne(queryWrapper); GardsNuclearfacility nuclearfacility = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(nuclearfacility)){ if (Objects.nonNull(nuclearfacility)){
throw new RuntimeException("当前同名称的核设施已存在,新增失败"); result.error500("当前同名称的核设施已存在,新增失败");
return result;
} }
} }
this.baseMapper.insert(gardsNuclearfacility); this.baseMapper.insert(gardsNuclearfacility);
@ -86,14 +87,16 @@ public class GardsNuclearfacilityServiceImpl extends ServiceImpl<GardsNuclearfac
wrapper.eq(GardsNuclearfacility::getFacilityId,gardsNuclearfacility.getFacilityId()); wrapper.eq(GardsNuclearfacility::getFacilityId,gardsNuclearfacility.getFacilityId());
GardsNuclearfacility stations = this.baseMapper.selectOne(wrapper); GardsNuclearfacility stations = this.baseMapper.selectOne(wrapper);
if (Objects.isNull(stations)){ if (Objects.isNull(stations)){
throw new RuntimeException("修改失败,当前数据不存在!"); result.error500("修改失败,当前数据不存在!");
return result;
} }
if (StringUtils.isNotBlank(gardsNuclearfacility.getFacilityName())){ if (StringUtils.isNotBlank(gardsNuclearfacility.getFacilityName())){
LambdaQueryWrapper<GardsNuclearfacility> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GardsNuclearfacility> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GardsNuclearfacility::getFacilityName, gardsNuclearfacility.getFacilityName()); queryWrapper.eq(GardsNuclearfacility::getFacilityName, gardsNuclearfacility.getFacilityName());
GardsNuclearfacility nuclearfacility = this.baseMapper.selectOne(queryWrapper); GardsNuclearfacility nuclearfacility = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(nuclearfacility) && !nuclearfacility.getFacilityId().equals(gardsNuclearfacility.getFacilityId())){ if (Objects.nonNull(nuclearfacility) && !nuclearfacility.getFacilityId().equals(gardsNuclearfacility.getFacilityId())){
throw new RuntimeException("当前核设施"+gardsNuclearfacility.getFacilityName()+"已存在,修改失败"); result.error500("当前核设施"+gardsNuclearfacility.getFacilityName()+"已存在,修改失败");
return result;
} }
} }
LambdaQueryWrapper<GardsNuclearfacility> nuclearfacilityQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GardsNuclearfacility> nuclearfacilityQueryWrapper = new LambdaQueryWrapper<>();

View File

@ -93,7 +93,8 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
GardsStations stations = this.baseMapper.selectOne(queryWrapper); GardsStations stations = this.baseMapper.selectOne(queryWrapper);
//如果数据不为空 //如果数据不为空
if (Objects.nonNull(stations)) { if (Objects.nonNull(stations)) {
throw new RuntimeException("当前台站信息已存在,新增失败"); result.error500("当前台站信息已存在,新增失败");
return result;
} }
} }
this.baseMapper.insert(gardsStations); this.baseMapper.insert(gardsStations);
@ -114,7 +115,8 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
wrapper.eq(GardsStations::getStationId,gardsStations.getStationId()); wrapper.eq(GardsStations::getStationId,gardsStations.getStationId());
GardsStations stations = this.baseMapper.selectOne(wrapper); GardsStations stations = this.baseMapper.selectOne(wrapper);
if (Objects.isNull(stations)){ if (Objects.isNull(stations)){
throw new RuntimeException("修改失败,当前数据不存在!"); result.error500("修改失败,当前数据不存在!");
return result;
} }
if (StringUtils.isNotBlank(gardsStations.getStationCode())){ if (StringUtils.isNotBlank(gardsStations.getStationCode())){
//根据传递的台站编码查询 //根据传递的台站编码查询
@ -122,7 +124,8 @@ public class GardsStationsServiceImpl extends ServiceImpl<GardsStationsMapper, G
queryWrapper.eq(GardsStations::getStationCode,gardsStations.getStationCode()); queryWrapper.eq(GardsStations::getStationCode,gardsStations.getStationCode());
GardsStations oldStations = this.baseMapper.selectOne(queryWrapper); GardsStations oldStations = this.baseMapper.selectOne(queryWrapper);
if (Objects.nonNull(oldStations) && !oldStations.getStationId().equals(gardsStations.getStationId())) { if (Objects.nonNull(oldStations) && !oldStations.getStationId().equals(gardsStations.getStationId())) {
throw new RuntimeException("当前台站信息"+gardsStations.getStationCode()+"已存在,修改失败"); result.error500("当前台站信息"+gardsStations.getStationCode()+"已存在,修改失败");
return result;
} }
} }
LambdaQueryWrapper<GardsStations> stationsQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GardsStations> stationsQueryWrapper = new LambdaQueryWrapper<>();

View File

@ -332,7 +332,7 @@ public class SysTaskServiceImpl extends ServiceImpl<SysTaskMapper, SysTask> impl
String username = sysTaskVo.getUsername(); String username = sysTaskVo.getUsername();
String stationNames = ""; String stationNames = "";
for (SysTaskStation sysTaskStation:sysTaskVo.getStationList()) { for (SysTaskStation sysTaskStation:sysTaskVo.getStationList()) {
stationNames+=sysTaskStation.getStationName()+","; stationNames+=sysTaskStation.getStationName()+StringPool.COMMA;
} }
stationNames = stationNames.substring(0,stationNames.length()-1); stationNames = stationNames.substring(0,stationNames.length()-1);
if (StringUtils.isNotBlank(stationNames)){ if (StringUtils.isNotBlank(stationNames)){
@ -355,6 +355,7 @@ public class SysTaskServiceImpl extends ServiceImpl<SysTaskMapper, SysTask> impl
@Override @Override
public void exportImportTemplate(HttpServletRequest request, HttpServletResponse response) { public void exportImportTemplate(HttpServletRequest request, HttpServletResponse response) {
String fileName = "排班任务导入模板"; String fileName = "排班任务导入模板";
List<SysTaskExportVo> list = this.createList();
try { try {
//处理需要导出的列 //处理需要导出的列
List<Object[]> annotationList = Lists.newArrayList(); List<Object[]> annotationList = Lists.newArrayList();
@ -365,13 +366,26 @@ public class SysTaskServiceImpl extends ServiceImpl<SysTaskMapper, SysTask> impl
annotationList.add(new Object[] {ef,field}); annotationList.add(new Object[] {ef,field});
} }
} }
new ExportExcel().createXlsxExcel("排班任务信息", annotationList, 2, false).writeToXlsx(request, response, fileName); new ExportExcel().createXlsxExcel("排班任务信息", annotationList, 2, false)
.setDataList(list).writeToXlsx(request, response, fileName);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
throw new BusinessException("模板导出失败"); throw new BusinessException("模板导出失败");
} }
} }
private List<SysTaskExportVo> createList(){
List<SysTaskExportVo> list = new ArrayList<>();
for(int i=1;i<=2;i++){
SysTaskExportVo vo = new SysTaskExportVo();
vo.setSchedulingDate("1997-01-01");
vo.setStationName("AAA"+StringPool.COMMA+"BBB");
vo.setUserName("sample"+i);
list.add(vo);
}
return list;
}
@Override @Override
@Transactional @Transactional
public ImportViewVo importExcel(List<SysTaskExportVo> dataList, int headRow) { public ImportViewVo importExcel(List<SysTaskExportVo> dataList, int headRow) {