|  | @ -22,6 +22,7 @@ import com.alibaba.fastjson.JSONObject; | 
			
		
	
		
		
			
				
					|  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
			
		
	
		
		
			
				
					|  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
		
			
				
					|  |  | import com.baomidou.mybatisplus.core.metadata.IPage; |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.baomidou.mybatisplus.core.toolkit.IdWorker; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.rocketmq.messages.InitCustomerMQMsg; |  |  | import com.epmet.commons.rocketmq.messages.InitCustomerMQMsg; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.constant.FieldConstant; |  |  | import com.epmet.commons.tools.constant.FieldConstant; | 
			
		
	
	
		
		
			
				
					|  | @ -585,6 +586,74 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerDao, CustomerEn | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public void initLocal(CustomerInitFormDTO input) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //1.调用epmet-third服务,根据客户Id查询第三方服务中的客户、组织、管理员等信息
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //PaUserDTO paUser = ConvertUtils.mapToEntity(map3, PaUserDTO.class);
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         String customerId = IdWorker.getIdStr(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         String agencyId = IdWorker.getIdStr(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //2.校验当前客户是否已初始化,不存在则初始客户信息
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         CustomerEntity entity = baseDao.selectById(customerId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (null != entity) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             throw new RenException(EpmetErrorCode.OPER_CUSTOMER_EXISTS.getCode()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         CustomerInitFormDTO.PaCustomer paCustomer = input.getPaCustomer(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         CustomerInitFormDTO.PaCustomerAgency paCustomerAgency = input.getPaAgency(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         CustomerInitFormDTO.PaUser paUser = input.getPaUser(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         paCustomerAgency.setId(agencyId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //2-1.新增客户信息
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         CustomerEntity customerEntity = new CustomerEntity(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         customerEntity.setId(customerId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         customerEntity.setCustomerName(paCustomer.getCustomerName()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         customerEntity.setTitle(""); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         customerEntity.setOrganizationNumber(""); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         customerEntity.setOrganizationImg(""); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         customerEntity.setValidityTime(getValidityTime()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         customerEntity.setOrganizationLevel(paCustomerAgency.getLevel()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         customerEntity.setLogo(""); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //新客户默认可以创建三个网格
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         customerEntity.setGridNumber(NumConstant.THREE); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (baseDao.insert(customerEntity) < NumConstant.ONE) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_ERROR.getCode()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         // *.发送初始化客户信息到mq,让监听者完成初始化操作
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         InitCustomerMQMsg msgContent = new InitCustomerMQMsg(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         msgContent.setCustomerId(customerId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         msgContent.setAgency(constructAgencyInfo4CustomerInit(ConvertUtils.sourceToTarget(paCustomerAgency, PaCustomerAgencyDTO.class))); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         msgContent.setStaff(constructStaffInfo4CustomerInit(agencyId, ConvertUtils.sourceToTarget(paUser, PaUserDTO.class))); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         SystemMsgFormDTO systemMsgFormDTO = new SystemMsgFormDTO(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         systemMsgFormDTO.setMessageType(SystemMessageType.INIT_CUSTOMER); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         systemMsgFormDTO.setContent(msgContent); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Result sendMsgResult = epmetMessageOpenFeignClient.sendSystemMsgByMQ(systemMsgFormDTO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (! sendMsgResult.success()) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             throw new RenException("发送(初始化客户信息)系统消息到message服务失败:{}", sendMsgResult.getInternalMsg()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //2021.1.25  sun  新增初始化客户积分规则和评价指标权重  start
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //8.客户初始化已有的积分规则
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Result<InitPointRuleResultDTO> resultPoint = epmetPointOpenFeignClient.initPointRule(customerId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (!resultPoint.success()) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             throw new RenException(resultPoint.getCode(), resultPoint.getInternalMsg()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //9.新客户初始化评价指标 权重
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         InitCustomerIndexForm indexForm = new InitCustomerIndexForm(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         indexForm.setCustomerId(customerId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Result<Boolean> resultData = dataStatisticalOpenFeignClient.initCustomerIndex(indexForm); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (!resultData.success()) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             throw new RenException(resultData.getCode(), resultData.getInternalMsg()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //2021.1.25  end
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     private InitCustomerMQMsg.InitCustomerStaff constructStaffInfo4CustomerInit(String agencyId, PaUserDTO paUser) { |  |  |     private InitCustomerMQMsg.InitCustomerStaff constructStaffInfo4CustomerInit(String agencyId, PaUserDTO paUser) { | 
			
		
	
		
		
			
				
					|  |  |         InitCustomerMQMsg.InitCustomerStaff staff = new InitCustomerMQMsg.InitCustomerStaff(); |  |  |         InitCustomerMQMsg.InitCustomerStaff staff = new InitCustomerMQMsg.InitCustomerStaff(); | 
			
		
	
		
		
			
				
					|  |  |         staff.setAgencyId(agencyId); |  |  |         staff.setAgencyId(agencyId); | 
			
		
	
	
		
		
			
				
					|  | 
 |