白蚁普查
parent
1bc5a7615b
commit
94c1fb9de0
2
ruoyi
2
ruoyi
|
|
@ -1 +1 @@
|
|||
Subproject commit d456ff189647e16ffaaa170738d785eeee1253c0
|
||||
Subproject commit 16e1fc95534519a06bc1dca0df64ffceeb3c9931
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
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.TermiteSurveyPageSo;
|
||||
import com.gunshi.project.xyt.model.TermiteSurvey;
|
||||
import com.gunshi.project.xyt.service.TermiteSurveyService;
|
||||
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-28 10:29:58
|
||||
*/
|
||||
@Tag(name = "白蚁普查")
|
||||
@RestController
|
||||
@RequestMapping(value="/termite/survey")
|
||||
public class TermiteSurveyController extends AbstractCommonFileController{
|
||||
|
||||
@Autowired
|
||||
private TermiteSurveyService service;
|
||||
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<TermiteSurvey> insert(@Validated(Insert.class) @RequestBody TermiteSurvey dto) {
|
||||
return R.ok(service.saveData(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<TermiteSurvey> update(@Validated(Update.class) @RequestBody TermiteSurvey 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 = "详情")
|
||||
@GetMapping("/detail/{id}")
|
||||
public R<TermiteSurvey> detail(@Schema(name = "id") @PathVariable("id") Long id) {
|
||||
return R.ok(service.detail(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页")
|
||||
@PostMapping("/page")
|
||||
public R<Page<TermiteSurvey>> page(@RequestBody @Validated TermiteSurveyPageSo page) {
|
||||
return R.ok(service.pageQuery(page));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getGroupId() {
|
||||
return "termiteSurvey";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.gunshi.project.xyt.entity.so;
|
||||
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Created by wanyan on 2024/3/19
|
||||
*
|
||||
* @author wanyan
|
||||
* @version 1.0
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "白蚁普查分页查询对象")
|
||||
public class TermiteSurveyPageSo {
|
||||
|
||||
@NotNull(message = "分页参数不能为空")
|
||||
@Schema(description = "分页参数")
|
||||
private PageSo pageSo;
|
||||
|
||||
@Schema(description="年份")
|
||||
private Integer year;
|
||||
|
||||
@Schema(description="危害情况(0无危害 1有危害)")
|
||||
private Integer isHarm;
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.model.BzDictRel;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 描述: 业务关联字典
|
||||
* author: xusan
|
||||
* date: 2024-08-28 10:05:21
|
||||
*/
|
||||
@Mapper
|
||||
public interface BzDictRelMapper extends BaseMapper<BzDictRel> {
|
||||
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.model.RiskControlDictRel;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 描述: 风险管控关联字典
|
||||
* author: xusan
|
||||
* date: 2024-08-22 14:18:58
|
||||
*/
|
||||
@Mapper
|
||||
public interface RiskControlDictRelMapper extends BaseMapper<RiskControlDictRel> {
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.model.RiskControlDictRel;
|
||||
import com.gunshi.project.xyt.model.BzDictRel;
|
||||
import com.gunshi.project.xyt.model.RiskControlInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -19,14 +19,14 @@ public interface RiskControlInfoMapper extends BaseMapper<RiskControlInfo> {
|
|||
|
||||
@Select("""
|
||||
<script>
|
||||
select t.*,s.dict_nm from public.risk_control_dict_rel t
|
||||
select t.*,s.dict_nm from public.bz_dict_rel t
|
||||
left join public.sys_dict_b s
|
||||
on t.sys_dict_id = s.id
|
||||
where t.risk_control_id in
|
||||
where t.business_id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</script>
|
||||
""")
|
||||
List<RiskControlDictRel> queryRelList(@Param("ids") List<Long> ids);
|
||||
List<BzDictRel> queryRelList(@Param("ids") List<Long> ids);
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.model.TermiteSurveyDetail;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 描述: 白蚁普查明细
|
||||
* author: xusan
|
||||
* date: 2024-08-28 10:25:17
|
||||
*/
|
||||
@Mapper
|
||||
public interface TermiteSurveyDetailMapper extends BaseMapper<TermiteSurveyDetail> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.project.xyt.entity.so.TermiteSurveyPageSo;
|
||||
import com.gunshi.project.xyt.model.TermiteSurvey;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 描述: 白蚁普查
|
||||
* author: xusan
|
||||
* date: 2024-08-28 10:29:58
|
||||
*/
|
||||
@Mapper
|
||||
public interface TermiteSurveyMapper extends BaseMapper<TermiteSurvey> {
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
with m1 as (
|
||||
select t.*,to_char(t.report_date,'YYYY') as year from public.termite_survey t),
|
||||
m2 as (select survey_id,count(is_harm) as harmNum from termite_survey_detail where is_harm = 1 GROUP BY survey_id),
|
||||
m3 as (select survey_id,count(is_handle) as handleNum from termite_survey_detail where is_handle = 1 GROUP BY survey_id)
|
||||
select m1.*,m2.harmNum,m3.handleNum from m1
|
||||
left join m2 on m1.id = m2.survey_id
|
||||
left join m3 on m1.id = m3.survey_id
|
||||
<where>
|
||||
<if test="obj.year != null ">
|
||||
m1.year = #{obj.year}
|
||||
</if>
|
||||
<if test="obj.isHarm != null ">
|
||||
m2.harmNum > 0
|
||||
</if>
|
||||
</where>
|
||||
order by m1.report_date desc
|
||||
</script>
|
||||
""")
|
||||
Page<TermiteSurvey> pageQuery(Page<TermiteSurvey> page,@Param("obj") TermiteSurveyPageSo page1);
|
||||
}
|
||||
|
|
@ -8,19 +8,22 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述: 风险管控关联字典
|
||||
* 描述: 业务关联字典
|
||||
* author: xusan
|
||||
* date: 2024-08-22 14:18:58
|
||||
* date: 2024-08-28 10:05:20
|
||||
*/
|
||||
@Schema(description="风险管控关联字典")
|
||||
@Schema(description="业务关联字典")
|
||||
@Data
|
||||
@TableName("public.risk_control_dict_rel")
|
||||
public class RiskControlDictRel implements Serializable {
|
||||
@TableName("public.bz_dict_rel")
|
||||
public class BzDictRel implements Serializable {
|
||||
|
||||
public final static String thisTableName = "BzDictRel";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
|
@ -33,12 +36,12 @@ public class RiskControlDictRel implements Serializable {
|
|||
private Long id;
|
||||
|
||||
/**
|
||||
* 风险管控id
|
||||
* 业务id
|
||||
*/
|
||||
@TableField(value="risk_control_id")
|
||||
@Schema(description="风险管控id")
|
||||
@TableField(value="business_id")
|
||||
@Schema(description="业务id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long riskControlId;
|
||||
private Long businessId;
|
||||
|
||||
/**
|
||||
* 字典id
|
||||
|
|
@ -48,7 +51,16 @@ public class RiskControlDictRel implements Serializable {
|
|||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long sysDictId;
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
*/
|
||||
@TableField(value="group_id")
|
||||
@Schema(description="业务类型")
|
||||
@Size(max = 100,message = "业务类型最大长度要小于 100")
|
||||
private String groupId;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "字典名称")
|
||||
private String dictNm;
|
||||
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ public class RiskControlInfo implements Serializable {
|
|||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "可能导致的后果")
|
||||
private List<RiskControlDictRel> result;
|
||||
private List<BzDictRel> result;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "现场图片")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,91 @@
|
|||
package com.gunshi.project.xyt.model;
|
||||
|
||||
|
||||
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 com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.gunshi.core.dateformat.DateFormatString;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: 白蚁普查
|
||||
* author: xusan
|
||||
* date: 2024-08-28 10:29:58
|
||||
*/
|
||||
@Schema(description="白蚁普查")
|
||||
@Data
|
||||
@TableName("public.termite_survey")
|
||||
public class TermiteSurvey implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
@Schema(description="主键")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 上报时间
|
||||
*/
|
||||
@TableField(value="report_date")
|
||||
@Schema(description="上报时间")
|
||||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD, timezone = "GMT+8")
|
||||
private Date reportDate;
|
||||
|
||||
/**
|
||||
* 普查类型(1日常检查排查 2定期普查 3专项调查)
|
||||
*/
|
||||
@TableField(value="survey_type")
|
||||
@Schema(description="普查类型(1日常检查排查 2定期普查 3专项调查)")
|
||||
private Integer surveyType;
|
||||
|
||||
/**
|
||||
* 普查方式(1人工排查法 2引诱法 3仪器探测法 4其它)
|
||||
*/
|
||||
@TableField(value="survey_way")
|
||||
@Schema(description="普查方式(1人工排查法 2引诱法 3仪器探测法 4其它)")
|
||||
private Integer surveyWay;
|
||||
|
||||
/**
|
||||
* 上报人id
|
||||
*/
|
||||
@TableField(value="report_user_id")
|
||||
@Schema(description="上报人id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long reportUserId;
|
||||
|
||||
/**
|
||||
* 上报人
|
||||
*/
|
||||
@TableField(value="report_user_name")
|
||||
@Schema(description="上报人")
|
||||
@Size(max = 50,message = "上报人最大长度要小于 50")
|
||||
private String reportUserName;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "白蚁危害处数")
|
||||
private Integer harmNum;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "已处置处数")
|
||||
private Integer handleNum;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "明细")
|
||||
private List<TermiteSurveyDetail> details;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
package com.gunshi.project.xyt.model;
|
||||
|
||||
|
||||
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 com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: 白蚁普查明细
|
||||
* author: xusan
|
||||
* date: 2024-08-28 10:25:17
|
||||
*/
|
||||
@Schema(description="白蚁普查明细")
|
||||
@Data
|
||||
@TableName("public.termite_survey_detail")
|
||||
public class TermiteSurveyDetail implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
@Schema(description="主键")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 普查id
|
||||
*/
|
||||
@TableField(value="survey_id")
|
||||
@Schema(description="普查id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long surveyId;
|
||||
|
||||
/**
|
||||
* 部位
|
||||
*/
|
||||
@TableField(value="position")
|
||||
@Schema(description="部位")
|
||||
@Size(max = 50,message = "部位最大长度要小于 50")
|
||||
private String position;
|
||||
|
||||
/**
|
||||
* 危害情况(0 无危害 1有危害)
|
||||
*/
|
||||
@TableField(value="is_harm")
|
||||
@Schema(description="危害情况(0 无危害 1有危害)")
|
||||
private Integer isHarm;
|
||||
|
||||
/**
|
||||
* 桩号
|
||||
*/
|
||||
@TableField(value="pile_number")
|
||||
@Schema(description="桩号")
|
||||
@Size(max = 50,message = "桩号最大长度要小于 50")
|
||||
private String pileNumber;
|
||||
|
||||
/**
|
||||
* 普查长度(m)
|
||||
*/
|
||||
@TableField(value="survey_len")
|
||||
@Schema(description="普查长度(m)")
|
||||
private BigDecimal surveyLen;
|
||||
|
||||
/**
|
||||
* 是否致险(0否 1是)
|
||||
*/
|
||||
@TableField(value="is_danger")
|
||||
@Schema(description="是否致险(0否 1是)")
|
||||
private Integer isDanger;
|
||||
|
||||
/**
|
||||
* 渗漏处数
|
||||
*/
|
||||
@TableField(value="leakage")
|
||||
@Schema(description="渗漏处数")
|
||||
private Integer leakage;
|
||||
|
||||
/**
|
||||
* 穿坝处数
|
||||
*/
|
||||
@TableField(value="dam_cross")
|
||||
@Schema(description="穿坝处数")
|
||||
private Integer damCross;
|
||||
|
||||
/**
|
||||
* 跌窝处数
|
||||
*/
|
||||
@TableField(value="fall_nest")
|
||||
@Schema(description="跌窝处数")
|
||||
private Integer fallNest;
|
||||
|
||||
/**
|
||||
* 是否已处置(0否 1是)
|
||||
*/
|
||||
@TableField(value="is_handle")
|
||||
@Schema(description="是否已处置(0否 1是)")
|
||||
private Integer isHandle;
|
||||
|
||||
/**
|
||||
* 处置情况说明
|
||||
*/
|
||||
@TableField(value="handle_desc")
|
||||
@Schema(description="处置情况说明")
|
||||
@Size(max = 500,message = "处置情况说明最大长度要小于 500")
|
||||
private String handleDesc;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "活动迹象")
|
||||
private List<BzDictRel> actSign;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "现场图片")
|
||||
private List<FileAssociations> pics;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "现场视频")
|
||||
private List<FileAssociations> videos;
|
||||
|
||||
}
|
||||
|
|
@ -4,8 +4,8 @@ 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 com.gunshi.project.xyt.mapper.BzDictRelMapper;
|
||||
import com.gunshi.project.xyt.model.BzDictRel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -14,36 +14,43 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: 风险管控关联字典
|
||||
* 描述: 业务关联字典
|
||||
* author: xusan
|
||||
* date: 2024-08-22 14:18:58
|
||||
* date: 2024-08-28 10:05:21
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class RiskControlDictRelService extends ServiceImpl<RiskControlDictRelMapper, RiskControlDictRel>
|
||||
public class BzDictRelService extends ServiceImpl<BzDictRelMapper, BzDictRel>
|
||||
{
|
||||
|
||||
public void saveRel(List<RiskControlDictRel> result, Long id) {
|
||||
public void saveRel(List<BzDictRel> result, Long id,String groupId) {
|
||||
if (CollectionUtils.isNotEmpty(result)) {
|
||||
result.stream().forEach(rel->{
|
||||
rel.setId(IdWorker.getId());
|
||||
rel.setRiskControlId(id);
|
||||
if(id != null){
|
||||
rel.setBusinessId(id);
|
||||
}
|
||||
rel.setGroupId(groupId);
|
||||
});
|
||||
this.saveBatch(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void deleteRel(Long id) {
|
||||
LambdaQueryWrapper<RiskControlDictRel> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.eq(RiskControlDictRel::getRiskControlId,id);
|
||||
LambdaQueryWrapper<BzDictRel> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.eq(BzDictRel::getBusinessId,id);
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
public void updateRel(List<RiskControlDictRel> result, Long id) {
|
||||
public void updateRel(List<BzDictRel> result, Long id,String groupId) {
|
||||
deleteRel(id);
|
||||
saveRel(result,id);
|
||||
saveRel(result,id,groupId);
|
||||
}
|
||||
|
||||
public void removeByBzIds(List<Long> detailIds) {
|
||||
LambdaQueryWrapper<BzDictRel> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.in(BzDictRel::getBusinessId,detailIds);
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2,6 +2,8 @@ package com.gunshi.project.xyt.service;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.xyt.mapper.FileAssociationsMapper;
|
||||
import com.gunshi.project.xyt.model.FileAssociations;
|
||||
|
|
@ -13,6 +15,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -152,7 +155,9 @@ public class FileAssociationsService extends ServiceImpl<FileAssociationsMapper,
|
|||
if (attachList != null && !attachList.isEmpty()) {
|
||||
for (FileAssociations attach : attachList) {
|
||||
attach.setId(IdWorker.getId());
|
||||
attach.setBusinessId(businessId);
|
||||
if(StringUtils.isNotEmpty(businessId)){
|
||||
attach.setBusinessId(businessId);
|
||||
}
|
||||
attach.setTableName(tableName);
|
||||
attach.setType(type);
|
||||
}
|
||||
|
|
@ -168,4 +173,8 @@ public class FileAssociationsService extends ServiceImpl<FileAssociationsMapper,
|
|||
return this.baseMapper.queryFileList(businessId,tableName,type);
|
||||
}
|
||||
|
||||
public boolean removeByBzIds(List<String> businessIds) {
|
||||
return this.remove(new QueryWrapper<FileAssociations>().in("business_id", businessIds));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ 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.BzDictRel;
|
||||
import com.gunshi.project.xyt.model.RiskControlInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -34,14 +34,14 @@ public class RiskControlInfoService extends ServiceImpl<RiskControlInfoMapper, R
|
|||
private FileAssociationsService fileService;
|
||||
|
||||
@Autowired
|
||||
private RiskControlDictRelService riskControlDictRelService;
|
||||
private BzDictRelService bzDictRelService;
|
||||
|
||||
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());
|
||||
bzDictRelService.saveRel(dto.getResult(),dto.getId(),getGroupId());
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ public class RiskControlInfoService extends ServiceImpl<RiskControlInfoMapper, R
|
|||
boolean result = this.updateById(dto);
|
||||
if (result) {
|
||||
fileService.saveFile(dto.getFiles(), getGroupId(), String.valueOf(dto.getId()));
|
||||
riskControlDictRelService.updateRel(dto.getResult(),dto.getId());
|
||||
bzDictRelService.updateRel(dto.getResult(),dto.getId(),getGroupId());
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ public class RiskControlInfoService extends ServiceImpl<RiskControlInfoMapper, R
|
|||
boolean data = this.removeById(id);
|
||||
if (data) {
|
||||
fileService.deleteFile(getGroupId(), id.toString());
|
||||
riskControlDictRelService.deleteRel(id);
|
||||
bzDictRelService.deleteRel(id);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
|
@ -90,8 +90,8 @@ public class RiskControlInfoService extends ServiceImpl<RiskControlInfoMapper, R
|
|||
|
||||
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));
|
||||
List<BzDictRel> relList = this.baseMapper.queryRelList(ids);
|
||||
Map<Long, List<BzDictRel>> map = relList.stream().collect(Collectors.groupingBy(BzDictRel::getBusinessId));
|
||||
for (RiskControlInfo record : records) {
|
||||
record.setResult(map.get(record.getId()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,129 @@
|
|||
package com.gunshi.project.xyt.service;
|
||||
|
||||
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.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.xyt.mapper.RiskControlInfoMapper;
|
||||
import com.gunshi.project.xyt.mapper.TermiteSurveyDetailMapper;
|
||||
import com.gunshi.project.xyt.model.BzDictRel;
|
||||
import com.gunshi.project.xyt.model.FileAssociations;
|
||||
import com.gunshi.project.xyt.model.TermiteSurvey;
|
||||
import com.gunshi.project.xyt.model.TermiteSurveyDetail;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 描述: 白蚁普查明细
|
||||
* author: xusan
|
||||
* date: 2024-08-28 10:25:17
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class TermiteSurveyDetailService extends ServiceImpl<TermiteSurveyDetailMapper, TermiteSurveyDetail>
|
||||
{
|
||||
@Autowired
|
||||
private FileAssociationsService fileService;
|
||||
|
||||
@Autowired
|
||||
private BzDictRelService bzDictRelService;
|
||||
|
||||
@Autowired
|
||||
private RiskControlInfoMapper controlInfoMapper;
|
||||
|
||||
public void saveDetail(List<TermiteSurveyDetail> details, Long id) {
|
||||
if(!CollectionUtils.isEmpty(details)){
|
||||
List<FileAssociations> picList = new ArrayList<>();
|
||||
List<FileAssociations> videoList = new ArrayList<>();
|
||||
List<BzDictRel> relList = new ArrayList<>();
|
||||
for (TermiteSurveyDetail detail : details){
|
||||
Long detailId = IdWorker.getId();
|
||||
detail.setId(detailId);
|
||||
detail.setSurveyId(id);
|
||||
if(CollectionUtils.isNotEmpty(detail.getActSign())){
|
||||
detail.getActSign().stream().forEach(o->o.setBusinessId(detailId));
|
||||
relList.addAll(detail.getActSign());
|
||||
}
|
||||
if(CollectionUtils.isNotEmpty(detail.getPics())){
|
||||
detail.getPics().stream().forEach(o->o.setBusinessId(detailId.toString()));
|
||||
picList.addAll(detail.getPics());
|
||||
}
|
||||
if(CollectionUtils.isNotEmpty(detail.getVideos())){
|
||||
detail.getVideos().stream().forEach(o->o.setBusinessId(detailId.toString()));
|
||||
videoList.addAll(detail.getVideos());
|
||||
}
|
||||
}
|
||||
this.saveBatch(details);
|
||||
bzDictRelService.saveRel(relList,null,getGroupId());
|
||||
fileService.save(picList,null,getGroupId(),getPicType());
|
||||
fileService.save(videoList,null,getGroupId(),getVideoType());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getPicType() {
|
||||
return "termitePic";
|
||||
}
|
||||
|
||||
private String getVideoType() {
|
||||
return "termiteVideo";
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return "termiteSurvey";
|
||||
}
|
||||
|
||||
|
||||
public void updateDetail(List<TermiteSurveyDetail> details, Long id) {
|
||||
delDetail(id);
|
||||
saveDetail(details,id);
|
||||
}
|
||||
|
||||
public void delDetail(Long id) {
|
||||
List<TermiteSurveyDetail> list = getDetailById(id);
|
||||
if(CollectionUtils.isEmpty(list)){
|
||||
return;
|
||||
}
|
||||
List<Long> detailIds = list.stream().map(TermiteSurveyDetail::getId).collect(Collectors.toList());
|
||||
List<String> ids = detailIds.stream().map(Object::toString).collect(Collectors.toList());
|
||||
//删除附件
|
||||
fileService.removeByBzIds(ids);
|
||||
//删除字典
|
||||
bzDictRelService.removeByBzIds(detailIds);
|
||||
this.removeBatchByIds(detailIds);
|
||||
}
|
||||
|
||||
public TermiteSurvey detail(TermiteSurvey termiteSurvey) {
|
||||
List<TermiteSurveyDetail> list = getDetailById(termiteSurvey.getId());
|
||||
if(CollectionUtils.isEmpty(list)){
|
||||
return termiteSurvey;
|
||||
}
|
||||
List<Long> ids = list.stream().map(TermiteSurveyDetail::getId).collect(Collectors.toList());
|
||||
List<BzDictRel> relList = controlInfoMapper.queryRelList(ids);
|
||||
Map<Long, List<BzDictRel>> map = relList.stream().collect(Collectors.groupingBy(BzDictRel::getBusinessId));
|
||||
for(TermiteSurveyDetail detail : list){
|
||||
detail.setActSign(map.get(detail.getId()));
|
||||
detail.setPics(fileService.queryFileList(detail.getId().toString(),getGroupId(),getPicType()));
|
||||
detail.setVideos(fileService.queryFileList(detail.getId().toString(),getGroupId(),getVideoType()));
|
||||
}
|
||||
termiteSurvey.setDetails(list);
|
||||
return termiteSurvey;
|
||||
}
|
||||
|
||||
private List<TermiteSurveyDetail> getDetailById(Long id){
|
||||
LambdaQueryWrapper<TermiteSurveyDetail> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.eq(TermiteSurveyDetail::getSurveyId,id);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
package com.gunshi.project.xyt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.xyt.entity.so.TermiteSurveyPageSo;
|
||||
import com.gunshi.project.xyt.mapper.TermiteSurveyMapper;
|
||||
import com.gunshi.project.xyt.model.TermiteSurvey;
|
||||
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.Objects;
|
||||
|
||||
/**
|
||||
* 描述: 白蚁普查
|
||||
* author: xusan
|
||||
* date: 2024-08-28 10:29:58
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class TermiteSurveyService extends ServiceImpl<TermiteSurveyMapper, TermiteSurvey>
|
||||
{
|
||||
@Autowired
|
||||
private TermiteSurveyDetailService detailService;
|
||||
|
||||
public TermiteSurvey saveData(TermiteSurvey dto) {
|
||||
dto.setId(IdWorker.getId());
|
||||
boolean result = this.save(dto);
|
||||
if (result) {
|
||||
detailService.saveDetail(dto.getDetails(),dto.getId());
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
public TermiteSurvey updateData(TermiteSurvey dto) {
|
||||
if (Objects.isNull(this.getById(dto.getId()))) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
boolean result = this.updateById(dto);
|
||||
if (result) {
|
||||
detailService.updateDetail(dto.getDetails(),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) {
|
||||
detailService.delDetail(id);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public TermiteSurvey detail(Long id) {
|
||||
TermiteSurvey termiteSurvey = this.getById(id);
|
||||
if(Objects.isNull(termiteSurvey)){
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
return detailService.detail(termiteSurvey);
|
||||
}
|
||||
|
||||
public Page<TermiteSurvey> pageQuery(TermiteSurveyPageSo page) {
|
||||
return this.baseMapper.pageQuery(page.getPageSo().toPage(),page);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue