svn to git

0 parents
Showing 71 changed files with 4245 additions and 0 deletions
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>framework-rop</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rop-dj-staff-miniprogram</artifactId>
<version>5.3.0-SNAPSHOT</version>
<name>rop-dj-staff</name>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-smartcarlife-api</artifactId>
<version>5.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-staff-api</artifactId>
<version>5.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rop-common</artifactId>
<version>5.3.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
package cn.com.glsx.dj.staff.miniprogram;
import org.oreframework.boot.main.AbsOreBootStarter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
/**
* @Title: Main.java
* @Description:
* @author zengqi
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@SpringBootApplication
@ServletComponentScan
public class Main extends AbsOreBootStarter {
@Override
public void run(String[] args)
{
SpringApplication.run(Main.class, args);
}
public static void main(String[] args)
{
Main main = new Main();
main.run(args);
}
}
package cn.com.glsx.dj.staff.miniprogram.config;
import org.oreframework.boot.autoconfigure.rop.metadata.RopProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.rop.RopServlet;
import com.rop.config.InterceptorHolder;
import cn.com.glsx.dj.staff.miniprogram.interceptor.ThreadLocalCacheInterceptor;
@Configuration
@ConditionalOnClass({RopServlet.class})
@EnableConfigurationProperties({RopProperty.class})
public class OperaeLogAutoConfigure {
@Bean
public InterceptorHolder threadLocalCacheInterceptor() {
return new InterceptorHolder(new ThreadLocalCacheInterceptor());
}
}
package cn.com.glsx.dj.staff.miniprogram.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @Title: SystemProperty.java
* @Description:
* @author zengqi
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Configuration
@ConfigurationProperties("system")
public class SystemProperty {
// 对应配置项:system.name
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package cn.com.glsx.dj.staff.miniprogram.config.dubbo;
import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
/**
* @Title: DubboConfig.java
* @Description: Dubbo服务注册配置
* @author zengqi
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class DubboConfig {
@Autowired
protected ReferenceBuilderFactory factory;
protected final boolean check = false;
protected final int timeout = 30000;
}
package cn.com.glsx.dj.staff.miniprogram.config.dubbo;
import cn.com.glsx.merchants.remote.MerchantStaffRemote;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class PlatformMerchantsDubboConfig extends DubboConfig {
@Bean
public MerchantStaffRemote merchantStaffRemote(){
return factory.builder(MerchantStaffRemote.class).timeout(timeout).check(check).version("2.0.0").build();
}
}
package cn.com.glsx.dj.staff.miniprogram.config.dubbo;
import cn.com.glsx.scrm.proxy.remote.CommonProxyRemote;
import cn.com.glsx.scrm.proxy.remote.merchant.MerchantRemote;
import cn.com.glsx.scrm.proxy.remote.merchant.StaffRemote;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ProxyDubboConfig extends DubboConfig {
@Bean
public StaffRemote staffRemote() {
return factory.builder(StaffRemote.class).check(check).timeout(timeout).build();
}
@Bean
public MerchantRemote merchantRemote() {
return factory.builder(MerchantRemote.class).check(check).timeout(timeout).build();
}
@Bean
public CommonProxyRemote commonProxyRemote() {
return factory.builder(CommonProxyRemote.class).check(check).timeout(timeout).build();
}
}
package cn.com.glsx.dj.staff.miniprogram.config.dubbo;
import cn.com.glsx.dj.smartcarlife.remote.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class SmartCarLifeDubboConfig extends DubboConfig {
@Bean
public ServiceMerchantRefRemote serviceMerchantRefRemote(){
return factory.builder(ServiceMerchantRefRemote.class).timeout(timeout).check(check).build();
}
@Bean
public SceneMerchantRefRemote sceneMerchantRefRemote(){
return factory.builder(SceneMerchantRefRemote.class).check(check).timeout(timeout).build();
}
@Bean
public YqMerchantConfigRemote yqMerchantConfigRemote(){
return factory.builder(YqMerchantConfigRemote.class).check(check).timeout(timeout).build();
}
@Bean
public MerchantServiceCenterRemote merchantServiceCenterRemote(){
return factory.builder(MerchantServiceCenterRemote.class).protocol("dubbo").check(check).timeout(timeout).version("1.0.0").build();
}
@Bean
public MerchantSubRefRemote merchantSubRefRemote(){
return factory.builder(MerchantSubRefRemote.class).check(check).timeout(timeout).build();
}
@Bean
public OperationLogRemote operationLogRemote(){
return factory.builder(OperationLogRemote.class).timeout(timeout).check(check).build();
}
@Bean
public ServiceMerchantStaffAllocationRemote serviceMerchantStaffAllocationRemote(){
return factory.builder(ServiceMerchantStaffAllocationRemote.class).check(check).version("1.0.0").timeout(timeout).build();
}
@Bean
public ServiceMerchantRemote serviceMerchantRemote(){
return factory.builder(ServiceMerchantRemote.class).timeout(timeout).check(check).build();
}
@Bean
public SalesMerchantRelationRemote salesMerchantRelationRemote(){
return factory.builder(SalesMerchantRelationRemote.class).timeout(timeout).check(check).build();
}
@Bean
public ShopMerchantDirectorConfigRemote shopMerchantDirectorConfigRemote(){
return factory.builder(ShopMerchantDirectorConfigRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
@Bean
public StaffBaseInfoRemote staffBaseInfoRemote(){
return factory.builder(StaffBaseInfoRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
}
package cn.com.glsx.dj.staff.miniprogram.config.dubbo;
import cn.com.glsx.dj.staff.remote.RecruitmentDemandRemote;
import cn.com.glsx.dj.staff.remote.RecruitmentResumeRemote;
import cn.com.glsx.dj.staff.remote.dict.DictRemote;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class StaffDubboConfig extends DubboConfig {
@Bean
public RecruitmentDemandRemote recruitmentDemandRemote(){
return factory.builder(RecruitmentDemandRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
@Bean
public RecruitmentResumeRemote recruitmentResumeRemote(){
return factory.builder(RecruitmentResumeRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
@Bean
public DictRemote dictRemote(){
return factory.builder(DictRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
}
package cn.com.glsx.dj.staff.miniprogram.constant;
/**
*
* @Title LoginConstants
* @Description:
* @author Suro
* @date 2021/9/15 14:15
* @version V1.0
* @Company:didihu.com.cn
**/
public class LoginConstants {
/** 获取手机号登录校验码时 手机号缓存 用于校验短时间内是否重复性获取验证码**/
public static final String PHONE_CODE_CACHE = "ROP_DJ_SALE_SMS_LOGIN_";
public static final String MINI_USER_KEY = "SSO_MINI_USER_SESSION";
public static final String WEAPP_JS_CODE_SESSION_KEY = "WEAPP_JS_CODE_SESSION_KEY";
public static final String WEAPP_OPEN_ID = "WEAPP_OPEN_ID";
public static final String WEAPP_UNION_ID = "WEAPP_UNION_ID";
public static final String WEAPP_WECHAT_USER_INFO_ID = "WEAPP_WECHAT_USER_INFO_ID";
public static final String WECHATID = "SESSION_WECHATID";
/** 服务顾问分享 **/
public static final String SERVICE_SHARING="packageServicer/pages/sharing/sharing";
/** 活动详情分享 **/
public static final String ACTIVITY_SHARING="packageIndex/pages/activityInfo/activityInfo";
/**
* 短信来源
*/
public final static String SMS_SOURCE = "ddh-carlife-miniprograme-login";
/**
* 短注册来源
*/
public final static String RIGISTER_SOURCE = "101";
/**
* 图形验证码
*/
public static final String VERIFY_CODE = "SSO_VERIFY_CODE_";
/**
* 选择登录令牌
*/
public static final String LOGIN_SELECT_TOKEN = "SSO_LOGIN_SELECT_";
/**
* 企业微信用户ID
*/
public static final String WORK_WECHAT_USER_ID = "SSO_WORK_WECHAT_USER_ID_";
/**
* 记录园区店登录时选择的4S店及场景
*/
public static final String LOGIN_SELECT_MERCHANT_SCENE = "LOGIN_SELECT_MERCHANT_SCENE_";
/**
* 全局配置登录模块
*/
public static final String LOGIN_MODULE = "LOGIN";
}
package cn.com.glsx.dj.staff.miniprogram.constant;
public class RedisKeyConstants {
/**
* 条形码缓存
*/
public final static String DJ_SMARTCARLIFE_BARCODE_MAP = "DJ_SMARTCARLIFE_BARCODE_MAP";
/**
* 员工绩效查看密码校验缓存
*/
public final static String DJ_BUSINESS_SCHOOL_STAFF_PPPWD_CHECK_FAILED_COUNT = "DJ_BUSINESS_SCHOOL_STAFF_PPPWD_CHECK_FAILED_COUNT_%s";
/**
* 2.1报价单防止重复提交录单缓存key
*/
public final static String VEHICLE_DAMAGE_UPGRADE_QUOTATION_ANTI_SHAKE = "rop-dj-car-boutique:quotation_add_anti_shake:";
/**
* 驻店日报不能重复提交校验key
*/
public final static String DJ_BUSINESS_SCHOOL_STAFF_DAILY_REPORT_CHECK = "DJ_BOUTIQUE_STAFF_DAILY_REPORT_CHECK_%s";
}
package cn.com.glsx.dj.staff.miniprogram.constant;
public interface RopConstants {
/** 登录信息session**/
final String LOGIN_SESSION = "ROP_CARBOUTIQUE_USER";
/** 登录授权手机号**/
final String LOGIN_PHONE_SESSION = "ROP_CARBOUTIQUE_USER_PHONE";
/** WEB SOCKET SESSION缓存前缀**/
final String LOGIN_WS_SESSION_PREFIX = "LOGIN_WS_SESSION_";
/** 登录的产品编号 **/
final String LOGIN_PRODUCT_CODE = "ROP_LOGIN_PRODUCT_CODE";
/** 登录账号密码**/
final String LOGIN_ACCOUNT_PWD_SESSION = "ROP_CARBOUTIQUE_USER_ACCOUNT_PWD";
}
package cn.com.glsx.dj.staff.miniprogram.constant;
import java.math.BigDecimal;
/**
* @Title: ServiceConstants.java
* @Description: 业务相关常量
* @author caiym
* @date 2020年12月03日 10:25
* @version V1.0.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2020
*/
public class ServiceConstants {
/**
* excel导出最大数量
*/
public static final int EXPORT_MAX_SIZE_DEFAULT = 30000;
public static final String DEFAULT_FILM_GOOD_TYPES = "[1,4,6,12,14]";
public static final BigDecimal ONEHUNDRED_BIGDECIMAL = BigDecimal.valueOf(100);
/**
* 保留两位小数
*/
public static final int SCALE = 2;
public static final String DATE_START_TIME = " 00:00:00";
public static final String DATE_END_TIME = " 23:59:59";
public static final String DATE_TIME_REGEX = "^\\d{4}(-)(1[0-2]|0\\d)\\1([0-2]\\d|\\d|30|31) ([0-1]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$";
}
package cn.com.glsx.dj.staff.miniprogram.controller;
import cn.com.glsx.dj.staff.miniprogram.request.ExampleRequest;
import cn.com.glsx.dj.staff.miniprogram.request.LoginRequest;
import cn.com.glsx.dj.staff.miniprogram.response.ExampleResponse;
import cn.com.glsx.dj.staff.miniprogram.response.LoginResponse;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.rop.AbstractRopRequest;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import com.rop.session.SimpleSession;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.UUID;
/**
* @Title: ExampleController.java
* @Description:
* @author Alvin
* @date 2019年9月2日 下午3:27:41
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
@Api("示例接口")
public class ExampleController
{
/**
* logger
*/
protected final Logger logger = LoggerFactory.getLogger(getClass());
/**
* 接口例子
*
* @param req ExampleRequest
* @return Object
* @throws Exception 异常
*/
@ServiceMethod(method = "org.ore.api.example", needInSession = NeedInSessionType.NO)
@ApiOperation("get接口示例")
public RopResponse<ExampleResponse> getExample(ExampleRequest req)
throws Exception
{
ExampleResponse response = new ExampleResponse();
response.setField1("Ni Hao");
response.setField2(req.getName());
return RopResponse.success(response);
}
/**
* 会话示例
* @param request
* @return
* @throws Exception
* @author Alvin
* @date 2019年9月22日 下午3:31:25
*/
@ServiceMethod(method = "org.ore.api.example.insession", needInSession = NeedInSessionType.YES)
@ApiOperation("会话示例")
public RopResponse<ExampleResponse> getExampleInSession(ExampleRequest request) throws Exception{
return getExample(request);
}
/**
* 登录示例
* @param request
* @return
* @author Alvin
* @date 2019年9月22日 下午3:51:53
*/
@ServiceMethod(method = "org.ore.api.example.login", needInSession = NeedInSessionType.NO)
@ApiOperation("登录示例")
public RopResponse<LoginResponse> login(LoginRequest request){
// 创建会话
SimpleSession session = new SimpleSession();
session.setAttribute("userName", request.getUserName());
String sessionId = UUID.randomUUID().toString();
request.getRopRequestContext().addSession(sessionId, session);
LoginResponse response = new LoginResponse();
response.setSessionId(sessionId);
return RopResponse.success(response);
}
/**
* 登出示例
* @param request
* @return
* @author Alvin
* @date 2019年9月22日 下午3:53:24
*/
@ServiceMethod(method = "org.ore.api.example.logout", needInSession = NeedInSessionType.NO)
@ApiOperation("登出示例")
public RopResponse<Boolean> logout(AbstractRopRequest request){
// 删除会话
request.getRopRequestContext().removeSession();
return RopResponse.success(true);
}
}
package cn.com.glsx.dj.staff.miniprogram.controller.common;
import cn.com.glsx.dj.staff.miniprogram.convert.DictConvert;
import cn.com.glsx.dj.staff.miniprogram.request.common.DictListRequest;
import cn.com.glsx.dj.staff.miniprogram.response.common.DictListResponse;
import cn.com.glsx.dj.staff.miniprogram.util.CommonUtil;
import cn.com.glsx.dj.staff.model.Dict;
import cn.com.glsx.dj.staff.remote.dict.DictRemote;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
@Api("字典")
public class DictController {
@Autowired
private DictRemote dictRemote;
@Autowired
private Environment env;
@ApiOperation("查询字典列表")
@ServiceMethod(method = "dj.api.staff.miniprogram.dict.list", needInSession = NeedInSessionType.YES)
public RopResponse<List<DictListResponse>> list(DictListRequest request){
RpcPagination<Dict> pagination = CommonUtil.getRpcPagination(Dict.class);
pagination.setPageSize(env.getProperty("dict.page.size", Integer.class, 100));
RpcResponse<RpcPagination<Dict>> response = dictRemote.dictPage(pagination);
if (!response.isSuccess()) {
return RopResponse.error(response);
}
List<DictListResponse> list = response.getResult().getList().stream().map(DictConvert.INSTANCE::toDictListResponse).collect(Collectors.toList());
return RopResponse.success(list);
}
}
package cn.com.glsx.dj.staff.miniprogram.controller.recruitment;
import cn.com.glsx.dj.staff.dto.recruitment.RecruitmentDemandDTO;
import cn.com.glsx.dj.staff.miniprogram.request.common.CommonIdRequest;
import cn.com.glsx.dj.staff.miniprogram.request.recruitment.RecruitmentDemandAddRequest;
import cn.com.glsx.dj.staff.miniprogram.request.recruitment.RecruitmentDemandPageRequest;
import cn.com.glsx.dj.staff.miniprogram.request.recruitment.RecruitmentDemandStoreListRequest;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandDetailResponse;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandPageResponse;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandStatResponse;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandStoreListResponse;
import cn.com.glsx.dj.staff.miniprogram.service.recruitment.RecruitmentDemandService;
import cn.com.glsx.dj.staff.miniprogram.util.CommonUtil;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.rop.AbstractRopRequest;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
@Slf4j
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
@Api("招聘需求")
public class RecruitmentDemandController {
@Autowired
private RecruitmentDemandService recruitmentDemandService;
@ApiOperation("招聘需求统计")
@ServiceMethod(method = "dj.api.staff.miniprogram.recruitment.demand.stat", needInSession = NeedInSessionType.YES)
public RopResponse<RecruitmentDemandStatResponse> statRecruitmentDemand(AbstractRopRequest request){
RecruitmentDemandDTO dto = RecruitmentDemandDTO.builder().regionOperationId(CommonUtil.getLoginUserInfo().getUuid()).build();
return recruitmentDemandService.statRecruitmentDemand(dto);
}
@ApiOperation("招聘需求分页查询")
@ServiceMethod(method = "dj.api.staff.miniprogram.recruitment.page", needInSession = NeedInSessionType.YES)
public RopResponse<RpcPagination<RecruitmentDemandPageResponse>> pageRecruitmentDemand(RecruitmentDemandPageRequest request){
return recruitmentDemandService.pageRecruitmentDemand(request);
}
@ApiOperation("招聘管理已完成/已驳回,确认flag标配已确认")
@ServiceMethod(method = "dj.api.staff.miniprogram.recruitment.confirm", needInSession = NeedInSessionType.YES)
public RopResponse<Boolean> updateConfirmFlagToConfirmed(CommonIdRequest request){
return recruitmentDemandService.updateConfirmFlagToConfirmed(request);
}
@ApiOperation("招聘需求详情")
@ServiceMethod(method = "dj.api.staff.miniprogram.recruitment.demand.detail", needInSession = NeedInSessionType.YES)
public RopResponse<RecruitmentDemandDetailResponse> getRecruitmentDemandDetail(CommonIdRequest request){
return recruitmentDemandService.getRecruitmentDemandDetail(request);
}
@ApiOperation("添加招聘需求-门店列表")
@ServiceMethod(method = "dj.api.staff.miniprogram.recruitment.demand.store.list", needInSession = NeedInSessionType.YES)
public RopResponse<List<RecruitmentDemandStoreListResponse>> listStore(RecruitmentDemandStoreListRequest request){
return recruitmentDemandService.listStore(request);
}
@ApiOperation("添加招聘需求")
@ServiceMethod(method = "dj.api.staff.miniprogram.recruitment.demand.add", needInSession = NeedInSessionType.YES)
public RopResponse<Boolean> add(RecruitmentDemandAddRequest request){
RecruitmentDemandDTO dto = CommonUtil.convertRequest(RecruitmentDemandDTO.class);
return recruitmentDemandService.addRecruitmentDemand(dto);
}
}
package cn.com.glsx.dj.staff.miniprogram.controller.recruitment;
import cn.com.glsx.dj.staff.miniprogram.request.recruitment.RecruitmentResumeProcessRequest;
import cn.com.glsx.dj.staff.miniprogram.service.recruitment.RecruitmentResumeService;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
@Api("招聘简历(入职计划)")
public class RecruitmentResumeController {
@Autowired
private RecruitmentResumeService recruitmentResumeService;
@ApiOperation("简历处理")
@ServiceMethod(method = "dj.api.staff.miniprogram.recruitment.resume.process", needInSession = NeedInSessionType.YES)
public RopResponse<Boolean> processResume(RecruitmentResumeProcessRequest request){
return recruitmentResumeService.processResume(request);
}
}
package cn.com.glsx.dj.staff.miniprogram.convert;
import cn.com.glsx.dj.staff.miniprogram.response.common.DictListResponse;
import cn.com.glsx.dj.staff.model.Dict;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface DictConvert {
DictConvert INSTANCE = Mappers.getMapper(DictConvert.class);
DictListResponse toDictListResponse(Dict sourceEntity);
}
package cn.com.glsx.dj.staff.miniprogram.convert;
import cn.com.glsx.dj.staff.dto.recruitment.RecruitmentDemandDTO;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandDetailResponse;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandPageResponse;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandStatResponse;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentResponse;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
@Mapper(uses = {RecruitmentResumeDTOConvert.class, RecruitmentOnboardingPlanDTOConvert.class})
public interface RecruitmentDemandDTOConvert {
RecruitmentDemandDTOConvert INSTANCE = Mappers.getMapper(RecruitmentDemandDTOConvert.class);
RecruitmentDemandStatResponse toRecruitmentDemandStatResponse(RecruitmentDemandDTO sourceEntity);
RecruitmentDemandPageResponse toRecruitmentDemandPageResponse(RecruitmentDemandDTO dto);
@Mappings({
@Mapping(source = "dto", target = "recruitment"),
@Mapping(source = "resumes", target = "recruitmentPlans"),
@Mapping(source = "onboardingPlans", target = "onboardingPlans"),
@Mapping(source = "recruitmentQuantity", target = "stat.recruitmentQuantity"),
@Mapping(source = "resumeCount", target = "stat.resumeCount"),
@Mapping(source = "processResumeCount", target = "stat.processResumeCount"),
@Mapping(source = "entryCount", target = "stat.entryCount")
})
RecruitmentDemandDetailResponse toRecruitmentDemandDetailResponse(RecruitmentDemandDTO dto);
RecruitmentResponse toRecruitmentResponse(RecruitmentDemandDTO sourceEntity);
}
package cn.com.glsx.dj.staff.miniprogram.convert;
import cn.com.glsx.dj.staff.dto.recruitment.RecruitmentOnboardingPlanDTO;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentOnboardingPlanResponse;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface RecruitmentOnboardingPlanDTOConvert {
RecruitmentOnboardingPlanDTOConvert INSTANCE = Mappers.getMapper(RecruitmentOnboardingPlanDTOConvert.class);
RecruitmentOnboardingPlanResponse toRecruitmentOnboardingPlanResponse(RecruitmentOnboardingPlanDTO sourceEntity);
}
package cn.com.glsx.dj.staff.miniprogram.convert;
import cn.com.glsx.dj.staff.dto.recruitment.RecruitmentResumeDTO;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentResumeResponse;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface RecruitmentResumeDTOConvert {
RecruitmentResumeDTOConvert INSTANCE = Mappers.getMapper(RecruitmentResumeDTOConvert.class);
RecruitmentResumeResponse toRecruitmentResumeResponse(RecruitmentResumeDTO sourceEntity);
}
package cn.com.glsx.dj.staff.miniprogram.convert;
public class RecruitmentResumeDTOConvertHelper {
}
package cn.com.glsx.dj.staff.miniprogram.enums;
public enum LoginRoleEnum {
DIRECTOR(1,"总监"),
REGIONAL_MANAGER(2,"大区经理"),
SALES(3, "销售人员")
;
private final int value;
private final String name;
LoginRoleEnum(int value,String name){
this.value = value;
this.name = name;
}
public int getValue() {
return value;
}
public String getName() {
return name;
}
public static LoginRoleEnum getByValue(Integer value) {
if(value == null) {
return null;
}
for(LoginRoleEnum e:LoginRoleEnum.values()) {
if(e.getValue() == value) {
return e;
}
}
return null;
}
}
package cn.com.glsx.dj.staff.miniprogram.enums;
import cn.com.glsx.framework.core.enums.ErrorEnum;
import java.util.HashMap;
import java.util.Map;
public enum RopErrorEnum implements ErrorEnum{
/** 您的手机号暂未注册 **/
LOGIN_NO_PERMISSION_ERROR("40990101","您的手机号暂未注册"),
/** 登录授权已失效,请刷新 **/
LOGIN_TOKEN_ERROR("40990102","登录授权已失效,请刷新"),
/** 获取登录信息-登录失效**/
GET_LOGIN_EXPIRE("40990301", "登录失效"),
/** 招聘需求-获取门店列表失败 **/
RECRUITMENT_DEMAND_GET_STORE_LIST_ERROR("50000101", "获取门店列表失败");
private String value;
private String displayName;
static Map<String, RopErrorEnum> enumMap = new HashMap<String, RopErrorEnum>();
static{
for(RopErrorEnum code:RopErrorEnum.values()){
enumMap.put(code.getValue(), code);
}
}
RopErrorEnum(String value, String displayName){
this.value = value;
this.displayName = displayName;
}
public static RopErrorEnum getEnum(String value){
return enumMap.get(value);
}
@Override
public String getValue() {
return value;
}
@Override
public String getDisplayName() {
return displayName;
}
}
package cn.com.glsx.dj.staff.miniprogram.interceptor;
import cn.com.glsx.dj.carboutique.response.LoginUserInfoResponse;
import cn.com.glsx.dj.smartcarlife.model.OperationLog;
import cn.com.glsx.dj.smartcarlife.remote.OperationLogRemote;
import cn.com.glsx.dj.staff.miniprogram.util.CommonUtil;
import com.alibaba.fastjson.JSONObject;
import com.rop.AbstractInterceptor;
import com.rop.RopRequestContext;
import com.rop.ServiceMethodDefinition;
import com.rop.annotation.ServiceMethodBean;
import org.apache.commons.lang.StringUtils;
import org.oreframework.boot.autoconfigure.rop.metadata.RopProperty;
public class OperateLogAutoSaveInterceptor extends AbstractInterceptor {
private OperationLogRemote operationLogRemote;
private RopProperty ropProperty;
public OperateLogAutoSaveInterceptor() {
}
public OperateLogAutoSaveInterceptor(OperationLogRemote operationLogRemote, RopProperty ropProperty) {
this.operationLogRemote = operationLogRemote;
this.ropProperty = ropProperty;
}
@Override
public void beforeService(RopRequestContext ropRequestContext) {
super.beforeService(ropRequestContext);
ServiceMethodDefinition serviceMethodDefinition = ropRequestContext.getServiceMethodHandler().getServiceMethodDefinition();
String methodTitle = serviceMethodDefinition.getMethodTitle();
//没有title的方法不加入日志记录
if(StringUtils.isBlank(methodTitle)){
return;
}
ServiceMethodBean serviceMethodBean = ropRequestContext.getClass().getAnnotation(ServiceMethodBean.class);
String groupTitle = serviceMethodDefinition.getMethodGroupTitle();
if(StringUtils.isNotBlank(methodTitle) && !ServiceMethodDefinition.DEFAULT_GROUP_TITLE.equals(groupTitle)){
methodTitle = groupTitle.concat("-").concat(methodTitle);
}else if(serviceMethodBean != null && StringUtils.isNotBlank(serviceMethodBean.groupTitle())){
methodTitle = serviceMethodBean.groupTitle().concat("-").concat(methodTitle);
}
OperationLog log = new OperationLog();
log.setAppkey(ropRequestContext.getAppKey());
log.setIpAddress(ropRequestContext.getIp());
log.setMethod(ropRequestContext.getMethod());
log.setCreatedBy("admin");
LoginUserInfoResponse loginUser = CommonUtil.getLoginUserInfo();
if(null != loginUser){
log.setMerchantId(loginUser.getMerchantId());
log.setCreatedBy(loginUser.getAccountName());
}
log.setMethodTitle(methodTitle);
JSONObject json = new JSONObject();
json.putAll(ropRequestContext.getAllParams());
if(ropProperty != null && ropProperty.getSysparams() != null){
json.remove(ropProperty.getSysparams().getAppkeyParamName());
json.remove(ropProperty.getSysparams().getFormatParamName());
json.remove(ropProperty.getSysparams().getJsonpParamName());
json.remove(ropProperty.getSysparams().getLocaleParamName());
json.remove(ropProperty.getSysparams().getMethodParamName());
json.remove(ropProperty.getSysparams().getSessionidParamName());
json.remove(ropProperty.getSysparams().getSignParamName());
json.remove(ropProperty.getSysparams().getTimestampParamName());
json.remove(ropProperty.getSysparams().getVersionParamName());
}
log.setContent(json.toJSONString());
operationLogRemote.insert(log);
}
}
package cn.com.glsx.dj.staff.miniprogram.interceptor;
import cn.com.glsx.dj.staff.miniprogram.util.ThreadLocalCache;
import com.rop.AbstractInterceptor;
import com.rop.RopRequestContext;
public class ThreadLocalCacheInterceptor extends AbstractInterceptor{
@Override
public void beforeService(RopRequestContext ropRequestContext) {
super.beforeService(ropRequestContext);
ThreadLocalCache.setRopRequestContext(ropRequestContext);
}
@Override
public void beforeResponse(RopRequestContext ropRequestContext) {
super.beforeResponse(ropRequestContext);
ThreadLocalCache.removeRopRequestContext();
}
@Override
public int getOrder() {
return Integer.MIN_VALUE;
}
}
package cn.com.glsx.dj.staff.miniprogram.request;
import com.rop.AbstractRopRequest;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
* 例子参数实体类
*
* @author alvin.zengqi
* @version [版本号, 2019-09-02]
* @see [相关类/方法]
* @since [产品/模块版本]
*/
public class ExampleRequest extends AbstractRopRequest
{
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
* 得到属性字符串
* @return String 属性字符串
*/
public String toString()
{
return ToStringBuilder.reflectionToString(this);
}
}
\ No newline at end of file
package cn.com.glsx.dj.staff.miniprogram.request;
import com.rop.AbstractRopRequest;
import org.apache.commons.lang.builder.ToStringBuilder;
import javax.validation.constraints.NotNull;
/**
* @Title: LoginRequest.java
* @Description:
* @author Alvin
* @date 2019年9月22日 下午3:47:04
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
public class LoginRequest extends AbstractRopRequest {
/**
* 用户名
*/
@NotNull
private String userName;
/**
* 密码
*/
@NotNull
private String password;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String toString()
{
return ToStringBuilder.reflectionToString(this);
}
}
package cn.com.glsx.dj.staff.miniprogram.request.common;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* 包含参数id的公共请求方法
* @author chenx
*/
@Data
public class CommonIdRequest extends AbstractRopRequest {
@NotNull
@ApiModelProperty(name = "id", notes = "id", dataType = "int", required = true)
private Integer id;
}
package cn.com.glsx.dj.staff.miniprogram.request.common;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class CommonPageRequest extends AbstractRopRequest {
/** 当前页码**/
@ApiModelProperty(name="currentPage", notes = "当前页码", dataType = "int", required = true, example = "1")
private int currentPage;
/** 每页条数**/
@ApiModelProperty(name="当前页码", notes = "每页条数", dataType = "int", required = true, example = "20")
private int pageSize;
}
package cn.com.glsx.dj.staff.miniprogram.request.common;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class DictListRequest extends AbstractRopRequest {
@NotBlank(message = "业务类型编码不能为空")
@ApiModelProperty(notes="业务类型编码", required = true)
private String businessCode;
@NotBlank(message = "字典类型编码不能为空")
@ApiModelProperty(notes="字典类型编码", required = true)
private String typeCode;
}
package cn.com.glsx.dj.staff.miniprogram.request.recruitment;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Data
public class RecruitmentDemandAddRequest extends AbstractRopRequest {
@NotBlank(message = "门店id不能为空")
@ApiModelProperty(notes="门店id(门店和园区店商户)", required = true)
private String merchantId;
@NotBlank(message = "门店名称不能为空")
@ApiModelProperty(notes="门店名称", required = true)
private String merchantName;
@NotNull(message = "招聘数量不能为空")
@ApiModelProperty(notes="招聘数量", required = true)
private Integer recruitmentQuantity;
@NotBlank(message = "业务类型值不能为空")
@ApiModelProperty(notes="业务类型值", required = true)
private String businessType;
@NotBlank(message = "业务类型名称不能为空")
@ApiModelProperty(notes="业务类型名称", required = true)
private String businessTypeName;
@NotBlank(message = "招聘类型值不能为空")
@ApiModelProperty(notes="招聘类型值", required = true)
private String recruitmentType;
@NotBlank(message = "招聘类型名称不能为空")
@ApiModelProperty(notes="招聘类型名称", required = true)
private String recruitmentTypeName;
@ApiModelProperty(notes="需求描述")
private String requirementDescription;
}
package cn.com.glsx.dj.staff.miniprogram.request.recruitment;
import cn.com.glsx.dj.staff.miniprogram.request.common.CommonPageRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class RecruitmentDemandPageRequest extends CommonPageRequest {
@ApiModelProperty(notes="是否只查待处理")
private Boolean onlyWaiting;
}
package cn.com.glsx.dj.staff.miniprogram.request.recruitment;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class RecruitmentDemandStoreListRequest extends AbstractRopRequest {
@ApiModelProperty(notes="商户名称-模糊搜索")
private String merchantName;
}
package cn.com.glsx.dj.staff.miniprogram.request.recruitment;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
@Data
public class RecruitmentResumeProcessRequest extends AbstractRopRequest {
@NotNull(message = "id 不能为空")
@ApiModelProperty(notes="id", required = true)
private Integer id;
@NotNull(message = "处理结果不能为空")
@Range(min = 1, max = 2, message = "处理结果取值范围:1-人员不匹配 2-已完成面试")
@ApiModelProperty(notes="处理结果,1-人员不匹配 2-已完成面试", required = true)
private Byte processResult;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(notes="面试时间", required = true)
private Date interviewTime;
@Range(min = 0, max = 1, message = "面试结果取值范围:0-不通过 1-通过")
@ApiModelProperty(notes="面试结果,0-不通过 1-通过")
private Byte interviewResult;
@Size(max = 255, message = "说明长度不能超过255字符")
@ApiModelProperty(notes="说明")
private String description;
}
package cn.com.glsx.dj.staff.miniprogram.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
* ExampleResponse
* @author alvin.zengqi
* @version [版本号, 2019-09-02]
* @see [相关类/方法]
* @since [产品/模块版本]
*/
@ApiModel(description = "响应值示例")
public class ExampleResponse
{
@ApiModelProperty(name = "field1", notes = "字段1", dataType = "string", required = true, example = "aaaaa")
private String field1 = "1";
@ApiModelProperty(name = "field2", notes = "字段2", dataType = "string", required = true, example = "bbbbb", value = "字段2")
private String field2 = "2";
public void setField1(String field1) {
this.field1 = field1;
}
public String getField2() {
return field2;
}
public void setField2(String field2) {
this.field2 = field2;
}
/**
* 得到属性字符串
*
* @return String 属性字符串
*/
public String toString()
{
return ToStringBuilder.reflectionToString(this);
}
}
\ No newline at end of file
package cn.com.glsx.dj.staff.miniprogram.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang.builder.ToStringBuilder;
import java.io.Serializable;
/**
* @Title: LoginResponse.java
* @Description:
* @author Alvin
* @date 2019年9月22日 下午3:48:18
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@ApiModel(description = "响应值示例")
public class LoginResponse implements Serializable{
private static final long serialVersionUID = 5224077845643787410L;
/**
* 会话ID
*/
@ApiModelProperty(name = "sessionId", notes = "会话ID", dataType = "string", required = true, example = "asdfasdf23423432432")
private String sessionId;
public String getSessionId() {
return sessionId;
}
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
public String toString()
{
return ToStringBuilder.reflectionToString(this);
}
}
package cn.com.glsx.dj.staff.miniprogram.response.common;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class DictListResponse implements Serializable {
private static final long serialVersionUID = -7106801224673994443L;
@ApiModelProperty(notes="业务类型编码")
private String businessCode;
@ApiModelProperty(notes="字典类型编码")
private String typeCode;
@ApiModelProperty(notes="字典类型名称")
private String typeName;
@ApiModelProperty(notes="字典项名称")
private String itemName;
@ApiModelProperty(notes="字典项值")
private String itemValue;
}
package cn.com.glsx.dj.staff.miniprogram.response.recruitment;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class RecruitmentDemandDetailResponse implements Serializable {
private static final long serialVersionUID = 6150591673270949380L;
@ApiModelProperty(notes="id")
private Integer id;
@ApiModelProperty(notes="统计")
private RecruitmentDemandDetailStatResponse stat;
@ApiModelProperty(notes="入职计划列表")
private List<RecruitmentOnboardingPlanResponse> onboardingPlans;
@ApiModelProperty(notes="招聘计划列表")
private List<RecruitmentResumeResponse> recruitmentPlans;
@ApiModelProperty(notes="招聘信息")
private RecruitmentResponse recruitment;
}
package cn.com.glsx.dj.staff.miniprogram.response.recruitment;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class RecruitmentDemandDetailStatResponse implements Serializable {
private static final long serialVersionUID = -240435242406101226L;
@ApiModelProperty(notes="需求数量")
private Integer recruitmentQuantity;
@ApiModelProperty(notes="投递简历数")
private Integer resumeCount;
@ApiModelProperty(notes="处理简历数")
private Integer processResumeCount;
@ApiModelProperty(notes="入职人数")
private Integer entryCount;
}
package cn.com.glsx.dj.staff.miniprogram.response.recruitment;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class RecruitmentDemandPageResponse implements Serializable {
private static final long serialVersionUID = -6032761913055433926L;
@ApiModelProperty(notes="id")
private Integer id;
@ApiModelProperty(notes="门店id(门店和园区店商户)")
private String merchantId;
@ApiModelProperty(notes="门店名称")
private String merchantName;
@ApiModelProperty(notes="招聘数量")
private Integer recruitmentQuantity;
@ApiModelProperty(notes="业务类型值")
private String businessType;
@ApiModelProperty(notes="业务类型名称")
private String businessTypeName;
@ApiModelProperty(notes="招聘类型值")
private String recruitmentType;
@ApiModelProperty(notes="招聘类型名称")
private String recruitmentTypeName;
@ApiModelProperty(notes="状态, 0-待人事确认 1-招聘中 2-已完成 3-已驳回")
private Byte status;
@ApiModelProperty(notes="确认flag,N-未确认 Y-已确认")
private String confirmFlag;
@ApiModelProperty(notes="待处理简历数量")
private Integer waitProcessResumeCount;
}
package cn.com.glsx.dj.staff.miniprogram.response.recruitment;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class RecruitmentDemandStatResponse implements Serializable {
private static final long serialVersionUID = -3496267307927860038L;
@ApiModelProperty(notes="待处理个数")
private Integer waitProcessCount;
@ApiModelProperty(notes="全部个数")
private Integer totalCount;
}
package cn.com.glsx.dj.staff.miniprogram.response.recruitment;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.io.Serializable;
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@Data
public class RecruitmentDemandStoreListResponse implements Serializable {
private static final long serialVersionUID = 7223563533987585281L;
@ApiModelProperty(notes="商户号")
private Integer merchantId;
@ApiModelProperty(notes="商户名称")
private String merchantName;
}
package cn.com.glsx.dj.staff.miniprogram.response.recruitment;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class RecruitmentOnboardingPlanResponse implements Serializable {
private static final long serialVersionUID = 2684109056149948533L;
@ApiModelProperty(notes="id")
private Integer id;
@ApiModelProperty(notes="人员姓名")
private String personName;
@ApiModelProperty(notes="手机号")
private String phoneNumber;
@ApiModelProperty(notes="入职时间")
private Date onboardingDate;
@ApiModelProperty(notes="性格类型值")
private String personalityType;
@ApiModelProperty(notes="性格类型名")
private String personalityName;
@ApiModelProperty(notes="能力表现类型值")
private String abilityPerformanceType;
@ApiModelProperty(notes="能力表现类型名")
private String abilityPerformanceName;
@ApiModelProperty(notes="学历类型值")
private String educationLevelType;
@ApiModelProperty(notes="学历类型名")
private String educationLevelName;
@ApiModelProperty(notes="形象类型值")
private String appearanceType;
@ApiModelProperty(notes="岗位匹配度类型名")
private String appearanceName;
@ApiModelProperty(notes="岗位匹配度类型名")
private String positionMatchDegreeType;
@ApiModelProperty(notes="岗位匹配度类型名")
private String positionMatchDegreeName;
}
package cn.com.glsx.dj.staff.miniprogram.response.recruitment;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class RecruitmentResponse implements Serializable {
private static final long serialVersionUID = 7619145861586162260L;
@ApiModelProperty(notes="门店名称")
private String merchantName;
@ApiModelProperty(notes="门店id(门店和园区店商户)")
private String merchantId;
@ApiModelProperty(notes="业务类型值")
private String businessType;
@ApiModelProperty(notes="业务类型名称")
private String businessTypeName;
@ApiModelProperty(notes="招聘类型值")
private String recruitmentType;
@ApiModelProperty(notes="招聘类型名称")
private String recruitmentTypeName;
@ApiModelProperty(notes="招聘负责人")
private String recruiterName;
@ApiModelProperty(notes="招聘负责人手机号")
private String recruiterPhone;
@ApiModelProperty(notes="需求描述")
private String requirementDescription;
@ApiModelProperty(notes="申请时间")
private Date createdDate;
@ApiModelProperty(notes = "状态, 0-待人事确认 1-招聘中 2-已完成 3-已驳回")
private Byte status;
@ApiModelProperty(notes="拒绝理由")
private String recallReason;
}
package cn.com.glsx.dj.staff.miniprogram.response.recruitment;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class RecruitmentResumeResponse implements Serializable {
private static final long serialVersionUID = 986556021485613947L;
@ApiModelProperty(notes="id")
private Integer id;
@ApiModelProperty(notes="状态, 0-待处理 1-已完成")
private Byte status;
@ApiModelProperty(notes="综合结果,0-待处理 1-人员不匹配 2 面试通过 3 面试不通过")
private Byte mixResult;
@ApiModelProperty(notes="人员姓名")
private String personName;
@ApiModelProperty(notes="手机号")
private String phoneNumber;
@ApiModelProperty(notes="简历URL")
private String resumeUrl;
@ApiModelProperty(notes="投递时间")
private Date createdDate;
}
package cn.com.glsx.dj.staff.miniprogram.service.recruitment;
import cn.com.glsx.dj.carboutique.response.LoginUserInfoResponse;
import cn.com.glsx.dj.smartcarlife.dto.MerchantListDTO;
import cn.com.glsx.dj.smartcarlife.dto.SceneMerchantRefDTO;
import cn.com.glsx.dj.smartcarlife.dto.ShopMerchantDirectorConfigDTO;
import cn.com.glsx.dj.smartcarlife.enums.DirectorTypeEnum;
import cn.com.glsx.dj.smartcarlife.remote.SceneMerchantRefRemote;
import cn.com.glsx.dj.smartcarlife.remote.ShopMerchantDirectorConfigRemote;
import cn.com.glsx.dj.staff.dto.recruitment.RecruitmentDemandDTO;
import cn.com.glsx.dj.staff.miniprogram.convert.RecruitmentDemandDTOConvert;
import cn.com.glsx.dj.staff.miniprogram.enums.RopErrorEnum;
import cn.com.glsx.dj.staff.miniprogram.request.common.CommonIdRequest;
import cn.com.glsx.dj.staff.miniprogram.request.recruitment.RecruitmentDemandPageRequest;
import cn.com.glsx.dj.staff.miniprogram.request.recruitment.RecruitmentDemandStoreListRequest;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandDetailResponse;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandPageResponse;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandStatResponse;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandStoreListResponse;
import cn.com.glsx.dj.staff.miniprogram.util.CommonUtil;
import cn.com.glsx.dj.staff.remote.RecruitmentDemandRemote;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = RpcServiceException.class)
public class RecruitmentDemandService {
@Autowired
private ShopMerchantDirectorConfigRemote shopMerchantDirectorConfigRemote;
@Autowired
private SceneMerchantRefRemote sceneMerchantRefRemote;
@Autowired
private RecruitmentDemandRemote recruitmentDemandRemote;
/**
* 门店列表
*
* @param request
* @return cn.com.glsx.framework.rop.response.RopResponse<java.util.List<cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandStoreListResponse>>
* @author caiym
* @date 2025年10月20日 15:19:14
*/
public RopResponse<List<RecruitmentDemandStoreListResponse>> listStore(RecruitmentDemandStoreListRequest request) {
log.info("list store, 1.查找当前登录人作为区域运营的门店列表");
ShopMerchantDirectorConfigDTO dto = ShopMerchantDirectorConfigDTO.builder()
.directorTypes(Arrays.asList(DirectorTypeEnum.AREA_SUPERVISION_1_1.getValue(), DirectorTypeEnum.AREA_SUPERVISION_2_1.getValue()))
.directorUserId(CommonUtil.getLoginUserInfo().getUuid())
.merchantName(request.getMerchantName()).build();
RpcResponse<List<ShopMerchantDirectorConfigDTO>> shopDirectorConfigResp = shopMerchantDirectorConfigRemote.list(dto);
if (!shopDirectorConfigResp.hasResult()) {
log.error("list store, 1.查找当前登录人作为区域运营的门店列表失败, msg:{}", shopDirectorConfigResp.getMessage());
return RopResponse.error(RopErrorEnum.RECRUITMENT_DEMAND_GET_STORE_LIST_ERROR);
}
List<RecruitmentDemandStoreListResponse> shopStoreList = new ArrayList<>(shopDirectorConfigResp.getResult().stream()
.filter(o -> o != null && o.getMerchantId() != null).map(o -> RecruitmentDemandStoreListResponse.builder()
.merchantId(o.getMerchantId()).merchantName(o.getMerchantName()).build()).collect(Collectors.toMap(RecruitmentDemandStoreListResponse::getMerchantId, o -> o, (o1, o2) -> o1)).values());
log.info("list store, 1.查找当前登录人作为区域运营的门店列表成功, size:{}", shopStoreList.size());
List<RecruitmentDemandStoreListResponse> storeList = new ArrayList<>();
if (CollectionUtils.isEmpty(shopStoreList)) {
return RopResponse.success(storeList);
}
storeList.addAll(shopStoreList);
log.info("list store, 2.查找门店关联园区店列表");
List<Integer> shopMerchantIds = shopStoreList.stream().map(RecruitmentDemandStoreListResponse::getMerchantId).distinct().collect(Collectors.toList());
SceneMerchantRefDTO sceneMerchantRefDTO = SceneMerchantRefDTO.builder().mainMerchantIdList(shopMerchantIds).subMerchantName(request.getMerchantName()).build();
RpcResponse<List<MerchantListDTO>> queryYqShopBy4sResp = sceneMerchantRefRemote.queryYqShopBy4s(sceneMerchantRefDTO);
if (!queryYqShopBy4sResp.hasResult()) {
log.error("list store, 2.查找门店关联园区店列表失败, msg:{}", queryYqShopBy4sResp.getMessage());
return RopResponse.error(RopErrorEnum.RECRUITMENT_DEMAND_GET_STORE_LIST_ERROR);
}
log.info("list store, 2.查找门店关联园区店列表成功, size:{}", queryYqShopBy4sResp.getResult().size());
if (CollectionUtils.isNotEmpty(queryYqShopBy4sResp.getResult())) {
List<RecruitmentDemandStoreListResponse> yqStoreList = queryYqShopBy4sResp.getResult().stream()
.filter(o -> o != null && o.getYqMerchantId() != null).map(o -> RecruitmentDemandStoreListResponse.builder()
.merchantId(o.getYqMerchantId()).merchantName(o.getYqMerchantName()).build()).collect(Collectors.toList());
storeList.addAll(yqStoreList);
}
return RopResponse.success(storeList);
}
/**
* 统计区域运营的招聘需求数量
*
* @param dto
* @return cn.com.glsx.framework.rop.response.RopResponse<cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandStatResponse>
* @author caiym
* @date 2025年10月20日 15:19:26
*/
public RopResponse<RecruitmentDemandStatResponse> statRecruitmentDemand(RecruitmentDemandDTO dto) {
log.info("statRecruitmentDemand dto:{}", dto);
return CommonUtil.convertRopResponse(recruitmentDemandRemote.statRecruitmentDemand(dto), RecruitmentDemandDTOConvert.INSTANCE::toRecruitmentDemandStatResponse);
}
/**
* 分页查询招聘需求
*
* @param request
* @return cn.com.glsx.framework.rop.response.RopResponse<cn.com.glsx.framework.core.beans.rpc.RpcPagination<cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandPageResponse>>
* @author caiym
* @date 2025年10月20日 15:19:37
*/
public RopResponse<RpcPagination<RecruitmentDemandPageResponse>> pageRecruitmentDemand(RecruitmentDemandPageRequest request) {
RpcPagination<RecruitmentDemandDTO> pagination = CommonUtil.getRpcPagination(RecruitmentDemandDTO.class);
pagination.getCondition().setRegionOperationId(CommonUtil.getLoginUserInfo().getUuid());
return CommonUtil.convertPaginationRopResponse(recruitmentDemandRemote.pageRecruitmentDemand(pagination), RecruitmentDemandDTOConvert.INSTANCE::toRecruitmentDemandPageResponse);
}
/**
* 标记招聘需求已确认
*
* @param request
* @return cn.com.glsx.framework.rop.response.RopResponse<java.lang.Boolean>
* @author caiym
* @date 2025年10月20日 15:19:47
*/
public RopResponse<Boolean> updateConfirmFlagToConfirmed(CommonIdRequest request) {
RecruitmentDemandDTO dto = RecruitmentDemandDTO.builder().id(request.getId()).updatedBy(CommonUtil.getAccountName()).build();
return CommonUtil.convertRopResponse(recruitmentDemandRemote.updateConfirmFlagToConfirmed(dto));
}
/**
* 获取招聘需求详情
*
* @param request
* @return cn.com.glsx.framework.rop.response.RopResponse<cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandDetailResponse>
* @author caiym
* @date 2025年10月20日 15:19:57
*/
public RopResponse<RecruitmentDemandDetailResponse> getRecruitmentDemandDetail(CommonIdRequest request) {
RecruitmentDemandDTO dto = RecruitmentDemandDTO.builder().id(request.getId()).build();
return CommonUtil.convertRopResponse(recruitmentDemandRemote.getRecruitmentDemandDetail(dto), RecruitmentDemandDTOConvert.INSTANCE::toRecruitmentDemandDetailResponse);
}
/**
* 添加招聘需求
*
* @param dto
* @return cn.com.glsx.framework.rop.response.RopResponse<java.lang.Boolean>
* @author caiym
* @date 2025年10月22日 16:55:16
*/
public RopResponse<Boolean> addRecruitmentDemand(RecruitmentDemandDTO dto) {
dto.setUpdatedBy(CommonUtil.getUserName());
LoginUserInfoResponse loginUserInfo = CommonUtil.getLoginUserInfo();
dto.setRegionOperationId(loginUserInfo.getUuid());
dto.setRegionOperationName(loginUserInfo.getName());
RpcResponse<RecruitmentDemandDTO> response = recruitmentDemandRemote.recruitmentDemandAdd(dto);
if (!response.isSuccess()) {
return RopResponse.error(response.getError());
}
return RopResponse.success(response.getResult().getId() != null);
}
}
package cn.com.glsx.dj.staff.miniprogram.service.recruitment;
import cn.com.glsx.dj.staff.dto.recruitment.RecruitmentResumeDTO;
import cn.com.glsx.dj.staff.miniprogram.request.recruitment.RecruitmentResumeProcessRequest;
import cn.com.glsx.dj.staff.miniprogram.util.CommonUtil;
import cn.com.glsx.dj.staff.remote.RecruitmentResumeRemote;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Service
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = RpcServiceException.class)
public class RecruitmentResumeService {
@Autowired
private RecruitmentResumeRemote recruitmentResumeRemote;
public RopResponse<Boolean> processResume(RecruitmentResumeProcessRequest request) {
RecruitmentResumeDTO dto = CommonUtil.convertRequest(RecruitmentResumeDTO.class);
dto.setUpdatedBy(CommonUtil.getAccountName());
dto.setProcessorName(CommonUtil.getUserName());
return CommonUtil.convertRopResponse(recruitmentResumeRemote.processResume(dto));
}
}
package cn.com.glsx.dj.staff.miniprogram.util;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.*;
/**
* @Title: AES.java
* @Description:
* @author Alvin.zengqi
* @date 2018年3月20日 下午6:21:11
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
public class AES {
public static boolean initialized = false;
/**
* AES解密
*
* @param content
* 密文
* @return
* @throws InvalidAlgorithmParameterException
* @throws NoSuchProviderException
*/
public byte[] decrypt(byte[] content, byte[] keyByte, byte[] ivByte) throws InvalidAlgorithmParameterException {
initialize();
try {
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
Key sKeySpec = new SecretKeySpec(keyByte, "AES");
// 初始化
cipher.init(Cipher.DECRYPT_MODE, sKeySpec, generateIV(ivByte));
byte[] result = cipher.doFinal(content);
return result;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (NoSuchProviderException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static void initialize() {
if (initialized) {
return;
}
Security.addProvider(new BouncyCastleProvider());
initialized = true;
}
/**
* 生成iv
* @param iv
* @return
* @throws Exception
*/
public static AlgorithmParameters generateIV(byte[] iv) throws Exception {
AlgorithmParameters params = AlgorithmParameters.getInstance("AES");
params.init(new IvParameterSpec(iv));
return params;
}
}
package cn.com.glsx.dj.staff.miniprogram.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* @Title: ApplicationContextRegister.java
* @Description:
* @author caiym
* @date 2021年01月18日 14:14
* @version V1.0.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2021
*/
@Component
public class ApplicationContextRegister implements ApplicationContextAware {
private static Logger logger = LoggerFactory.getLogger(ApplicationContextRegister.class);
private static ApplicationContext APPLICATION_CONTEXT;
/**
* 设置spring上下文
* @param applicationContext spring上下文
* @throws BeansException
* */
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
logger.debug("ApplicationContext registed-->{}", applicationContext);
APPLICATION_CONTEXT = applicationContext;
}
/**
* 获取容器
* @return
*/
public static ApplicationContext getApplicationContext() {
return APPLICATION_CONTEXT;
}
/**
* 获取容器对象
* @param type
* @param <T>
* @return
*/
public static <T> T getBean(Class<T> type) {
return APPLICATION_CONTEXT.getBean(type);
}
}
\ No newline at end of file
package cn.com.glsx.dj.staff.miniprogram.util;
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
public final class Base64 {
private static final int BASELENGTH = 128;
private static final int LOOKUPLENGTH = 64;
private static final int TWENTYFOURBITGROUP = 24;
private static final int EIGHTBIT = 8;
private static final int SIXTEENBIT = 16;
private static final int FOURBYTE = 4;
private static final int SIGN = -128;
private static final char PAD = '=';
private static final boolean fDebug = false;
private static final byte[] base64Alphabet = new byte[128];
private static final char[] lookUpBase64Alphabet = new char[64];
public Base64() {
}
private static boolean isWhiteSpace(char octect) {
return octect == ' ' || octect == '\r' || octect == '\n' || octect == '\t';
}
private static boolean isPad(char octect) {
return octect == '=';
}
private static boolean isData(char octect) {
return octect < 128 && base64Alphabet[octect] != -1;
}
public static String encode(byte[] binaryData) {
if (binaryData == null) {
return null;
} else {
int lengthDataBits = binaryData.length * 8;
if (lengthDataBits == 0) {
return "";
} else {
int fewerThan24bits = lengthDataBits % 24;
int numberTriplets = lengthDataBits / 24;
int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets;
char[] encodedData = new char[numberQuartet * 4];
byte k = 0;
byte l = 0;
byte b1 = 0;
byte b2 = 0;
int encodedIndex = 0;
int dataIndex = 0;
byte val2 = 0;
for(int i = 0; i < numberTriplets; ++i) {
b1 = binaryData[dataIndex++];
b2 = binaryData[dataIndex++];
byte b3 = binaryData[dataIndex++];
l = (byte)(b2 & 15);
k = (byte)(b1 & 3);
val2 = (b1 & -128) == 0 ? (byte)(b1 >> 2) : (byte)(b1 >> 2 ^ 192);
val2 = (b2 & -128) == 0 ? (byte)(b2 >> 4) : (byte)(b2 >> 4 ^ 240);
byte val3 = (b3 & -128) == 0 ? (byte)(b3 >> 6) : (byte)(b3 >> 6 ^ 252);
encodedData[encodedIndex++] = lookUpBase64Alphabet[val2];
encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | k << 4];
encodedData[encodedIndex++] = lookUpBase64Alphabet[l << 2 | val3];
encodedData[encodedIndex++] = lookUpBase64Alphabet[b3 & 63];
}
byte val1;
if (fewerThan24bits == 8) {
b1 = binaryData[dataIndex];
k = (byte)(b1 & 3);
val1 = (b1 & -128) == 0 ? (byte)(b1 >> 2) : (byte)(b1 >> 2 ^ 192);
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex++] = lookUpBase64Alphabet[k << 4];
encodedData[encodedIndex++] = '=';
encodedData[encodedIndex++] = '=';
} else if (fewerThan24bits == 16) {
b1 = binaryData[dataIndex];
b2 = binaryData[dataIndex + 1];
l = (byte)(b2 & 15);
k = (byte)(b1 & 3);
val1 = (b1 & -128) == 0 ? (byte)(b1 >> 2) : (byte)(b1 >> 2 ^ 192);
val2 = (b2 & -128) == 0 ? (byte)(b2 >> 4) : (byte)(b2 >> 4 ^ 240);
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | k << 4];
encodedData[encodedIndex++] = lookUpBase64Alphabet[l << 2];
encodedData[encodedIndex++] = '=';
}
return new String(encodedData);
}
}
}
public static byte[] decode(String encoded) {
if (encoded == null) {
return null;
} else {
encoded.replaceAll(" ", "+");
char[] base64Data = encoded.toCharArray();
int len = removeWhiteSpace(base64Data);
if (len % 4 != 0) {
return null;
} else {
int numberQuadruple = len / 4;
if (numberQuadruple == 0) {
return new byte[0];
} else {
byte[] decodedData = null;
byte b1 = 0;
byte b2 = 0;
byte b3 = 0;
byte b4 = 0;
char d1 = 0;
char d2 = 0;
char d3 = 0;
char d4 = 0;
int i = 0;
int encodedIndex = 0;
int dataIndex = 0;
for(decodedData = new byte[numberQuadruple * 3]; i < numberQuadruple - 1; ++i) {
if (!isData(d1 = base64Data[dataIndex++]) || !isData(d2 = base64Data[dataIndex++]) || !isData(d3 = base64Data[dataIndex++]) || !isData(d4 = base64Data[dataIndex++])) {
return null;
}
b1 = base64Alphabet[d1];
b2 = base64Alphabet[d2];
b3 = base64Alphabet[d3];
b4 = base64Alphabet[d4];
decodedData[encodedIndex++] = (byte)(b1 << 2 | b2 >> 4);
decodedData[encodedIndex++] = (byte)((b2 & 15) << 4 | b3 >> 2 & 15);
decodedData[encodedIndex++] = (byte)(b3 << 6 | b4);
}
if (isData(d1 = base64Data[dataIndex++]) && isData(d2 = base64Data[dataIndex++])) {
b1 = base64Alphabet[d1];
b2 = base64Alphabet[d2];
d3 = base64Data[dataIndex++];
d4 = base64Data[dataIndex++];
if (isData(d3) && isData(d4)) {
b3 = base64Alphabet[d3];
b4 = base64Alphabet[d4];
decodedData[encodedIndex++] = (byte)(b1 << 2 | b2 >> 4);
decodedData[encodedIndex++] = (byte)((b2 & 15) << 4 | b3 >> 2 & 15);
decodedData[encodedIndex++] = (byte)(b3 << 6 | b4);
return decodedData;
} else {
byte[] tmp;
if (isPad(d3) && isPad(d4)) {
if ((b2 & 15) != 0) {
return null;
} else {
tmp = new byte[i * 3 + 1];
System.arraycopy(decodedData, 0, tmp, 0, i * 3);
tmp[encodedIndex] = (byte)(b1 << 2 | b2 >> 4);
return tmp;
}
} else if (!isPad(d3) && isPad(d4)) {
b3 = base64Alphabet[d3];
if ((b3 & 3) != 0) {
return null;
} else {
tmp = new byte[i * 3 + 2];
System.arraycopy(decodedData, 0, tmp, 0, i * 3);
tmp[encodedIndex++] = (byte)(b1 << 2 | b2 >> 4);
tmp[encodedIndex] = (byte)((b2 & 15) << 4 | b3 >> 2 & 15);
return tmp;
}
} else {
return null;
}
}
} else {
return null;
}
}
}
}
}
private static int removeWhiteSpace(char[] data) {
if (data == null) {
return 0;
} else {
int newSize = 0;
int len = data.length;
for(int i = 0; i < len; ++i) {
if (!isWhiteSpace(data[i])) {
data[newSize++] = data[i];
}
}
return newSize;
}
}
static {
int i;
for(i = 0; i < 128; ++i) {
base64Alphabet[i] = -1;
}
for(i = 90; i >= 65; --i) {
base64Alphabet[i] = (byte)(i - 65);
}
for(i = 122; i >= 97; --i) {
base64Alphabet[i] = (byte)(i - 97 + 26);
}
for(i = 57; i >= 48; --i) {
base64Alphabet[i] = (byte)(i - 48 + 52);
}
base64Alphabet[43] = 62;
base64Alphabet[47] = 63;
for(i = 0; i <= 25; ++i) {
lookUpBase64Alphabet[i] = (char)(65 + i);
}
i = 26;
int j;
for(j = 0; i <= 51; ++j) {
lookUpBase64Alphabet[i] = (char)(97 + j);
++i;
}
i = 52;
for(j = 0; i <= 61; ++j) {
lookUpBase64Alphabet[i] = (char)(48 + j);
++i;
}
lookUpBase64Alphabet[62] = '+';
lookUpBase64Alphabet[63] = '/';
}
}
package cn.com.glsx.dj.staff.miniprogram.util;
import cn.com.glsx.dj.carboutique.constant.RopConstants;
import cn.com.glsx.dj.carboutique.enums.LoginRoleEnum;
import cn.com.glsx.dj.carboutique.response.LoginUserInfoResponse;
import cn.com.glsx.dj.smartcarlife.dto.MerchantListDTO;
import cn.com.glsx.dj.smartcarlife.dto.ServiceMerchantRefDTO;
import cn.com.glsx.dj.smartcarlife.dto.ServiceMerchantStaffAllocationDTO;
import cn.com.glsx.dj.smartcarlife.dto.ShopMerchantDirectorConfigDTO;
import cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.StaffBaseInfoDTO;
import cn.com.glsx.dj.smartcarlife.enums.DirectorTypeEnum;
import cn.com.glsx.dj.smartcarlife.enums.SceneTypeEnum;
import cn.com.glsx.dj.smartcarlife.enums.StaffAllocationEnum.StaffAllocationUserType;
import cn.com.glsx.dj.smartcarlife.model.SalesMerchantRelation;
import cn.com.glsx.dj.smartcarlife.remote.*;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.StatusEnum;
import cn.com.glsx.framework.core.util.DateUtils;
import cn.com.glsx.framework.rop.response.RopResponse;
import cn.com.glsx.merchants.model.request.MerchantStaffRequest;
import cn.com.glsx.merchants.model.response.MerchantStaffResponse;
import cn.com.glsx.merchants.remote.MerchantStaffRemote;
import cn.com.glsx.scrm.proxy.enums.AccountTypeEnum;
import cn.com.glsx.scrm.proxy.enums.UserTypeEnum;
import com.rop.RopRequestContext;
import com.rop.session.SimpleSession;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.oreframework.boot.env.OrePropertyConfigurer;
import org.oreframework.redis.service.RedisService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
@Component
public class CommonUtil {
private static final Logger logger = LoggerFactory.getLogger(CommonUtil.class);
//无权限时商户号ID
public static final int NO_PERMISSION_MERCHANT_ID = -1;
public static final List<Integer> NO_PERMISSION_LIST = new ArrayList<>(Arrays.asList(NO_PERMISSION_MERCHANT_ID));//没有权限时的列表数据
private static ServiceMerchantRefRemote serviceMerchantRefRemote;
private static RedisService redisService;
private static ServiceMerchantStaffAllocationRemote serviceMerchantStaffAllocationRemote;
private static ServiceMerchantRemote serviceMerchantRemote;
private static SalesMerchantRelationRemote salesMerchantRelationRemote;
private static ShopMerchantDirectorConfigRemote shopMerchantDirectorConfigRemote;
private static StaffBaseInfoRemote staffBaseInfoRemote;
private static SceneMerchantRefRemote sceneMerchantRefRemote;
private static MerchantStaffRemote merchantStaffRemote;
//求交集,如果其中一个为空集合 则直接返回另一个
public static List<Integer> getRetainMerchantIdList(final List<Integer> merchantId1List,final List<Integer> merchantId2List) {
if (CollectionUtils.isEmpty(merchantId1List) ) {
return merchantId2List;
}
if (CollectionUtils.isEmpty(merchantId2List) ) {
return merchantId1List;
}
List<Integer> list1 = new ArrayList<>(merchantId1List);
List<Integer> list2 = new ArrayList<>(merchantId2List);
list1.retainAll(list2);
if (CollectionUtils.isEmpty(list1)) {
list1.add(NO_PERMISSION_MERCHANT_ID);
}
return list1;
}
public static <T> RpcPagination<T> convertRpcPagination(RpcPagination<?> origPagination) {
RpcPagination<T> resp = new RpcPagination<>();
resp.setPageSize(origPagination.getPageSize());
resp.setPageNum(origPagination.getPageNum());
resp.setTotal(origPagination.getTotal());
resp.setPages(origPagination.getPages());
resp.setStartRow(origPagination.getStartRow());
resp.setEndRow(origPagination.getEndRow());
resp.setList(new ArrayList<>());
return resp;
}
public static <E,T> RopResponse<RpcPagination<T>> convertPaginationRopResponse(RpcResponse<RpcPagination<E>> rpcRes, ConvertHandler<E,T> handler) {
if(rpcRes.isSuccess()){
RpcPagination<E> result = rpcRes.getResult();
if(result == null) {
return RopResponse.success(null);
}
RpcPagination<T> resp = convertRpcPagination(result);
if (CollectionUtils.isNotEmpty(result.getList())) {
List<T> list = result.getList().stream().map(handler::convert).collect(Collectors.toList());
resp.setList(list);
}
return RopResponse.success(resp);
}
return RopResponse.error(rpcRes);
}
public static List<Integer> convert2Integer(String[] strArr) {
if(strArr == null || strArr.length == 0) {
return null;
}
List<Integer> list = new ArrayList<>();
for(String s:strArr) {
try {
list.add(Integer.valueOf(s));
}catch(Exception e) {
}
}
return list.isEmpty() ? null:list;
}
public static List<Byte> convertByte(String[] strArr) {
if (strArr == null || strArr.length == 0) {
return null;
}
List<Byte> list = new ArrayList<>();
for (String s : strArr) {
try {
list.add(Byte.valueOf(s));
} catch (Exception e) {
}
}
return list.isEmpty() ? null : list;
}
public static LoginRoleEnum getLoginRole() {
return getLoginRole(false);
}
public static LoginRoleEnum getLoginRole(boolean isSubLogin) {
LoginUserInfoResponse loginUserInfo = getLoginUserInfo(isSubLogin);
if(loginUserInfo == null || loginUserInfo.getLoginRole() == null) {
return null;
}
return LoginRoleEnum.getByValue(loginUserInfo.getLoginRole());
}
public static void setLoginRole(LoginUserInfoResponse loginUserInfo) {
if(loginUserInfo == null){
return;
}
if(loginUserInfo.getIsSuper() != null && loginUserInfo.getIsSuper()){
loginUserInfo.setLoginRole(LoginRoleEnum.SUPER.getValue());
return;
}
if(loginUserInfo.getUserType() != null && loginUserInfo.getUserType() == UserTypeEnum.MERCHANT.getValue()) {
loginUserInfo.setLoginRole(LoginRoleEnum.MERCHANT_MANAGER.getValue());
return;
}
MerchantStaffRequest staffRequest = new MerchantStaffRequest();
staffRequest.setMerchantNo(loginUserInfo.getMerchantId());
staffRequest.setStaffUuid(loginUserInfo.getUuid());
List<MerchantStaffResponse> staffList = merchantStaffRemote.findMerchantStaffListRemote(staffRequest).getResult();
logger.info("login Staff:{}",staffList);
if(CollectionUtils.isNotEmpty(staffList)) {
MerchantStaffResponse staff = staffList.get(0);
if(StringUtils.isNoneBlank(staff.getRoleName()) && staff.getRoleName().contains(OrePropertyConfigurer.getString("technician.roleName.keword","技师"))) {
loginUserInfo.setLoginRole(LoginRoleEnum.TECHNICIAN.getValue());
return;
}
}
ShopMerchantDirectorConfigDTO condition = ShopMerchantDirectorConfigDTO.builder()
.directorUserId(loginUserInfo.getUuid()).build();
if(Objects.equals(loginUserInfo.getSceneType(),SceneTypeEnum.SCENE1_1.getValue())){
condition.setDirectorType(DirectorTypeEnum.AREA_SUPERVISION_1_1.getValue());
}else if(Objects.equals(loginUserInfo.getSceneType(),SceneTypeEnum.SCENE1_0.getValue())){
condition.setDirectorType(DirectorTypeEnum.AREA_SUPERVISION_2_1.getValue());
}else {
condition.setDirectorTypes(Arrays.asList(DirectorTypeEnum.AREA_SUPERVISION_1_1.getValue(),DirectorTypeEnum.AREA_SUPERVISION_2_1.getValue()));
}
if(loginUserInfo.getShopMerchantId() != null) {
condition.setMerchantIdList(Arrays.asList(loginUserInfo.getShopMerchantId()));
}
List<ShopMerchantDirectorConfigDTO> list = shopMerchantDirectorConfigRemote.list(condition).getResult();
if(CollectionUtils.isNotEmpty(list)) {
loginUserInfo.setLoginRole(LoginRoleEnum.AREA_SUPERVISION.getValue());
return;
}
ShopMerchantDirectorConfigDTO dto = ShopMerchantDirectorConfigDTO.builder().directorUserId(loginUserInfo.getUuid()).directorTypes(Arrays.asList(DirectorTypeEnum.BOUTIQUE_DIRECTOR.getValue(), DirectorTypeEnum.QUOTATION_DIRECTOR.getValue())).build();
List<ShopMerchantDirectorConfigDTO> shopMerchantDirectorConfigs = shopMerchantDirectorConfigRemote.listWithYq(dto).getResult();
if(CollectionUtils.isNotEmpty(shopMerchantDirectorConfigs)) {
loginUserInfo.setLoginRole(LoginRoleEnum.SALES.getValue());
return;
}
dto = ShopMerchantDirectorConfigDTO.builder().directorUserId(loginUserInfo.getUuid()).directorTypes(Arrays.asList(DirectorTypeEnum.FLIGHT_SUPERVISION.getValue())).build();
shopMerchantDirectorConfigs = shopMerchantDirectorConfigRemote.listWithYq(dto).getResult();
if(CollectionUtils.isNotEmpty(shopMerchantDirectorConfigs)) {
loginUserInfo.setLoginRole(LoginRoleEnum.FLIGHT_SUPERVISION.getValue());
return;
}
ServiceMerchantStaffAllocationDTO staffAllocation = ServiceMerchantStaffAllocationDTO.builder()
.userType(StaffAllocationUserType.RESIDENT_MANAGER.getValue()).userId(loginUserInfo.getUuid()).latestFlag(StatusEnum.YES.getValue()).dataMonth(DateUtils.formatDate(new Date(), "yyyy-MM"))
.build();
staffAllocation.setYqMerchantId(loginUserInfo.getMerchantId());
List<ServiceMerchantStaffAllocationDTO> staffAllocationList = serviceMerchantStaffAllocationRemote.list(staffAllocation).getResult();
if(CollectionUtils.isNotEmpty(staffAllocationList)) {
loginUserInfo.setLoginRole(LoginRoleEnum.RESIDENT.getValue());
}
}
public static void setLoginRoleOnSelectMerchant(LoginUserInfoResponse loginUserInfo) {
loginUserInfo.setLoginRoleOnSelectMerchant(null);
if(loginUserInfo.getShopMerchantId() == null) {
return;
}
ShopMerchantDirectorConfigDTO condition = ShopMerchantDirectorConfigDTO.builder()
.directorUserId(loginUserInfo.getUuid()).build();
if(Objects.equals(loginUserInfo.getSceneType(),SceneTypeEnum.SCENE1_1.getValue())){
condition.setDirectorType(DirectorTypeEnum.AREA_SUPERVISION_1_1.getValue());
}else if(Objects.equals(loginUserInfo.getSceneType(),SceneTypeEnum.SCENE1_0.getValue())){
condition.setDirectorType(DirectorTypeEnum.AREA_SUPERVISION_2_1.getValue());
}else {
condition.setDirectorTypes(Arrays.asList(DirectorTypeEnum.AREA_SUPERVISION_1_1.getValue(),DirectorTypeEnum.AREA_SUPERVISION_2_1.getValue()));
}
if(loginUserInfo.getShopMerchantId() != null) {
condition.setMerchantIdList(Arrays.asList(loginUserInfo.getShopMerchantId()));
}
List<ShopMerchantDirectorConfigDTO> list = shopMerchantDirectorConfigRemote.list(condition).getResult();
if(CollectionUtils.isNotEmpty(list)) {
loginUserInfo.setLoginRoleOnSelectMerchant(LoginRoleEnum.AREA_SUPERVISION.getValue());
return;
}
ServiceMerchantStaffAllocationDTO staffAllocation = ServiceMerchantStaffAllocationDTO.builder()
.userType(StaffAllocationUserType.RESIDENT_MANAGER.getValue()).userId(loginUserInfo.getUuid()).latestFlag(StatusEnum.YES.getValue()).dataMonth(DateUtils.formatDate(new Date(), "yyyy-MM"))
.merchantId(loginUserInfo.getShopMerchantId())
.build();
List<ServiceMerchantStaffAllocationDTO> staffAllocationList = serviceMerchantStaffAllocationRemote.list(staffAllocation).getResult();
if(CollectionUtils.isNotEmpty(staffAllocationList)) {
loginUserInfo.setLoginRoleOnSelectMerchant(LoginRoleEnum.RESIDENT.getValue());
}
}
public static String getWsSessionId(String loginSessionId){
if(loginSessionId == null){
loginSessionId = ThreadLocalCache.getRopRequestContext().getSessionId();
}
if(StringUtils.isNotBlank(loginSessionId)){
String wsSessionId = redisService.get(RopConstants.LOGIN_WS_SESSION_PREFIX.concat(loginSessionId));
if(StringUtils.isNotBlank(wsSessionId)){
saveWsSessionId(loginSessionId,wsSessionId);
}
return wsSessionId;
}
return null;
}
public static void saveWsSessionId(String loginSessionId,String wsSessionId){
if(loginSessionId == null){
loginSessionId = ThreadLocalCache.getRopRequestContext().getSessionId();
}
redisService.set(RopConstants.LOGIN_WS_SESSION_PREFIX.concat(loginSessionId), wsSessionId,
3600 * 24);
}
public static <T> RpcPagination<T> getRpcPagination(Class<T> conditionClass){
RpcPagination<T> rpcPagination = new RpcPagination<>();
RopRequestContext content = ThreadLocalCache.getRopRequestContext();
rpcPagination.setPageNum(1);
rpcPagination.setPageSize(10);
if(StringUtils.isNotBlank(content.getParamValue("currentPage"))){
rpcPagination.setPageNum(Integer.valueOf(content.getParamValue("currentPage")));
}else if(StringUtils.isNotBlank(content.getParamValue("pageNum"))){
rpcPagination.setPageNum(Integer.valueOf(content.getParamValue("pageNum")));
}
if(StringUtils.isNotBlank(content.getParamValue("pageSize"))){
rpcPagination.setPageSize(Integer.valueOf(content.getParamValue("pageSize")));
}
rpcPagination.setCondition(convertRequest(conditionClass));
return rpcPagination;
}
public static <T, K> RpcPagination<T> getPageResponse(RpcPagination<K> pagination) {
RpcPagination<T> resp = new RpcPagination<>();
resp.setPageSize(pagination.getPageSize());
resp.setPageNum(pagination.getPageNum());
resp.setTotal(pagination.getTotal());
resp.setPages(pagination.getPages());
resp.setStartRow(pagination.getStartRow());
resp.setEndRow(pagination.getEndRow());
resp.setList(new ArrayList<>());
return resp;
}
public static <T> T convertRequest(Class<T> clazz){
try {
RopRequestContext content = ThreadLocalCache.getRopRequestContext();
T bean = clazz.newInstance();
BeanUtils.copyProperties(content.getRopRequest(), bean);
return bean;
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
public static<T> RopResponse<T> convertRopResponse(RpcResponse<T> rpcRes){
return RopResponse.result(rpcRes);
}
public static<T,V> RopResponse<V> convertRopResponse(RpcResponse<T> rpcRes,ConvertHandler<T,V> handler){
if(rpcRes.isSuccess()) {
return RopResponse.success(handler.convert(rpcRes.getResult()));
}
return RopResponse.error(rpcRes);
}
public static <T,V> RopResponse<List<V>> convertListRopResponse(RpcResponse<List<T>> rpcRes,ConvertHandler<T,V> handler){
if(rpcRes.isSuccess()){
if(CollectionUtils.isEmpty(rpcRes.getResult())) {
return RopResponse.success(null);
}else{
return RopResponse.success(rpcRes.getResult().stream().map(handler::convert).collect(Collectors.toList()));
}
}
return RopResponse.error(rpcRes);
}
public static LoginUserInfoResponse getLoginUserInfo(){
RopRequestContext context = ThreadLocalCache.getRopRequestContext();
SimpleSession session = (SimpleSession) context.getSession();
if(session == null){
return null;
}
LoginUserInfoResponse loginUserInfo = (LoginUserInfoResponse)session.getAttribute(RopConstants.LOGIN_SESSION);
return loginUserInfo;
}
public static LoginUserInfoResponse getLoginUserInfo(boolean isSubLogin){
RopRequestContext context = ThreadLocalCache.getRopRequestContext();
SimpleSession session = (SimpleSession) context.getSession();
if(session == null){
return null;
}
LoginUserInfoResponse loginUserInfo = (LoginUserInfoResponse)session.getAttribute(RopConstants.LOGIN_SESSION);
return isSubLogin ? loginUserInfo.getSubLoginUser():loginUserInfo;
}
public static Integer getMerchantId(){
LoginUserInfoResponse loginUserInfo = getLoginUserInfo();
if(loginUserInfo != null){
return loginUserInfo.getMerchantId();
}
return null;
}
public static Integer getMerchantId(boolean isSubLogin){
LoginUserInfoResponse loginUserInfo = getLoginUserInfo(isSubLogin);
if(loginUserInfo != null){
return loginUserInfo.getMerchantId();
}
return null;
}
public static String getAccountName(){
LoginUserInfoResponse loginUserInfo = getLoginUserInfo();
if(loginUserInfo != null){
return loginUserInfo.getAccountName();
}
return null;
}
public static String getUserName(){
LoginUserInfoResponse user = getLoginUserInfo();
return getUserName(user);
}
public static String getUserName(LoginUserInfoResponse user){
if(user == null){
return null;
}
if(user.getUserType() == UserTypeEnum.MERCHANT.getValue()) {
return user.getMerchantName();
}
return user.getName();
}
public static boolean isSuperOfLoginUser(boolean isSubLogin){
LoginUserInfoResponse loginUser = getLoginUserInfo(isSubLogin);
if(loginUser.getIsSuper() != null && loginUser.getIsSuper()){
return true;
}
return false;
}
public static boolean isSpecficBusinessRole(){
return isAreaSupervisionOfLoginUser() || isSaleOfLoginUser() || isFlightSupervisionOfLoginUser();
}
//当前登录用户是否是区域督导
public static boolean isAreaSupervisionOfLoginUser(){
return Objects.equals(CommonUtil.getLoginRole(),LoginRoleEnum.AREA_SUPERVISION);
}
//当前登录用户是否是广联销售
public static boolean isSaleOfLoginUser(){
return Objects.equals(CommonUtil.getLoginRole(),LoginRoleEnum.SALES);
}
//当前登录用户是否是飞行督导
public static boolean isFlightSupervisionOfLoginUser(){
return Objects.equals(CommonUtil.getLoginRole(),LoginRoleEnum.FLIGHT_SUPERVISION);
}
/**
* 当前登录用户所属商户是否是园区店
* @Description:
* @param isSubLogin
* @return
* @author zhoulm
* @date 2021年6月16日 下午3:45:02
*/
public static boolean isYqMerchantOfLoginUser(boolean isSubLogin){
LoginUserInfoResponse loginUser = getLoginUserInfo(isSubLogin);
if(CollectionUtils.isNotEmpty(loginUser.getMerchantAccountList()) &&
(loginUser.getMerchantAccountList().contains(String.valueOf(AccountTypeEnum.YQ_SHOP.getValue())) ||
loginUser.getMerchantAccountList().contains(String.valueOf(AccountTypeEnum.VIRTUAL_YQ_SHOP.getValue())))){
return true;
}
return false;
}
/**
* 当前登录用户所属商户是否是服务商
* @Description:
* @param isSubLogin
* @return
* @author zhoulm
* @date 2022年3月4日 上午11:08:39
*/
public static boolean isServieMerchantOfLoginUser(boolean isSubLogin){
LoginUserInfoResponse loginUser = getLoginUserInfo(isSubLogin);
if(CollectionUtils.isNotEmpty(loginUser.getMerchantAccountList()) &&
loginUser.getMerchantAccountList().contains(String.valueOf(AccountTypeEnum.SERVICE_SHOP.getValue()))){
return true;
}
return false;
}
/**
* 获取当前登录用户能查看的商户列表数据(以园区店维度)
* @return
*/
public static List<Integer> getMerchantIds(){
return getMerchantIds(false);
}
/**
* 获取当前登录用户能查看的商户列表数据(以园区店维度)
* @params isSubLogin 是否是子账号身份
* @return
*/
public static List<Integer> getMerchantIds(boolean isSubLogin){
List<Integer> list = new ArrayList<Integer>();
list.add(-1);
LoginUserInfoResponse loginUser = getLoginUserInfo();
if(isSubLogin){
loginUser = loginUser.getSubLoginUser();
}
if(loginUser == null){
logger.info("getMerchantIds1:{}",list);
return list;
}
if(loginUser.getIsSuper() != null && loginUser.getIsSuper()){
logger.info("getMerchantIds2:null");
return null;
}
if(LoginRoleEnum.AREA_SUPERVISION == CommonUtil.getLoginRole(isSubLogin)){
List<Integer> areaSupervisionYqMerchantIds = getAreaSupervisionYqMerchantIds();
logger.info("getMerchantIds6:{}",areaSupervisionYqMerchantIds);
return areaSupervisionYqMerchantIds;
}else if(LoginRoleEnum.SALES == CommonUtil.getLoginRole(isSubLogin)){
List<Integer> salesYqMerchantIds = getSalesYqMerchantIds();
logger.info("getMerchantIds7:{}",salesYqMerchantIds);
return salesYqMerchantIds;
}else if(isServieMerchantOfLoginUser(isSubLogin)) {
List<Integer> merchantIdList = loginUser.getPermissionMerchantIds();
if(CollectionUtils.isEmpty(merchantIdList)){
merchantIdList = new ArrayList<>();
merchantIdList.add(loginUser.getMerchantId());
}
ServiceMerchantRefDTO condition = new ServiceMerchantRefDTO();
condition.setMerchantIdList(merchantIdList);
condition.setMerchantType(AccountTypeEnum.SERVICE_SHOP.getValue());
List<Integer> yqMerchantIds = serviceMerchantRefRemote.listYqMerchantId(condition).getResult();
if(CollectionUtils.isNotEmpty(yqMerchantIds)){
logger.info("getMerchantIds5:{}",yqMerchantIds);
return yqMerchantIds;
}
}else{
if(CollectionUtils.isNotEmpty(loginUser.getPermissionMerchantIds())) {
list.addAll(loginUser.getPermissionMerchantIds());
}else {
list.add(loginUser.getMerchantId());
}
}
return list;
}
public static List<Integer> getAreaSupervisionYqMerchantIds() {
LoginUserInfoResponse loginUserInfo = CommonUtil.getLoginUserInfo();
List<Integer> shopMerchantIds = getAreaSupervisionShopMerchantIds(loginUserInfo);
if(shopMerchantIds.size() == 1 && shopMerchantIds.get(0) == NO_PERMISSION_MERCHANT_ID) {
return NO_PERMISSION_LIST;
}
List<MerchantListDTO> list = sceneMerchantRefRemote.queryYqSceneRefByShopIds(shopMerchantIds,loginUserInfo.getSceneType().intValue()).getResult();
if(CollectionUtils.isNotEmpty(list)){
return list.stream().map(MerchantListDTO::getMerchantId).distinct().collect(Collectors.toList());
}else{
logger.error("获取督导园区店商户权限失败,未查询到关联园区店数据");
return NO_PERMISSION_LIST;
}
}
public static List<Integer> getSalesYqMerchantIds() {
LoginUserInfoResponse loginUserInfo = CommonUtil.getLoginUserInfo();
if (loginUserInfo == null) {
logger.error("getSalesYqMerchantIds:{}", "登录用户信息为空");
return NO_PERMISSION_LIST;
}
if (!Objects.equals(loginUserInfo.getLoginRole(), LoginRoleEnum.SALES.getValue())) {
logger.error("getSalesYqMerchantIds:{}", "当前登录用户不是广联销售");
return NO_PERMISSION_LIST;
}
ShopMerchantDirectorConfigDTO dto = ShopMerchantDirectorConfigDTO.builder().directorUserId(loginUserInfo.getUuid())
.directorTypes(Arrays.asList(DirectorTypeEnum.BOUTIQUE_DIRECTOR.getValue(), DirectorTypeEnum.QUOTATION_DIRECTOR.getValue())).build();
RpcResponse<List<ShopMerchantDirectorConfigDTO>> res = shopMerchantDirectorConfigRemote.listWithYq(dto);
if(res.hasResult()){
return res.getResult().stream().map(ShopMerchantDirectorConfigDTO::getYqMerchantId).distinct().collect(Collectors.toList());
}else{
logger.error("获取广联销售园区店商户权限失败,msg:{}", res.getMessage());
return NO_PERMISSION_LIST;
}
}
public static List<Integer> getSpecificBusinessRoleShopMerchantIds(){
if (isAreaSupervisionOfLoginUser()) {
return getAreaSupervisionShopMerchantIds();
}else if (isSaleOfLoginUser()) {
return getSalesShopMerchantIds();
}else if(isFlightSupervisionOfLoginUser()) {
return getFlightSupervisionShopMerchantIds();
}
return Arrays.asList(NO_PERMISSION_MERCHANT_ID);
}
//获取区域督导角色可见的4S店商户列表
public static List<Integer> getAreaSupervisionShopMerchantIds() {
return getAreaSupervisionShopMerchantIds(CommonUtil.getLoginUserInfo());
}
public static List<Integer> getAreaSupervisionShopMerchantIds(LoginUserInfoResponse loginUserInfo) {
if (loginUserInfo == null) {
logger.error("getAreaSupervisionShopMerchantIds:{}", "登录用户信息为空");
return NO_PERMISSION_LIST;
}
if (!Objects.equals(loginUserInfo.getLoginRole(), LoginRoleEnum.AREA_SUPERVISION.getValue())) {
logger.error("getAreaSupervisionShopMerchantIds:{}", "当前登录用户不是区域运营");
return NO_PERMISSION_LIST;
}
ShopMerchantDirectorConfigDTO condition = ShopMerchantDirectorConfigDTO.builder()
.directorUserId(loginUserInfo.getUuid()).build();
if(Objects.equals(loginUserInfo.getSceneType(),SceneTypeEnum.SCENE1_1.getValue())){
condition.setDirectorType(DirectorTypeEnum.AREA_SUPERVISION_1_1.getValue());
}else if(Objects.equals(loginUserInfo.getSceneType(),SceneTypeEnum.SCENE1_0.getValue())){
condition.setDirectorType(DirectorTypeEnum.AREA_SUPERVISION_2_1.getValue());
}else {
return NO_PERMISSION_LIST;
}
List<ShopMerchantDirectorConfigDTO> list = shopMerchantDirectorConfigRemote.list(condition).getResult();
if(CollectionUtils.isNotEmpty(list)){
return list.stream().map(ShopMerchantDirectorConfigDTO::getMerchantId).distinct().collect(Collectors.toList());
}else{
logger.error("获取督导4S店商户权限失败,无关联门店");
return NO_PERMISSION_LIST;
}
}
public static List<Integer> getFlightSupervisionShopMerchantIds() {
return getFlightSupervisionShopMerchantIds(CommonUtil.getLoginUserInfo());
}
public static List<Integer> getFlightSupervisionShopMerchantIds(LoginUserInfoResponse loginUserInfo) {
if (loginUserInfo == null || !Objects.equals(loginUserInfo.getLoginRole(), LoginRoleEnum.FLIGHT_SUPERVISION.getValue())) {
return NO_PERMISSION_LIST;
}
ShopMerchantDirectorConfigDTO dto = ShopMerchantDirectorConfigDTO.builder().directorUserId(loginUserInfo.getUuid()).directorTypes(Arrays.asList(DirectorTypeEnum.FLIGHT_SUPERVISION.getValue())).build();
List<ShopMerchantDirectorConfigDTO> shopMerchantDirectorConfigs = shopMerchantDirectorConfigRemote.listWithYq(dto).getResult();
if(CollectionUtils.isNotEmpty(shopMerchantDirectorConfigs)){
return shopMerchantDirectorConfigs.stream().map(ShopMerchantDirectorConfigDTO::getMerchantId).distinct().collect(Collectors.toList());
}else{
return NO_PERMISSION_LIST;
}
}
//获取广联销售角色可见的4S店商户列表
public static List<Integer> getSalesShopMerchantIds() {
return getSalesShopMerchantIds(CommonUtil.getLoginUserInfo());
}
public static List<Integer> getSalesShopMerchantIds(LoginUserInfoResponse loginUserInfo) {
if (loginUserInfo == null) {
logger.error("getSalesShopMerchantIds:{}", "登录用户信息为空");
return NO_PERMISSION_LIST;
}
if (!Objects.equals(loginUserInfo.getLoginRole(), LoginRoleEnum.SALES.getValue())) {
logger.error("getSalesShopMerchantIds:{}", "当前登录用户不是广联销售");
return NO_PERMISSION_LIST;
}
ShopMerchantDirectorConfigDTO dto = ShopMerchantDirectorConfigDTO.builder().directorUserId(loginUserInfo.getUuid())
.directorTypes(Arrays.asList(DirectorTypeEnum.BOUTIQUE_DIRECTOR.getValue(), DirectorTypeEnum.QUOTATION_DIRECTOR.getValue())).build();
RpcResponse<List<ShopMerchantDirectorConfigDTO>> res = shopMerchantDirectorConfigRemote.listWithYq(dto);
if(res.hasResult()){
return res.getResult().stream().map(ShopMerchantDirectorConfigDTO::getMerchantId).distinct().collect(Collectors.toList());
}else{
logger.error("获取广联销售4s店商户权限失败,msg:{}", res.getMessage());
return NO_PERMISSION_LIST;
}
}
public static List<Integer> getShopMerchantIdList(List<Integer> shopMerchantIdList, Boolean isSuper, String phone) {
List<Integer> merchantIdList = null;
if (CollectionUtils.isNotEmpty(shopMerchantIdList)) {
merchantIdList = shopMerchantIdList;
} else if (isSuper) {
merchantIdList = serviceMerchantRemote.listAllShopMerchantId().getResult();
} else if (StringUtils.isNotBlank(phone)){
merchantIdList = salesMerchantRelationRemote.getByPhone(phone).getResult().stream()
.map(SalesMerchantRelation::getMerchantId).collect(Collectors.toList());
}
return merchantIdList;
}
/**
*
* @Description:当前手机号是否导师
* @param staffPhone
* @return
*/
public static boolean isMentor(String staffPhone) {
if(StringUtils.isBlank(staffPhone)) {
return false;
}
List<StaffBaseInfoDTO> list = staffBaseInfoRemote.listMentor(StaffBaseInfoDTO.builder().mentorPhone(staffPhone).build()).getResult();
return CollectionUtils.isNotEmpty(list);
}
@Autowired
public void setServiceMerchantRefRemote(ServiceMerchantRefRemote serviceMerchantRefRemote) {
CommonUtil.serviceMerchantRefRemote = serviceMerchantRefRemote;
}
@Autowired
public void setRedisService(RedisService redisService) {
CommonUtil.redisService = redisService;
}
@Autowired
public void setServiceMerchantStaffAllocationRemote(ServiceMerchantStaffAllocationRemote serviceMerchantStaffAllocationRemote) {
CommonUtil.serviceMerchantStaffAllocationRemote = serviceMerchantStaffAllocationRemote;
}
@Autowired
public void setServiceMerchantRemote(ServiceMerchantRemote serviceMerchantRemote) {
CommonUtil.serviceMerchantRemote = serviceMerchantRemote;
}
@Autowired
public void setSalesMerchantRelationRemote(SalesMerchantRelationRemote salesMerchantRelationRemote) {
CommonUtil.salesMerchantRelationRemote = salesMerchantRelationRemote;
}
@Autowired
public void setShopMerchantDirectorConfigRemote(ShopMerchantDirectorConfigRemote shopMerchantDirectorConfigRemote) {
CommonUtil.shopMerchantDirectorConfigRemote = shopMerchantDirectorConfigRemote;
}
@Autowired
public void setStaffBaseInfoRemote(StaffBaseInfoRemote staffBaseInfoRemote) {
CommonUtil.staffBaseInfoRemote = staffBaseInfoRemote;
}
@Autowired
public void setSceneMerchantRefRemote(SceneMerchantRefRemote sceneMerchantRefRemote) {
CommonUtil.sceneMerchantRefRemote = sceneMerchantRefRemote;
}
@Autowired
public void setMerchantStaffRemote(MerchantStaffRemote merchantStaffRemote) {
CommonUtil.merchantStaffRemote = merchantStaffRemote;
}
}
package cn.com.glsx.dj.staff.miniprogram.util;
public interface ConvertHandler<T,V> {
V convert(T source);
}
package cn.com.glsx.dj.staff.miniprogram.util;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class DataUtils {
public static final BigDecimal ONEHUNDRED_BIGDECIMAL = BigDecimal.valueOf(100);
public static BigDecimal calRate(Integer integer1, Integer integer2, int scale, int roundingMode, boolean withPercentSign){
if (integer1 != null
&& integer2 != null
&& integer2 != 0) {
if (withPercentSign) {
return BigDecimal.valueOf(integer1).multiply(BigDecimal.valueOf(100)).divide(BigDecimal.valueOf(integer2), scale, roundingMode);
}
return BigDecimal.valueOf(integer1).divide(BigDecimal.valueOf(integer2), scale, roundingMode);
}
return null;
}
public static BigDecimal calRate(BigDecimal bigDecimal1, BigDecimal bigDecimal2, int scale, int roundingMode, boolean withPercentSign){
if (bigDecimal1 != null
&& bigDecimal2 != null
&& bigDecimal2.compareTo(BigDecimal.ZERO) != 0) {
if (withPercentSign) {
return bigDecimal1.multiply(BigDecimal.valueOf(100)).divide(bigDecimal2, scale, roundingMode);
}
return bigDecimal1.divide(bigDecimal2, scale, roundingMode);
}
return null;
}
public static BigDecimal calRate(BigDecimal bigDecimal1, Integer integer2, int scale, int roundingMode){
if (bigDecimal1 != null
&& integer2 != null
&& integer2 != 0) {
return bigDecimal1.divide(BigDecimal.valueOf(integer2), scale, roundingMode);
}
return null;
}
public static BigDecimal calRate(BigDecimal bigDecimal1, Integer integer2, int scale, int roundingMode, boolean withPercentSign){
if (bigDecimal1 != null
&& integer2 != null
&& integer2 != 0) {
if (withPercentSign) {
return bigDecimal1.multiply(BigDecimal.valueOf(100)).divide(BigDecimal.valueOf(integer2), scale, roundingMode);
}
return bigDecimal1.divide(BigDecimal.valueOf(integer2), scale, roundingMode);
}
return null;
}
public static BigDecimal calRate(Integer integer1, Integer integer2, int scale, int roundingMode){
return calRate(integer1, integer2, scale, roundingMode, true);
}
public static BigDecimal calRate(Integer integer1, Integer integer2){
return calRate(integer1, integer2, 2, BigDecimal.ROUND_HALF_UP, true);
}
public static BigDecimal getYuanByFen(Long fen){
if (fen != null) {
return BigDecimal.valueOf(fen).divide(ONEHUNDRED_BIGDECIMAL, 2, BigDecimal.ROUND_HALF_UP);
}
return null;
}
public static BigDecimal getYuanByFenInt(Integer fen){
if (fen != null) {
return BigDecimal.valueOf(fen).divide(ONEHUNDRED_BIGDECIMAL, 2, BigDecimal.ROUND_HALF_UP);
}
return null;
}
public static BigDecimal getPerByDouble(Double rate, Integer scale, RoundingMode roundingMode){
if (rate != null) {
return BigDecimal.valueOf(rate).multiply(ONEHUNDRED_BIGDECIMAL).setScale(scale, roundingMode);
}
return null;
}
public static BigDecimal setScale(BigDecimal value, Integer scale, RoundingMode roundingMode){
if (value != null) {
return value.setScale(scale, roundingMode);
}
return null;
}
}
package cn.com.glsx.dj.staff.miniprogram.util;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.temporal.TemporalAdjusters;
import java.util.Calendar;
import java.util.Date;
public class DateUtils extends cn.com.glsx.framework.core.util.DateUtils {
private static DateFormat dateFormat= new SimpleDateFormat(DATE_FORMAT);
public static Integer getMonthInt(Date date){
Calendar now = Calendar.getInstance();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
now.setTime(dateFormat.parse(formatDate(date)));
int month = now.get(2) + 1;
return month;
} catch (ParseException var4) {
var4.printStackTrace();
return null;
}
}
public static Integer getYearInt(Date date) {
Calendar cl = Calendar.getInstance();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
cl.setTime(dateFormat.parse(formatDate(date)));
return cl.get(1);
} catch (ParseException var3) {
var3.printStackTrace();
return 0;
}
}
/**
*
* @Description: 获取当月开始时间 yyyy-MM-01 00:00:00
* @param yearMonth yyyy-MM
* @return
*/
public static String getMonthFirstTime(String yearMonth) {
return yearMonth.concat("-01 00:00:00");
}
/**
*
* @Description: 获取当月开始时间 yyyy-MM-(28-31) 23:59:59
* @param yearMonth yyyy-MM
* @return
*/
public static String getMonthEndtTime(String yearMonth) {
Date date = parseDate(getMonthFirstTime(yearMonth), "yyyy-MM-dd HH:mm:ss");
return getOffsetDate(getOffsetDate(date, 1, Calendar.MONTH), -1,Calendar.SECOND,"yyyy-MM-dd HH:mm:ss");
}
/**
* 获取当前月的第一天
*/
public static Date getFirstDayCurrentMonth() {
LocalDateTime firstDayOfMonth = LocalDateTime.of(LocalDate.from(LocalDateTime.now().with(TemporalAdjusters.firstDayOfMonth())), LocalTime.MIN);
return Date.from(firstDayOfMonth.atZone(ZoneId.systemDefault()).toInstant());
}
public static Date getLastDayCurrentMonth() {
LocalDateTime lastDayOfMonth = LocalDateTime.of(LocalDate.from(LocalDateTime.now().with(TemporalAdjusters.lastDayOfMonth())), LocalTime.MAX);
return Date.from(lastDayOfMonth.atZone(ZoneId.systemDefault()).toInstant());
}
}
package cn.com.glsx.dj.staff.miniprogram.util;
import javax.servlet.http.HttpServletRequest;
/**
* @author zhouhaibao
* @version 1.0
* @description: ip获取工具类
* @date 2021/8/20 10:09
*/
public class IpUtils {
public static String getIpAddr(HttpServletRequest request) {
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("X-Forwarded-For");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("X-Real-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
if (ip != null) {
String[] ss = ip.split(",");
if (ss.length > 0) {
return ss[0];
}
}
return ip;
}
}
package cn.com.glsx.dj.staff.miniprogram.util;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
/**
* 数字转中文类<br>
* 包括:
* <pre>
* 1. 数字转中文大写形式,比如一百二十一
* 2. 数字转金额用的大写形式,比如:壹佰贰拾壹
* 3. 转金额形式,比如:壹佰贰拾壹
* </pre>
*
* @author fanqun, looly
**/
public class NumberChineseFormatter {
/**
* 中文形式,奇数位置是简体,偶数位置是记账繁体,0共用<br>
* 使用混合数组提高效率和数组复用
**/
private static final char[] DIGITS = {'零', '一', '壹', '二', '贰', '三', '叁', '四', '肆', '五', '伍',
'六', '陆', '七', '柒', '八', '捌', '九', '玖'};
/**
* 金额
*/
private static final String MONEY_UNIT = "圆";
/**
* 汉字转阿拉伯数字的
*/
private static final ChineseUnit[] CHINESE_NAME_VALUE = {
new ChineseUnit(' ', 1, false),
new ChineseUnit('十', 10, false),
new ChineseUnit('拾', 10, false),
new ChineseUnit('百', 100, false),
new ChineseUnit('佰', 100, false),
new ChineseUnit('千', 1000, false),
new ChineseUnit('仟', 1000, false),
new ChineseUnit('万', 1_0000, true),
new ChineseUnit('亿', 1_0000_0000, true),
};
/**
* 阿拉伯数字转换成中文,小数点后四舍五入保留两位. 使用于整数、小数的转换.
*
* @param amount 数字
* @param isUseTraditional 是否使用繁体
* @return 中文
*/
public static String format(double amount, boolean isUseTraditional) {
return format(amount, isUseTraditional, false);
}
/**
* 阿拉伯数字转换成中文,小数点后四舍五入保留两位. 使用于整数、小数的转换.
*
* @param amount 数字
* @param isUseTraditional 是否使用繁体
* @param isMoneyMode 是否为金额模式
* @return 中文
*/
public static String format(double amount, boolean isUseTraditional, boolean isMoneyMode) {
if(0 == amount){
return "零";
}
Assert.checkBetween(amount, -99_9999_9999_9999.99, 99_9999_9999_9999.99,
"Number support only: (-99999999999999.99 ~ 99999999999999.99)!");
final StringBuilder chineseStr = new StringBuilder();
// 负数
if (amount < 0) {
chineseStr.append("负");
amount = -amount;
}
long yuan = Math.round(amount * 100);
final int fen = (int) (yuan % 10);
yuan = yuan / 10;
final int jiao = (int) (yuan % 10);
yuan = yuan / 10;
// 元
if(false == isMoneyMode || 0 != yuan){
// 金额模式下,无需“零元”
chineseStr.append(longToChinese(yuan, isUseTraditional));
if(isMoneyMode){
chineseStr.append(MONEY_UNIT);
}
}
if(0 == jiao && 0 == fen){
//无小数部分的金额结尾
if(isMoneyMode){
//chineseStr.append("整");
}
return chineseStr.toString();
}
// 小数部分
if(false == isMoneyMode){
chineseStr.append("点");
}
// 角
if(0 == yuan && 0 == jiao){
// 元和角都为0时,只有非金额模式下补“零”
if(false == isMoneyMode){
chineseStr.append("零");
}
}else{
chineseStr.append(numberToChinese(jiao, isUseTraditional));
if(isMoneyMode && 0 != jiao){
chineseStr.append("角");
}
}
// 分
if(0 != fen){
chineseStr.append(numberToChinese(fen, isUseTraditional));
if(isMoneyMode){
chineseStr.append("分");
}
}
return chineseStr.toString();
}
/**
* 阿拉伯数字(支持正负整数)转换成中文
*
* @param amount 数字
* @param isUseTraditional 是否使用繁体
* @return 中文
* @since 5.7.17
*/
public static String format(long amount, boolean isUseTraditional){
if(0 == amount){
return "零";
}
Assert.checkBetween(amount, -99_9999_9999_9999.99, 99_9999_9999_9999.99,
"Number support only: (-99999999999999.99 ~ 99999999999999.99)!");
final StringBuilder chineseStr = new StringBuilder();
// 负数
if (amount < 0) {
chineseStr.append("负");
amount = -amount;
}
chineseStr.append(longToChinese(amount, isUseTraditional));
return chineseStr.toString();
}
/**
* 阿拉伯数字(支持正负整数)四舍五入后转换成中文节权位简洁计数单位,例如 -5_5555 =》 -5.56万
*
* @param amount 数字
* @return 中文
*/
public static String formatSimple(long amount) {
if (amount < 1_0000 && amount > -1_0000) {
return String.valueOf(amount);
}
String res;
if (amount < 1_0000_0000 && amount > -1_0000_0000) {
res = NumberUtil.div(amount, 1_0000, 2) + "万";
} else if (amount < 1_0000_0000_0000L && amount > -1_0000_0000_0000L) {
res = NumberUtil.div(amount, 1_0000_0000, 2) + "亿";
} else {
res = NumberUtil.div(amount, 1_0000_0000_0000L, 2) + "万亿";
}
return res;
}
/**
* 格式化-999~999之间的数字<br>
* 这个方法显示10~19以下的数字时使用"十一"而非"一十一"。
*
* @param amount 数字
* @param isUseTraditional 是否使用繁体
* @return 中文
* @since 5.7.17
*/
public static String formatThousand(int amount, boolean isUseTraditional){
Assert.checkBetween(amount, -999, 999, "Number support only: (-999 ~ 999)!");
final String chinese = thousandToChinese(amount, isUseTraditional);
if(amount < 20 && amount > 10){
// "十一"而非"一十一"
return chinese.substring(1);
}
return chinese;
}
/**
* 数字字符转中文,非数字字符原样返回
*
* @param c 数字字符
* @param isUseTraditional 是否繁体
* @return 中文字符
* @since 5.3.9
*/
public static String numberCharToChinese(char c, boolean isUseTraditional) {
if (c < '0' || c > '9') {
return String.valueOf(c);
}
return String.valueOf(numberToChinese(c - '0', isUseTraditional));
}
/**
* 阿拉伯数字整数部分转换成中文,只支持正数
*
* @param amount 数字
* @param isUseTraditional 是否使用繁体
* @return 中文
*/
private static String longToChinese(long amount, boolean isUseTraditional) {
if(0 == amount){
return "零";
}
//将数字以万为单位分为多份
int[] parts = new int[4];
for (int i = 0; amount != 0; i++) {
parts[i] = (int) (amount % 10000);
amount = amount / 10000;
}
final StringBuilder chineseStr = new StringBuilder();
int partValue;
String partChinese;
// 千
partValue = parts[0];
if(partValue > 0){
partChinese = thousandToChinese(partValue, isUseTraditional);
chineseStr.insert(0, partChinese);
if(partValue < 1000){
// 和万位之间空0,则补零,如一万零三百
addPreZero(chineseStr);
}
}
// 万
partValue = parts[1];
if(partValue > 0){
if((partValue % 10 == 0 && parts[0] > 0)){
// 如果"万"的个位是0,则补零,如十万零八千
addPreZero(chineseStr);
}
partChinese = thousandToChinese(partValue, isUseTraditional);
chineseStr.insert(0, partChinese + "万");
if(partValue < 1000){
// 和亿位之间空0,则补零,如一亿零三百万
addPreZero(chineseStr);
}
} else{
addPreZero(chineseStr);
}
// 亿
partValue = parts[2];
if(partValue > 0){
if((partValue % 10 == 0 && parts[1] > 0)){
// 如果"万"的个位是0,则补零,如十万零八千
addPreZero(chineseStr);
}
partChinese = thousandToChinese(partValue, isUseTraditional);
chineseStr.insert(0, partChinese + "亿");
if(partValue < 1000){
// 和万亿位之间空0,则补零,如一万亿零三百亿
addPreZero(chineseStr);
}
} else{
addPreZero(chineseStr);
}
// 万亿
partValue = parts[3];
if(partValue > 0){
if(parts[2] == 0){
chineseStr.insert(0, "亿");
}
partChinese = thousandToChinese(partValue, isUseTraditional);
chineseStr.insert(0, partChinese + "万");
}
if(StrUtil.isNotEmpty(chineseStr) && '零' == chineseStr.charAt(0)){
return chineseStr.substring(1);
}
return chineseStr.toString();
}
/**
* 把一个 0~9999 之间的整数转换为汉字的字符串,如果是 0 则返回 ""
*
* @param amountPart 数字部分
* @param isUseTraditional 是否使用繁体单位
* @return 转换后的汉字
*/
private static String thousandToChinese(int amountPart, boolean isUseTraditional) {
if (amountPart == 0) {
// issue#I4R92H@Gitee
return String.valueOf(DIGITS[0]);
}
int temp = amountPart;
StringBuilder chineseStr = new StringBuilder();
boolean lastIsZero = true; // 在从低位往高位循环时,记录上一位数字是不是 0
for (int i = 0; temp > 0; i++) {
int digit = temp % 10;
if (digit == 0) { // 取到的数字为 0
if (false == lastIsZero) {
// 前一个数字不是 0,则在当前汉字串前加“零”字;
chineseStr.insert(0, "零");
}
lastIsZero = true;
} else { // 取到的数字不是 0
chineseStr.insert(0, numberToChinese(digit, isUseTraditional) + getUnitName(i, isUseTraditional));
lastIsZero = false;
}
temp = temp / 10;
}
return chineseStr.toString();
}
/**
* 把中文转换为数字 如 二百二十 220<br>
* 见:https://www.d5.nz/read/sfdlq/text-part0000_split_030.html
* <ul>
* <li>一百一十二 -》 112</li>
* <li>一千零一十二 -》 1012</li>
* </ul>
*
* @param chinese 中文字符
* @return 数字
* @since 5.6.0
*/
public static int chineseToNumber(String chinese) {
final int length = chinese.length();
int result = 0;
// 节总和
int section = 0;
int number = 0;
ChineseUnit unit = null;
char c;
for (int i = 0; i < length; i++) {
c = chinese.charAt(i);
final int num = chineseToNumber(c);
if (num >= 0) {
if (num == 0) {
// 遇到零时节结束,权位失效,比如两万二零一十
if (number > 0 && null != unit) {
section += number * (unit.value / 10);
}
unit = null;
} else if (number > 0) {
// 多个数字同时出现,报错
throw new IllegalArgumentException(StrUtil.format("Bad number '{}{}' at: {}", chinese.charAt(i - 1), c, i));
}
// 普通数字
number = num;
} else {
unit = chineseToUnit(c);
if (null == unit) {
// 出现非法字符
throw new IllegalArgumentException(StrUtil.format("Unknown unit '{}' at: {}", c, i));
}
//单位
if (unit.secUnit) {
// 节单位,按照节求和
section = (section + number) * unit.value;
result += section;
section = 0;
} else {
// 非节单位,和单位前的单数字组合为值
int unitNumber = number;
if(0 == number && 0 == i){
// issue#1726,对于单位开头的数组,默认赋予1
// 十二 -> 一十二
// 百二 -> 一百二
unitNumber = 1;
}
section += (unitNumber * unit.value);
}
number = 0;
}
}
if (number > 0 && null != unit) {
number = number * (unit.value / 10);
}
return result + section + number;
}
/**
* 查找对应的权对象
*
* @param chinese 中文权位名
* @return 权对象
*/
private static ChineseUnit chineseToUnit(char chinese) {
for (ChineseUnit chineseNameValue : CHINESE_NAME_VALUE) {
if (chineseNameValue.name == chinese) {
return chineseNameValue;
}
}
return null;
}
/**
* 将汉字单个数字转换为int类型数字
*
* @param chinese 汉字数字,支持简体和繁体
* @return 数字,-1表示未找到
* @since 5.6.4
*/
private static int chineseToNumber(char chinese) {
if ('两' == chinese) {
// 口语纠正
chinese = '二';
}
final int i = ArrayUtil.indexOf(DIGITS, chinese);
if (i > 0) {
return (i + 1) / 2;
}
return i;
}
/**
* 单个数字转汉字
*
* @param number 数字
* @param isUseTraditional 是否使用繁体
* @return 汉字
*/
private static char numberToChinese(int number, boolean isUseTraditional) {
if (0 == number) {
return DIGITS[0];
}
return DIGITS[number * 2 - (isUseTraditional ? 0 : 1)];
}
/**
* 获取对应级别的单位
*
* @param index 级别,0表示各位,1表示十位,2表示百位,以此类推
* @param isUseTraditional 是否使用繁体
* @return 单位
*/
private static String getUnitName(int index, boolean isUseTraditional) {
if (0 == index) {
return StrUtil.EMPTY;
}
return String.valueOf(CHINESE_NAME_VALUE[index * 2 - (isUseTraditional ? 0 : 1)].name);
}
/**
* 权位
*
* @author totalo
* @since 5.6.0
*/
private static class ChineseUnit {
/**
* 中文权名称
*/
private final char name;
/**
* 10的倍数值
*/
private final int value;
/**
* 是否为节权位,它不是与之相邻的数字的倍数,而是整个小节的倍数。<br>
* 例如二十三万,万是节权位,与三无关,而和二十三关联
*/
private final boolean secUnit;
/**
* 构造
*
* @param name 名称
* @param value 值,即10的倍数
* @param secUnit 是否为节权位
*/
public ChineseUnit(char name, int value, boolean secUnit) {
this.name = name;
this.value = value;
this.secUnit = secUnit;
}
}
private static void addPreZero(StringBuilder chineseStr){
if(StrUtil.isEmpty(chineseStr)){
return;
}
final char c = chineseStr.charAt(0);
if('零' != c){
chineseStr.insert(0, '零');
}
}
}
package cn.com.glsx.dj.staff.miniprogram.util;
import lombok.Data;
import java.util.List;
/**
* 分页对象
*/
@Data
public class Pagination<T> {
private Integer pageSize;
private Integer pageNum;
private Integer count;
private List<T> data;
}
package cn.com.glsx.dj.staff.miniprogram.util;
import com.rop.RopRequestContext;
public class ThreadLocalCache {
private static ThreadLocal<RopRequestContext> ropRequestContextCache = new ThreadLocal<RopRequestContext>();
public static void setRopRequestContext(RopRequestContext ropRequestContext){
ropRequestContextCache.set(ropRequestContext);
}
public static RopRequestContext getRopRequestContext(){
return ropRequestContextCache.get();
}
public static void removeRopRequestContext(){
ropRequestContextCache.remove();
}
}
package cn.com.glsx.dj.staff.miniprogram.util;
import java.nio.charset.Charset;
import java.util.Arrays;
/**
* @Title: WxPKCS7Encoder.java
* @Description:
* @author Alvin.zengqi
* @date 2018年3月20日 下午6:30:08
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
public class WxPKCS7Encoder {
private static final Charset CHARSET = Charset.forName("utf-8");
private static final int BLOCK_SIZE = 32;
/**
* 获得对明文进行补位填充的字节.
*
* @param count 需要进行填充补位操作的明文字节个数
* @return 补齐用的字节数组
*/
public static byte[] encode(int count) {
// 计算需要填充的位数
int amountToPad = BLOCK_SIZE - (count % BLOCK_SIZE);
if (amountToPad == 0) {
amountToPad = BLOCK_SIZE;
}
// 获得补位所用的字符
char padChr = chr(amountToPad);
String tmp = new String();
for (int index = 0; index < amountToPad; index++) {
tmp += padChr;
}
return tmp.getBytes(CHARSET);
}
/**
* 删除解密后明文的补位字符
*
* @param decrypted 解密后的明文
* @return 删除补位字符后的明文
*/
public static byte[] decode(byte[] decrypted) {
int pad = decrypted[decrypted.length - 1];
if (pad < 1 || pad > BLOCK_SIZE) {
pad = 0;
}
return Arrays.copyOfRange(decrypted, 0, decrypted.length - pad);
}
/**
* 将数字转化成ASCII码对应的字符,用于对明文进行补码
*
* @param a 需要转化的数字
* @return 转化得到的字符
*/
public static char chr(int a) {
byte target = (byte) (a & 0xFF);
return (char) target;
}
}
server.port=8594
server.servlet.context-path=/rop-dj-staff-miniprogram
server.display-name=rop-dj-staff-miniprogram
logging.config=classpath:logback.xml
logging.path=/data/java_log/jetty/rop-dj-staff-miniprogram/rop-dj-staff-miniprogram.log
logging.level.root=INFO
ore.starter.class-name=Main
# diamond config
ore.diamond.group=dijia
ore.diamond.dataId=rop-dj-staff-miniprogram
ore.diamond.env=release
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<property resource="config/application.properties" />
<property name="APP_NAME" value="${server.display-name}" />
<property name="LOG_PATH" value="${logging.path}" />
<property name="LOG_LEVEL" value="${logging.level}" />
<contextName>${APP_NAME}</contextName>
<turboFilter class="org.oreframework.boot.logging.logback.OreBootTurboFilter">
<Marker>oreframework</Marker>
</turboFilter>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="org.oreframework.commons.log.OrePatternLayout">
<pattern>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [${APP_NAME}] [%traceid] [%thread] %-5level [%logger{36}.%method %line] - %msg%n</pattern>
</pattern>
</layout>
</appender>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- <Encoding> Label Old version of this label can not be used -->
<!-- <Encoding>UTF-8</Encoding> -->
<File>${LOG_PATH}</File>
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> -->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${LOG_PATH}.%d{yyyy-MM-dd}.%i</FileNamePattern>
<MaxHistory>15</MaxHistory>
<maxFileSize>200MB</maxFileSize>
</rollingPolicy>
<layout class="org.oreframework.commons.log.OrePatternLayout">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [${APP_NAME}] [%traceid] [%thread] %-5level [%logger{36}.%method %line] - %msg%n</pattern>
</layout>
<!-- 根据文件大小滚动,不支持 SizeBasedTriggeringPolicy 这种配置-->
<!-- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>200MB</MaxFileSize>
</triggeringPolicy> -->
</appender>
<root level="${LOG_LEVEL}">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
\ No newline at end of file
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/application.name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
#LOGS_FILE=`sed '/log4j.appender.logToFile.File/!d;s/.*=//' classes/log4j.properties | tr -d '\r'`
LOGS_FILE=`sed '/name="LOG_PATH"/!d;s/.*value="\(.*\)".*/\1/g' classes/logback.xml`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
LOGS_DIR=`dirname $LOGS_FILE`
else
LOGS_DIR=$DEPLOY_DIR/logs
fi
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
DUMP_DIR=$LOGS_DIR/dump
if [ ! -d $DUMP_DIR ]; then
mkdir $DUMP_DIR
fi
DUMP_DATE=`date +%Y%m%d%H%M%S`
DATE_DIR=$DUMP_DIR/$DUMP_DATE
if [ ! -d $DATE_DIR ]; then
mkdir $DATE_DIR
fi
echo -e "Dumping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
jstack $PID > $DATE_DIR/jstack-$PID.dump 2>&1
echo -e ".\c"
jinfo $PID > $DATE_DIR/jinfo-$PID.dump 2>&1
echo -e ".\c"
jstat -gcutil $PID > $DATE_DIR/jstat-gcutil-$PID.dump 2>&1
echo -e ".\c"
jstat -gccapacity $PID > $DATE_DIR/jstat-gccapacity-$PID.dump 2>&1
echo -e ".\c"
jmap $PID > $DATE_DIR/jmap-$PID.dump 2>&1
echo -e ".\c"
jmap -heap $PID > $DATE_DIR/jmap-heap-$PID.dump 2>&1
echo -e ".\c"
jmap -histo $PID > $DATE_DIR/jmap-histo-$PID.dump 2>&1
echo -e ".\c"
if [ -r /usr/sbin/lsof ]; then
/usr/sbin/lsof -p $PID > $DATE_DIR/lsof-$PID.dump
echo -e ".\c"
fi
done
if [ -r /bin/netstat ]; then
/bin/netstat -an > $DATE_DIR/netstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/iostat ]; then
/usr/bin/iostat > $DATE_DIR/iostat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/mpstat ]; then
/usr/bin/mpstat > $DATE_DIR/mpstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/vmstat ]; then
/usr/bin/vmstat > $DATE_DIR/vmstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/free ]; then
/usr/bin/free -t > $DATE_DIR/free.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/sar ]; then
/usr/bin/sar > $DATE_DIR/sar.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/uptime ]; then
/usr/bin/uptime > $DATE_DIR/uptime.dump 2>&1
echo -e ".\c"
fi
echo "OK!"
echo "DUMP: $DATE_DIR"
#!/bin/bash
ENV=$1
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
cd `dirname $0`
./stop.sh
./start.sh $ENV
\ No newline at end of file
#!/bin/bash
cd `dirname $0`
if [ "$1" = "start" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./start.sh $ENV
else
if [ "$1" = "stop" ]; then
./stop.sh
else
if [ "$1" = "debug" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./start.sh $ENV debug
else
if [ "$1" = "restart" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./restart.sh $ENV
else
if [ "$1" = "dump" ]; then
./dump.sh
else
echo "ERROR: Please input argument: start or stop or debug or restart or dump"
exit 1
fi
fi
fi
fi
fi
#!/bin/bash
JAVA_HOME="/app/soft/jdk1.8.0_20"
ENV=$1
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/server.display-name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
SERVER_PORT=`sed '/server.port/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
LOGS_FILE=`sed '/logging.path/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
echo "server name is $SERVER_NAME"
echo "server port is $SERVER_PORT"
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -n "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME already started!"
echo "PID: $PIDS"
exit 1
fi
if [ -n "$SERVER_PORT" ]; then
SERVER_PORT_COUNT=`netstat -tln | grep $SERVER_PORT | wc -l`
if [ $SERVER_PORT_COUNT -gt 0 ]; then
echo "ERROR: The $SERVER_NAME port $SERVER_PORT already used!"
exit 1
fi
fi
LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
LOGS_DIR=`dirname $LOGS_FILE`
else
LOGS_DIR=$DEPLOY_DIR/logs
fi
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
STDOUT_FILE=$LOGS_DIR/stdout.log
LIB_DIR=$DEPLOY_DIR/lib
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'|tr "\n" ":"`
JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
JAVA_DEBUG_OPTS=""
if [ "$2" = "debug" ]; then
JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
fi
JAVA_JMX_OPTS=""
if [ "$2" = "jmx" ]; then
JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
fi
JAVA_MEM_OPTS=""
BITS=`file $JAVA_HOME/bin/java | grep 64-bit`
if [ -n "$BITS" ]; then
JAVA_MEM_OPTS=" -server -Xmx1g -Xms1g -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
else
JAVA_MEM_OPTS=" -server -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
fi
echo -e "Starting the $SERVER_NAME ...\c"
nohup $JAVA_HOME/bin/java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS -classpath $CONF_DIR:$LIB_JARS org.oreframework.boot.bootstrap.OreBootApplication env=$ENV > $STDOUT_FILE 2>&1 &
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
if [ -n "$SERVER_PORT" ]; then
COUNT=`netstat -an | grep $SERVER_PORT | wc -l`
else
COUNT=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
fi
if [ $COUNT -gt 0 ]; then
break
fi
done
echo "OK!"
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" | awk '{print $2}'`
echo "PID: $PIDS"
echo "STDOUT: $STDOUT_FILE"
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/application.name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
#if [ "$1" != "skip" ]; then
#$BIN_DIR/dump.sh
#fi
echo -e "Stopping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
kill $PID > /dev/null 2>&1
done
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=1
for PID in $PIDS ; do
PID_EXIST=`ps --no-heading -p $PID`
if [ -n "$PID_EXIST" ]; then
COUNT=0
break
fi
done
done
echo "OK!"
echo "PID: $PIDS"
package cn.com.glsx.dj.staff.miniprogram;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
* @Title: IpConfiguration.java
* @Description:
* @author Alvin
* @date 2019年9月3日 上午11:05:17
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Component
public class IpConfiguration implements ApplicationListener<WebServerInitializedEvent> {
private int serverPort;
@Override
public void onApplicationEvent(WebServerInitializedEvent event) {
serverPort = event.getWebServer().getPort();
}
public int getPort(){
return serverPort;
}
}
package cn.com.glsx.dj.staff.miniprogram.controller;
import cn.com.glsx.dj.staff.miniprogram.IpConfiguration;
import com.alibaba.fastjson.JSONObject;
import com.rop.utils.RopUtils;
import org.apache.commons.lang.StringUtils;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.DefaultUriTemplateHandler;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import java.util.Map;
import java.util.Map.Entry;
/**
* @Title: BaseControllerTest.java
* @Description:
* @author Alvin
* @date 2019年9月3日 上午9:32:12
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class BaseControllerTest{
String url = "http://localhost:";
@Value("${server.servlet.context-path}")
String contextPath;
@Autowired
private IpConfiguration ip;
final String appKey = "48e5e13229b82c1b4e6e8c96151f0637";
final String secret = "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b";
protected String sessionId;
@Before
public void setUp() throws Exception {
url = url.concat(String.valueOf(ip.getPort())).concat(contextPath).concat("/router");
//sessionId = mockLogin();
}
public String mockLogin() throws Exception {
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(4);
params.add("v", "1.0.0");
params.add("method", "dj.api.smartcarlife.mocklogin");
JSONObject jsonObject = JSONObject.parseObject(post(params));
System.out.println(jsonObject);
String sessionId = (String) jsonObject.get("data");
System.out.println("get sessionId:"+sessionId);
return sessionId;
}
public String get(MultiValueMap<String, String> paramsMap) throws Exception{
return get(paramsMap, String.class);
}
public void addNotSignParams(MultiValueMap<String, String> params){
}
public <T> T get(MultiValueMap<String, String> paramsMap, Class<T> responseType) throws Exception{
MultiValueMap<String, String> params = getSysParams();
params.putAll(paramsMap);
for(Entry<String, String> entry:params.toSingleValueMap().entrySet()){
if(StringUtils.isEmpty(entry.getValue())){
params.remove(entry.getKey());
}
}
String sign = RopUtils.sign(params.toSingleValueMap(), secret);
params.add("sign", sign);
// this.addNotSignParams(params);
RestTemplate rest = new RestTemplate();
RopUriTemplateHandler uriTemplateHandler = new RopUriTemplateHandler();
rest.setUriTemplateHandler(uriTemplateHandler);
return rest.getForObject(url, responseType, params.toSingleValueMap());
}
public String post(MultiValueMap<String, String> paramsMap) throws Exception{
return post(paramsMap, String.class);
}
public <T> T post(MultiValueMap<String, String> paramsMap, Class<T> responseType) throws Exception{
MultiValueMap<String, String> params = getSysParams();
params.putAll(paramsMap);
for(Entry<String, String> entry:params.toSingleValueMap().entrySet()){
if(StringUtils.isEmpty(entry.getValue())){
params.remove(entry.getKey());
}
}
String sign = RopUtils.sign(params.toSingleValueMap(), secret);
params.add("sign", sign);
this.addNotSignParams(params);
return new RestTemplate().postForObject(url, params, responseType);
}
public MultiValueMap<String, String> getSysParams(){
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(16);
params.add("appKey", appKey);
params.add("format", "json");
params.add("locale", "zh_CN");
if(sessionId != null){
params.add("sessionId", sessionId);
}
return params;
}
class RopUriTemplateHandler extends DefaultUriTemplateHandler{
@Override
protected UriComponents expandAndEncode(UriComponentsBuilder builder,
Map<String, ?> uriVariables) {
if(uriVariables != null && !uriVariables.isEmpty()){
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
for(Entry<String, ?> entry:uriVariables.entrySet()){
params.add(entry.getKey(), entry.getValue().toString());
}
builder.queryParams(params);
}
return super.expandAndEncode(builder, uriVariables);
}
}
}
package cn.com.glsx.dj.staff.miniprogram.controller;
import org.junit.Test;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
/**
* @Title: ExampleControllerTest.java
* @Description:
* @author Alvin
* @date 2019年9月3日 上午9:33:00
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
public class ExampleControllerTest extends BaseControllerTest {
@Test
public void testGetExample() throws Exception{
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(4);
params.add("v", "1.0.0");
params.add("method", "org.ore.api.example.insession");
params.add("name", "alvin");
params.add("sessionId", "adaf5df0-e106-4b41-a947-84889582dcaf");
System.out.println(get(params));
}
@Test
public void testLoginExample() throws Exception{
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(4);
params.add("v", "1.0.0");
params.add("method", "org.ore.api.example.login");
params.add("userName", "alvin");
params.add("password", "123456");
System.out.println(post(params));
}
}
package cn.com.glsx.dj.staff.miniprogram.controller;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
public class LoginControllerTest extends BaseControllerTest{
@Test
public void testLogin() throws Exception{
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(4);
params.add("v", "1.0.0");
params.add("method", "dj.api.smartcarlife.workWechat.login");
params.add("code", "u34KUdHJ_SoidHz8-QsQIb7UqnbDIHvlllnpf3rz5Bc");
System.out.println(get(params));
}
@Test
public void testSelectAccountLogin() throws Exception{
testLogin();
this.sessionId = "fcb09a4e-1a7d-4144-93ef-4691e0a67cd0";
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(4);
params.add("v", "1.0.0");
params.add("method", "dj.api.smartcarlife.workWechat.selectAccountLogin");
params.add("id", "1000254");
System.out.println(get(params));
}
@Test
public void testAuthPhone() throws Exception {
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(4);
params.add("v", "1.0.0");
params.add("method", "dj.api.smartcarlife.mocklogin");
JSONObject jsonObject = JSONObject.parseObject(post(params));
System.out.println(jsonObject);
String sessionId = (String) jsonObject.get("data");
System.out.println("get sessionId:"+sessionId);
}
@Test
public void testgetSignatureSwitch()throws Exception {
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(4);
params.add("v", "1.0.0");
params.add("method", "dj.api.smartcarlife.serviceMerchant.getSignatureSwitch");
params.add("merchantId","44211757");
System.out.println(get(params));
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!