18 changed files with 827 additions and 8 deletions
@ -0,0 +1,26 @@ |
|||
package com.kms.yxgh.base.enums; |
|||
|
|||
import lombok.Getter; |
|||
|
|||
/** |
|||
* @ClassName: RecordStatus |
|||
* @Description: TODO |
|||
* @Date: 2023/11/15 上午11:56 * |
|||
* @author: hxh |
|||
* @version: 1.0 |
|||
*/ |
|||
|
|||
@Getter |
|||
public enum YhRecordStatus { |
|||
|
|||
SAVED("已保存", 0L), |
|||
CONFIRMED("已确认", 1L); |
|||
|
|||
private final Long value; |
|||
private final String name; |
|||
|
|||
YhRecordStatus(String name, Long value) { |
|||
this.name = name; |
|||
this.value = value; |
|||
} |
|||
} |
@ -0,0 +1,89 @@ |
|||
package com.kms.yxgh.df.controller; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.kms.common.utils.BaseEntityUtils; |
|||
import com.kms.yxgh.base.Response; |
|||
import com.kms.yxgh.df.domain.DfYhPlan; |
|||
import com.kms.yxgh.df.dto.DfYhPlanDetailDto; |
|||
import com.kms.yxgh.df.service.DfYhPlanService; |
|||
import com.shuili.common.annotation.Log; |
|||
import com.shuili.common.core.controller.BaseController; |
|||
import com.shuili.common.core.domain.AjaxResult; |
|||
import com.shuili.common.core.domain.SearchParam; |
|||
import com.shuili.common.enums.BusinessType; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import java.util.Arrays; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.PutMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
|
|||
/** |
|||
* 堤防维修养护计划Controller |
|||
* |
|||
* @author sy |
|||
* @date 2023-11-20 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/run/df/yh/plan") |
|||
@Api(tags = "堤防维修养护计划") |
|||
public class DfYhPlanController extends BaseController { |
|||
|
|||
@Autowired |
|||
private DfYhPlanService dfYhPlanService; |
|||
|
|||
/** |
|||
* 查询堤防维修养护计划列表 |
|||
*/ |
|||
@PostMapping("/list") |
|||
@ApiOperation("堤防维修养护计划列表") |
|||
public IPage list(@RequestBody SearchParam<DfYhPlan> sp) { |
|||
return dfYhPlanService.selectPage(sp); |
|||
} |
|||
|
|||
/** |
|||
* 获取堤防维修养护计划详细信息 |
|||
*/ |
|||
@ApiOperation(" 堤防维修养护计划详情") |
|||
@GetMapping(value = "/{id}") |
|||
public Response<?> getInfo(@PathVariable("id") Long id) { |
|||
return Response.ok(dfYhPlanService.getById(id)); |
|||
} |
|||
|
|||
/** |
|||
* 新增堤防维修养护计划 |
|||
*/ |
|||
@Log(title = "堤防维修养护计划新增", businessType = BusinessType.INSERT) |
|||
@PostMapping |
|||
@ApiOperation("堤防维修养护计划新增") |
|||
public Response<DfYhPlanDetailDto> add(@RequestBody DfYhPlanDetailDto dfYhPlan) { |
|||
return Response.ok(dfYhPlanService.add(dfYhPlan)); |
|||
} |
|||
|
|||
/** |
|||
* 修改堤防维修养护计划 |
|||
*/ |
|||
@ApiOperation("堤防维修养护计划修改") |
|||
@Log(title = "堤防维修养护计划修改", businessType = BusinessType.UPDATE) |
|||
@PutMapping |
|||
public Response<DfYhPlanDetailDto> edit(@RequestBody DfYhPlanDetailDto dfYhPlan) { |
|||
return Response.ok(dfYhPlanService.update(dfYhPlan)); |
|||
} |
|||
|
|||
/** |
|||
* 删除堤防维修养护计划 |
|||
*/ |
|||
@ApiOperation("堤防维修养护计划删除") |
|||
@Log(title = "堤防维修养护计划删除", businessType = BusinessType.DELETE) |
|||
@DeleteMapping("/{id}") |
|||
public Response<Boolean> remove(@PathVariable String id) { |
|||
return Response.ok(dfYhPlanService.deleteById(id)); |
|||
} |
|||
} |
@ -0,0 +1,87 @@ |
|||
package com.kms.yxgh.df.controller; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.kms.yxgh.base.Response; |
|||
import com.kms.yxgh.df.domain.DfYhRecord; |
|||
import com.kms.yxgh.df.dto.DfYhRecordDetailDto; |
|||
import com.kms.yxgh.df.service.DfYhRecordService; |
|||
import com.shuili.common.annotation.Log; |
|||
import com.shuili.common.core.controller.BaseController; |
|||
import com.shuili.common.core.domain.SearchParam; |
|||
import com.shuili.common.enums.BusinessType; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.PutMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
|
|||
/** |
|||
* 堤防维修养护记录Controller |
|||
* |
|||
* @author sy |
|||
* @date 2023-11-20 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/run/df/yh/record") |
|||
@Api(tags = "堤防维修养护记录") |
|||
public class DfYhRecordController extends BaseController { |
|||
|
|||
@Autowired |
|||
private DfYhRecordService dfYhRecordService; |
|||
|
|||
/** |
|||
* 查询堤防维修养护记录列表 |
|||
*/ |
|||
@PostMapping("/list") |
|||
@ApiOperation("堤防维修养护记录列表") |
|||
public IPage list(@RequestBody SearchParam<DfYhRecord> sp) { |
|||
return dfYhRecordService.selectPage(sp); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 获取堤防维修养护记录详细信息 |
|||
*/ |
|||
@ApiOperation(" 堤防维修养护记录详情") |
|||
@GetMapping(value = "/{id}") |
|||
public Response<DfYhRecordDetailDto> getInfo(@PathVariable("id") String id) { |
|||
return Response.ok(dfYhRecordService.getDetailById(id)); |
|||
} |
|||
|
|||
/** |
|||
* 新增堤防维修养护记录 |
|||
*/ |
|||
@Log(title = "堤防维修养护记录新增", businessType = BusinessType.INSERT) |
|||
@PostMapping |
|||
@ApiOperation("堤防维修养护记录新增") |
|||
public Response<DfYhRecordDetailDto> add(@RequestBody DfYhRecordDetailDto dfYhRecord) { |
|||
return Response.ok(dfYhRecordService.add(dfYhRecord)); |
|||
} |
|||
|
|||
/** |
|||
* 修改堤防维修养护记录 |
|||
*/ |
|||
@ApiOperation("堤防维修养护记录修改") |
|||
@Log(title = "堤防维修养护记录修改", businessType = BusinessType.UPDATE) |
|||
@PutMapping |
|||
public Response<DfYhRecordDetailDto> edit(@RequestBody DfYhRecordDetailDto dfYhRecord) { |
|||
return Response.ok(dfYhRecordService.update(dfYhRecord)); |
|||
} |
|||
|
|||
/** |
|||
* 删除堤防维修养护记录 |
|||
*/ |
|||
@ApiOperation("堤防维修养护记录删除") |
|||
@Log(title = "堤防维修养护记录删除", businessType = BusinessType.DELETE) |
|||
@DeleteMapping("/{id}") |
|||
public Response<Boolean> remove(@PathVariable String id) { |
|||
return Response.ok(dfYhRecordService.deleteById(id)); |
|||
} |
|||
} |
@ -0,0 +1,46 @@ |
|||
package com.kms.yxgh.df.domain; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.kms.yxgh.base.SyBaseEntity; |
|||
import com.shuili.common.annotation.Excel; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 堤防维修养护执行人对象 bs_sgc_df_yhjlzx |
|||
* |
|||
* @author sy |
|||
* @date 2023-11-20 |
|||
*/ |
|||
@TableName("bs_sgc_df_yhjlzx") |
|||
@Data |
|||
@ApiModel("堤防维修养护执行人") |
|||
public class DfYhOperator extends SyBaseEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 养护记录ID |
|||
*/ |
|||
@Excel(name = "养护记录ID") |
|||
@ApiModelProperty("养护记录ID") |
|||
private String recordId; |
|||
|
|||
/** |
|||
* 执行人ID |
|||
*/ |
|||
@Excel(name = "执行人ID") |
|||
@ApiModelProperty("执行人ID") |
|||
private String operatorUid; |
|||
|
|||
/** |
|||
* 执行人名称 |
|||
*/ |
|||
@Excel(name = "执行人名称") |
|||
@ApiModelProperty("执行人名称") |
|||
private String operatorName; |
|||
|
|||
|
|||
} |
@ -0,0 +1,77 @@ |
|||
package com.kms.yxgh.df.domain; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.kms.yxgh.base.SyBaseEntity; |
|||
import com.shuili.common.annotation.Excel; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import java.util.Date; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 堤防维修养护计划对象 bs_sgc_df_yhjh |
|||
* |
|||
* @author sy |
|||
* @date 2023-11-20 |
|||
*/ |
|||
@TableName("bs_sgc_df_yhjh") |
|||
@Data |
|||
@ApiModel("堤防维修养护计划") |
|||
public class DfYhPlan extends SyBaseEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 堤防代码 |
|||
*/ |
|||
@Excel(name = "堤防代码") |
|||
@ApiModelProperty("堤防代码") |
|||
private String dikeCode; |
|||
|
|||
/** |
|||
* 名称 |
|||
*/ |
|||
@Excel(name = "名称") |
|||
@ApiModelProperty("名称") |
|||
private String name; |
|||
|
|||
/** |
|||
* 计划时间 |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd") |
|||
@Excel(name = "计划时间", width = 30, dateFormat = "yyyy-MM-dd") |
|||
@ApiModelProperty("计划时间") |
|||
private Date planTime; |
|||
|
|||
/** |
|||
* 国补资金 |
|||
*/ |
|||
@Excel(name = "国补资金") |
|||
@ApiModelProperty("国补资金") |
|||
private Long nationalSupplement; |
|||
|
|||
/** |
|||
* 自筹资金 |
|||
*/ |
|||
@Excel(name = "自筹资金") |
|||
@ApiModelProperty("自筹资金") |
|||
private Long selfSupplement; |
|||
|
|||
/** |
|||
* 具体地点 |
|||
*/ |
|||
@Excel(name = "具体地点") |
|||
@ApiModelProperty("具体地点") |
|||
private String location; |
|||
|
|||
/** |
|||
* 维修养护内容 |
|||
*/ |
|||
@Excel(name = "维修养护内容") |
|||
@ApiModelProperty("维修养护内容") |
|||
private String content; |
|||
|
|||
|
|||
} |
@ -0,0 +1,80 @@ |
|||
package com.kms.yxgh.df.domain; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.kms.yxgh.base.SyBaseEntity; |
|||
import com.shuili.common.annotation.Excel; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 堤防维修养护记录对象 bs_sgc_df_yhjl |
|||
* |
|||
* @author sy |
|||
* @date 2023-11-20 |
|||
*/ |
|||
@TableName("bs_sgc_df_yhjl") |
|||
@Data |
|||
@ApiModel("堤防维修养护记录") |
|||
public class DfYhRecord extends SyBaseEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 计划代码 |
|||
*/ |
|||
@Excel(name = "计划代码") |
|||
@ApiModelProperty("计划代码") |
|||
private String planId; |
|||
|
|||
/** |
|||
* 名称 |
|||
*/ |
|||
@Excel(name = "名称") |
|||
@ApiModelProperty("名称") |
|||
private String name; |
|||
|
|||
/** |
|||
* 维护前 |
|||
*/ |
|||
@Excel(name = "维护前") |
|||
@ApiModelProperty("维护前") |
|||
private String before; |
|||
|
|||
/** |
|||
* 维护过程 |
|||
*/ |
|||
@Excel(name = "维护过程") |
|||
@ApiModelProperty("维护过程") |
|||
private String middle; |
|||
|
|||
/** |
|||
* 维护结束 |
|||
*/ |
|||
@Excel(name = "维护结束") |
|||
@ApiModelProperty("维护结束") |
|||
private String after; |
|||
|
|||
/** |
|||
* 养护费用 |
|||
*/ |
|||
@Excel(name = "养护费用") |
|||
@ApiModelProperty("养护费用") |
|||
private Long maintenanceFunds; |
|||
|
|||
/** |
|||
* 落实情况 |
|||
*/ |
|||
@Excel(name = "落实情况") |
|||
@ApiModelProperty("落实情况") |
|||
private String implement; |
|||
|
|||
|
|||
/** |
|||
* 状态 |
|||
*/ |
|||
@Excel(name = "状态") |
|||
@ApiModelProperty("状态") |
|||
private Long status; |
|||
} |
@ -0,0 +1,67 @@ |
|||
package com.kms.yxgh.df.dto; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import java.util.Date; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 堤防维修养护计划详情 |
|||
* |
|||
* @author sy |
|||
* @date 2023-11-20 |
|||
*/ |
|||
@Data |
|||
@ApiModel("堤防维修养护计划") |
|||
public class DfYhPlanDetailDto { |
|||
|
|||
@ApiModelProperty("养护计划id") |
|||
private String id; |
|||
|
|||
/** |
|||
* 堤防代码 |
|||
*/ |
|||
@ApiModelProperty("堤防代码") |
|||
private String dikeCode; |
|||
|
|||
/** |
|||
* 名称 |
|||
*/ |
|||
@ApiModelProperty("名称") |
|||
private String name; |
|||
|
|||
/** |
|||
* 计划时间 |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd") |
|||
@ApiModelProperty("计划时间") |
|||
private Date planTime; |
|||
|
|||
/** |
|||
* 国补资金 |
|||
*/ |
|||
@ApiModelProperty("国补资金") |
|||
private Long nationalSupplement; |
|||
|
|||
/** |
|||
* 自筹资金 |
|||
*/ |
|||
@ApiModelProperty("自筹资金") |
|||
private Long selfSupplement; |
|||
|
|||
/** |
|||
* 具体地点 |
|||
*/ |
|||
@ApiModelProperty("具体地点") |
|||
private String location; |
|||
|
|||
/** |
|||
* 维修养护内容 |
|||
*/ |
|||
@ApiModelProperty("维修养护内容") |
|||
private String content; |
|||
|
|||
|
|||
} |
@ -0,0 +1,63 @@ |
|||
package com.kms.yxgh.df.dto; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import java.util.List; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 堤防维修养护记录 |
|||
* |
|||
* @author sy |
|||
* @date 2023-11-20 |
|||
*/ |
|||
@Data |
|||
@ApiModel("堤防维修养护记录") |
|||
public class DfYhRecordDetailDto { |
|||
|
|||
@ApiModelProperty("养护记录id") |
|||
private String id; |
|||
|
|||
@ApiModelProperty("计划代码") |
|||
private String planId; |
|||
|
|||
@ApiModelProperty("名称") |
|||
private String name; |
|||
|
|||
@ApiModelProperty("维护前") |
|||
private String before; |
|||
|
|||
@ApiModelProperty("维护过程") |
|||
private String middle; |
|||
|
|||
@ApiModelProperty("维护结束") |
|||
private String after; |
|||
|
|||
@ApiModelProperty("养护费用") |
|||
private Long maintenanceFunds; |
|||
|
|||
@ApiModelProperty("落实情况") |
|||
private String implement; |
|||
|
|||
@ApiModelProperty("状态") |
|||
private Long status; |
|||
|
|||
@ApiModelProperty("养护人员") |
|||
private List<OperatorDto> operators; |
|||
|
|||
|
|||
@Data |
|||
public static class OperatorDto { |
|||
|
|||
@ApiModelProperty("主键") |
|||
private String id; |
|||
|
|||
@ApiModelProperty("用户id") |
|||
private String uid; |
|||
|
|||
@ApiModelProperty("用户名称") |
|||
private String name; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.kms.yxgh.df.mapper; |
|||
|
|||
import com.kms.yxgh.df.domain.DfYhOperator; |
|||
import org.springframework.stereotype.Repository; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
|
|||
/** |
|||
* 堤防维修养护执行人Mapper接口 |
|||
* |
|||
* @author sy |
|||
* @date 2023-11-20 |
|||
*/ |
|||
@Repository |
|||
public interface DfYhOperatorMapper extends BaseMapper<DfYhOperator> { |
|||
|
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.kms.yxgh.df.mapper; |
|||
|
|||
import com.kms.yxgh.df.domain.DfYhPlan; |
|||
import org.springframework.stereotype.Repository; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
|
|||
/** |
|||
* 堤防维修养护计划Mapper接口 |
|||
* |
|||
* @author sy |
|||
* @date 2023-11-20 |
|||
*/ |
|||
@Repository |
|||
public interface DfYhPlanMapper extends BaseMapper<DfYhPlan> { |
|||
|
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.kms.yxgh.df.mapper; |
|||
|
|||
import com.kms.yxgh.df.domain.DfYhRecord; |
|||
import org.springframework.stereotype.Repository; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
|
|||
/** |
|||
* 堤防维修养护记录Mapper接口 |
|||
* |
|||
* @author sy |
|||
* @date 2023-11-20 |
|||
*/ |
|||
@Repository |
|||
public interface DfYhRecordMapper extends BaseMapper<DfYhRecord> { |
|||
|
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.kms.yxgh.df.service; |
|||
|
|||
import com.kms.yxgh.df.domain.DfYhOperator; |
|||
import com.kms.yxgh.df.mapper.DfYhOperatorMapper; |
|||
import com.shuili.common.core.service.BaseService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* 堤防维修养护执行人Service接口 |
|||
* |
|||
* @author sy |
|||
* @date 2023-11-20 |
|||
*/ |
|||
@Service |
|||
public class DfYhOperatorService extends BaseService<DfYhOperatorMapper, DfYhOperator>{ |
|||
|
|||
} |
@ -0,0 +1,83 @@ |
|||
package com.kms.yxgh.df.service; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import com.kms.yxgh.base.DfException; |
|||
import com.kms.yxgh.df.domain.DfYhPlan; |
|||
import com.kms.yxgh.df.dto.DfYhPlanDetailDto; |
|||
import com.kms.yxgh.df.mapper.DfYhPlanMapper; |
|||
import com.kms.yxgh.util.BeanCopyUtils; |
|||
import com.shuili.common.core.service.BaseService; |
|||
import com.shuili.common.exception.BaseException; |
|||
import com.shuili.common.utils.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
/** |
|||
* 堤防维修养护计划Service接口 |
|||
* |
|||
* @author sy |
|||
* @date 2023-11-20 |
|||
*/ |
|||
@Service |
|||
public class DfYhPlanService extends BaseService<DfYhPlanMapper, DfYhPlan> { |
|||
|
|||
|
|||
public DfYhPlanDetailDto getDetailById(String id) { |
|||
DfYhPlan dfPlan = this.getById(id); |
|||
return BeanCopyUtils.copy(dfPlan, DfYhPlanDetailDto.class); |
|||
} |
|||
|
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
public DfYhPlanDetailDto add(DfYhPlanDetailDto dto) { |
|||
DfYhPlan dfPlan = BeanCopyUtils.copy(dto, DfYhPlan.class); |
|||
if (dfPlan != null) { |
|||
if (checkNameDistinct(dfPlan.getId(), dfPlan.getName())) { |
|||
getBaseMapper().insert(dfPlan); |
|||
dto.setId(dfPlan.getId()); |
|||
return dto; |
|||
} else { |
|||
throw new DfException("该名称已存在"); |
|||
} |
|||
|
|||
} |
|||
return null; |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
public DfYhPlanDetailDto update(DfYhPlanDetailDto dto) { |
|||
if (exist(dto.getId())) { |
|||
DfYhPlan dfPlan = BeanCopyUtils.copy(dto, DfYhPlan.class); |
|||
if (dfPlan != null) { |
|||
if (checkNameDistinct(dfPlan.getId(), dfPlan.getName())) { |
|||
getBaseMapper().updateById(dfPlan); |
|||
return dto; |
|||
} else { |
|||
throw new DfException("该名称已存在"); |
|||
} |
|||
} |
|||
} |
|||
throw new BaseException("源数据不存在,请确认id值是否正确"); |
|||
|
|||
} |
|||
|
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
public Boolean deleteById(String id) { |
|||
return removeById(id); |
|||
} |
|||
|
|||
private boolean checkNameDistinct(String id, String name) { |
|||
Wrapper<DfYhPlan> wp = Wrappers.<DfYhPlan>lambdaQuery() |
|||
.eq(DfYhPlan::getName, name) |
|||
.ne(StringUtils.isNotEmpty(id), DfYhPlan::getId, id); |
|||
return this.getBaseMapper().selectCount(wp) <= 0; |
|||
} |
|||
|
|||
private boolean exist(String id) { |
|||
Wrapper<DfYhPlan> wp = Wrappers.<DfYhPlan>lambdaQuery() |
|||
.eq(DfYhPlan::getId, id); |
|||
return this.getBaseMapper().selectCount(wp) > 0; |
|||
} |
|||
} |
@ -0,0 +1,136 @@ |
|||
package com.kms.yxgh.df.service; |
|||
|
|||
import cn.hutool.core.collection.CollectionUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import com.kms.yxgh.base.DfException; |
|||
import com.kms.yxgh.base.enums.YhRecordStatus; |
|||
import com.kms.yxgh.df.domain.DfYhOperator; |
|||
import com.kms.yxgh.df.domain.DfYhRecord; |
|||
import com.kms.yxgh.df.dto.DfYhRecordDetailDto; |
|||
import com.kms.yxgh.df.dto.DfYhRecordDetailDto.OperatorDto; |
|||
import com.kms.yxgh.df.mapper.DfYhOperatorMapper; |
|||
import com.kms.yxgh.df.mapper.DfYhRecordMapper; |
|||
import com.kms.yxgh.util.BeanCopyUtils; |
|||
import com.kms.yxgh.util.StreamUtils; |
|||
import com.shuili.common.core.service.BaseService; |
|||
import com.shuili.common.exception.BaseException; |
|||
import java.util.List; |
|||
import java.util.function.Consumer; |
|||
import lombok.AllArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
/** |
|||
* 堤防维修养护记录Service接口 |
|||
* |
|||
* @author sy |
|||
* @date 2023-11-20 |
|||
*/ |
|||
@AllArgsConstructor |
|||
@Service |
|||
public class DfYhRecordService extends BaseService<DfYhRecordMapper, DfYhRecord> { |
|||
|
|||
private final DfYhOperatorMapper dfYhOperatorMapper; |
|||
|
|||
public DfYhRecordDetailDto getDetailById(String id) { |
|||
DfYhRecord record = this.getBaseMapper().selectById(id); |
|||
if (record != null) { |
|||
DfYhRecordDetailDto dto = BeanCopyUtils.copy(record, DfYhRecordDetailDto.class); |
|||
Wrapper<DfYhOperator> wp = Wrappers.<DfYhOperator>lambdaQuery() |
|||
.eq(DfYhOperator::getRecordId, id); |
|||
List<DfYhOperator> items = dfYhOperatorMapper.selectList(wp); |
|||
if (CollectionUtil.isNotEmpty(items) && dto != null) { |
|||
dto.setOperators(StreamUtils.toList(items, r -> BeanCopyUtils.copy(r, OperatorDto.class))); |
|||
return dto; |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
public DfYhRecordDetailDto add(DfYhRecordDetailDto dto) { |
|||
DfYhRecord dfYhRecord = BeanCopyUtils.copy(dto, DfYhRecord.class); |
|||
if (dfYhRecord != null) { |
|||
if (existRecord(dto.getPlanId())) { |
|||
getBaseMapper().insert(dfYhRecord); |
|||
dto.setId(dfYhRecord.getId()); |
|||
if (CollectionUtil.isNotEmpty(dto.getOperators())) { |
|||
dto.getOperators().forEach(insertOperator(dto.getId())); |
|||
} |
|||
return dto; |
|||
} else { |
|||
throw new DfException("该维护计划已经存在维护记录"); |
|||
} |
|||
|
|||
} |
|||
return null; |
|||
} |
|||
|
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
public DfYhRecordDetailDto update(DfYhRecordDetailDto dfRecord) { |
|||
if (exist(dfRecord.getId())) { |
|||
if (checkStatus(dfRecord.getId())) { |
|||
DfYhRecord dfYhRecord = BeanCopyUtils.copy(dfRecord, DfYhRecord.class); |
|||
if (dfYhRecord != null) { |
|||
getBaseMapper().updateById(dfYhRecord); |
|||
String id = dfRecord.getId(); |
|||
deleteItems(id); |
|||
if (CollectionUtil.isNotEmpty(dfRecord.getOperators())) { |
|||
dfRecord.getOperators().forEach(insertOperator(id)); |
|||
} |
|||
return dfRecord; |
|||
} |
|||
} else { |
|||
throw new BaseException("已确认的记录不能修改"); |
|||
} |
|||
} |
|||
throw new BaseException("源数据不存在,请确认id值是否正确"); |
|||
} |
|||
|
|||
private Consumer<OperatorDto> insertOperator(String id) { |
|||
return (o) -> { |
|||
DfYhOperator item = new DfYhOperator(); |
|||
item.setRecordId(id); |
|||
item.setOperatorName(o.getName()); |
|||
item.setOperatorUid(o.getUid()); |
|||
dfYhOperatorMapper.insert(item); |
|||
}; |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
public Boolean deleteById(String id) { |
|||
boolean rt = removeById(id); |
|||
if (rt) { |
|||
deleteItems(id); |
|||
} |
|||
return rt; |
|||
} |
|||
|
|||
private void deleteItems(String id) { |
|||
Wrapper<DfYhOperator> wp = Wrappers.<DfYhOperator>lambdaQuery() |
|||
.eq(DfYhOperator::getRecordId, id); |
|||
dfYhOperatorMapper.delete(wp); |
|||
} |
|||
|
|||
private boolean checkStatus(String id) { |
|||
Wrapper<DfYhRecord> wp = Wrappers.<DfYhRecord>lambdaQuery() |
|||
.eq(DfYhRecord::getId, id) |
|||
.eq(DfYhRecord::getStatus, YhRecordStatus.CONFIRMED.getValue()); |
|||
return !(this.getBaseMapper().selectCount(wp) > 0); |
|||
} |
|||
|
|||
private boolean exist(String id) { |
|||
Wrapper<DfYhRecord> wp = Wrappers.<DfYhRecord>lambdaQuery() |
|||
.eq(DfYhRecord::getId, id); |
|||
return this.getBaseMapper().selectCount(wp) > 0; |
|||
} |
|||
|
|||
private boolean existRecord(String planId) { |
|||
Wrapper<DfYhRecord> wp = Wrappers.<DfYhRecord>lambdaQuery() |
|||
.eq(DfYhRecord::getPlanId, planId); |
|||
return this.getBaseMapper().selectCount(wp) > 0; |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue