forked from rongchao/epmet-cloud-rizhao
24 changed files with 1004 additions and 77 deletions
@ -0,0 +1,86 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
|
|||
/** |
|||
* 日照:贫困人员慰问记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-06-17 |
|||
*/ |
|||
@Data |
|||
public class PovertyCondoleDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 贫困人员ID |
|||
*/ |
|||
private String povertyId; |
|||
|
|||
/** |
|||
* 居民ID |
|||
*/ |
|||
private Integer resiUserId; |
|||
|
|||
/** |
|||
* 贫困人员姓名 |
|||
*/ |
|||
private String userName; |
|||
|
|||
/** |
|||
* 慰问时间 |
|||
*/ |
|||
private Date condoleTime; |
|||
|
|||
/** |
|||
* 慰问人员,多人以“,”相隔 |
|||
*/ |
|||
private String condoleStaff; |
|||
|
|||
/** |
|||
* 慰问内容 |
|||
*/ |
|||
private String content; |
|||
|
|||
/** |
|||
* 详细描述 |
|||
*/ |
|||
private String remark; |
|||
|
|||
/** |
|||
* 图片 |
|||
*/ |
|||
private List<String> imgs; |
|||
|
|||
/** |
|||
* 电话 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 身份证号码 |
|||
*/ |
|||
private String idCard; |
|||
|
|||
/** |
|||
* 贫困属性 |
|||
*/ |
|||
private String povertyType; |
|||
|
|||
/** |
|||
* 脱贫状态 |
|||
*/ |
|||
private Integer povertyStatus; |
|||
|
|||
} |
@ -0,0 +1,62 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
|
|||
/** |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-06-16 |
|||
*/ |
|||
@Data |
|||
public class PovertyManageDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 居民ID |
|||
*/ |
|||
private String resiUserId; |
|||
|
|||
/** |
|||
* 组织ID |
|||
*/ |
|||
private String agencyId; |
|||
|
|||
/** |
|||
* 网格ID |
|||
*/ |
|||
private String gridId; |
|||
|
|||
/** |
|||
* 姓名 |
|||
*/ |
|||
private String userName; |
|||
|
|||
/** |
|||
* 电话 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 身份证号码 |
|||
*/ |
|||
private String idCard; |
|||
|
|||
/** |
|||
* 贫困属性 |
|||
*/ |
|||
private String povertyType; |
|||
|
|||
/** |
|||
* 脱贫状态 |
|||
*/ |
|||
private Integer povertyStatus; |
|||
|
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.epmet.dto.form.povertyManage; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author yan Lu |
|||
* @description 描述 |
|||
* @create 2023/6/18 21:46 |
|||
*/ |
|||
@Data |
|||
public class PovertyCondoleAttrDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -5490762499712805180L; |
|||
|
|||
private String pcId; |
|||
|
|||
private String url; |
|||
} |
@ -0,0 +1,47 @@ |
|||
package com.epmet.dto.form.povertyManage; |
|||
|
|||
import com.epmet.commons.tools.dto.form.PageFormDTO; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author yan Lu |
|||
* @description 贫困人员慰问记录 |
|||
* @create 2023/6/17 15:44 |
|||
*/ |
|||
@Data |
|||
public class PovertyCondoleFormDto extends PageFormDTO implements Serializable { |
|||
|
|||
|
|||
private static final long serialVersionUID = 8556498763914596452L; |
|||
|
|||
private String id; |
|||
|
|||
private String povertyId; |
|||
|
|||
private String resiUserId; |
|||
|
|||
private String userName; |
|||
|
|||
private String idCard; |
|||
|
|||
private String content; |
|||
|
|||
private String remark; |
|||
|
|||
private String condoleStaff; |
|||
|
|||
private String povertyStatus; |
|||
|
|||
private String povertyType; |
|||
|
|||
private List<String> imgs; |
|||
|
|||
private String condoleTime; |
|||
|
|||
private String startTime; |
|||
|
|||
private String endTime; |
|||
} |
@ -0,0 +1,144 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|||
import com.epmet.commons.tools.annotation.MaskResponse; |
|||
import com.epmet.commons.tools.aop.NoRepeatSubmit; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.enums.DictTypeEnum; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.AssertUtils; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.commons.tools.validator.group.AddGroup; |
|||
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|||
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|||
import com.epmet.dto.PovertyCondoleDTO; |
|||
import com.epmet.dto.form.povertyManage.PovertyCondoleAttrDTO; |
|||
import com.epmet.dto.form.povertyManage.PovertyCondoleFormDto; |
|||
import com.epmet.entity.PovertyCondoleAttrEntity; |
|||
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|||
import com.epmet.service.PovertyCondoleAttrService; |
|||
import com.epmet.service.PovertyCondoleService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.util.CollectionUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.text.ParseException; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 日照:贫困人员慰问记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-06-17 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("povertyCondole") |
|||
public class PovertyCondoleController { |
|||
|
|||
@Autowired |
|||
private PovertyCondoleService povertyCondoleService; |
|||
|
|||
@Autowired |
|||
private PovertyCondoleAttrService attrService; |
|||
|
|||
@Autowired |
|||
private EpmetAdminOpenFeignClient adminOpenFeignClient; |
|||
|
|||
@RequestMapping("page") |
|||
@MaskResponse(fieldNames = {"mobile", "idCard"}, fieldsMaskType = {MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD}) |
|||
public Result<PageData<PovertyCondoleDTO>> page(@RequestParam Map<String, Object> params) { |
|||
PageData<PovertyCondoleDTO> page = povertyCondoleService.page(params); |
|||
if (null != page && page.getList().size() > 0) { |
|||
buildData(page.getList()); |
|||
} |
|||
return new Result<PageData<PovertyCondoleDTO>>().ok(page); |
|||
} |
|||
|
|||
@RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET}) |
|||
public Result<PovertyCondoleDTO> get(@PathVariable("id") String id) { |
|||
PovertyCondoleDTO data = povertyCondoleService.get(id); |
|||
List<PovertyCondoleAttrDTO> imgs = attrService.selectByPcId(id); |
|||
if (!CollectionUtils.isEmpty(imgs)) { |
|||
List<String> imageList = new ArrayList<>(); |
|||
imgs.forEach(file -> { |
|||
imageList.add(file.getUrl()); |
|||
}); |
|||
data.setImgs(imageList); |
|||
} |
|||
return new Result<PovertyCondoleDTO>().ok(data); |
|||
} |
|||
|
|||
@NoRepeatSubmit |
|||
@PostMapping("save") |
|||
public Result save(@RequestBody PovertyCondoleFormDto dto) throws ParseException { |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
dto.setId(IdWorker.getIdStr()); |
|||
if (!CollectionUtils.isEmpty(dto.getImgs())) { |
|||
List<PovertyCondoleAttrEntity> imageList = new ArrayList<>(); |
|||
buildImgs(imageList, dto.getImgs(), dto.getId()); |
|||
attrService.insertBatch(imageList); |
|||
} |
|||
povertyCondoleService.save(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@NoRepeatSubmit |
|||
@PostMapping("update") |
|||
public Result update(@RequestBody PovertyCondoleFormDto dto) throws ParseException { |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
if (!CollectionUtils.isEmpty(dto.getImgs())) { |
|||
List<PovertyCondoleAttrEntity> imageList = new ArrayList<>(); |
|||
buildImgs(imageList, dto.getImgs(), dto.getId()); |
|||
attrService.insertBatch(imageList); |
|||
} |
|||
povertyCondoleService.update(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PostMapping("delete") |
|||
public Result delete(@RequestBody String[] ids) { |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
povertyCondoleService.delete(ids); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PostMapping("search") |
|||
@MaskResponse(fieldNames = {"mobile", "idCard"}, fieldsMaskType = {MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD}) |
|||
public Result<PageData<PovertyCondoleDTO>> search(@RequestBody PovertyCondoleFormDto formDto) { |
|||
PageData<PovertyCondoleDTO> page = povertyCondoleService.search(formDto); |
|||
if (null != page && page.getList().size() > 0) { |
|||
buildData(page.getList()); |
|||
} |
|||
return new Result().ok(page); |
|||
} |
|||
|
|||
private void buildData(List<PovertyCondoleDTO> dtoList) { |
|||
Result<Map<String, String>> dictMapRes = adminOpenFeignClient.dictMap(DictTypeEnum.POVERTY_TYPE.getCode()); |
|||
if (null != dictMapRes.getData() && dictMapRes.getData().size() > 0) { |
|||
Map<String, String> dictMap = dictMapRes.getData(); |
|||
for (PovertyCondoleDTO dto : dtoList) { |
|||
if (null != dto.getPovertyType()) { |
|||
dto.setPovertyType(dictMap.get(dto.getPovertyType())); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
private void buildImgs(List<PovertyCondoleAttrEntity> imgList, List<String> dtoImgs, String dtoId) { |
|||
for (String url : dtoImgs) { |
|||
PovertyCondoleAttrEntity attr = new PovertyCondoleAttrEntity(); |
|||
attr.setPovertyCondoleId(dtoId); |
|||
attr.setAttachmentUrl(url); |
|||
attr.setAttachmentFormat(url.substring(url.lastIndexOf(".") + NumConstant.ONE).toLowerCase()); |
|||
attr.setAttachmentType("image"); |
|||
imgList.add(attr); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.epmet.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dto.form.povertyManage.PovertyCondoleAttrDTO; |
|||
import com.epmet.entity.PovertyCondoleAttrEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author yan Lu |
|||
* @description 描述 |
|||
* @create 2023/6/18 21:40 |
|||
*/ |
|||
@Mapper |
|||
public interface PovertyCondoleAttrDao extends BaseDao<PovertyCondoleAttrEntity> { |
|||
|
|||
List<PovertyCondoleAttrDTO> selectByPcId(@Param("pcId") String pcId); |
|||
|
|||
} |
@ -0,0 +1,24 @@ |
|||
package com.epmet.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dto.PovertyCondoleDTO; |
|||
import com.epmet.entity.PovertyCondoleEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 日照:贫困人员慰问记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-06-17 |
|||
*/ |
|||
@Mapper |
|||
public interface PovertyCondoleDao extends BaseDao<PovertyCondoleEntity> { |
|||
|
|||
List<PovertyCondoleDTO> search(@Param("userName") String userName, @Param("idCard") String idCard, |
|||
@Param("condoleStaff") String condoleStaff, @Param("povertyType") String povertyType, |
|||
@Param("povertyStatus") String povertyStatus, @Param("content") String content, |
|||
@Param("startTime") String startTime, @Param("endTime") String endTime); |
|||
} |
@ -0,0 +1,36 @@ |
|||
package com.epmet.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* @author yan Lu |
|||
* @description 描述 |
|||
* @create 2023/6/18 21:10 |
|||
*/ |
|||
@EqualsAndHashCode(callSuper = false) |
|||
@TableName("poverty_condole_attr") |
|||
@Data |
|||
public class PovertyCondoleAttrEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
private String id; |
|||
|
|||
private String povertyCondoleId; |
|||
|
|||
private String fileName; |
|||
|
|||
private String attachmentName; |
|||
|
|||
private String attachmentSize; |
|||
|
|||
private String attachmentFormat; |
|||
|
|||
private String attachmentType; |
|||
|
|||
private String attachmentUrl; |
|||
|
|||
} |
@ -0,0 +1,58 @@ |
|||
package com.epmet.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 日照:贫困人员慰问记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-06-17 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("poverty_condole") |
|||
public class PovertyCondoleEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 贫困人员ID |
|||
*/ |
|||
private String povertyId; |
|||
|
|||
/** |
|||
* 居民ID |
|||
*/ |
|||
private String resiUserId; |
|||
|
|||
/** |
|||
* 贫困人员姓名 |
|||
*/ |
|||
private String userName; |
|||
|
|||
/** |
|||
* 慰问时间 |
|||
*/ |
|||
private Date condoleTime; |
|||
|
|||
/** |
|||
* 慰问人员,多人以“,”相隔 |
|||
*/ |
|||
private String condoleStaff; |
|||
|
|||
/** |
|||
* 慰问内容 |
|||
*/ |
|||
private String content; |
|||
|
|||
/** |
|||
* 详细描述 |
|||
*/ |
|||
private String remark; |
|||
|
|||
} |
@ -0,0 +1,60 @@ |
|||
package com.epmet.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 日照:贫困人员慰问记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-06-17 |
|||
*/ |
|||
@Data |
|||
public class PovertyCondoleExcel { |
|||
|
|||
@Excel(name = "主键ID") |
|||
private String id; |
|||
|
|||
@Excel(name = "贫困人员ID") |
|||
private String povertyId; |
|||
|
|||
@Excel(name = "居民ID") |
|||
private Integer resiUserId; |
|||
|
|||
@Excel(name = "贫困人员姓名") |
|||
private String name; |
|||
|
|||
@Excel(name = "慰问时间") |
|||
private Date condoleTiem; |
|||
|
|||
@Excel(name = "慰问人员,多人以“,”相隔") |
|||
private String condoleStaff; |
|||
|
|||
@Excel(name = "慰问内容") |
|||
private String content; |
|||
|
|||
@Excel(name = "详细描述") |
|||
private String remark; |
|||
|
|||
@Excel(name = "删除标识:0.未删除 1.已删除") |
|||
private Integer delFlag; |
|||
|
|||
@Excel(name = "乐观锁") |
|||
private Integer revision; |
|||
|
|||
@Excel(name = "创建人") |
|||
private String createdBy; |
|||
|
|||
@Excel(name = "创建时间") |
|||
private Date createdTime; |
|||
|
|||
@Excel(name = "更新人") |
|||
private String updatedBy; |
|||
|
|||
@Excel(name = "更新时间") |
|||
private Date updatedTime; |
|||
|
|||
|
|||
} |
@ -0,0 +1,22 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.dto.form.povertyManage.PovertyCondoleAttrDTO; |
|||
import com.epmet.entity.PovertyCondoleAttrEntity; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author yan Lu |
|||
* @description 描述 |
|||
* @create 2023/6/18 21:21 |
|||
*/ |
|||
public interface PovertyCondoleAttrService extends BaseService<PovertyCondoleAttrEntity> { |
|||
|
|||
void update(PovertyCondoleAttrDTO dto); |
|||
|
|||
void delete(String[] ids); |
|||
|
|||
List<PovertyCondoleAttrDTO> selectByPcId(String id); |
|||
|
|||
} |
@ -0,0 +1,82 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.PovertyCondoleDTO; |
|||
import com.epmet.dto.form.povertyManage.PovertyCondoleFormDto; |
|||
import com.epmet.entity.PovertyCondoleEntity; |
|||
|
|||
import java.text.ParseException; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 日照:贫困人员慰问记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-06-17 |
|||
*/ |
|||
public interface PovertyCondoleService extends BaseService<PovertyCondoleEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<PovertyCondoleDTO> |
|||
* @author generator |
|||
* @date 2023-06-17 |
|||
*/ |
|||
PageData<PovertyCondoleDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<PovertyCondoleDTO> |
|||
* @author generator |
|||
* @date 2023-06-17 |
|||
*/ |
|||
List<PovertyCondoleDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return PovertyCondoleDTO |
|||
* @author generator |
|||
* @date 2023-06-17 |
|||
*/ |
|||
PovertyCondoleDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2023-06-17 |
|||
*/ |
|||
void save(PovertyCondoleFormDto dto) throws ParseException; |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2023-06-17 |
|||
*/ |
|||
void update(PovertyCondoleFormDto dto) throws ParseException; |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2023-06-17 |
|||
*/ |
|||
void delete(String[] ids); |
|||
|
|||
PageData<PovertyCondoleDTO> search(PovertyCondoleFormDto formDto); |
|||
} |
@ -0,0 +1,37 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.dao.PovertyCondoleAttrDao; |
|||
import com.epmet.dto.form.povertyManage.PovertyCondoleAttrDTO; |
|||
import com.epmet.entity.PovertyCondoleAttrEntity; |
|||
import com.epmet.service.PovertyCondoleAttrService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author yan Lu |
|||
* @description 描述 |
|||
* @create 2023/6/18 21:38 |
|||
*/ |
|||
@Service |
|||
public class PovertyCondoleAttrServiceImpl extends BaseServiceImpl<PovertyCondoleAttrDao, PovertyCondoleAttrEntity> implements PovertyCondoleAttrService { |
|||
|
|||
@Override |
|||
public void update(PovertyCondoleAttrDTO dto) { |
|||
PovertyCondoleAttrEntity entity = ConvertUtils.sourceToTarget(dto, PovertyCondoleAttrEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
public void delete(String[] ids) { |
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
@Override |
|||
public List<PovertyCondoleAttrDTO> selectByPcId(String id) { |
|||
return baseDao.selectByPcId(id); |
|||
} |
|||
} |
@ -0,0 +1,101 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.epmet.commons.tools.constant.FieldConstant; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.dao.PovertyCondoleDao; |
|||
import com.epmet.dto.PovertyCondoleDTO; |
|||
import com.epmet.dto.form.povertyManage.PovertyCondoleFormDto; |
|||
import com.epmet.entity.PovertyCondoleEntity; |
|||
import com.epmet.service.PovertyCondoleService; |
|||
import com.github.pagehelper.PageHelper; |
|||
import com.github.pagehelper.PageInfo; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.text.ParseException; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 日照:贫困人员慰问记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-06-17 |
|||
*/ |
|||
@Service |
|||
public class PovertyCondoleServiceImpl extends BaseServiceImpl<PovertyCondoleDao, PovertyCondoleEntity> implements PovertyCondoleService { |
|||
|
|||
|
|||
@Override |
|||
public PageData<PovertyCondoleDTO> page(Map<String, Object> params) { |
|||
IPage<PovertyCondoleEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, PovertyCondoleDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<PovertyCondoleDTO> list(Map<String, Object> params) { |
|||
List<PovertyCondoleEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
return ConvertUtils.sourceToTarget(entityList, PovertyCondoleDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<PovertyCondoleEntity> getWrapper(Map<String, Object> params) { |
|||
String id = (String) params.get(FieldConstant.ID_HUMP); |
|||
QueryWrapper<PovertyCondoleEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public PovertyCondoleDTO get(String id) { |
|||
PovertyCondoleEntity entity = baseDao.selectById(id); |
|||
|
|||
return ConvertUtils.sourceToTarget(entity, PovertyCondoleDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(PovertyCondoleFormDto dto) throws ParseException { |
|||
PovertyCondoleEntity entity = ConvertUtils.sourceToTarget(dto, PovertyCondoleEntity.class); |
|||
if (StringUtils.isNotEmpty(dto.getCondoleTime())) { |
|||
entity.setCondoleTime(new SimpleDateFormat("yyyy-MM-dd").parse(dto.getCondoleTime())); |
|||
} |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(PovertyCondoleFormDto dto) throws ParseException { |
|||
PovertyCondoleEntity entity = ConvertUtils.sourceToTarget(dto, PovertyCondoleEntity.class); |
|||
if (StringUtils.isNotEmpty(dto.getCondoleTime())) { |
|||
entity.setCondoleTime(new SimpleDateFormat("yyyy-MM-dd").parse(dto.getCondoleTime())); |
|||
} |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
@Override |
|||
public PageData<PovertyCondoleDTO> search(PovertyCondoleFormDto formDto) { |
|||
PageInfo<PovertyCondoleDTO> pageInfo = PageHelper.startPage(formDto.getPageNo(), formDto.getPageSize(), formDto.getIsPage()) |
|||
.doSelectPageInfo(() -> baseDao.search(formDto.getUserName(), formDto.getIdCard(), formDto.getCondoleStaff(), formDto.getPovertyType(), |
|||
formDto.getPovertyStatus(), formDto.getContent(), formDto.getStartTime(), formDto.getEndTime())); |
|||
return new PageData<>(pageInfo.getList() == null ? new ArrayList<>() : pageInfo.getList(), pageInfo.getTotal()); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,75 @@ |
|||
<?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.epmet.dao.PovertyCondoleDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.PovertyCondoleEntity" id="povertyCondoleMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="povertyId" column="POVERTY_ID"/> |
|||
<result property="resiUserId" column="RESI_USER_ID"/> |
|||
<result property="userName" column="USER_NAME"/> |
|||
<result property="condoleTime" column="CONDOLE_TIME"/> |
|||
<result property="condoleStaff" column="CONDOLE_STAFF"/> |
|||
<result property="content" column="CONTENT"/> |
|||
<result property="remark" column="REMARK"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
<sql id="retrunMap"> |
|||
pc.id, |
|||
pm.USER_NAME, |
|||
pm.MOBILE, |
|||
pm.ID_CARD, |
|||
pm.POVERTY_TYPE, |
|||
pm.POVERTY_STATUS, |
|||
pc.CONDOLE_TIME, |
|||
pc.CONDOLE_STAFF, |
|||
pc.CONTENT, |
|||
pc.REMARK |
|||
</sql> |
|||
<select id="search" resultType="com.epmet.dto.PovertyCondoleDTO"> |
|||
SELECT |
|||
<include refid="retrunMap"/> |
|||
FROM poverty_condole pc |
|||
LEFT JOIN poverty_manage pm ON pc.POVERTY_ID = pm.ID |
|||
<where> |
|||
pc.DEL_FLAG = 0 |
|||
<if test="null != content and content != ''"> |
|||
AND pc.CONTENT LIKE concat( '%', #{content}, '%') |
|||
</if> |
|||
<if test="null != userName and userName != ''"> |
|||
AND pm.USER_NAME LIKE concat( '%', #{userName}, '%') |
|||
</if> |
|||
<if test="null != idCard and idCard != ''"> |
|||
AND pm.ID_CARD LIKE concat( '%', #{idCard}, '%') |
|||
</if> |
|||
<if test="null != povertyType and povertyType != ''"> |
|||
AND pm.POVERTY_TYPE = #{povertyType} |
|||
</if> |
|||
<if test="null != povertyStatus and povertyStatus != ''"> |
|||
AND pm.POVERTY_STATUS = #{povertyStatus} |
|||
</if> |
|||
<if test="null != condoleStaff and condoleStaff != ''"> |
|||
AND pc.CONDOLE_STAFF LIKE concat( '%', #{condoleStaff}, '%') |
|||
</if> |
|||
<if test="null != startTime and startTime != '' and null != endTime and endTime !=''"> |
|||
AND DATE_FORMAT(pc.CONDOLE_TIME,"%Y-%m-%d") BETWEEN DATE_FORMAT(#{startTime},"%Y-%m-%d") AND |
|||
DATE_FORMAT(#{endTime},"%Y-%m-%d") |
|||
</if> |
|||
<if test="null != startTime and startTime != ''"> |
|||
AND DATE_FORMAT(pc.CONDOLE_TIME,"%Y-%m-%d") >= DATE_FORMAT(#{startTime},"%Y-%m-%d") |
|||
</if> |
|||
<if test="null != endTime and endTime != ''"> |
|||
AND DATE_FORMAT(pc.CONDOLE_TIME,"%Y-%m-%d") <= DATE_FORMAT(#{endTime},"%Y-%m-%d") |
|||
</if> |
|||
</where> |
|||
|
|||
</select> |
|||
|
|||
|
|||
</mapper> |
Loading…
Reference in new issue