@@ -91,6 +91,7 @@ subprojects { | |||
implementation group: 'cn.com.taiji.common', name: 'gly-common', version: '2.3.10.7' | |||
implementation 'org.springframework.boot:spring-boot-starter-web' | |||
implementation 'com.alibaba:druid-spring-boot-starter:1.2.8' | |||
implementation group: 'com.alibaba', name: 'fastjson', version: '2.0.4' | |||
compileOnly 'org.projectlombok:lombok' | |||
testCompileOnly 'org.projectlombok:lombok' | |||
annotationProcessor 'org.projectlombok:lombok' |
@@ -22,7 +22,7 @@ public class QtkServicehallMap extends StringPropertyUUIDEntity { | |||
@Size(max = 64) | |||
@Column(name = "CENTER_SERVICEHALL_ID") | |||
private String centerServicehallId; | |||
private String centerServiceHallId; | |||
@Size(max = 200) | |||
@Column(name = "CENTER_SERVICEHALL_NAME") | |||
private String centerServicehallName; |
@@ -12,4 +12,6 @@ public interface QtkAgencyRepo extends AbstractJpaRepo<QtkAgency, String>{ | |||
@Query("from QtkAgency where agencyId in ?1 ") | |||
List<QtkAgency> listByAgencyIds(List<String> agencyIds); | |||
QtkAgency findByAgencyId(String agencyId); | |||
} |
@@ -5,4 +5,7 @@ import cn.com.taiji.core.entity.basic.QtkServicehallMap; | |||
public interface QtkServicehallMapRepo extends AbstractJpaRepo<QtkServicehallMap, String>{ | |||
QtkServicehallMap findByCenterServiceHallId(String centerServicehallId); | |||
} |
@@ -0,0 +1,32 @@ | |||
package cn.com.taiji.core.repo.request.issue; | |||
import cn.com.taiji.common.pub.dao.HqlBuilder; | |||
import cn.com.taiji.common.repo.request.jpa.JpaDateTimePageableDataRequest; | |||
import cn.com.taiji.core.entity.basic.QtkServicehallMap; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
@Getter | |||
@Setter | |||
public class QtkServicehallMapPageRequest extends JpaDateTimePageableDataRequest<QtkServicehallMap>{ | |||
public QtkServicehallMapPageRequest() { | |||
this.orderBy="id"; | |||
this.desc=true; | |||
} | |||
@Override | |||
public HqlBuilder toSelectHql(){ | |||
HqlBuilder hql = new HqlBuilder("from QtkServicehallMap where 1=1 "); | |||
return hql; | |||
} | |||
} |
@@ -14,6 +14,8 @@ dependencies { | |||
implementation "com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery" | |||
implementation "com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config" | |||
implementation "org.springframework.cloud:spring-cloud-starter-openfeign" | |||
implementation 'com.alibaba:easyexcel:3.2.1' | |||
implementation 'com.squareup.okhttp3:okhttp:3.14.9' | |||
implementation(group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0') { | |||
// exclude group: 'net.bytebuddy',module: 'byte-buddy' | |||
} |
@@ -0,0 +1,59 @@ | |||
package cn.com.taiji.userw.api; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.common.web.ApiResponse; | |||
import cn.com.taiji.core.entity.basic.QtkServicehallMap; | |||
import cn.com.taiji.userw.dto.centerServiceHall.CenterHallDeleteRequestDTO; | |||
import cn.com.taiji.userw.dto.centerServiceHall.CenterHallAddOrUpdateReqDTO; | |||
import cn.com.taiji.userw.dto.centerServiceHall.CenterHallPageRequestDTO; | |||
import cn.com.taiji.userw.manager.serviceHall.CenterServiceHallManager; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.springframework.web.bind.annotation.*; | |||
import java.util.List; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/5/19 15:20 | |||
* @Filename:CenterServiceHallController | |||
* @description: 中心网点管理 | |||
*/ | |||
@Api(tags = {"中心网点管理"}) | |||
@RestController | |||
@RequestMapping("/centerServiceHall") | |||
public class CenterServiceHallController { | |||
@Autowired | |||
private CenterServiceHallManager manager; | |||
@ApiOperation(value = "获取中心网点编号信息") | |||
@GetMapping(value = "/getCenterServiceHall") | |||
public ApiResponse<List<QtkServicehallMap>> getCenterServiceHall() { | |||
return ApiResponse.of(manager.getCenterServiceHall()); | |||
} | |||
@ApiOperation(value = "新增修改") | |||
@GetMapping(value = "/addOrUpDate") | |||
public ApiResponse<?> getCenterServiceHall(@Validated @RequestBody CenterHallAddOrUpdateReqDTO reqDto) { | |||
manager.addOrUpdate(reqDto); | |||
return ApiResponse.success().setMessage("新增成功"); | |||
} | |||
@ApiOperation(value = "删除") | |||
@GetMapping(value = "/delete") | |||
public ApiResponse<?> getCenterServiceHall(@Validated @RequestBody CenterHallDeleteRequestDTO reqDto) { | |||
manager.delete(reqDto); | |||
return ApiResponse.success().setMessage("删除成功"); | |||
} | |||
@ApiOperation(value = "分页查询") | |||
@GetMapping(value = "/page") | |||
public ApiResponse<Pagination> getCenterServiceHall(@Validated @RequestBody CenterHallPageRequestDTO reqDto) { | |||
Pagination page = manager.page(reqDto); | |||
return ApiResponse.of(page); | |||
} | |||
} |
@@ -0,0 +1,103 @@ | |||
package cn.com.taiji.userw.api; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.common.web.ApiResponse; | |||
import cn.com.taiji.common.web.ApiValidController; | |||
import cn.com.taiji.core.entity.basic.QtkServicehallLocation; | |||
import cn.com.taiji.userw.dto.serviceHall.*; | |||
import cn.com.taiji.userw.manager.serviceHall.ServiceHallManager; | |||
import cn.com.taiji.userw.model.FormatException; | |||
import cn.com.taiji.userw.model.serviceHall.ServiceHallSonQueryModel; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import javax.validation.Valid; | |||
import java.util.List; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/5/17 16:04 | |||
* @Filename:ServiceHallController | |||
* @description: 网点管理 | |||
*/ | |||
@Api(tags = {"网点管理"}) | |||
@RestController | |||
@RequestMapping("/serviceHall") | |||
public class ServiceHallController extends ApiValidController{ | |||
@Autowired | |||
private ServiceHallManager manager; | |||
@ApiOperation(value = "查询网点") | |||
@PostMapping(value = "/serviceHallSelect") | |||
public ApiResponse<Pagination> queryPage(@Validated @RequestBody ServiceHallPageRequestDTO reqDto) throws ManagerException { | |||
Pagination query = manager.query(reqDto); | |||
return ApiResponse.of(query); | |||
} | |||
@ApiOperation(value = "网点子级节点查询") | |||
@PostMapping(value = "/serviceHallSonSelect") | |||
public ApiResponse<List<ServiceHallSonQueryModel>> querySon(@RequestBody ServiceHallSonQueryRequestDTO reqDto) throws ManagerException { | |||
List<ServiceHallSonQueryModel> query = manager.querySon(reqDto); | |||
return ApiResponse.of(query); | |||
} | |||
//网点子级节点查询 todo | |||
@ApiOperation(value = "获取网点编号") | |||
@PostMapping(value = "/getServiceHallId") | |||
public ApiResponse<String> queryByAgencyId(@Validated @RequestBody ServiceHallGetIdRequestDTO reqDto) throws ManagerException { | |||
return ApiResponse.of(manager.queryByAgencyId(reqDto)); | |||
} | |||
// 新增网点 todo | |||
@ApiOperation(value = "新增网点") | |||
@PostMapping(value = "/serviceHallInsert") | |||
public ApiResponse<?> serviceHallInsertLevel(@Valid @RequestBody ServiceHallAddOneRequestDTO reqDto) throws ManagerException, FormatException { | |||
manager.add(reqDto); | |||
return ApiResponse.success().setMessage("新增一级网点成功"); | |||
} | |||
@ApiOperation(value = "修改网点") | |||
@PostMapping(value = "/serviceHallUpdate") | |||
public ApiResponse<?> serviceHallInsertUpdate(@Valid @RequestBody ServiceHallUpdateRequestDTO reqDto) throws ManagerException, FormatException { | |||
manager.update(reqDto); | |||
return ApiResponse.success().setMessage("修改网点成功"); | |||
} | |||
@ApiOperation(value = "删除网点") | |||
@PostMapping(value = "/serviceHallDelete") | |||
public ApiResponse serviceHallInsertDelete(@Valid @RequestBody ServiceHallDeleteRequestDTO reqDto) throws ManagerException { | |||
manager.delete(reqDto); | |||
return ApiResponse.success().setMessage("删除网点成功"); | |||
} | |||
@ApiOperation(value = "查询网点位置列表") | |||
@PostMapping(value = "/queryLocations") | |||
public ApiResponse<List<QtkServicehallLocation>> queryLocations(@Valid @RequestBody ServiceHallDeleteRequestDTO reqDto) throws ManagerException { | |||
return ApiResponse.of(manager.queryLocations(reqDto)); | |||
} | |||
@ApiOperation(value = "网点信息批量导入") | |||
@PostMapping(value = "/registerFullBath") | |||
public ApiResponse<String> registerFullBath(@Valid @RequestBody ServiceHallRegisterFullBatchRequestDTO reqDto) throws Exception { | |||
String path = manager.registerFullBath(reqDto); | |||
return ApiResponse.of(path); | |||
} | |||
@ApiOperation(value = "办公地点信息批量导入") | |||
@PostMapping(value = "/registerLocationBath") | |||
public ApiResponse<String> registerFullBath(@Valid @RequestBody ServiceHallRegisterLocationBatchReqDTO reqDto) throws Exception { | |||
String path = manager.registerLocationBath(reqDto); | |||
return ApiResponse.of(path); | |||
} | |||
} |
@@ -30,6 +30,7 @@ public abstract class AbstractBizRequestDTO extends BaseValidDTO { | |||
private String channelId; | |||
@IntegerConstant(values = "1,2", message = "网点类型错误!线下网点填写2") | |||
private Integer channelType; | |||
@NotBlank | |||
private String staffId; | |||
private String terminalId; | |||
@@ -42,9 +43,9 @@ public abstract class AbstractBizRequestDTO extends BaseValidDTO { | |||
@Override | |||
protected void validate(ViolationValidator validator) { | |||
if (getOrderSource() == SourceType.SERVICE_HALL) { | |||
validator.validFieldNotBlank("staffId", staffId); | |||
} | |||
// if (getOrderSource() == SourceType.SERVICE_HALL) { | |||
// validator.validFieldNotBlank("staffId", staffId); | |||
// } | |||
} | |||
// @JsonIgnore |
@@ -0,0 +1,22 @@ | |||
package cn.com.taiji.userw.dto.centerServiceHall; | |||
import cn.com.taiji.core.model.comm.protocol.constraint.FixedLength; | |||
import cn.com.taiji.userw.dto.AbstractBizRequestDTO; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotBlank; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/5/19 20:23 | |||
* @Filename:CenterHallRequestDTO | |||
* @description: 中心网点新增请求参数 | |||
*/ | |||
@Data | |||
public class CenterHallAddOrUpdateReqDTO extends AbstractBizRequestDTO { | |||
@NotBlank(message = "中心网点编号不能为空") | |||
@FixedLength(length = 19, message = "中心网点编号必须是19位") | |||
private String centerServiceHallId; | |||
@NotBlank(message = "网点名称不能为空") | |||
private String centerServicehallName; | |||
} |
@@ -0,0 +1,25 @@ | |||
package cn.com.taiji.userw.dto.centerServiceHall; | |||
import cn.com.taiji.userw.dto.AbstractBizRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import javax.validation.constraints.NotBlank; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/5/19 20:45 | |||
* @Filename:CenterHallDeleteRequestDTO | |||
* @description: | |||
*/ | |||
@ApiModel(description = "删除中心网点信息") | |||
@Getter | |||
@Setter | |||
public class CenterHallDeleteRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "中心网点id") | |||
@NotBlank | |||
private String id; | |||
} |
@@ -0,0 +1,22 @@ | |||
package cn.com.taiji.userw.dto.centerServiceHall; | |||
import cn.com.taiji.core.model.comm.protocol.constraint.FixedLength; | |||
import cn.com.taiji.userw.dto.AbstractBizRequestDTO; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/5/19 20:23 | |||
* @Filename:CenterHallRequestDTO | |||
* @description: 中心网点新增请求参数 | |||
*/ | |||
@Data | |||
public class CenterHallPageRequestDTO extends AbstractBizRequestDTO { | |||
@NotNull | |||
private Integer pageNo; | |||
@NotNull | |||
private Integer pageSize; | |||
} |
@@ -0,0 +1,59 @@ | |||
package cn.com.taiji.userw.dto.serviceHall; | |||
import cn.com.taiji.common.valid.ViolationValidator; | |||
import cn.com.taiji.core.model.comm.protocol.constraint.FixedLength; | |||
import cn.com.taiji.userw.dto.AbstractBizRequestDTO; | |||
import cn.com.taiji.userw.model.serviceHall.ServiceHallLocationModel; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.Valid; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
import java.util.List; | |||
@ApiModel(description = "新增一级网点请求参数") | |||
@Data | |||
public class ServiceHallAddOneRequestDTO extends AbstractBizRequestDTO { | |||
@FixedLength(length = 19, message = "上级网点编号必须是19位") | |||
@ApiModelProperty(value = "上级网点编号") | |||
private String superServiceHallId;//上级网点编号 | |||
@FixedLength(length = 19, message = "网点编号必须是19位") | |||
@NotBlank(message = "网点编号不能为空") | |||
@ApiModelProperty(value = "网点编号",required = true) | |||
private String serviceHallId; | |||
@NotBlank | |||
@FixedLength(length = 19, message = "中心网点编号必须是19位") | |||
@ApiModelProperty(value = "中心网点编号") | |||
private String centerServiceHallId; | |||
@ApiModelProperty(value = "联系人") | |||
private String contact; | |||
@NotBlank(message = "网点名称不能为空") | |||
private String name;//网点名称 | |||
@NotBlank(message = "机构编号不能为空") | |||
private String agencyId;//机构编号 | |||
@NotBlank(message = "手机号不能为空") | |||
private String tel;//手机号 | |||
@NotBlank(message = "地址不能为空") | |||
private String address;//地址 | |||
@NotNull | |||
@ApiModelProperty(value = "经度") | |||
private Double longitude;//经度 | |||
@NotNull | |||
@ApiModelProperty(value = "纬度") | |||
private Double latitude;//纬度 | |||
@NotNull | |||
@ApiModelProperty(value = "半径距离") | |||
private Integer radial;//半径距离 | |||
// 位置信息 | |||
@Valid | |||
private List<ServiceHallLocationModel> locationModels; | |||
@Override | |||
protected void validate(ViolationValidator validator) { | |||
validator.validField("superServiceHallId",!agencyId.equals(superServiceHallId.substring(0, 11)),"上级网点不属于该渠道"); | |||
validator.validField("serviceHallId",!agencyId.equals(serviceHallId.substring(0, 11)),"网点编号必须以渠道编号开头"); | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
package cn.com.taiji.userw.dto.serviceHall; | |||
import cn.com.taiji.common.model.BaseModel; | |||
import cn.com.taiji.userw.dto.AbstractBizRequestDTO; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotBlank; | |||
@Data | |||
public class ServiceHallDeleteRequestDTO extends AbstractBizRequestDTO { | |||
@NotBlank(message = "网点编号不能为空") | |||
private String serviceHallId;//网点名称 | |||
} |
@@ -0,0 +1,20 @@ | |||
package cn.com.taiji.userw.dto.serviceHall; | |||
import cn.com.taiji.common.valid.ViolationValidator; | |||
import cn.com.taiji.userw.dto.AbstractBizRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotBlank; | |||
@ApiModel("获取网点编号请求") | |||
@Data | |||
public class ServiceHallGetIdRequestDTO extends AbstractBizRequestDTO { | |||
@NotBlank | |||
@ApiModelProperty(value = "机构编号") | |||
private String agencyId;//机构编号 | |||
} |
@@ -0,0 +1,29 @@ | |||
package cn.com.taiji.userw.dto.serviceHall; | |||
import cn.com.taiji.userw.dto.AbstractBizRequestDTO; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotNull; | |||
@ApiModel(description = "网点查询请求参数") | |||
@Data | |||
public class ServiceHallPageRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "网点名称") | |||
private String name;//网点名称 | |||
@ApiModelProperty(value = "网点编号") | |||
private String servicehallId;//网点编号 | |||
@ApiModelProperty(value = "渠道编号") | |||
private String agencyId;//渠道编号 | |||
@ApiModelProperty(value = "机构") | |||
private String agencyName;//渠道名称 | |||
private String superServiceHallName;//上级网点名称 | |||
@NotNull | |||
private Integer pageNo; | |||
@NotNull | |||
private Integer pageSize; | |||
} |
@@ -0,0 +1,23 @@ | |||
package cn.com.taiji.userw.dto.serviceHall; | |||
import cn.com.taiji.userw.dto.AbstractBizRequestDTO; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotBlank; | |||
/** | |||
* @description: | |||
* @author: wangyan | |||
* @date Created in 2025/03/27 11:58 | |||
*/ | |||
@Data | |||
public class ServiceHallRegisterFullBatchRequestDTO extends AbstractBizRequestDTO { | |||
/** | |||
* excel文件的url下载地址 后缀 | |||
*/ | |||
@NotBlank(message = "excel文件地址不能为空") | |||
@ApiModelProperty(value = "excel文件地址") | |||
private String excelFileUrl; | |||
} |
@@ -0,0 +1,22 @@ | |||
package cn.com.taiji.userw.dto.serviceHall; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotBlank; | |||
/** | |||
* @description: | |||
* @author: wangyan | |||
* @date Created in 2025/03/27 17:08 | |||
*/ | |||
@Data | |||
public class ServiceHallRegisterLocationBatchReqDTO { | |||
@NotBlank(message = "excel文件地址不能为空") | |||
@ApiModelProperty(value = "excel文件地址") | |||
private String excelFileUrl; | |||
@NotBlank(message = "") | |||
@ApiModelProperty(value = "网点数据id") | |||
private String serviceHallId; | |||
} |
@@ -0,0 +1,13 @@ | |||
package cn.com.taiji.userw.dto.serviceHall; | |||
import cn.com.taiji.common.pub.StringTools; | |||
import cn.com.taiji.common.valid.BaseValidDTO; | |||
import cn.com.taiji.common.valid.ViolationValidator; | |||
import cn.com.taiji.userw.dto.AbstractBizRequestDTO; | |||
import lombok.Data; | |||
@Data | |||
public class ServiceHallSonQueryRequestDTO extends AbstractBizRequestDTO { | |||
// private String servicehallId; | |||
} |
@@ -0,0 +1,55 @@ | |||
package cn.com.taiji.userw.dto.serviceHall; | |||
import cn.com.taiji.common.valid.ViolationValidator; | |||
import cn.com.taiji.core.model.comm.protocol.constraint.FixedLength; | |||
import cn.com.taiji.userw.dto.AbstractBizRequestDTO; | |||
import cn.com.taiji.userw.model.serviceHall.ServiceHallLocationModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.Valid; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
import java.util.List; | |||
@Data | |||
public class ServiceHallUpdateRequestDTO extends AbstractBizRequestDTO { | |||
@NotBlank | |||
@ApiModelProperty(value = "网点ID") | |||
private String id; | |||
@NotBlank(message = "网点编号不能为空") | |||
@FixedLength(length = 19, message = "网点编号必须是19位") | |||
private String serviceHallId;//网点编号 | |||
@NotBlank(message = "网点名称不能为空") | |||
private String name;//网点名称 | |||
private String superServiceHallId;//上级网点编号 | |||
@NotBlank(message = "手机号不能为空") | |||
private String tel;//手机号 | |||
@NotBlank(message = "地址不能为空") | |||
private String address;//地址 | |||
@NotNull | |||
@ApiModelProperty(value = "经度") | |||
private Double longitude;//经度 | |||
@NotNull | |||
@ApiModelProperty(value = "纬度") | |||
private Double latitude;//纬度 | |||
@NotNull | |||
@ApiModelProperty(value = "半径距离") | |||
private Integer radial;//半径距离 | |||
@NotBlank(message = "渠道编号") | |||
private String agencyId; | |||
@ApiModelProperty(value = "联系人") | |||
private String contact; | |||
@NotBlank | |||
@FixedLength(length = 19,message = "中心网点编号必须是19位") | |||
@ApiModelProperty(value = "中心网点编号") | |||
private String centerServiceHallId; | |||
// 位置信息 | |||
@Valid | |||
private List<ServiceHallLocationModel> locationModels; | |||
@Override | |||
protected void validate(ViolationValidator validator) { | |||
validator.validField("serviceHallId",agencyId.equals(serviceHallId.substring(0, 11)),"网点编号必须以渠道编号开头"); | |||
} | |||
} |
@@ -0,0 +1,164 @@ | |||
package cn.com.taiji.userw.manager.excel.listener; | |||
import cn.com.taiji.common.pub.BeanTools; | |||
import cn.com.taiji.common.pub.CollectionTools; | |||
import cn.com.taiji.common.pub.StringTools; | |||
import cn.com.taiji.core.entity.basic.QtkAgency; | |||
import cn.com.taiji.core.entity.basic.QtkServiceHall; | |||
import cn.com.taiji.core.entity.basic.QtkServicehallMap; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkAgencyRepo; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkServicehallMapRepo; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkServicehallRepo; | |||
import cn.com.taiji.userw.model.excel.ServiceHallRegisterData; | |||
import com.alibaba.excel.context.AnalysisContext; | |||
import com.alibaba.excel.read.listener.ReadListener; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.time.LocalDateTime; | |||
import java.util.*; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @description: | |||
* @author: wangyan | |||
* @date Created in 2025/03/27 14:22 | |||
*/ | |||
@Service | |||
public class ServiceHallRegisterFullBatchListener implements ReadListener<ServiceHallRegisterData> { | |||
@Autowired | |||
private QtkServicehallRepo serviceHallRepo; | |||
@Autowired | |||
private QtkAgencyRepo qtkAgencyRepo; | |||
@Autowired | |||
private QtkServicehallMapRepo serviceHallMapRepo; | |||
private Set<ServiceHallRegisterData> errors = new HashSet<>(); | |||
private List<ServiceHallRegisterData> result = new ArrayList<>(); | |||
@Override | |||
public void invoke(ServiceHallRegisterData data, AnalysisContext context) { | |||
StringBuilder builder = new StringBuilder(); | |||
if (StringTools.isEmpty(data.getName())) builder.append("网点名称不能为空").append(","); | |||
if (StringTools.isEmpty(data.getAddress())) builder.append("地址不能为空").append(","); | |||
if (StringTools.isEmpty(data.getContact())) builder.append("联系人不能为空").append(","); | |||
if (StringTools.isEmpty(data.getTel())) builder.append("电话不能为空").append(","); | |||
if (StringTools.isEmpty(data.getLongitude())) builder.append("经度不能为空").append(","); | |||
if (StringTools.isEmpty(data.getLatitude())) builder.append("纬度不能为空").append(","); | |||
if (StringTools.isEmpty(data.getRadial())) builder.append("半径距(米)不能为空").append(","); | |||
if (StringTools.isEmpty(data.getCenterServiceHallId())) { | |||
builder.append("中心网点编号不为空").append(","); | |||
} else { | |||
QtkServicehallMap serviceHallId = serviceHallMapRepo.findByCenterServiceHallId(data.getCenterServiceHallId()); | |||
if (serviceHallId == null) { | |||
builder.append("中心网点编号不存在").append(","); | |||
} else { | |||
data.setCenterServiceHallName(serviceHallId.getCenterServicehallName()); | |||
} | |||
} | |||
if (StringTools.hasText(data.getSuperServiceHallId())) { | |||
if (data.getSuperServiceHallId().length() != 19) { | |||
builder.append("上级网点编号不合规!").append(","); | |||
} | |||
if (StringTools.hasText(data.getAgencyId())&&!data.getSuperServiceHallId().substring(0, 11).equals(data.getAgencyId())) { | |||
builder.append("上级网点不属于该机构!").append(","); | |||
} | |||
QtkServiceHall byServiceHallId = serviceHallRepo.findByServiceHallId(data.getSuperServiceHallId()); | |||
serviceHallRepo.findByServiceHallId(data.getSuperServiceHallId()); | |||
if (null == byServiceHallId) { | |||
builder.append("上级网点编号不存在!").append(","); | |||
} | |||
} | |||
if (StringTools.hasText(data.getServiceHallId()) && StringTools.hasText(data.getAgencyId()) && | |||
!data.getAgencyId().equals(data.getServiceHallId().substring(0, 11))) { | |||
builder.append("网点编号必须以渠道编号开头").append(","); | |||
} | |||
if (StringTools.hasText(data.getServiceHallId())) { | |||
QtkServiceHall byServiceHallId = serviceHallRepo.findByServiceHallId(data.getServiceHallId()); | |||
if (null != byServiceHallId) { | |||
builder.append("该网点编号已存在!").append(","); | |||
} | |||
} | |||
if (StringTools.isEmpty(data.getAgencyId())) { | |||
builder.append("渠道编号不能为空").append(","); | |||
} else { | |||
if (data.getAgencyId().length() != 11) { | |||
builder.append("渠道编号不合规!").append(","); | |||
} | |||
QtkAgency qtkAgency = qtkAgencyRepo.findByAgencyId(data.getAgencyId()); | |||
if (null == qtkAgency) { | |||
builder.append("渠道编号不存在!").append(","); | |||
} | |||
} | |||
if (StringTools.hasText(data.getName()) && StringTools.hasText(data.getAgencyId())) { | |||
QtkServiceHall serviceHall = serviceHallRepo.findByAgencyIdAndName(data.getAgencyId(), data.getName()); | |||
if (null != serviceHall) { | |||
builder.append("该渠道下已存在同名网点"); | |||
} | |||
} | |||
if (StringTools.hasText(builder.toString())) { | |||
data.setRemark(builder.substring(0, builder.length() - 1).toString()); | |||
errors.add(data); | |||
} else { | |||
result.add(data); | |||
} | |||
} | |||
@Override | |||
public void doAfterAllAnalysed(AnalysisContext context) { | |||
if (!CollectionTools.isEmpty(result)) { | |||
for (int i = 0; i < result.size(); i++) { | |||
QtkServiceHall serviceHall = covertToQtk(result.get(i)); | |||
serviceHallRepo.save(serviceHall); | |||
} | |||
} | |||
} | |||
private QtkServiceHall covertToQtk(ServiceHallRegisterData from) { | |||
QtkServiceHall qtkServiceHall = new QtkServiceHall(); | |||
BeanTools.copyProperties(from, qtkServiceHall); | |||
if (StringTools.isEmpty(from.getServiceHallId())) { | |||
qtkServiceHall.setServiceHallId(getServiceHallId(from.getAgencyId()).toString()); | |||
} else { | |||
qtkServiceHall.setServiceHallId(from.getServiceHallId()); | |||
} | |||
qtkServiceHall.setInsertTime(LocalDateTime.now()); | |||
return qtkServiceHall; | |||
} | |||
//生成网点信息编号 | |||
private Long getServiceHallId(String agencyId) { | |||
//TODO 网点编号生成 | |||
List<String> serHalIds = serviceHallRepo.findSerHalIdByAgencyId(agencyId); | |||
List<Long> serviceHallIds = serHalIds.stream().map(Long::valueOf).collect(Collectors.toList()); | |||
Long serviceHallId = Long.valueOf(agencyId + "00000001"); | |||
while (serviceHallIds.contains(serviceHallId)) { | |||
serviceHallId++; | |||
} | |||
return serviceHallId; | |||
} | |||
public Set<ServiceHallRegisterData> getErrors() { | |||
return errors; | |||
} | |||
public List<ServiceHallRegisterData> getResult() { | |||
return result; | |||
} | |||
public void setErrors(Set<ServiceHallRegisterData> errors) { | |||
this.errors = errors; | |||
} | |||
public void setResult(List<ServiceHallRegisterData> result) { | |||
this.result = result; | |||
} | |||
} |
@@ -0,0 +1,92 @@ | |||
package cn.com.taiji.userw.manager.excel.listener; | |||
import cn.com.taiji.common.pub.BeanTools; | |||
import cn.com.taiji.common.pub.CollectionTools; | |||
import cn.com.taiji.common.pub.StringTools; | |||
import cn.com.taiji.core.entity.basic.QtkServiceHall; | |||
import cn.com.taiji.core.entity.basic.QtkServicehallLocation; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkServicehallLocationRepo; | |||
import cn.com.taiji.userw.model.excel.ServiceLocationRegisterData; | |||
import com.alibaba.excel.context.AnalysisContext; | |||
import com.alibaba.excel.read.listener.ReadListener; | |||
import org.apache.commons.compress.utils.Lists; | |||
import java.time.LocalDateTime; | |||
import java.util.ArrayList; | |||
import java.util.HashSet; | |||
import java.util.List; | |||
import java.util.Set; | |||
/** | |||
* @description: | |||
* @author: wangyan | |||
* @date Created in 2025/03/27 17:29 | |||
*/ | |||
public class ServiceHallRegisterLocationBatchListener implements ReadListener<ServiceLocationRegisterData> { | |||
private QtkServicehallLocationRepo LocationRepo; | |||
private QtkServiceHall serviceHall; | |||
private Set<ServiceLocationRegisterData> errors = new HashSet<>(); | |||
private List<ServiceLocationRegisterData> result = new ArrayList<>(); | |||
public ServiceHallRegisterLocationBatchListener(QtkServicehallLocationRepo LocationRepo, QtkServiceHall serviceHall) { | |||
this.LocationRepo = LocationRepo; | |||
this.serviceHall = serviceHall; | |||
} | |||
@Override | |||
public void invoke(ServiceLocationRegisterData data, AnalysisContext context) { | |||
StringBuilder builder=new StringBuilder(); | |||
if (StringTools.isEmpty(data.getName())) builder.append("名称不能为空").append(","); | |||
if (StringTools.isEmpty(data.getAddress())) builder.append("地址不能为空").append(","); | |||
if (StringTools.isEmpty(data.getLongitude())) builder.append("经度不能为空").append(","); | |||
if (StringTools.isEmpty(data.getLatitude())) builder.append("纬度不能为空").append(","); | |||
if (StringTools.isEmpty(data.getRadial())) builder.append("半径距(米)不能为空").append(","); | |||
if(StringTools.hasText(builder.toString())){ | |||
data.setRemark(builder.substring(0,builder.length()-1).toString()); | |||
errors.add(data); | |||
}else{ | |||
result.add(data); | |||
} | |||
} | |||
@Override | |||
public void doAfterAllAnalysed(AnalysisContext context) { | |||
List<QtkServicehallLocation> locations = Lists.newArrayList(); | |||
if (!CollectionTools.isEmpty(result)) { | |||
for (ServiceLocationRegisterData serviceLocationRegisterData : result) { | |||
QtkServicehallLocation serviceHall = covertToQtk(serviceLocationRegisterData); | |||
locations.add(serviceHall); | |||
} | |||
LocationRepo.saveAll(locations); | |||
} | |||
} | |||
private QtkServicehallLocation covertToQtk(ServiceLocationRegisterData from) { | |||
QtkServicehallLocation location = new QtkServicehallLocation(); | |||
BeanTools.copyProperties(from, location); | |||
location.setAgencyId(serviceHall.getAgencyId()); | |||
location.setServicehallId(serviceHall.getServiceHallId()); | |||
location.setServicehallName(serviceHall.getName()); | |||
location.setInsertTime(LocalDateTime.now()); | |||
return location; | |||
} | |||
public Set<ServiceLocationRegisterData> getErrors() { | |||
return errors; | |||
} | |||
public void setErrors(Set<ServiceLocationRegisterData> errors) { | |||
this.errors = errors; | |||
} | |||
public List<ServiceLocationRegisterData> getResult() { | |||
return result; | |||
} | |||
public void setResult(List<ServiceLocationRegisterData> result) { | |||
this.result = result; | |||
} | |||
} |
@@ -0,0 +1,26 @@ | |||
package cn.com.taiji.userw.manager.serviceHall; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.core.entity.basic.QtkServicehallMap; | |||
import cn.com.taiji.userw.dto.centerServiceHall.CenterHallDeleteRequestDTO; | |||
import cn.com.taiji.userw.dto.centerServiceHall.CenterHallAddOrUpdateReqDTO; | |||
import cn.com.taiji.userw.dto.centerServiceHall.CenterHallPageRequestDTO; | |||
import java.util.List; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/5/19 15:23 | |||
* @Filename:CenterServiceHallManager | |||
* @description: | |||
*/ | |||
public interface CenterServiceHallManager { | |||
List<QtkServicehallMap> getCenterServiceHall(); | |||
void addOrUpdate(CenterHallAddOrUpdateReqDTO reqDto); | |||
void delete(CenterHallDeleteRequestDTO reqDto); | |||
Pagination page(CenterHallPageRequestDTO reqDto); | |||
} |
@@ -0,0 +1,57 @@ | |||
package cn.com.taiji.userw.manager.serviceHall; | |||
import cn.com.taiji.common.manager.AbstractManager; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.core.entity.basic.QtkServicehallMap; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkServicehallMapRepo; | |||
import cn.com.taiji.userw.dto.centerServiceHall.CenterHallDeleteRequestDTO; | |||
import cn.com.taiji.userw.dto.centerServiceHall.CenterHallAddOrUpdateReqDTO; | |||
import cn.com.taiji.userw.dto.centerServiceHall.CenterHallPageRequestDTO; | |||
import cn.com.taiji.userw.repo.jpa.request.CenterServiceHallPageRequest; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.List; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/5/19 15:23 | |||
* @Filename:CenterServiceHallManagerImpl | |||
* @description: 中心网点管理 | |||
*/ | |||
@Service | |||
public class CenterServiceHallManagerImpl extends AbstractManager implements CenterServiceHallManager { | |||
@Autowired | |||
private QtkServicehallMapRepo qtkServicehallMapRepo; | |||
@Override | |||
public List<QtkServicehallMap> getCenterServiceHall() { | |||
List<QtkServicehallMap> all = qtkServicehallMapRepo.findAll(); | |||
return all; | |||
} | |||
@Override | |||
public void addOrUpdate(CenterHallAddOrUpdateReqDTO reqDto){ | |||
QtkServicehallMap serviceHallId = qtkServicehallMapRepo.findByCenterServiceHallId(reqDto.getCenterServiceHallId()); | |||
if (serviceHallId != null) { | |||
serviceHallId.setCenterServicehallName(reqDto.getCenterServicehallName()); | |||
qtkServicehallMapRepo.merge(serviceHallId); | |||
}else { | |||
QtkServicehallMap servicehallMap = copyProperties(reqDto, new QtkServicehallMap()); | |||
qtkServicehallMapRepo.persist(servicehallMap); | |||
} | |||
} | |||
@Override | |||
public void delete(CenterHallDeleteRequestDTO reqDto) { | |||
qtkServicehallMapRepo.deleteById(reqDto.getId()); | |||
} | |||
@Override | |||
public Pagination page(CenterHallPageRequestDTO reqDto) { | |||
CenterServiceHallPageRequest request = copyProperties(reqDto, new CenterServiceHallPageRequest()); | |||
return qtkServicehallMapRepo.page(request); | |||
} | |||
} | |||
@@ -0,0 +1,37 @@ | |||
package cn.com.taiji.userw.manager.serviceHall; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.core.entity.basic.QtkServicehallLocation; | |||
import cn.com.taiji.userw.dto.serviceHall.*; | |||
import cn.com.taiji.userw.model.serviceHall.ServiceHallSonQueryModel; | |||
import java.util.List; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/5/17 16:23 | |||
* @Filename:ServiceHallManager | |||
* @description: | |||
*/ | |||
public interface ServiceHallManager { | |||
Pagination query(ServiceHallPageRequestDTO reqDto); | |||
List<ServiceHallSonQueryModel> querySon(ServiceHallSonQueryRequestDTO reqDto); | |||
String queryByAgencyId(ServiceHallGetIdRequestDTO reqDto); | |||
void add(ServiceHallAddOneRequestDTO reqDto) throws ManagerException; | |||
void update(ServiceHallUpdateRequestDTO reqDto) throws ManagerException; | |||
void delete(ServiceHallDeleteRequestDTO reqDto) throws ManagerException; | |||
List<QtkServicehallLocation> queryLocations(ServiceHallDeleteRequestDTO reqDto); | |||
String registerFullBath(ServiceHallRegisterFullBatchRequestDTO reqDto) throws ManagerException; | |||
String registerLocationBath(ServiceHallRegisterLocationBatchReqDTO reqDto) throws ManagerException; | |||
} |
@@ -0,0 +1,323 @@ | |||
package cn.com.taiji.userw.manager.serviceHall; | |||
import cn.com.taiji.common.manager.AbstractManager; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.model.dao.Pagination; | |||
import cn.com.taiji.common.pub.BeanTools; | |||
import cn.com.taiji.core.entity.basic.QtkAgency; | |||
import cn.com.taiji.core.entity.basic.QtkServiceHall; | |||
import cn.com.taiji.core.entity.basic.QtkServicehallLocation; | |||
import cn.com.taiji.core.entity.user.Staff; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkAgencyRepo; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkServicehallLocationRepo; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkServicehallMapRepo; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkServicehallRepo; | |||
import cn.com.taiji.core.repo.jpa.user.StaffRepo; | |||
import cn.com.taiji.userw.dto.serviceHall.*; | |||
import cn.com.taiji.userw.manager.excel.listener.ServiceHallRegisterFullBatchListener; | |||
import cn.com.taiji.userw.manager.excel.listener.ServiceHallRegisterLocationBatchListener; | |||
import cn.com.taiji.userw.model.excel.ServiceHallRegisterData; | |||
import cn.com.taiji.userw.model.excel.ServiceLocationRegisterData; | |||
import cn.com.taiji.userw.model.serviceHall.ServiceHallLocationModel; | |||
import cn.com.taiji.userw.model.serviceHall.ServiceHallReturnModel; | |||
import cn.com.taiji.userw.model.serviceHall.ServiceHallSonQueryModel; | |||
import cn.com.taiji.userw.repo.jpa.request.ServiceHallPageRequest; | |||
import cn.com.taiji.userw.tools.MinioUtile; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.io.FileUtil; | |||
import com.alibaba.excel.EasyExcel; | |||
import org.apache.commons.compress.utils.Lists; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.io.*; | |||
import java.time.LocalDateTime; | |||
import java.util.*; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/5/17 16:23 | |||
* @Filename:ServiceHallManagerImpl | |||
* @description: 网点管理 | |||
*/ | |||
@Service | |||
public class ServiceHallManagerImpl extends AbstractManager implements ServiceHallManager{ | |||
@Autowired | |||
private QtkServicehallRepo serviceHallRepo; | |||
@Autowired | |||
private QtkAgencyRepo qtkAgencyRepo; | |||
private Map<String, String> serviceHallMap; | |||
private Map<String, String> agencyMap; | |||
@Autowired | |||
private QtkServicehallMapRepo qtkServicehallMapRepo; | |||
@Autowired | |||
private StaffRepo staffRepo; | |||
@Autowired | |||
private QtkServicehallLocationRepo locationRepo; | |||
@Autowired | |||
private ServiceHallRegisterFullBatchListener listener; | |||
@Autowired | |||
private MinioUtile minioUtile; | |||
@Override | |||
public Pagination query(ServiceHallPageRequestDTO reqDto) { | |||
ServiceHallPageRequest request = copyProperties(reqDto, new ServiceHallPageRequest()); | |||
Pagination page = serviceHallRepo.page(request); | |||
// 提取并去重上级网点编号 | |||
List<String> superIds = page.getResult(QtkServiceHall.class).stream().map(QtkServiceHall::getSuperServiceHallId) | |||
.distinct().collect(Collectors.toList()); | |||
//提取渠道编号 | |||
List<String> agencyIds = page.getResult(QtkServiceHall.class).stream().map(QtkServiceHall::getAgencyId) | |||
.distinct().collect(Collectors.toList()); | |||
// 查询上级网点名称并转化为 Map | |||
serviceHallMap = serviceHallRepo.listBySuperServiceHallIds(superIds) | |||
.stream() | |||
.collect(Collectors.toMap(QtkServiceHall::getServiceHallId, QtkServiceHall::getName)); | |||
agencyMap = qtkAgencyRepo.listByAgencyIds(agencyIds) | |||
.stream() | |||
.collect(Collectors.toMap( QtkAgency::getAgencyId, QtkAgency::getName)); | |||
return page.convertResult(this::conver); | |||
} | |||
private ServiceHallReturnModel conver(QtkServiceHall hall) { | |||
ServiceHallReturnModel model = copyProperties(hall, new ServiceHallReturnModel()); | |||
// 设置上级网点名称 | |||
model.setSuperServiceHallName(serviceHallMap.get(hall.getSuperServiceHallId())); | |||
// 渠道名称 | |||
model.setAgencyName(agencyMap.get(hall.getAgencyId())); | |||
return model; | |||
} | |||
@Override | |||
public List<ServiceHallSonQueryModel> querySon(ServiceHallSonQueryRequestDTO reqDto) { | |||
List<QtkServiceHall> all = serviceHallRepo.findAll(); | |||
Map<String, List<QtkServiceHall>> collect = all.stream().collect(Collectors.groupingBy(QtkServiceHall::getSuperServiceHallId)); | |||
List<QtkServiceHall> remove = collect.remove(null); | |||
return querySon(remove, collect); | |||
} | |||
//递归 | |||
public List<ServiceHallSonQueryModel> querySon(List<QtkServiceHall> serviceHalls,Map<String, List<QtkServiceHall>> collect) { | |||
ArrayList<ServiceHallSonQueryModel> returnModes = new ArrayList<>(); | |||
for (QtkServiceHall serviceHall : serviceHalls) { | |||
ServiceHallSonQueryModel model = new ServiceHallSonQueryModel(); | |||
String serviceHallId = serviceHall.getServiceHallId(); | |||
model.setServicehallId(serviceHallId); | |||
model.setServicehallName(serviceHall.getName()); | |||
List<QtkServiceHall> serviceHalls1 = collect.get(serviceHallId); | |||
if (serviceHalls1 != null){ | |||
model.setChildrens(querySon(serviceHalls1, collect)); | |||
} | |||
returnModes.add(model); | |||
} | |||
return returnModes; | |||
} | |||
@Override | |||
public String queryByAgencyId(ServiceHallGetIdRequestDTO reqDto) { | |||
return getServiceHallId(reqDto.getAgencyId()).toString(); | |||
} | |||
@Override | |||
public void add(ServiceHallAddOneRequestDTO reqDto) throws ManagerException { | |||
reqDto.validate(); | |||
Staff staff = staffRepo.findByStaffId(reqDto.getStaffId()); | |||
if (staff == null) throw new ManagerException("员工不存在"); | |||
//数据没有问题,验证机构下网点名称是否重复 | |||
QtkServiceHall byServiceHallId = serviceHallRepo.findByServiceHallId(reqDto.getServiceHallId()); | |||
if (byServiceHallId != null) throw new ManagerException("该网点编号已存在"); | |||
if (qtkAgencyRepo.findByAgencyId(reqDto.getAgencyId()) == null) { | |||
throw new ManagerException("渠道不存在"); | |||
} | |||
QtkServiceHall serviceHall = serviceHallRepo.findByAgencyIdAndName(reqDto.getAgencyId(), reqDto.getName()); | |||
if (serviceHall != null) throw new ManagerException("该机构下已存在同名网点"); | |||
QtkServiceHall newServiceHall = new QtkServiceHall(); | |||
newServiceHall.setServiceHallId(reqDto.getServiceHallId()); | |||
newServiceHall.setName(reqDto.getName()); | |||
newServiceHall.setAgencyId(reqDto.getAgencyId()); | |||
newServiceHall.setTel(reqDto.getTel()); | |||
newServiceHall.setContact(reqDto.getContact()); | |||
newServiceHall.setAddress(reqDto.getAddress()); | |||
newServiceHall.setLongitude(reqDto.getLongitude()); | |||
newServiceHall.setLatitude(reqDto.getLatitude()); | |||
newServiceHall.setRadial(reqDto.getRadial()); | |||
newServiceHall.setMapChannelId(reqDto.getCenterServiceHallId()); | |||
serviceHallRepo.save(newServiceHall); | |||
if (!isEmpty(reqDto.getLocationModels())) { | |||
List<QtkServicehallLocation> locations = Lists.newArrayList(); | |||
for (ServiceHallLocationModel model : reqDto.getLocationModels()) { | |||
QtkServicehallLocation location = new QtkServicehallLocation(); | |||
BeanTools.copyProperties(model, location); | |||
location.setAgencyId(newServiceHall.getAgencyId()); | |||
location.setServicehallId(newServiceHall.getServiceHallId()); | |||
location.setServicehallName(newServiceHall.getName()); | |||
location.setInsertTime(LocalDateTime.now()); | |||
locations.add(location); | |||
} | |||
locationRepo.persistAll(locations); | |||
} | |||
} | |||
@Override | |||
public void update(ServiceHallUpdateRequestDTO reqDto) throws ManagerException { | |||
Staff staff = staffRepo.findByStaffId(reqDto.getStaffId()); | |||
if (staff == null) throw new ManagerException("员工不存在"); | |||
QtkServiceHall qtkServiceHall = serviceHallRepo.findById(reqDto.getId()).orElse(null); | |||
if (qtkServiceHall == null) throw new ManagerException("网点不存在"); | |||
LocalDateTime now = LocalDateTime.now(); | |||
String oldServiceHallId = qtkServiceHall.getServiceHallId(); | |||
if (!oldServiceHallId.equals(reqDto.getServiceHallId())) { | |||
//网点编号被修改,要验证数据库是否已存在此编号 | |||
QtkServiceHall serviceHall = serviceHallRepo.findByServiceHallId(reqDto.getServiceHallId()); | |||
if (!serviceHall.getId().equals(reqDto.getId())) { | |||
throw new ManagerException("该网点编号已存在,请修改"); | |||
} | |||
} | |||
if (!qtkServiceHall.getName().equals(reqDto.getName()) || !qtkServiceHall.getAgencyId().equals(reqDto.getAgencyId())) { | |||
//渠道或者网点名修改,要要验证渠道下的网点名不能重复 | |||
//一个机构有很多网点,但是不能是相同网点名 | |||
QtkServiceHall nserviceHall = serviceHallRepo.findByAgencyIdAndName(reqDto.getAgencyId(), reqDto.getName()); | |||
if (nserviceHall != null) { | |||
throw new ManagerException("您修改的信息,在此渠道已有相同网点名"); | |||
} | |||
} | |||
qtkServiceHall.setName(reqDto.getName()); | |||
qtkServiceHall.setTel(reqDto.getTel()); | |||
qtkServiceHall.setAddress(reqDto.getAddress()); | |||
qtkServiceHall.setServiceHallId(reqDto.getServiceHallId()); | |||
qtkServiceHall.setAgencyId(reqDto.getAgencyId()); | |||
qtkServiceHall.setContact(reqDto.getContact()); | |||
qtkServiceHall.setLongitude(reqDto.getLongitude()); | |||
qtkServiceHall.setLatitude(reqDto.getLatitude()); | |||
qtkServiceHall.setMapChannelId(reqDto.getCenterServiceHallId()); | |||
qtkServiceHall.setUpdateTime(now); | |||
// 更新时间 todo | |||
serviceHallRepo.save(qtkServiceHall); | |||
//更新多网点 todo | |||
locationRepo.deleteByHallId(oldServiceHallId); | |||
if (CollectionUtil.isEmpty(reqDto.getLocationModels())) { | |||
List<QtkServicehallLocation> locations = Lists.newArrayList(); | |||
for (ServiceHallLocationModel model : reqDto.getLocationModels()) { | |||
QtkServicehallLocation location = new QtkServicehallLocation(); | |||
BeanTools.copyProperties(model, location); | |||
location.setAgencyId(qtkServiceHall.getAgencyId()); | |||
location.setServicehallId(qtkServiceHall.getServiceHallId()); | |||
location.setServicehallName(qtkServiceHall.getName()); | |||
locations.add(location); | |||
} | |||
locationRepo.persistAll(locations); | |||
} | |||
} | |||
@Override | |||
public void delete(ServiceHallDeleteRequestDTO reqDto) throws ManagerException { | |||
Staff staff = staffRepo.findByStaffId(reqDto.getStaffId()); | |||
if (staff == null) throw new ManagerException("员工不存在"); | |||
//判断是否有下级网点 | |||
List<QtkServiceHall> serviceHalls = serviceHallRepo.findBySuperServiceHallId(reqDto.getServiceHallId()); | |||
if (CollectionUtil.isEmpty(serviceHalls)) throw new ManagerException("该网点存在下级网点,不允许删除"); | |||
serviceHallRepo.updateState(0, LocalDateTime.now(), reqDto.getServiceHallId()); | |||
} | |||
@Override | |||
public List<QtkServicehallLocation> queryLocations(ServiceHallDeleteRequestDTO reqDto) { | |||
return locationRepo.findByServicehallId(reqDto.getServiceHallId()); | |||
} | |||
@Override | |||
public String registerFullBath(ServiceHallRegisterFullBatchRequestDTO reqDto) throws ManagerException { | |||
String path = null; | |||
File tempFile = null; | |||
tempFile = minioUtile.getFileByUrl(reqDto.getExcelFileUrl()); | |||
//获取文件流 | |||
InputStream fileInputStream = null; | |||
try { | |||
fileInputStream = new FileInputStream(tempFile); | |||
} catch (FileNotFoundException e) { | |||
throw new ManagerException("通过文件流失败!"); | |||
} | |||
//读取文件数据并保存 | |||
listener.setErrors(new HashSet<>()); | |||
listener.setResult(new ArrayList<>()); | |||
EasyExcel.read(fileInputStream, | |||
ServiceHallRegisterData.class, | |||
listener | |||
) | |||
.sheet() | |||
.headRowNumber(2) | |||
.doRead(); | |||
Set<ServiceHallRegisterData> errors = listener.getErrors(); | |||
if(errors.size()>0){ | |||
File upFile = null; | |||
try { | |||
upFile = File.createTempFile("temp_", ".xlsx"); | |||
} catch (IOException e) { | |||
throw new ManagerException("上传文件创建失败!"); | |||
} | |||
EasyExcel.write(upFile, ServiceHallRegisterData.class).sheet() | |||
.doWrite(errors); | |||
path = minioUtile.fileUploadHttp(upFile); | |||
} | |||
//删除临时文件 | |||
FileUtil.del(tempFile); | |||
return path; | |||
} | |||
@Override | |||
public String registerLocationBath(ServiceHallRegisterLocationBatchReqDTO reqDto) throws ManagerException { | |||
QtkServiceHall serviceHall = serviceHallRepo.findByServiceHallId(reqDto.getServiceHallId()); | |||
if(null==serviceHall){ | |||
throw new ManagerException("网点信息不存在"); | |||
} | |||
String path = null; | |||
File tempFile = minioUtile.getFileByUrl(reqDto.getExcelFileUrl()); | |||
//获取文件流 | |||
InputStream fileInputStream = null; | |||
try { | |||
fileInputStream = new FileInputStream(tempFile); | |||
} catch (FileNotFoundException e) { | |||
throw new ManagerException("通过文件流失败!"); | |||
} | |||
ServiceHallRegisterLocationBatchListener listener= | |||
new ServiceHallRegisterLocationBatchListener(locationRepo,serviceHall); | |||
//读取文件数据并保存 | |||
EasyExcel.read(fileInputStream, | |||
ServiceLocationRegisterData.class, | |||
listener | |||
) | |||
.sheet() | |||
.headRowNumber(2) | |||
.doRead(); | |||
Set<ServiceLocationRegisterData> errors = listener.getErrors(); | |||
if(errors.size()>0){ | |||
File upFile = null; | |||
try { | |||
upFile = File.createTempFile("temp_", ".xlsx"); | |||
} catch (IOException e) { | |||
throw new ManagerException("上传文件创建失败!"); | |||
} | |||
EasyExcel.write(upFile, ServiceLocationRegisterData.class).sheet() | |||
.doWrite(errors); | |||
path = minioUtile.fileUploadHttp(upFile); | |||
} | |||
//删除临时文件 | |||
FileUtil.del(tempFile); | |||
return path; | |||
} | |||
private Long getServiceHallId(String agencyId) { | |||
List<String> serviceHalls = serviceHallRepo.findSerHalIdByAgencyId(agencyId); | |||
List<Long> serviceHallIds = serviceHalls.stream().map(Long::valueOf).collect(Collectors.toList()); | |||
Long serviceHallId = Long.valueOf(agencyId + "00000001"); | |||
while (serviceHallIds.contains(serviceHallId)) { | |||
serviceHallId++; | |||
} | |||
return serviceHallId; | |||
} | |||
} |
@@ -0,0 +1,56 @@ | |||
package cn.com.taiji.userw.model.excel; | |||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | |||
import com.alibaba.excel.annotation.ExcelProperty; | |||
import com.alibaba.excel.annotation.write.style.*; | |||
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
/** | |||
* @description:网点信息批量注册 | |||
* @author: wangyan | |||
* @date Created in 2025/03/27 14:09 | |||
*/ | |||
@HeadStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER) | |||
@HeadFontStyle(fontHeightInPoints = 12) | |||
@HeadRowHeight(40) | |||
@ColumnWidth(20) | |||
@ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.LEFT) | |||
@ContentFontStyle(fontHeightInPoints = 10, fontName = "宋体") | |||
@ExcelIgnoreUnannotated | |||
@Getter | |||
@Setter | |||
public class ServiceHallRegisterData { | |||
@ExcelProperty(index = 0, value = "序号") | |||
private String orderNum; | |||
@ExcelProperty(index = 1, value = "渠道编号") | |||
private String agencyId; | |||
@ExcelProperty(index = 2, value = "上级网点编号") | |||
private String superServiceHallId; | |||
@ExcelProperty(index = 3, value = "网点编号") | |||
private String serviceHallId; | |||
@ExcelProperty(index = 4, value = "中心网点编号") | |||
private String centerServiceHallId; | |||
@ExcelProperty(index = 5, value = "网点名称") | |||
private String name; | |||
@ExcelProperty(index = 6, value = "地址") | |||
private String address; | |||
@ExcelProperty(index = 7, value = "联系人") | |||
private String contact; | |||
@ExcelProperty(index = 8, value = "联系电话") | |||
private String tel; | |||
@ExcelProperty(index = 9, value = "经度") | |||
private Double longitude;//经度 | |||
@ExcelProperty(index = 10, value = "纬度") | |||
private Double latitude;//纬度 | |||
@ExcelProperty(index = 11, value = "半径米") | |||
private Integer radial;//半径米 | |||
@ExcelProperty(index = 12, value = "导入失败原因") | |||
private String remark; | |||
private String centerServiceHallName; | |||
} |
@@ -0,0 +1,40 @@ | |||
package cn.com.taiji.userw.model.excel; | |||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | |||
import com.alibaba.excel.annotation.ExcelProperty; | |||
import com.alibaba.excel.annotation.write.style.*; | |||
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
/** | |||
* @description: | |||
* @author: wangyan | |||
* @date Created in 2025/03/27 17:16 | |||
*/ | |||
@HeadStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER) | |||
@HeadFontStyle(fontHeightInPoints = 12) | |||
@HeadRowHeight(40) | |||
@ColumnWidth(20) | |||
@ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.LEFT) | |||
@ContentFontStyle(fontHeightInPoints = 10, fontName = "宋体") | |||
@ExcelIgnoreUnannotated | |||
@Getter | |||
@Setter | |||
public class ServiceLocationRegisterData { | |||
@ExcelProperty(index = 0, value = "序号") | |||
private String orderNum; | |||
@ExcelProperty(index = 1, value = "网点名称") | |||
private String name; // 网点名称 | |||
@ExcelProperty(index = 2, value = "地址") | |||
private String address; // 地址 | |||
@ExcelProperty(index = 3, value = "经度") | |||
private Double longitude;// 经度 | |||
@ExcelProperty(index = 4, value = "纬度") | |||
private Double latitude;// 纬度 | |||
@ExcelProperty(index = 5, value = "半径距离(米)") | |||
private Integer radial;// 半径米 | |||
@ExcelProperty(index = 6, value = "导入失败原因") | |||
private String remark; | |||
} |
@@ -0,0 +1,31 @@ | |||
package cn.com.taiji.userw.model.serviceHall; | |||
import cn.com.taiji.common.model.BaseModel; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
@ApiModel("新增网点-位置信息") | |||
@Data | |||
public class ServiceHallLocationModel extends BaseModel { | |||
@NotBlank | |||
@ApiModelProperty(value = "位置名称") | |||
private String name;//名称 | |||
@NotBlank | |||
@ApiModelProperty(value = "地址") | |||
private String address;//地址 | |||
@NotNull | |||
@ApiModelProperty(value = "经度") | |||
private Double longitude;//经度 | |||
@NotNull | |||
@ApiModelProperty(value = "纬度") | |||
private Double latitude;//纬度 | |||
@NotNull | |||
@ApiModelProperty(value = "半径距离") | |||
private Integer radial;//半径距离 | |||
} |
@@ -0,0 +1,22 @@ | |||
package cn.com.taiji.userw.model.serviceHall; | |||
import cn.com.taiji.core.entity.basic.QtkServiceHall; | |||
import lombok.Data; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/5/17 17:45 | |||
* @Filename:ServiceHallReturnModel | |||
* @description: | |||
*/ | |||
@Data | |||
public class ServiceHallReturnModel extends QtkServiceHall { | |||
/** | |||
* 上级网点名称 | |||
*/ | |||
private String superServiceHallName; | |||
//机构名称 | |||
private String agencyName; | |||
} |
@@ -0,0 +1,35 @@ | |||
package cn.com.taiji.userw.model.serviceHall; | |||
import cn.com.taiji.common.model.BaseModel; | |||
import java.util.List; | |||
public class ServiceHallSonQueryModel extends BaseModel { | |||
private String servicehallId; | |||
private String servicehallName; | |||
List<ServiceHallSonQueryModel> childrens; | |||
public String getServicehallId() { | |||
return servicehallId; | |||
} | |||
public void setServicehallId(String servicehallId) { | |||
this.servicehallId = servicehallId; | |||
} | |||
public String getServicehallName() { | |||
return servicehallName; | |||
} | |||
public void setServicehallName(String servicehallName) { | |||
this.servicehallName = servicehallName; | |||
} | |||
public List<ServiceHallSonQueryModel> getChildrens() { | |||
return childrens; | |||
} | |||
public void setChildrens(List<ServiceHallSonQueryModel> childrens) { | |||
this.childrens = childrens; | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
package cn.com.taiji.userw.repo.jpa.request; | |||
import cn.com.taiji.common.pub.dao.HqlBuilder; | |||
import cn.com.taiji.common.repo.request.jpa.JpaPageableDataRequest; | |||
import cn.com.taiji.core.entity.basic.QtkServiceHall; | |||
import cn.com.taiji.core.entity.basic.QtkServicehallMap; | |||
import lombok.Data; | |||
@Data | |||
public class CenterServiceHallPageRequest extends JpaPageableDataRequest<QtkServicehallMap> { | |||
@Override | |||
public HqlBuilder toSelectHql() { | |||
HqlBuilder hql = new HqlBuilder("from QtkServicehallMap where 1=1 "); | |||
return hql; | |||
} | |||
} |
@@ -0,0 +1,26 @@ | |||
package cn.com.taiji.userw.repo.jpa.request; | |||
import cn.com.taiji.common.pub.dao.HqlBuilder; | |||
import cn.com.taiji.common.repo.request.jpa.JpaPageableDataRequest; | |||
import cn.com.taiji.core.entity.basic.QtkServiceHall; | |||
import lombok.Data; | |||
@Data | |||
public class ServiceHallPageRequest extends JpaPageableDataRequest<QtkServiceHall> { | |||
private String name;//网点名称 | |||
private String servicehallId; | |||
private String agencyId; | |||
private String agencyName; | |||
@Override | |||
public HqlBuilder toSelectHql() { | |||
HqlBuilder hql = new HqlBuilder("from QtkServiceHall where 1=1 "); | |||
hql.append(" and name like :name ", like(name)); | |||
hql.append(" and servicehallId = :servicehallId ", servicehallId); | |||
hql.append(" and agencyId = :agencyId ", agencyId); | |||
hql.append(" and agencyName like :agencyName ", like(agencyName)); | |||
return hql; | |||
} | |||
} |
@@ -0,0 +1,98 @@ | |||
package cn.com.taiji.userw.tools; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.pub.CommonAbstract; | |||
import cn.com.taiji.userw.model.excel.ServiceHallRegisterData; | |||
import cn.hutool.core.io.FileUtil; | |||
import com.alibaba.excel.EasyExcel; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.JSONObject; | |||
import okhttp3.*; | |||
import org.apache.commons.io.FileUtils; | |||
import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.stereotype.Component; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.net.URL; | |||
import java.net.URLEncoder; | |||
import java.util.List; | |||
/** | |||
* @Author:ChenChao | |||
* @Date:2025/5/19 16:51 | |||
* @Filename:MinoinUtile | |||
* @description: | |||
*/ | |||
@Component | |||
public class MinioUtile extends CommonAbstract { | |||
@Value("${vmi-minio.minIoUrl}") | |||
private String minioDownloadUrl; | |||
@Value("${vmi-minio.uploadUrl}") | |||
private String fileUploadUrl; | |||
public File getFileByUrl(String excelUrl) throws ManagerException { | |||
// minioDownloadUrl = "https://qtzl.etcjz.cn"; | |||
String[] split = excelUrl.split("/"); | |||
String urlStr = ""; | |||
String fileName = ""; | |||
for (int i = 0; i < split.length; i++) { | |||
if (i == 0) { | |||
urlStr += minioDownloadUrl + "/" + split[i]; //补充下载IP地址和端口号前缀 | |||
} else if (i == split.length - 1) { //最后以为获取文件名 | |||
urlStr += "/" + URLEncoder.encode(split[i]).replace("+", "%20"); | |||
String[] s = split[i].split("_", 0); | |||
fileName = s.length == 1 ? s[0] : s[1]; | |||
} else { | |||
urlStr += "/" + split[i]; | |||
} | |||
} | |||
File tempFile = null; | |||
//try-with-resources,自动关闭流 | |||
try (InputStream in = new URL(urlStr).openConnection().getInputStream()) { | |||
tempFile = FileUtil.createTempFile(null); | |||
FileUtils.copyInputStreamToFile(in, tempFile); | |||
} catch (Exception e) { | |||
logger.error("读取失败:" + e.getMessage()); | |||
throw new ManagerException("通过url获取下载文件失败!"); | |||
} | |||
return tempFile; | |||
} | |||
public String fileUploadHttp(File file) throws ManagerException { | |||
String bucket = "default-bucket"; | |||
OkHttpClient client = new OkHttpClient().newBuilder() | |||
.build(); | |||
RequestBody requestBody = RequestBody.create(MediaType.parse("application/octet-stream"), | |||
file); | |||
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM) | |||
.addFormDataPart("bucket", bucket) | |||
.addFormDataPart("file", file.getName(),requestBody) | |||
.build(); | |||
Request request = new Request.Builder() | |||
.url(fileUploadUrl) | |||
.method("POST", body) | |||
.build(); | |||
String datastr = null; | |||
try { | |||
Response response = client.newCall(request).execute(); | |||
datastr = response.body().string(); | |||
}catch (IOException e) { | |||
e.printStackTrace(); | |||
throw new ManagerException("上传到文件服务出错!"); | |||
} | |||
JSONObject jsonObject = JSON.parseObject(datastr); | |||
if (jsonObject.getInteger("code") != 200) { | |||
throw new ManagerException(jsonObject.getString("msg")); | |||
} | |||
datastr = jsonObject.getString("data"); | |||
JSONObject json = JSON.parseObject(datastr); | |||
String url = bucket + "/" + json.getString("ossFilePath"); | |||
file.delete(); | |||
return url; | |||
} | |||
} |
@@ -14,7 +14,7 @@ spring: | |||
discovery: | |||
enabled: true | |||
server-addr: 100.64.2.105:8848 | |||
namespace: guizhou-issuer | |||
namespace: zhywpt-new-test | |||
username: nacos | |||
password: '!@#$%qwertASDFG' | |||
ip: 127.0.0.1 | |||
@@ -23,7 +23,7 @@ spring: | |||
enabled: true | |||
file-extension: yaml # 必须修改成yaml | |||
server-addr: 100.64.2.105:8848 | |||
namespace: guizhou-issuer | |||
namespace: zhywpt-new-test | |||
username: nacos | |||
password: '!@#$%qwertASDFG' | |||
extension-configs: | |||
@@ -31,6 +31,8 @@ spring: | |||
refresh: true | |||
- data-id: comm-client.yaml | |||
refresh: true | |||
- data-id: minio-client.yaml | |||
refresh: true | |||
server: | |||
port: 9083 | |||
servlet: |