|
|
@ -23,11 +23,16 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.constant.OperCustomizeConstant; |
|
|
|
import com.epmet.dao.CustomerHomeDao; |
|
|
|
import com.epmet.dto.CustomerHomeDTO; |
|
|
|
import com.epmet.dto.CustomerHomeTemplateDTO; |
|
|
|
import com.epmet.dto.FunctionDTO; |
|
|
|
import com.epmet.entity.CustomerFunctionEntity; |
|
|
|
import com.epmet.entity.CustomerHomeDetailEntity; |
|
|
|
import com.epmet.entity.CustomerHomeEntity; |
|
|
|
import com.epmet.redis.CustomerHomeRedis; |
|
|
|
import com.epmet.service.CustomerHomeService; |
|
|
|
import com.epmet.service.*; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -36,9 +41,10 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 客户首页表 |
|
|
|
* 客户首页表 |
|
|
|
* |
|
|
|
* @author generator generator@elink-cn.com |
|
|
|
* @since v1.0.0 2020-03-10 |
|
|
@ -46,59 +52,124 @@ import java.util.Map; |
|
|
|
@Service |
|
|
|
public class CustomerHomeServiceImpl extends BaseServiceImpl<CustomerHomeDao, CustomerHomeEntity> implements CustomerHomeService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private CustomerHomeRedis customerHomeRedis; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<CustomerHomeDTO> page(Map<String, Object> params) { |
|
|
|
IPage<CustomerHomeEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, CustomerHomeDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<CustomerHomeDTO> list(Map<String, Object> params) { |
|
|
|
List<CustomerHomeEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
|
|
|
|
|
return ConvertUtils.sourceToTarget(entityList, CustomerHomeDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<CustomerHomeEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<CustomerHomeEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
|
|
|
|
return wrapper; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public CustomerHomeDTO get(String id) { |
|
|
|
CustomerHomeEntity entity = baseDao.selectById(id); |
|
|
|
return ConvertUtils.sourceToTarget(entity, CustomerHomeDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(CustomerHomeDTO dto) { |
|
|
|
CustomerHomeEntity entity = ConvertUtils.sourceToTarget(dto, CustomerHomeEntity.class); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(CustomerHomeDTO dto) { |
|
|
|
CustomerHomeEntity entity = ConvertUtils.sourceToTarget(dto, CustomerHomeEntity.class); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
@Autowired |
|
|
|
private CustomerHomeRedis customerHomeRedis; |
|
|
|
@Autowired |
|
|
|
private CustomerHomeDetailService customerHomeDetailService; |
|
|
|
@Autowired |
|
|
|
private CustomerHomeTemplateService customerHomeTemplateService; |
|
|
|
@Autowired |
|
|
|
private FunctionService functionService; |
|
|
|
@Autowired |
|
|
|
private CustomerFunctionService customerFunctionService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<CustomerHomeDTO> page(Map<String, Object> params) { |
|
|
|
IPage<CustomerHomeEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, CustomerHomeDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<CustomerHomeDTO> list(Map<String, Object> params) { |
|
|
|
List<CustomerHomeEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
|
|
|
|
|
return ConvertUtils.sourceToTarget(entityList, CustomerHomeDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<CustomerHomeEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<CustomerHomeEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
|
|
|
|
return wrapper; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public CustomerHomeDTO get(String id) { |
|
|
|
CustomerHomeEntity entity = baseDao.selectById(id); |
|
|
|
return ConvertUtils.sourceToTarget(entity, CustomerHomeDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(CustomerHomeDTO dto) { |
|
|
|
CustomerHomeEntity entity = ConvertUtils.sourceToTarget(dto, CustomerHomeEntity.class); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(CustomerHomeDTO dto) { |
|
|
|
CustomerHomeEntity entity = ConvertUtils.sourceToTarget(dto, CustomerHomeEntity.class); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void init(CustomerHomeDTO dto) { |
|
|
|
|
|
|
|
//居民端模板
|
|
|
|
List<CustomerHomeTemplateDTO> resiTempList = customerHomeTemplateService.getTemplateByClient(OperCustomizeConstant.RESIDENT); |
|
|
|
//居民端草稿
|
|
|
|
saveHome(dto.getCustomerId(), OperCustomizeConstant.RESIDENT, OperCustomizeConstant.STATUS_IS_DRAFT, resiTempList); |
|
|
|
//居民端已发布
|
|
|
|
saveHome(dto.getCustomerId(), OperCustomizeConstant.RESIDENT, OperCustomizeConstant.STATUS_IS_RELEASED, resiTempList); |
|
|
|
//政府端模板
|
|
|
|
List<CustomerHomeTemplateDTO> govTempList = customerHomeTemplateService.getTemplateByClient(OperCustomizeConstant.GOV); |
|
|
|
//政府端草稿
|
|
|
|
saveHome(dto.getCustomerId(), OperCustomizeConstant.GOV, OperCustomizeConstant.STATUS_IS_DRAFT, govTempList); |
|
|
|
//政府端已发布
|
|
|
|
saveHome(dto.getCustomerId(), OperCustomizeConstant.GOV, OperCustomizeConstant.STATUS_IS_RELEASED, govTempList); |
|
|
|
//customer_function数据
|
|
|
|
List<FunctionDTO> functionList = functionService.queryFunctionList().getData(); |
|
|
|
List<CustomerFunctionEntity> customerFunctionList = functionList.stream().map(function -> { |
|
|
|
CustomerFunctionEntity entity = new CustomerFunctionEntity(); |
|
|
|
entity.setCustomerId(dto.getCustomerId()); |
|
|
|
entity.setFunctionId(function.getId()); |
|
|
|
return entity; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
customerFunctionService.insertBatch(customerFunctionList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 往customer_home和customer_home_detail存入数据 |
|
|
|
* |
|
|
|
* @param customerId 客户ID |
|
|
|
* @param client 所 状态 0已发布, 1草稿 |
|
|
|
* @return void |
|
|
|
* @author zhaoqifeng |
|
|
|
* @date 2020/5/22 13:36 |
|
|
|
*/ |
|
|
|
private void saveHome(String customerId, Integer client, Integer status, List<CustomerHomeTemplateDTO> tempList) { |
|
|
|
CustomerHomeEntity entity = new CustomerHomeEntity(); |
|
|
|
entity.setCustomerId(customerId); |
|
|
|
entity.setClientType(client); |
|
|
|
entity.setStatus(status); |
|
|
|
baseDao.insert(entity); |
|
|
|
|
|
|
|
List<CustomerHomeDetailEntity> list = tempList.stream().map(temp -> { |
|
|
|
CustomerHomeDetailEntity detailEntity = new CustomerHomeDetailEntity(); |
|
|
|
detailEntity.setHomeId(entity.getId()); |
|
|
|
detailEntity.setComponentId(temp.getComponentId()); |
|
|
|
detailEntity.setConfiguration(temp.getConfiguration()); |
|
|
|
detailEntity.setDemoData(temp.getDemoData()); |
|
|
|
detailEntity.setDisplayOrder(temp.getDisplayOrder()); |
|
|
|
detailEntity.setRegion(temp.getRegion()); |
|
|
|
return detailEntity; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
customerHomeDetailService.insertBatch(list); |
|
|
|
} |
|
|
|
|
|
|
|
} |