|  | @ -24,16 +24,19 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.constant.NumConstant; |  |  | import com.epmet.commons.tools.constant.NumConstant; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.constant.StrConstant; |  |  | import com.epmet.commons.tools.constant.StrConstant; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.exception.EpmetErrorCode; |  |  | import com.epmet.commons.tools.exception.EpmetErrorCode; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.commons.tools.exception.EpmetException; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.exception.RenException; |  |  | import com.epmet.commons.tools.exception.RenException; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.redis.RedisKeys; |  |  | import com.epmet.commons.tools.redis.RedisKeys; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.redis.RedisUtils; |  |  | import com.epmet.commons.tools.redis.RedisUtils; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.utils.DateUtils; |  |  | import com.epmet.commons.tools.utils.DateUtils; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.commons.tools.utils.Result; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dao.*; |  |  | import com.epmet.dao.*; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.form.CustomerFormQueryDTO; |  |  | import com.epmet.dto.form.CustomerFormQueryDTO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.result.CustomerFormResultDTO; |  |  | import com.epmet.dto.result.CustomerFormResultDTO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.result.FormGroupDTO; |  |  | import com.epmet.dto.result.FormGroupDTO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.result.FormItemResult; |  |  | import com.epmet.dto.result.FormItemResult; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.entity.*; |  |  | import com.epmet.entity.*; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.feign.EpmetHeartOpenFeignClient; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.redis.CustomerFootBarRedis; |  |  | import com.epmet.redis.CustomerFootBarRedis; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.IcFormService; |  |  | import com.epmet.service.IcFormService; | 
			
		
	
		
		
			
				
					|  |  | import lombok.extern.slf4j.Slf4j; |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
	
		
		
			
				
					|  | @ -43,6 +46,7 @@ import org.springframework.stereotype.Service; | 
			
		
	
		
		
			
				
					|  |  | import org.springframework.transaction.annotation.Transactional; |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
		
			
				
					|  |  | import org.springframework.util.CollectionUtils; |  |  | import org.springframework.util.CollectionUtils; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import javax.annotation.Resource; | 
			
		
	
		
		
			
				
					|  |  | import java.util.Date; |  |  | import java.util.Date; | 
			
		
	
		
		
			
				
					|  |  | import java.util.List; |  |  | import java.util.List; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -72,6 +76,10 @@ public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity> | 
			
		
	
		
		
			
				
					|  |  |     private IcResiCategoryStatsConfigDao icResiCategoryStatsConfigDao; |  |  |     private IcResiCategoryStatsConfigDao icResiCategoryStatsConfigDao; | 
			
		
	
		
		
			
				
					|  |  |     @Autowired |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |     private IcResiCategoryWarnConfigDao icResiCategoryWarnConfigDao; |  |  |     private IcResiCategoryWarnConfigDao icResiCategoryWarnConfigDao; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private IcFormListItemDao icFormListItemDao; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Resource | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private EpmetHeartOpenFeignClient epmetHeartOpenFeignClient; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     /** |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |      * 获取居民信息表单 |  |  |      * 获取居民信息表单 | 
			
		
	
	
		
		
			
				
					|  | @ -131,7 +139,9 @@ public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity> | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |     public String initCustomerFormByCode(String customerId, String areaCode, String formCode) { |  |  |     public String initCustomerFormByCode(String customerId, String areaCode, String formCode) { | 
			
		
	
		
		
			
				
					|  |  |         CustomerFormResultDTO formResultDTO = baseDao.selectByCode(customerId, formCode); |  |  |         CustomerFormResultDTO formResultDTO = baseDao.selectByCode(customerId, formCode); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //客户已经存在了表单的数据
 | 
			
		
	
		
		
			
				
					|  |  |         if (formResultDTO != null) { |  |  |         if (formResultDTO != null) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |             return "该客户已经存在了表单的数据"; |  |  |             return "该客户已经存在了表单的数据"; | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |         String defaultCustomerId = "default"; |  |  |         String defaultCustomerId = "default"; | 
			
		
	
	
		
		
			
				
					|  | @ -164,7 +174,7 @@ public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity> | 
			
		
	
		
		
			
				
					|  |  |         if (CollectionUtils.isEmpty(itemList)) { |  |  |         if (CollectionUtils.isEmpty(itemList)) { | 
			
		
	
		
		
			
				
					|  |  |             return "默认配置错误"; |  |  |             return "默认配置错误"; | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |         //设置item
 |  |  |         //设置ic_form_item
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         itemList.forEach(item -> { |  |  |         itemList.forEach(item -> { | 
			
		
	
		
		
			
				
					|  |  |             item.setId(newPrefixed + item.getId()); |  |  |             item.setId(newPrefixed + item.getId()); | 
			
		
	
		
		
			
				
					|  |  |             item.setCustomerId(customerId); |  |  |             item.setCustomerId(customerId); | 
			
		
	
	
		
		
			
				
					|  | @ -192,6 +202,7 @@ public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity> | 
			
		
	
		
		
			
				
					|  |  |             icFormItemDao.insert(item); |  |  |             icFormItemDao.insert(item); | 
			
		
	
		
		
			
				
					|  |  |         }); |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //设置ic_form_item_options
 | 
			
		
	
		
		
			
				
					|  |  |         LambdaQueryWrapper<IcFormItemOptionsEntity> wrapperOptions = new LambdaQueryWrapper<>(); |  |  |         LambdaQueryWrapper<IcFormItemOptionsEntity> wrapperOptions = new LambdaQueryWrapper<>(); | 
			
		
	
		
		
			
				
					|  |  |         wrapperOptions.eq(IcFormItemOptionsEntity::getCustomerId, defaultCustomerId); |  |  |         wrapperOptions.eq(IcFormItemOptionsEntity::getCustomerId, defaultCustomerId); | 
			
		
	
		
		
			
				
					|  |  |         wrapperOptions.eq(IcFormItemOptionsEntity::getFormCode, formCode); |  |  |         wrapperOptions.eq(IcFormItemOptionsEntity::getFormCode, formCode); | 
			
		
	
	
		
		
			
				
					|  | @ -209,6 +220,7 @@ public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity> | 
			
		
	
		
		
			
				
					|  |  |             icFormItemOptionsDao.insert(item); |  |  |             icFormItemOptionsDao.insert(item); | 
			
		
	
		
		
			
				
					|  |  |         }); |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //设置ic_form_item_group
 | 
			
		
	
		
		
			
				
					|  |  |         LambdaQueryWrapper<IcFormItemGroupEntity> wrapperGroup = new LambdaQueryWrapper<>(); |  |  |         LambdaQueryWrapper<IcFormItemGroupEntity> wrapperGroup = new LambdaQueryWrapper<>(); | 
			
		
	
		
		
			
				
					|  |  |         wrapperGroup.eq(IcFormItemGroupEntity::getCustomerId, defaultCustomerId); |  |  |         wrapperGroup.eq(IcFormItemGroupEntity::getCustomerId, defaultCustomerId); | 
			
		
	
		
		
			
				
					|  |  |         wrapperGroup.eq(IcFormItemGroupEntity::getFormCode, formCode); |  |  |         wrapperGroup.eq(IcFormItemGroupEntity::getFormCode, formCode); | 
			
		
	
	
		
		
			
				
					|  | @ -225,6 +237,7 @@ public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity> | 
			
		
	
		
		
			
				
					|  |  |             icFormItemGroupDao.insert(item); |  |  |             icFormItemGroupDao.insert(item); | 
			
		
	
		
		
			
				
					|  |  |         }); |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //设置ic_form_query_builder
 | 
			
		
	
		
		
			
				
					|  |  |         LambdaQueryWrapper<IcFormQueryBuilderEntity> wrapperQuery = new LambdaQueryWrapper<>(); |  |  |         LambdaQueryWrapper<IcFormQueryBuilderEntity> wrapperQuery = new LambdaQueryWrapper<>(); | 
			
		
	
		
		
			
				
					|  |  |         wrapperQuery.eq(IcFormQueryBuilderEntity::getCustomerId, defaultCustomerId); |  |  |         wrapperQuery.eq(IcFormQueryBuilderEntity::getCustomerId, defaultCustomerId); | 
			
		
	
		
		
			
				
					|  |  |         wrapperQuery.eq(IcFormQueryBuilderEntity::getFormCode, formCode); |  |  |         wrapperQuery.eq(IcFormQueryBuilderEntity::getFormCode, formCode); | 
			
		
	
	
		
		
			
				
					|  | @ -241,6 +254,7 @@ public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity> | 
			
		
	
		
		
			
				
					|  |  |             icFormQueryBuilderDao.insert(item); |  |  |             icFormQueryBuilderDao.insert(item); | 
			
		
	
		
		
			
				
					|  |  |         }); |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //设置ic_resi_category_stats_config
 | 
			
		
	
		
		
			
				
					|  |  |         LambdaQueryWrapper<IcResiCategoryStatsConfigEntity> wrapperStats = new LambdaQueryWrapper<>(); |  |  |         LambdaQueryWrapper<IcResiCategoryStatsConfigEntity> wrapperStats = new LambdaQueryWrapper<>(); | 
			
		
	
		
		
			
				
					|  |  |         wrapperStats.eq(IcResiCategoryStatsConfigEntity::getCustomerId, defaultCustomerId); |  |  |         wrapperStats.eq(IcResiCategoryStatsConfigEntity::getCustomerId, defaultCustomerId); | 
			
		
	
		
		
			
				
					|  |  |         List<IcResiCategoryStatsConfigEntity> statsConfigList = icResiCategoryStatsConfigDao.selectList(wrapperStats); |  |  |         List<IcResiCategoryStatsConfigEntity> statsConfigList = icResiCategoryStatsConfigDao.selectList(wrapperStats); | 
			
		
	
	
		
		
			
				
					|  | @ -255,6 +269,7 @@ public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity> | 
			
		
	
		
		
			
				
					|  |  |             icResiCategoryStatsConfigDao.insert(item); |  |  |             icResiCategoryStatsConfigDao.insert(item); | 
			
		
	
		
		
			
				
					|  |  |         }); |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //设置ic_resi_category_warn_config
 | 
			
		
	
		
		
			
				
					|  |  |         LambdaQueryWrapper<IcResiCategoryWarnConfigEntity> wrapperWarn = new LambdaQueryWrapper<>(); |  |  |         LambdaQueryWrapper<IcResiCategoryWarnConfigEntity> wrapperWarn = new LambdaQueryWrapper<>(); | 
			
		
	
		
		
			
				
					|  |  |         wrapperWarn.eq(IcResiCategoryWarnConfigEntity::getCustomerId, defaultCustomerId); |  |  |         wrapperWarn.eq(IcResiCategoryWarnConfigEntity::getCustomerId, defaultCustomerId); | 
			
		
	
		
		
			
				
					|  |  |         List<IcResiCategoryWarnConfigEntity> warnConfigList = icResiCategoryWarnConfigDao.selectList(wrapperWarn); |  |  |         List<IcResiCategoryWarnConfigEntity> warnConfigList = icResiCategoryWarnConfigDao.selectList(wrapperWarn); | 
			
		
	
	
		
		
			
				
					|  | @ -269,6 +284,31 @@ public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity> | 
			
		
	
		
		
			
				
					|  |  |             icResiCategoryWarnConfigDao.insert(item); |  |  |             icResiCategoryWarnConfigDao.insert(item); | 
			
		
	
		
		
			
				
					|  |  |         }); |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //设置ic_form_list_item
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         LambdaQueryWrapper<IcFormListItemEntity> listItemWapper = new LambdaQueryWrapper<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         listItemWapper.eq(IcFormListItemEntity::getCustomerId, defaultCustomerId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         listItemWapper.eq(IcFormListItemEntity::getFormCode, formCode); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<IcFormListItemEntity> listItemList = icFormListItemDao.selectList(listItemWapper); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (CollectionUtils.isEmpty(listItemList)) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             return "默认配置错误"; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         listItemList.forEach(item -> { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             item.setId(newPrefixed + item.getId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             item.setCustomerId(customerId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             item.setFormItemId(newPrefixed + item.getFormItemId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             item.setCreatedBy("init_user"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             item.setCreatedTime(new Date()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             item.setUpdatedBy("init_user"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             item.setUpdatedTime(new Date()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             log.debug("stats:"+ JSON.toJSONString(item)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             icFormListItemDao.insert(item); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         }); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //设置ic_service_item_dict和ic_resi_demand_dict
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Result result = epmetHeartOpenFeignClient.customerInit(customerId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (!result.success()) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             throw new EpmetException(result.getCode(), result.getMsg()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |         return "初始化成功!客户ID:" + customerId + " formCode:" + formCode; |  |  |         return "初始化成功!客户ID:" + customerId + " formCode:" + formCode; | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
	
		
		
			
				
					|  | 
 |