| 
					
				 | 
			
			
				@@ -1,18 +1,20 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.qmrb.system.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hutool.core.collection.CollectionUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.hutool.core.util.StrUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.converter.ContractConverter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.mapper.CouponMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.pojo.entity.Contract; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.qmrb.system.pojo.entity.Contract; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.pojo.entity.Coupon; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.pojo.entity.SysRole; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.pojo.entity.SysUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.pojo.form.ContractForm; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.pojo.form.UserForm; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.qmrb.system.pojo.vo.ContractPlaceNumberRelVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.pojo.vo.ContractVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.pojo.query.ContractQuery; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.mapper.ContractMapper; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -21,6 +23,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.service.SysRoleService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.service.SysUserService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.service.UserService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.security.crypto.password.PasswordEncoder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -30,7 +33,9 @@ import jakarta.validation.Valid; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.RequiredArgsConstructor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -45,109 +50,115 @@ import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @RequiredArgsConstructor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> implements IContractService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private final ContractConverter converter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private CouponMapper couponMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private SysUserService userService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private SysRoleService roleService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private PasswordEncoder passwordEncoder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	/**分页查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 * */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public Page<ContractVO> getPage(ContractQuery queryParams) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 查询参数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private final ContractConverter converter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private CouponMapper couponMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private SysUserService userService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private SysRoleService roleService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private PasswordEncoder passwordEncoder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 分页查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Page<ContractVO> getPage(ContractQuery queryParams) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 查询参数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         int pageNum = queryParams.getPageNum(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         int pageSize = queryParams.getPageSize(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //Integer status = queryParams.getStatus(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //String keywords = queryParams.getKeywords(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Integer status = queryParams.getStatus(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // String keywords = queryParams.getKeywords(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 查询数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Page<ContractVO> pageResult = baseMapper.pageWithCoupon( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 new Page<>(pageNum, pageSize), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				queryParams 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                queryParams 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return pageResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 * 保存表单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 * */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public ContractForm saveForm(@Valid ContractForm form) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 实体对象转换 form->entity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Contract entity = converter.form2Entity(form); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 保存表单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ContractForm saveForm(@Valid ContractForm form) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 实体对象转换 form->entity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Contract entity = converter.form2Entity(form); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 持久化 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.save(entity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 创建协议时,创建客商用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		UserForm user = new UserForm(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		user.setUsername(form.getUsername()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		user.setPassword(form.getPassword()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		user.setContractId(entity.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		user.setUserType("2");//用户类型 1 系统用户 2扫码协议用户  3 包租协议用户' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		user.setMobile(form.getContactPhone()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		user.setNickname(form.getContractName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		List<SysRole> roles = roleService.list(new LambdaQueryWrapper<SysRole>().eq(SysRole::getCode, "CONTRACT"));//协议用户角色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if(CollectionUtil.isNotEmpty(roles)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			List<Long> roleIds = roles.stream().map(item -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				return item.getId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			}).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			user.setRoleIds(roleIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		userService.saveUser(user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 创建协议时,创建客商用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        UserForm user = new UserForm(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        user.setUsername(form.getUsername()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        user.setPassword(form.getPassword()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        user.setContractId(entity.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (form.getMaxParkingLotNum() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            user.setUserType("3");// 用户类型 1 系统用户 2扫码协议用户  3包租协议用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            user.setUserType("2");// 用户类型 1 系统用户 2扫码协议用户  3包租协议用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        user.setMobile(form.getContactPhone()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        user.setNickname(form.getContractName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<SysRole> roles = roleService.list(new LambdaQueryWrapper<SysRole>().eq(SysRole::getCode, "CONTRACT"));// 协议用户角色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (CollectionUtil.isNotEmpty(roles)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<Long> roleIds = roles.stream().map(item -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return item.getId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            user.setRoleIds(roleIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        userService.saveUser(user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ContractForm result = converter.entity2Form(entity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	/**更新 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 * */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public boolean updateForm(Long id, ContractForm form) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 修改账户或密码,更新用户表数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Contract contract = this.getById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		SysUser user = userService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getContractId, id)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Boolean changeFlag = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 校验账户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if(!contract.getUsername().equals(form.getUsername())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			changeFlag = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			user.setUsername(form.getUsername()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			long count = userService.count(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, form.getUsername())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			Assert.isTrue(count == 0, "用户名已存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		//校验密码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if(!contract.getPassword().equals(form.getPassword())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			changeFlag = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			String encode = passwordEncoder.encode(form.getPassword()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			user.setPassword(encode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if(changeFlag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			userService.updateById(user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Contract entity = converter.form2Entity(form); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		entity.setId(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 更新 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public boolean updateForm(Long id, ContractForm form) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 修改账户或密码,更新用户表数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Contract contract = this.getById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SysUser user = userService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getContractId, id)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Boolean changeFlag = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 校验账户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!contract.getUsername().equals(form.getUsername())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            changeFlag = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            user.setUsername(form.getUsername()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            long count = userService.count(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, form.getUsername())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Assert.isTrue(count == 0, "用户名已存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 校验密码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!contract.getPassword().equals(form.getPassword())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            changeFlag = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String encode = passwordEncoder.encode(form.getPassword()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            user.setPassword(encode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (changeFlag) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            userService.updateById(user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Contract entity = converter.form2Entity(form); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        entity.setId(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         boolean result = this.updateById(entity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	/**获取表单数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	 * */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public ContractForm getFormData(Long id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 获取entity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Contract entity = this.getById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 获取表单数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ContractForm getFormData(Long id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 获取entity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Contract entity = this.getById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Assert.isTrue(entity != null, "客商协议表不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 实体转换 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -177,4 +188,63 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return form; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Page<ContractVO> getCharterPage(ContractQuery queryParams) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 查询参数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int pageNum = queryParams.getPageNum(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int pageSize = queryParams.getPageSize(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Integer status = queryParams.getStatus(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // String keywords = queryParams.getKeywords(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 查询数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LambdaQueryWrapper<Contract> queryWrapper = new LambdaQueryWrapper<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // queryWrapper.ge(StrUtil.isNotBlank(queryParams.getStartTimeBegin()), Contract::getStartTime, queryParams.getStartTimeBegin()).le(StrUtil.isNotBlank(queryParams.getStartTimeEnd()), Contract::getStartTime, queryParams.getStartTimeEnd()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // queryWrapper.ge(StrUtil.isNotBlank(queryParams.getEndTimeBegin()), Contract::getEndTime, queryParams.getEndTimeBegin()).le(StrUtil.isNotBlank(queryParams.getEndTimeEnd()), Contract::getEndTime, queryParams.getEndTimeEnd()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        queryWrapper.eq(Contract::getContractType, "3"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        queryWrapper.orderByDesc(Contract::getCreateTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 查询数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Page<Contract> dictItemPage = this.page( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Page<>(pageNum, pageSize), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                queryWrapper 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 实体转换 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Page<ContractVO> pageResult = converter.entity2Page(dictItemPage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<ContractVO> records = pageResult.getRecords(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Long> contractIds = records.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .map(ContractVO::getId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 将 contractIds 拼接成字符串 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String contractIdsStr = String.join(",", contractIds.stream().map(String::valueOf).toArray(String[]::new)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 执行 SQL 查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Map<String, Object>> statistics = baseMapper.pageWithCharter(contractIdsStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 将统计结果映射到 ContractVO 中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Long, Map<String, Object>> statisticsMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (Map<String, Object> stat : statistics) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Long contractId = (Long) stat.get("contract_id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            statisticsMap.put(contractId, stat); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (ContractVO record : pageResult.getRecords()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Long contractId = record.getId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String largeTimeNums = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String smallTimeNums = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, Object> stat = statisticsMap.get(contractId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (stat != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                largeTimeNums = record.getBigParkingLotNum() + "/" + stat.get("largeRealTimeNum") + "/" + stat.get("largeInParkingCount"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                smallTimeNums = record.getSmallParkingLotNum() + "/" + stat.get("smallRealTimeNum") + "/" + stat.get("smallInParkingCount"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            record.setLargeTimeNums(largeTimeNums); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            record.setSmallTimeNums(smallTimeNums); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return pageResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |