22 changed files with 452 additions and 12 deletions
@ -0,0 +1,79 @@
|
||||
package com.biutag.supervision.controller.supervise; |
||||
|
||||
import cn.hutool.core.collection.CollectionUtil; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.biutag.supervision.pojo.Result; |
||||
import com.biutag.supervision.pojo.entity.SuperviseReport; |
||||
import com.biutag.supervision.pojo.entity.SuperviseReportFile; |
||||
import com.biutag.supervision.pojo.param.SupRiskPersonalQueryParam; |
||||
import com.biutag.supervision.pojo.param.SuperviseReportQueryParam; |
||||
import com.biutag.supervision.pojo.vo.SupRiskPersonalVo; |
||||
import com.biutag.supervision.pojo.vo.SuperviseReportVo; |
||||
import com.biutag.supervision.service.SuperviseReportFileService; |
||||
import com.biutag.supervision.service.SuperviseReportService; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequiredArgsConstructor |
||||
@RequestMapping("/supervise/report") |
||||
public class SuperviseReportController { |
||||
|
||||
private final SuperviseReportService service; |
||||
|
||||
private final SuperviseReportFileService fileService; |
||||
/** |
||||
* 分页 |
||||
* */ |
||||
@GetMapping |
||||
Result<Page<SuperviseReportVo>> queryPage(SuperviseReportQueryParam queryParam){ |
||||
return Result.success(service.page(queryParam)); |
||||
} |
||||
/** |
||||
* 编辑 |
||||
* */ |
||||
@PostMapping |
||||
Result addOrUpdata(@RequestBody SuperviseReportVo superviseReportVo){ |
||||
List<SuperviseReport> superviseReport = service.list(new LambdaQueryWrapper<SuperviseReport>().eq(SuperviseReport::getReportName,superviseReportVo.getReportName())); |
||||
if(CollectionUtil.isNotEmpty(superviseReport)){ |
||||
return Result.failed("报告名称不能重复,请填写报告全称"); |
||||
} |
||||
if(service.addOrUpdate(superviseReportVo)){ |
||||
return Result.success(); |
||||
}else{ |
||||
return Result.failed("操作失败"); |
||||
} |
||||
} |
||||
/** |
||||
* 删除 |
||||
* */ |
||||
@DeleteMapping("/{id}") |
||||
Result delDataById(@PathVariable String id){ |
||||
if(service.delById(id)){ |
||||
return Result.success(); |
||||
}else{ |
||||
return Result.failed("操作失败"); |
||||
} |
||||
} |
||||
/** |
||||
* 获取附件清单 |
||||
* */ |
||||
@GetMapping("getReportFile") |
||||
Result<List<SuperviseReportFile>> getReportFile(SuperviseReportQueryParam queryParam){ |
||||
List<SuperviseReportFile> files = service.getReportFile(queryParam); |
||||
return Result.success(files); |
||||
} |
||||
|
||||
@GetMapping("/getReportDetail/{id}") |
||||
Result<SuperviseReport> getReportDetail(@PathVariable String id){ |
||||
SuperviseReport superviseReport =service.getOne(new LambdaQueryWrapper<SuperviseReport>().eq(SuperviseReport::getId,id)); |
||||
return Result.success(superviseReport); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,9 @@
|
||||
package com.biutag.supervision.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.biutag.supervision.pojo.entity.SuperviseReport; |
||||
import com.biutag.supervision.pojo.entity.SuperviseReportFile; |
||||
|
||||
|
||||
public interface SuperviseReportFileMapper extends BaseMapper<SuperviseReportFile> { |
||||
} |
||||
@ -0,0 +1,14 @@
|
||||
package com.biutag.supervision.mapper; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.toolkit.Constants; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.biutag.supervision.pojo.entity.Sampling; |
||||
import com.biutag.supervision.pojo.entity.SuperviseReport; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
public interface SuperviseReportMapper extends BaseMapper<SuperviseReport> { |
||||
Page<SuperviseReport> queryPage(@Param("page") Page<SuperviseReport> page, @Param(Constants.WRAPPER) QueryWrapper<SuperviseReport> queryWrapper); |
||||
} |
||||
@ -0,0 +1,35 @@
|
||||
package com.biutag.supervision.pojo.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.time.LocalDateTime; |
||||
import java.util.Date; |
||||
|
||||
@Getter |
||||
@Setter |
||||
public class SuperviseReport { |
||||
@TableId |
||||
private String id; |
||||
//督察报告
|
||||
@TableField("report_name") |
||||
private String reportName; |
||||
//创建人
|
||||
@TableField("crt_time") |
||||
private LocalDateTime crtTime; |
||||
//创建单位
|
||||
@TableField("crt_depart") |
||||
private String crtDepart; |
||||
//创建单位Id
|
||||
@TableField("crt_depart_id") |
||||
private String crtDepartId; |
||||
//创建用户
|
||||
@TableField("crt_user") |
||||
private String crtUser; |
||||
//创建人警号
|
||||
@TableField("crt_emp_no") |
||||
private String crtEmpNo; |
||||
|
||||
} |
||||
@ -0,0 +1,42 @@
|
||||
package com.biutag.supervision.pojo.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.io.Serial; |
||||
import java.time.LocalDateTime; |
||||
|
||||
@Setter |
||||
@Getter |
||||
@TableName("supervise_report_file") |
||||
public class SuperviseReportFile { |
||||
@Serial |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Integer id; |
||||
|
||||
@TableField("file_name") |
||||
String fileName; |
||||
@TableField("file_path") |
||||
String filePath; |
||||
|
||||
@TableField("supervise_id") |
||||
String superviseId; |
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
@TableField("`crt_time`") |
||||
LocalDateTime crtTime; |
||||
|
||||
|
||||
Integer del; |
||||
} |
||||
@ -0,0 +1,13 @@
|
||||
package com.biutag.supervision.pojo.param; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
@Setter |
||||
@Getter |
||||
public class SuperviseReportQueryParam extends BasePage{ |
||||
//报告名称
|
||||
private String reportName; |
||||
//创建用户
|
||||
private String crtUser; |
||||
} |
||||
@ -0,0 +1,31 @@
|
||||
package com.biutag.supervision.pojo.vo; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.biutag.supervision.pojo.entity.SuperviseReportFile; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
@Getter |
||||
@Setter |
||||
public class SuperviseReportVo { |
||||
|
||||
private String id; |
||||
|
||||
//督察报告
|
||||
private String reportName; |
||||
//创建人
|
||||
private Date crtTime; |
||||
//创建单位
|
||||
private String crtDepart; |
||||
//创建单位Id
|
||||
private String crtDepartId; |
||||
//创建用户
|
||||
private String crtUser; |
||||
//创建人警号
|
||||
private String crtEmpNo; |
||||
//附件清单
|
||||
private List<SuperviseReportFile> files; |
||||
} |
||||
@ -0,0 +1,10 @@
|
||||
package com.biutag.supervision.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.biutag.supervision.mapper.SuperviseReportFileMapper; |
||||
import com.biutag.supervision.pojo.entity.SuperviseReportFile; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
@Service |
||||
public class SuperviseReportFileService extends ServiceImpl<SuperviseReportFileMapper, SuperviseReportFile> { |
||||
} |
||||
@ -0,0 +1,126 @@
|
||||
package com.biutag.supervision.service; |
||||
|
||||
import cn.hutool.core.bean.BeanUtil; |
||||
import cn.hutool.core.collection.CollectionUtil; |
||||
import cn.hutool.core.util.ObjectUtil; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.alibaba.fastjson2.JSONObject; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.biutag.supervision.common.UserContextHolder; |
||||
import com.biutag.supervision.constants.AppConstants; |
||||
import com.biutag.supervision.constants.enums.RoleCodeEnum; |
||||
import com.biutag.supervision.mapper.SuperviseReportMapper; |
||||
import com.biutag.supervision.pojo.entity.*; |
||||
import com.biutag.supervision.pojo.model.UserAuth; |
||||
import com.biutag.supervision.pojo.param.SamplingQueryParam; |
||||
import com.biutag.supervision.pojo.param.SuperviseReportQueryParam; |
||||
import com.biutag.supervision.pojo.vo.SamplingVo; |
||||
import com.biutag.supervision.pojo.vo.SuperviseReportVo; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.util.CollectionUtils; |
||||
|
||||
import java.time.LocalDateTime; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@RequiredArgsConstructor |
||||
@Service |
||||
public class SuperviseReportService extends ServiceImpl<SuperviseReportMapper, SuperviseReport> { |
||||
|
||||
private final SupDepartService departService; |
||||
|
||||
private final SuperviseReportFileService superviseReportFileService; |
||||
/** |
||||
* 分页查询 |
||||
* */ |
||||
public Page<SuperviseReportVo> page(SuperviseReportQueryParam queryParam){ |
||||
QueryWrapper<SuperviseReport> queryWrapper = new QueryWrapper<>(); |
||||
UserAuth user = UserContextHolder.getCurrentUser(); |
||||
// 权限
|
||||
if (!AppConstants.USER_TYPE_SUPER.equals(user.getUserType()) && !user.getRoleCodes().contains(RoleCodeEnum.FIRST_ADMIN.getCode())) { |
||||
if (user.getAuthDepartIds().isEmpty() || user.getRoleCodes().isEmpty()) { |
||||
return new Page<SuperviseReportVo>().setTotal(0).setRecords(new ArrayList<>()); |
||||
} |
||||
List<String> orgIds = departService.getAllNodeIds(user.getAuthDepartIds()); |
||||
queryWrapper.in("t.crt_depart_id", orgIds); |
||||
} |
||||
//查询条件
|
||||
queryWrapper.like(StrUtil.isNotEmpty(queryParam.getReportName()),"t.report_name",queryParam.getReportName()) |
||||
.like(StrUtil.isNotEmpty(queryParam.getCrtUser()),"t.crt_user",queryParam.getCrtUser()); |
||||
|
||||
Page<SuperviseReport> page= baseMapper.queryPage(Page.of(queryParam.getCurrent(), queryParam.getSize()), queryWrapper); |
||||
List<SuperviseReportVo> listData = new ArrayList<>(); |
||||
page.getRecords().forEach(s->{ |
||||
SuperviseReportVo vo =new SuperviseReportVo(); |
||||
BeanUtil.copyProperties(s,vo); |
||||
listData.add(vo); |
||||
}); |
||||
Page<SuperviseReportVo> voPage = new Page<>(page.getCurrent(),page.getSize(),page.getTotal()); |
||||
listData.forEach(s->{ |
||||
List<SuperviseReportFile> files= superviseReportFileService.list(new LambdaQueryWrapper<SuperviseReportFile>().eq(SuperviseReportFile::getSuperviseId,s.getId())); |
||||
if(CollectionUtil.isNotEmpty(files)){ |
||||
s.setFiles(files); |
||||
} |
||||
}); |
||||
voPage.setRecords(listData); |
||||
return voPage; |
||||
} |
||||
|
||||
/** |
||||
* 保存或修改 |
||||
* */ |
||||
public boolean addOrUpdate(SuperviseReportVo vo){ |
||||
SuperviseReport report =new SuperviseReport(); |
||||
BeanUtil.copyProperties(vo,report); |
||||
report.setCrtTime(LocalDateTime.now()); |
||||
UserAuth user = UserContextHolder.getCurrentUser(); |
||||
|
||||
// 权限
|
||||
if (!AppConstants.USER_TYPE_SUPER.equals(user.getUserType()) && !user.getRoleCodes().contains(RoleCodeEnum.FIRST_ADMIN.getCode())) { |
||||
report.setCrtDepart(user.getDepartName()); |
||||
report.setCrtDepartId(user.getDepartId()); |
||||
report.setCrtUser(user.getNickName()); |
||||
report.setCrtEmpNo(user.getEmpNo()); |
||||
} |
||||
if(baseMapper.insertOrUpdate(report) ){ |
||||
if( CollectionUtil.isNotEmpty(vo.getFiles())){ |
||||
superviseReportFileService.remove(new LambdaQueryWrapper<SuperviseReportFile>().eq(SuperviseReportFile::getSuperviseId,report.getId())); |
||||
vo.getFiles().forEach(s->{ |
||||
s.setSuperviseId(report.getId()); |
||||
s.setCrtTime(LocalDateTime.now()); |
||||
}); |
||||
return superviseReportFileService.saveOrUpdateBatch(vo.getFiles()); |
||||
} |
||||
return true; |
||||
}else{ |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 删除 |
||||
* */ |
||||
public boolean delById(String id){ |
||||
baseMapper.deleteById(id); |
||||
superviseReportFileService.remove(new LambdaQueryWrapper<SuperviseReportFile>().eq(SuperviseReportFile::getSuperviseId,id)); |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 获取文件附录 |
||||
* */ |
||||
public List<SuperviseReportFile> getReportFile(SuperviseReportQueryParam queryParam){ |
||||
SuperviseReport report=baseMapper.selectOne(new LambdaQueryWrapper<SuperviseReport>().eq(SuperviseReport::getReportName,queryParam.getReportName())); |
||||
if(ObjectUtil.isNotEmpty(report)){ |
||||
return superviseReportFileService.list(new LambdaQueryWrapper<SuperviseReportFile>().eq(SuperviseReportFile::getSuperviseId,report.getId())); |
||||
}else{ |
||||
return null; |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,14 @@
|
||||
<?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.biutag.supervision.mapper.SuperviseReportMapper"> |
||||
|
||||
<select id="queryPage" resultType="com.biutag.supervision.pojo.entity.SuperviseReport"> |
||||
select t.* |
||||
from supervise_report as t |
||||
${ew.getCustomSqlSegment} |
||||
</select> |
||||
|
||||
|
||||
</mapper> |
||||
Loading…
Reference in new issue