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

新增台站关注信息接口增加返回内容
删除台站关注信息接口增加返回内容
导出导入模板接口增加数据示例
导出接口修改台站名称列宽
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;
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.modules.entity.SysUserFocusStation;
import org.jeecg.modules.service.ISysUserFocusStationService;
@ -11,25 +14,29 @@ import java.util.List;
@RestController
@RequestMapping("sysUserFocusStation")
@Api(value = "关注台站管理", tags = "关注台站管理")
public class SysUserFocusStationController {
@Autowired
private ISysUserFocusStationService sysUserFocusStationService;
@GetMapping("findList")
@ApiOperation(value = "查询关注台站列表", notes = "查询关注台站列表")
public List<SysUserFocusStation> findList(){
List<SysUserFocusStation> result = sysUserFocusStationService.findList();
return result;
}
@PostMapping("create")
public void create(@RequestBody @Validated(value = InsertGroup.class) SysUserFocusStation sysUserFocusStation){
sysUserFocusStationService.create(sysUserFocusStation);
@ApiOperation(value = "新增关注", notes = "新增关注")
public Result create(@RequestBody @Validated(value = InsertGroup.class) SysUserFocusStation sysUserFocusStation){
return sysUserFocusStationService.create(sysUserFocusStation);
}
@DeleteMapping("deleteById")
public void deleteById(String stationId){
sysUserFocusStationService.deleteById(stationId);
@ApiOperation(value = "取消关注", notes = "取消关注")
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.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.util.Date;
@ -18,11 +19,10 @@ import java.util.Date;
public class SysUserFocusStation implements Serializable {
@TableId(value = "id", type = IdType.ASSIGN_ID)
@NotNull(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
private Integer id;
@NotBlank(message = "不能为空", groups = UpdateGroup.class)
private String id;
@TableField(value = "user_id")
@NotBlank(message = "不能为空", groups = {InsertGroup.class, UpdateGroup.class})
private String userId;
@TableField(value = "station_id")

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.entity.SysUserFocusStation;
import java.util.List;
@ -17,12 +18,12 @@ public interface ISysUserFocusStationService extends IService<SysUserFocusStatio
* 新增关注的台站核设施信息
* @param sysUserFocusStation
*/
void create(SysUserFocusStation sysUserFocusStation);
Result create(SysUserFocusStation sysUserFocusStation);
/**
* 取消关注
* @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.IdWorker;
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.util.SpringContextUtils;
import org.jeecg.modules.entity.GardsStations;
import org.jeecg.modules.entity.SysUser;
import org.jeecg.modules.entity.SysUserFocusStation;
import org.jeecg.modules.mapper.SysUserFocusStationMapper;
@ -38,7 +40,8 @@ public class SysUserFocusStationServiceImpl extends ServiceImpl<SysUserFocusStat
@Override
@Transactional
public void create(SysUserFocusStation sysUserFocusStation) {
public Result create(SysUserFocusStation sysUserFocusStation) {
Result result = new Result();
//获取request
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
//获取当前操作人用户名
@ -48,19 +51,23 @@ public class SysUserFocusStationServiceImpl extends ServiceImpl<SysUserFocusStat
userQueryWrapper.eq(SysUser::getUsername, username);
SysUser sysUser = sysUserMapper.selectOne(userQueryWrapper);
if (Objects.isNull(sysUser)){
throw new RuntimeException("当前用户不存在!");
result.error500("当前用户不存在!");
return result;
}
Long id = IdWorker.getId();
sysUserFocusStation.setId(Integer.valueOf(id.toString()));
sysUserFocusStation.setId(String.valueOf(id));
sysUserFocusStation.setUserId(sysUser.getId());
sysUserFocusStation.setCreateTime(new Date());
sysUserFocusStation.setCreateBy(username);
this.baseMapper.insert(sysUserFocusStation);
result.success("新增成功");
return result;
}
@Override
@Transactional
public void deleteById(String stationId) {
public Result deleteById(String stationId) {
Result result = new Result<>();
//获取request
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
//获取当前操作人用户名
@ -70,12 +77,15 @@ public class SysUserFocusStationServiceImpl extends ServiceImpl<SysUserFocusStat
userQueryWrapper.eq(SysUser::getUsername, username);
SysUser sysUser = sysUserMapper.selectOne(userQueryWrapper);
if (Objects.isNull(sysUser)){
throw new RuntimeException("当前用户不存在!");
result.error500("当前用户不存在!");
return result;
}
LambdaQueryWrapper<SysUserFocusStation> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysUserFocusStation::getUserId, sysUser.getId());
queryWrapper.eq(SysUserFocusStation::getStationId, stationId);
this.baseMapper.delete(queryWrapper);
result.success("删除成功");
return result;
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -332,7 +332,7 @@ public class SysTaskServiceImpl extends ServiceImpl<SysTaskMapper, SysTask> impl
String username = sysTaskVo.getUsername();
String stationNames = "";
for (SysTaskStation sysTaskStation:sysTaskVo.getStationList()) {
stationNames+=sysTaskStation.getStationName()+",";
stationNames+=sysTaskStation.getStationName()+StringPool.COMMA;
}
stationNames = stationNames.substring(0,stationNames.length()-1);
if (StringUtils.isNotBlank(stationNames)){
@ -355,6 +355,7 @@ public class SysTaskServiceImpl extends ServiceImpl<SysTaskMapper, SysTask> impl
@Override
public void exportImportTemplate(HttpServletRequest request, HttpServletResponse response) {
String fileName = "排班任务导入模板";
List<SysTaskExportVo> list = this.createList();
try {
//处理需要导出的列
List<Object[]> annotationList = Lists.newArrayList();
@ -365,13 +366,26 @@ public class SysTaskServiceImpl extends ServiceImpl<SysTaskMapper, SysTask> impl
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) {
e.printStackTrace();
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
@Transactional
public ImportViewVo importExcel(List<SysTaskExportVo> dataList, int headRow) {