|
|
@ -3,11 +3,21 @@ package com.epmet.plugin.power.modules.change.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.security.user.LoginUserUtil; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.plugin.power.modules.change.dao.ChangeWelfareDao; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|
|
|
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|
|
|
import com.epmet.dto.form.RentTenantDataFormDTO; |
|
|
|
import com.epmet.dto.result.RentTenantDataResultDTO; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.plugin.power.dto.change.ChangeWelfareDTO; |
|
|
|
import com.epmet.plugin.power.dto.change.CheckWelfareByIdCardDTO; |
|
|
|
import com.epmet.plugin.power.modules.change.dao.ChangeWelfareDao; |
|
|
|
import com.epmet.plugin.power.modules.change.entity.ChangeWelfareEntity; |
|
|
|
import com.epmet.plugin.power.modules.change.redis.ChangeWelfareRedis; |
|
|
|
import com.epmet.plugin.power.modules.change.service.ChangeWelfareService; |
|
|
@ -16,9 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* 福利表 |
|
|
@ -32,6 +40,12 @@ public class ChangeWelfareServiceImpl extends BaseServiceImpl<ChangeWelfareDao, |
|
|
|
@Autowired |
|
|
|
private ChangeWelfareRedis changeWelfareRedis; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
LoginUserUtil loginUserUtil; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<ChangeWelfareDTO> page(Map<String, Object> params) { |
|
|
|
IPage<ChangeWelfareEntity> page = baseDao.selectPage( |
|
|
@ -50,9 +64,19 @@ public class ChangeWelfareServiceImpl extends BaseServiceImpl<ChangeWelfareDao, |
|
|
|
|
|
|
|
private QueryWrapper<ChangeWelfareEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
String name = (String) params.get("name"); |
|
|
|
String idCard = (String) params.get("idCard"); |
|
|
|
String mobile = (String) params.get("mobile"); |
|
|
|
String startTime = (String) params.get("startTime"); |
|
|
|
String endTime = (String) params.get("endTime"); |
|
|
|
|
|
|
|
QueryWrapper<ChangeWelfareEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(name), "NAME", name); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(idCard), "ID_CARD", idCard); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(mobile), "MOBILE", mobile); |
|
|
|
wrapper.ge(StringUtils.isNotBlank(startTime), "JOIN_DATE", startTime); |
|
|
|
wrapper.le(StringUtils.isNotBlank(endTime), "JOIN_DATE", endTime); |
|
|
|
|
|
|
|
return wrapper; |
|
|
|
} |
|
|
@ -65,9 +89,28 @@ public class ChangeWelfareServiceImpl extends BaseServiceImpl<ChangeWelfareDao, |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(ChangeWelfareDTO dto) { |
|
|
|
public Result save(ChangeWelfareDTO dto) { |
|
|
|
|
|
|
|
|
|
|
|
RentTenantDataFormDTO formDTO = new RentTenantDataFormDTO(); |
|
|
|
formDTO.setUserId(dto.getUserId()); |
|
|
|
formDTO.setCustomerId(loginUserUtil.getLoginUserCustomerId()); |
|
|
|
ValidatorUtils.validateEntity(formDTO, UpdateGroup.class, DefaultGroup.class); |
|
|
|
Result<RentTenantDataResultDTO> result = epmetUserOpenFeignClient.getRentResiUserInfo(formDTO); |
|
|
|
|
|
|
|
dto.setIdCard(result.getData().getIdCard()); |
|
|
|
dto.setMobile(result.getData().getMobile()); |
|
|
|
dto.setGridId(result.getData().getGridId()); |
|
|
|
Map<String, Object> params = new HashMap<>(4); |
|
|
|
params.put("idCard", dto.getIdCard()); |
|
|
|
if (!list(params).isEmpty()) { |
|
|
|
return new Result().error("该人员已经迁入福利人口"); |
|
|
|
} |
|
|
|
dto.setJoinDate(DateUtils.format(new Date())); |
|
|
|
ChangeWelfareEntity entity = ConvertUtils.sourceToTarget(dto, ChangeWelfareEntity.class); |
|
|
|
entity.setCustomerId(loginUserUtil.getLoginUserCustomerId()); |
|
|
|
insert(entity); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -84,4 +127,33 @@ public class ChangeWelfareServiceImpl extends BaseServiceImpl<ChangeWelfareDao, |
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result removeWelfare(ChangeWelfareDTO dto) { |
|
|
|
if(StringUtils.isBlank(dto.getId())){ |
|
|
|
return new Result().error("id不可为空"); |
|
|
|
} |
|
|
|
dto.setRemoveDate(DateUtils.format(new Date())); |
|
|
|
baseDao.removeWelfare(dto); |
|
|
|
return new Result().ok("移除成功"); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Boolean checkWelfareByIdCard(CheckWelfareByIdCardDTO dto) { |
|
|
|
ChangeWelfareEntity entity = baseDao.selectByIdCard(dto.getIdCard()); |
|
|
|
return entity == null? false: true; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result saveWelfareInfo(ChangeWelfareDTO dto) { |
|
|
|
Map<String, Object> params = new HashMap<>(4); |
|
|
|
params.put("idCard", dto.getIdCard()); |
|
|
|
if (!list(params).isEmpty()) { |
|
|
|
return new Result().error("该人员已经迁入福利人口"); |
|
|
|
} |
|
|
|
dto.setJoinDate(DateUtils.format(new Date())); |
|
|
|
ChangeWelfareEntity entity = ConvertUtils.sourceToTarget(dto, ChangeWelfareEntity.class); |
|
|
|
insert(entity); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
} |