风险管控清单
parent
7d594dd6d9
commit
882f6a07d7
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.gunshi.project.xyt.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.gunshi.core.result.R;
|
||||||
|
import com.gunshi.project.xyt.entity.so.AttCctvBasePage;
|
||||||
|
import com.gunshi.project.xyt.model.RiskControlInfo;
|
||||||
|
import com.gunshi.project.xyt.service.RiskControlInfoService;
|
||||||
|
import com.gunshi.project.xyt.validate.markers.Insert;
|
||||||
|
import com.gunshi.project.xyt.validate.markers.Update;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
/**
|
||||||
|
* 描述: 风险管控清单
|
||||||
|
* author: xusan
|
||||||
|
* date: 2024-08-22 14:17:28
|
||||||
|
*/
|
||||||
|
@Tag(name = "风险管控清单")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value="/risk/info")
|
||||||
|
public class RiskControlInfoController extends AbstractCommonFileController{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RiskControlInfoService service;
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(summary = "新增")
|
||||||
|
@PostMapping("/insert")
|
||||||
|
public R<RiskControlInfo> insert(@Validated(Insert.class) @RequestBody RiskControlInfo dto) {
|
||||||
|
return R.ok(service.saveData(dto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "修改")
|
||||||
|
@PostMapping("/update")
|
||||||
|
public R<RiskControlInfo> update(@Validated(Update.class) @RequestBody RiskControlInfo dto) {
|
||||||
|
return R.ok(service.updateData(dto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除")
|
||||||
|
@GetMapping("/del/{id}")
|
||||||
|
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Long id) {
|
||||||
|
return R.ok(service.delData(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "分页")
|
||||||
|
@PostMapping("/page")
|
||||||
|
public R<Page<RiskControlInfo>> page(@RequestBody @Validated AttCctvBasePage page) {
|
||||||
|
return R.ok(service.pageQuery(page));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGroupId() {
|
||||||
|
return "riskControlInfo";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
package com.gunshi.project.xyt.mapper;
|
package com.gunshi.project.xyt.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.gunshi.project.xyt.model.RiskControlDictRel;
|
||||||
import com.gunshi.project.xyt.model.RiskControlInfo;
|
import com.gunshi.project.xyt.model.RiskControlInfo;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述: 风险管控清单
|
* 描述: 风险管控清单
|
||||||
|
|
@ -12,4 +17,16 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface RiskControlInfoMapper extends BaseMapper<RiskControlInfo> {
|
public interface RiskControlInfoMapper extends BaseMapper<RiskControlInfo> {
|
||||||
|
|
||||||
|
@Select("""
|
||||||
|
<script>
|
||||||
|
select t.*,s.dict_nm from public.risk_control_dict_rel t
|
||||||
|
left join public.sys_dict_b s
|
||||||
|
on t.sys_dict_id = s.id
|
||||||
|
where t.risk_control_id in
|
||||||
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</script>
|
||||||
|
""")
|
||||||
|
List<RiskControlDictRel> queryRelList(@Param("ids") List<Long> ids);
|
||||||
}
|
}
|
||||||
|
|
@ -48,4 +48,7 @@ public class RiskControlDictRel implements Serializable {
|
||||||
@JsonSerialize(using = ToStringSerializer.class)
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
private Long sysDictId;
|
private Long sysDictId;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "字典名称")
|
||||||
|
private String dictNm;
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.gunshi.project.xyt.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gunshi.project.xyt.mapper.RiskControlDictRelMapper;
|
||||||
|
import com.gunshi.project.xyt.model.RiskControlDictRel;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述: 风险管控关联字典
|
||||||
|
* author: xusan
|
||||||
|
* date: 2024-08-22 14:18:58
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class RiskControlDictRelService extends ServiceImpl<RiskControlDictRelMapper, RiskControlDictRel>
|
||||||
|
{
|
||||||
|
|
||||||
|
public void saveRel(List<RiskControlDictRel> result, Long id) {
|
||||||
|
if (CollectionUtils.isNotEmpty(result)) {
|
||||||
|
result.stream().forEach(rel->{
|
||||||
|
rel.setId(IdWorker.getId());
|
||||||
|
rel.setRiskControlId(id);
|
||||||
|
});
|
||||||
|
this.saveBatch(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteRel(Long id) {
|
||||||
|
LambdaQueryWrapper<RiskControlDictRel> queryWrapper = Wrappers.lambdaQuery();
|
||||||
|
queryWrapper.eq(RiskControlDictRel::getRiskControlId,id);
|
||||||
|
this.remove(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateRel(List<RiskControlDictRel> result, Long id) {
|
||||||
|
deleteRel(id);
|
||||||
|
saveRel(result,id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,107 @@
|
||||||
|
package com.gunshi.project.xyt.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.gunshi.project.xyt.entity.so.AttCctvBasePage;
|
||||||
|
import com.gunshi.project.xyt.mapper.RiskControlInfoMapper;
|
||||||
|
import com.gunshi.project.xyt.model.RiskControlDictRel;
|
||||||
|
import com.gunshi.project.xyt.model.RiskControlInfo;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述: 风险管控清单
|
||||||
|
* author: xusan
|
||||||
|
* date: 2024-08-22 14:17:28
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class RiskControlInfoService extends ServiceImpl<RiskControlInfoMapper, RiskControlInfo>
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private FileAssociationsService fileService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RiskControlDictRelService riskControlDictRelService;
|
||||||
|
|
||||||
|
public RiskControlInfo saveData(RiskControlInfo dto) {
|
||||||
|
dto.setId(IdWorker.getId());
|
||||||
|
boolean result = this.save(dto);
|
||||||
|
if (result) {
|
||||||
|
fileService.saveFile(dto.getFiles(), getGroupId(), String.valueOf(dto.getId()));
|
||||||
|
riskControlDictRelService.saveRel(dto.getResult(),dto.getId());
|
||||||
|
}
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RiskControlInfo updateData(RiskControlInfo dto) {
|
||||||
|
if (Objects.isNull(this.getById(dto.getId()))) {
|
||||||
|
throw new IllegalArgumentException("当前数据不存在");
|
||||||
|
}
|
||||||
|
boolean result = this.updateById(dto);
|
||||||
|
if (result) {
|
||||||
|
fileService.saveFile(dto.getFiles(), getGroupId(), String.valueOf(dto.getId()));
|
||||||
|
riskControlDictRelService.updateRel(dto.getResult(),dto.getId());
|
||||||
|
}
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean delData(Long id) {
|
||||||
|
if (Objects.isNull(this.getById(id))) {
|
||||||
|
throw new IllegalArgumentException("当前数据不存在");
|
||||||
|
}
|
||||||
|
boolean data = this.removeById(id);
|
||||||
|
if (data) {
|
||||||
|
fileService.deleteFile(getGroupId(), id.toString());
|
||||||
|
riskControlDictRelService.deleteRel(id);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroupId() {
|
||||||
|
return "riskControlInfo";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Page<RiskControlInfo> pageQuery(AttCctvBasePage page) {
|
||||||
|
LambdaQueryWrapper<RiskControlInfo> query = Wrappers.lambdaQuery();
|
||||||
|
if (ObjectUtils.isNotNull(page.getMenuId())) {
|
||||||
|
query.eq(RiskControlInfo::getMenuId, page.getMenuId());
|
||||||
|
}
|
||||||
|
query.orderByDesc(RiskControlInfo::getCreateDate);
|
||||||
|
Page<RiskControlInfo> res = this.page(page.getPageSo().toPage(), query);
|
||||||
|
if (res.getRecords() != null) {
|
||||||
|
fillAttach(res.getRecords());
|
||||||
|
fillRel(res.getRecords());
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillRel(List<RiskControlInfo> records) {
|
||||||
|
List<Long> ids = records.stream().map(RiskControlInfo::getId).collect(Collectors.toList());
|
||||||
|
List<RiskControlDictRel> relList = this.baseMapper.queryRelList(ids);
|
||||||
|
Map<Long, List<RiskControlDictRel>> map = relList.stream().collect(Collectors.groupingBy(RiskControlDictRel::getRiskControlId));
|
||||||
|
for (RiskControlInfo record : records) {
|
||||||
|
record.setResult(map.get(record.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillAttach(List<RiskControlInfo> ret) {
|
||||||
|
for (RiskControlInfo record : ret) {
|
||||||
|
record.setFiles(fileService.getFiles(getGroupId(), String.valueOf(record.getId())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue