Compare commits
1230 Commits
1557 changed files with 142972 additions and 1049 deletions
@ -0,0 +1,25 @@ |
|||||
|
|
||||
|
update tbs_budget_condition set brand_id = SUBSTRING_INDEX(target_level_path_ids,'_',1) |
||||
|
update tbs_budget set center_combo = concat(center_type,'_',center_id) |
||||
|
|
||||
|
update vtb_verification v |
||||
|
left join tbs_activity act on act.id = v.activity_id |
||||
|
set v.activity_code = act.activity_code |
||||
|
where v.verification_main_code like 'DHX%' |
||||
|
|
||||
|
|
||||
|
select tbs_budget.id from tbs_budget |
||||
|
LEFT JOIN tbs_budget_condition |
||||
|
on tbs_budget_condition.budget_id = tbs_budget.id |
||||
|
where tbs_budget.del_flag = 0 |
||||
|
and tbs_budget_condition.del_flag = 0 |
||||
|
and tbs_budget.condition_flag = 0 |
||||
|
and tbs_budget_condition.id is not null |
||||
|
GROUP BY tbs_budget.id |
||||
|
|
||||
|
|
||||
|
|
||||
|
update tbs_budget set condition_flag = 1 |
||||
|
where id in ( |
||||
|
) |
||||
|
|
@ -1,24 +1,33 @@ |
|||||
package com.qs.serve.common.config; |
package com.qs.serve.common.config; |
||||
|
|
||||
|
import com.qs.serve.common.util.Assert; |
||||
import lombok.experimental.UtilityClass; |
import lombok.experimental.UtilityClass; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
|
||||
/** |
/** |
||||
* @author YenHex |
* @author YenHex |
||||
* @since 2022/3/11 |
* @since 2022/3/11 |
||||
*/ |
*/ |
||||
|
@Slf4j |
||||
@UtilityClass |
@UtilityClass |
||||
public class DevEnvironmentConfig { |
public class DevEnvironmentConfig { |
||||
|
|
||||
private static Boolean devEnv = null; |
private static Boolean devEnv = null; |
||||
public static void openDevEnv(Boolean open){ |
public static void openDevEnv(Boolean open){ |
||||
if(devEnv==null){devEnv = open;} |
log.warn("环境变量:devEnv=>>> "+open); |
||||
|
devEnv = open; |
||||
} |
} |
||||
|
|
||||
|
public static Boolean isDev(){ |
||||
public static boolean isDev(){ |
|
||||
if(devEnv==null){ |
if(devEnv==null){ |
||||
return false; |
Assert.throwEx("资源加载中..."); |
||||
} |
} |
||||
return devEnv; |
return devEnv; |
||||
} |
} |
||||
|
|
||||
|
/** |
||||
|
* 开启账套 |
||||
|
*/ |
||||
|
public final static boolean OPEN_TENANT_BOOK = true; |
||||
|
|
||||
} |
} |
||||
|
@ -0,0 +1,25 @@ |
|||||
|
package com.qs.serve.common.config.properties; |
||||
|
|
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* @Author: YenHex |
||||
|
* @Date: 2021/3/3 |
||||
|
* @Version: 1.0 |
||||
|
**/ |
||||
|
@Getter |
||||
|
@Setter |
||||
|
@Component |
||||
|
@ConfigurationProperties(prefix = "aliyun.oss") |
||||
|
public class AliYunOssProperties { |
||||
|
|
||||
|
private String bucket; |
||||
|
private String accessKeyId; |
||||
|
private String accessKeySecret; |
||||
|
private String endpoint; |
||||
|
private String prefix; |
||||
|
|
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
package com.qs.serve.common.config.properties; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/3/27 |
||||
|
*/ |
||||
|
public class AuthUrlConst { |
||||
|
|
||||
|
public final static String[] AUTH_ALLOW_URL = new String[]{ |
||||
|
"bir/" |
||||
|
}; |
||||
|
|
||||
|
} |
@ -0,0 +1,36 @@ |
|||||
|
package com.qs.serve.common.config.properties; |
||||
|
|
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/9/7 |
||||
|
*/ |
||||
|
@Getter |
||||
|
@Setter |
||||
|
@Component |
||||
|
@ConfigurationProperties(prefix = "project.apis") |
||||
|
public class ProjectApisProperties { |
||||
|
|
||||
|
/** 支付接口 */ |
||||
|
private String costToPay; |
||||
|
|
||||
|
/** 同步核销的支付状态 */ |
||||
|
private String checkPayStatus; |
||||
|
|
||||
|
/** 调度系统-发货单 */ |
||||
|
private String diaoduPlanOrder; |
||||
|
|
||||
|
/** 嘉士利接口,spu转换sku */ |
||||
|
private String spuToSku; |
||||
|
|
||||
|
/** |
||||
|
* 原是生成销路通apt的中间表,替换伟成的接口直接生成 |
||||
|
*/ |
||||
|
private String policySyncCate; |
||||
|
|
||||
|
private String policySyncInv; |
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
package com.qs.serve.common.config.properties; |
||||
|
|
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* @Author: YenHex |
||||
|
* @Date: 2021/3/3 |
||||
|
* @Version: 1.0 |
||||
|
**/ |
||||
|
@Getter |
||||
|
@Setter |
||||
|
@Component |
||||
|
@ConfigurationProperties(prefix = "project") |
||||
|
public class ProjectProperties { |
||||
|
|
||||
|
private String closeAuth; |
||||
|
|
||||
|
private String birService; |
||||
|
|
||||
|
private String birServiceUrl; |
||||
|
|
||||
|
private String hostUrl; |
||||
|
|
||||
|
private String webUrl; |
||||
|
|
||||
|
private String pcWebLocal; |
||||
|
|
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
package com.qs.serve.common.config.properties; |
||||
|
|
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/6/18 |
||||
|
*/ |
||||
|
@Getter |
||||
|
@Setter |
||||
|
@Component |
||||
|
@ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.qisheng") |
||||
|
public class QiShengDsProperties { |
||||
|
|
||||
|
private String url; |
||||
|
private String username; |
||||
|
private String password; |
||||
|
|
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package com.qs.serve.common.config.properties; |
||||
|
|
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author: YenHex |
||||
|
* @Date: 2021/3/3 |
||||
|
* @Version: 1.0 |
||||
|
**/ |
||||
|
@Getter |
||||
|
@Setter |
||||
|
@Component |
||||
|
@ConfigurationProperties(prefix = "project.seeyon") |
||||
|
public class SeeYonProperties { |
||||
|
|
||||
|
private Boolean enable; |
||||
|
|
||||
|
private String url; |
||||
|
|
||||
|
private String extApi; |
||||
|
|
||||
|
} |
@ -0,0 +1,35 @@ |
|||||
|
package com.qs.serve.common.framework.annotations; |
||||
|
|
||||
|
import java.lang.annotation.*; |
||||
|
|
||||
|
/** |
||||
|
* 解决原有@CacheAble不支持独立失效策略场景 |
||||
|
* @author YenHex |
||||
|
* @since 2024/10/17 |
||||
|
*/ |
||||
|
@Target({ElementType.METHOD}) |
||||
|
@Retention(RetentionPolicy.RUNTIME) |
||||
|
@Documented |
||||
|
public @interface RedisCacheable { |
||||
|
|
||||
|
/** |
||||
|
* redis缓存前缀,默认类与方法名 |
||||
|
* @return |
||||
|
*/ |
||||
|
String prefix() default ""; |
||||
|
|
||||
|
/** |
||||
|
* 过期时间 |
||||
|
* @return |
||||
|
*/ |
||||
|
int expire() default 350; |
||||
|
|
||||
|
/** |
||||
|
* 缓存读取主键表达式 |
||||
|
* @return |
||||
|
*/ |
||||
|
String expression() default ""; |
||||
|
|
||||
|
String SIMPLE_KEY = "#key"; |
||||
|
|
||||
|
} |
@ -0,0 +1,4 @@ |
|||||
|
package com.qs.serve.common.framework.annotations; |
||||
|
|
||||
|
public @interface TagField { |
||||
|
} |
@ -0,0 +1,135 @@ |
|||||
|
package com.qs.serve.common.framework.aop; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.toolkit.StringPool; |
||||
|
import com.qs.serve.common.framework.annotations.RedisCacheable; |
||||
|
import com.qs.serve.common.framework.redis.RedisService; |
||||
|
import com.qs.serve.common.util.JsonUtil; |
||||
|
import com.qs.serve.common.util.StringUtils; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.aspectj.lang.ProceedingJoinPoint; |
||||
|
import org.aspectj.lang.Signature; |
||||
|
import org.aspectj.lang.annotation.Around; |
||||
|
import org.aspectj.lang.annotation.Aspect; |
||||
|
import org.aspectj.lang.annotation.Pointcut; |
||||
|
import org.aspectj.lang.reflect.MethodSignature; |
||||
|
import org.springframework.core.annotation.AnnotatedElementUtils; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.lang.reflect.Method; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.concurrent.TimeUnit; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/10/18 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
//@Aspect
|
||||
|
//@Component
|
||||
|
@AllArgsConstructor |
||||
|
public class RedisCacheAspect { |
||||
|
|
||||
|
private final RedisService redisService; |
||||
|
|
||||
|
@Pointcut("@annotation(com.qs.serve.common.framework.annotations.RedisCacheable)") |
||||
|
public void PointCut() {} |
||||
|
|
||||
|
@Around("PointCut()") |
||||
|
public Object redisCacheAdvice(ProceedingJoinPoint joinPoint) throws Throwable { |
||||
|
Object[] args = joinPoint.getArgs(); |
||||
|
Signature signature = joinPoint.getSignature(); |
||||
|
MethodSignature methodSignature = ((MethodSignature) signature); |
||||
|
Method method = methodSignature.getMethod(); |
||||
|
RedisCacheable redisCacheable = AnnotatedElementUtils.findMergedAnnotation(method, RedisCacheable.class); |
||||
|
if(redisCacheable!=null){ |
||||
|
String prefix = StringUtils.hasText(redisCacheable.prefix()) ? redisCacheable.prefix() |
||||
|
: methodSignature.getDeclaringType().getName() +"."+ methodSignature.getMethod().getName()+"()"; |
||||
|
//构建表达式key
|
||||
|
String pk = this.getPrimaryKey(methodSignature,redisCacheable,args); |
||||
|
String redisCacheKey = "RCache:" + prefix + (pk==null?"":pk); |
||||
|
Object result = redisService.get(redisCacheKey); |
||||
|
if(result!=null){ |
||||
|
return JsonUtil.jsonToMap(result.toString()); |
||||
|
} |
||||
|
result = joinPoint.proceed(args); |
||||
|
if(result!=null){ |
||||
|
redisService.set(redisCacheKey,JsonUtil.objectToJson(result),redisCacheable.expire(), TimeUnit.MILLISECONDS); |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
// 返回默认对象
|
||||
|
return joinPoint.proceed(args); |
||||
|
} |
||||
|
|
||||
|
public String getPrimaryKey(MethodSignature methodSignature,RedisCacheable annotation,Object[] args){ |
||||
|
String method = methodSignature.getDeclaringType().getName() |
||||
|
+"."+ methodSignature.getMethod().getName()+"()"; |
||||
|
final String expression = annotation.expression(); |
||||
|
//适配表达式读取key,key读取不到log.error,放行请求
|
||||
|
String primaryKey = null; |
||||
|
if(StringUtils.isNotEmpty(expression)){ |
||||
|
//
|
||||
|
if(expression.equals(RedisCacheable.SIMPLE_KEY)&&args.length==1){ |
||||
|
return args[0].toString(); |
||||
|
} |
||||
|
List<String> keys = new ArrayList<>(); |
||||
|
// 指定表名
|
||||
|
String tableName = null; |
||||
|
if(expression.contains(StringPool.DOT)){ |
||||
|
String[] keyArr = expression.split(StringPool.BACK_SLASH + StringPool.DOT); |
||||
|
for (String key : keyArr) { |
||||
|
if(key.contains(StringPool.DOLLAR)){ |
||||
|
tableName = key.replace(StringPool.DOLLAR,""); |
||||
|
continue; |
||||
|
} |
||||
|
keys.add(key); |
||||
|
} |
||||
|
}else { |
||||
|
keys.add(expression); |
||||
|
} |
||||
|
for (Object arg : args) { |
||||
|
// 跳过非指定的表名
|
||||
|
if(tableName!=null){ |
||||
|
String clazzName = arg.getClass().getSimpleName(); |
||||
|
if(!clazzName.equals(tableName)){ |
||||
|
continue; |
||||
|
} |
||||
|
} |
||||
|
// 读取key
|
||||
|
primaryKey = getPrimaryKeyRecursion(keys, arg, 0); |
||||
|
} |
||||
|
if(primaryKey==null){ |
||||
|
log.error("LockSubmitAspect失效,方法:{} 无法读取主键:{}",method,expression); |
||||
|
} |
||||
|
} |
||||
|
return primaryKey; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 递归读取主键 |
||||
|
* @param keys |
||||
|
* @param arg |
||||
|
* @param startIndex |
||||
|
* @return |
||||
|
*/ |
||||
|
private String getPrimaryKeyRecursion(List<String> keys, Object arg, int startIndex) { |
||||
|
String key = keys.get(startIndex); |
||||
|
Map<String,Object> param = JsonUtil.jsonToMap(JsonUtil.objectToJson(arg)); |
||||
|
Object val = param.get(key); |
||||
|
if(val!=null){ |
||||
|
boolean isLast = startIndex + 1== keys.size(); |
||||
|
if(isLast){ |
||||
|
return val.toString(); |
||||
|
}else { |
||||
|
// 自调支持无限层级
|
||||
|
return getPrimaryKeyRecursion(keys, val, startIndex + 1 ); |
||||
|
} |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
} |
@ -1,60 +0,0 @@ |
|||||
package com.qs.serve.common.framework.interceptor; |
|
||||
|
|
||||
import com.qs.serve.common.framework.redis.RedisService; |
|
||||
import com.qs.serve.common.framework.security.model.LoginUser; |
|
||||
import com.qs.serve.common.framework.security.model.LoginUserDTO; |
|
||||
import com.qs.serve.common.model.consts.GySysConst; |
|
||||
import com.qs.serve.common.model.consts.RedisCacheKeys; |
|
||||
import com.qs.serve.common.util.JsonUtil; |
|
||||
import org.springframework.context.annotation.Configuration; |
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
|
||||
import org.springframework.security.core.context.SecurityContextHolder; |
|
||||
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; |
|
||||
import org.springframework.web.servlet.HandlerInterceptor; |
|
||||
|
|
||||
import javax.annotation.Resource; |
|
||||
import javax.servlet.http.HttpServletRequest; |
|
||||
import javax.servlet.http.HttpServletResponse; |
|
||||
import java.io.IOException; |
|
||||
import java.util.Objects; |
|
||||
|
|
||||
/** |
|
||||
* API接口身份拦截器 |
|
||||
* @author YenHex |
|
||||
*/ |
|
||||
@Configuration(proxyBeanMethods = false) |
|
||||
public class ApiAuthInterceptor implements HandlerInterceptor { |
|
||||
|
|
||||
|
|
||||
@Resource private RedisService redisService; |
|
||||
|
|
||||
@Override |
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { |
|
||||
String token = request.getHeader(GySysConst.APP_TOKEN_PROP); |
|
||||
String loginUserJson = redisService.getString(RedisCacheKeys.LOGIN_KEY_WX+token); |
|
||||
if(loginUserJson!=null){ |
|
||||
LoginUser loginUser = Objects.requireNonNull(JsonUtil.jsonToPojo(loginUserJson, LoginUserDTO.class)).loginUser(); |
|
||||
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities()); |
|
||||
authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); |
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication); |
|
||||
return true; |
|
||||
} |
|
||||
try { |
|
||||
response.setHeader("Access-Control-Allow-Origin", "*"); |
|
||||
response.setHeader("Access-Control-Allow-Credentials", "true"); |
|
||||
response.setHeader("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS"); |
|
||||
response.setHeader("Access-Control-Max-Age", "86400"); |
|
||||
response.setHeader("Access-Control-Allow-Headers", "*"); |
|
||||
response.setStatus(200); |
|
||||
response.setCharacterEncoding("UTF-8"); |
|
||||
response.setCharacterEncoding("UTF-8"); |
|
||||
response.setContentType("application/json;charset=UTF-8"); |
|
||||
response.getWriter().print("{\"status\":401,\"msg\":\"用户信息无效或过期了\"}"); |
|
||||
response.getWriter().flush(); |
|
||||
} catch (IOException e) { |
|
||||
e.printStackTrace(); |
|
||||
} |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
} |
|
@ -0,0 +1,31 @@ |
|||||
|
package com.qs.serve.common.framework.interceptor; |
||||
|
|
||||
|
import com.alibaba.fastjson.serializer.JSONSerializer; |
||||
|
import com.alibaba.fastjson.serializer.ObjectSerializer; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.lang.reflect.Type; |
||||
|
import java.text.SimpleDateFormat; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/7/18 |
||||
|
*/ |
||||
|
public class LocalDateTimeFormatSerializer implements ObjectSerializer { |
||||
|
|
||||
|
@Override |
||||
|
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException { |
||||
|
if (object == null) { |
||||
|
serializer.out.writeNull(); |
||||
|
return; |
||||
|
} |
||||
|
LocalDateTime date = (LocalDateTime) object; |
||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
||||
|
String timeString = formatter.format(date); |
||||
|
serializer.write(timeString); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,69 @@ |
|||||
|
package com.qs.serve.common.framework.mybatis.handler.meta; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.plugins.handler.TableNameHandler; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
|
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 拓展表格名称 |
||||
|
* @author YenHex |
||||
|
* @since 2024/12/26 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
public class TableNameAppendHandler implements TableNameHandler { |
||||
|
|
||||
|
/** |
||||
|
* 用于记录哪些表可以使用该月份动态表名处理器(即哪些表按月分表) |
||||
|
*/ |
||||
|
private List<String> tableNames; |
||||
|
|
||||
|
/** |
||||
|
* 构造函数,构造动态表名处理器的时候,传递tableNames参数 |
||||
|
* @param tableNames |
||||
|
*/ |
||||
|
public TableNameAppendHandler(String ...tableNames) { |
||||
|
this.tableNames = Arrays.asList(tableNames); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 每个请求线程维护一个month数据,避免多线程数据冲突。所以使用ThreadLocal |
||||
|
*/ |
||||
|
private static final ThreadLocal<String> APPEND_DATA = new ThreadLocal<>(); |
||||
|
|
||||
|
/** |
||||
|
* 设置请求线程的month数据 |
||||
|
* @param name |
||||
|
*/ |
||||
|
public static void setAppend(String name) { |
||||
|
APPEND_DATA.set(name); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除当前请求线程的month数据 |
||||
|
*/ |
||||
|
public static void removeCache() { |
||||
|
APPEND_DATA.remove(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 动态表名接口实现方法 |
||||
|
* @param sql |
||||
|
* @param tableName |
||||
|
* @return |
||||
|
*/ |
||||
|
@Override |
||||
|
public String dynamicTableName(String sql, String tableName) { |
||||
|
if (this.tableNames.contains(tableName) && APPEND_DATA.get() != null){ |
||||
|
//表名增加月份后缀
|
||||
|
return tableName + "_" + APPEND_DATA.get(); |
||||
|
}else{ |
||||
|
if(this.tableNames.contains(tableName)){ |
||||
|
log.warn("APPEND_DATA is null, table is {}",tableName); |
||||
|
} |
||||
|
//表名原样返回
|
||||
|
return tableName; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
package com.qs.serve.common.framework.redis; |
||||
|
|
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.data.redis.cache.RedisCache; |
||||
|
import org.springframework.data.redis.cache.RedisCacheConfiguration; |
||||
|
import org.springframework.data.redis.cache.RedisCacheManager; |
||||
|
import org.springframework.data.redis.cache.RedisCacheWriter; |
||||
|
import org.springframework.util.StringUtils; |
||||
|
|
||||
|
import java.time.Duration; |
||||
|
|
||||
|
@Slf4j |
||||
|
public class TtlRedisCacheManager extends RedisCacheManager { |
||||
|
public TtlRedisCacheManager(RedisCacheWriter cacheWriter, RedisCacheConfiguration defaultCacheConfiguration) { |
||||
|
super(cacheWriter, defaultCacheConfiguration); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
protected RedisCache createRedisCache(String name, RedisCacheConfiguration cacheConfig) { |
||||
|
log.debug("TtlRedisCacheManager keyName:{}",name); |
||||
|
String[] cells = StringUtils.delimitedListToStringArray(name, "="); |
||||
|
name = cells[0]; |
||||
|
if (cells.length > 1) { |
||||
|
long ttl = Long.parseLong(cells[1]); |
||||
|
// 根据传参设置缓存失效时间,默认单位是秒
|
||||
|
cacheConfig = cacheConfig.entryTtl(Duration.ofSeconds(ttl)); |
||||
|
} |
||||
|
return super.createRedisCache(name, cacheConfig); |
||||
|
} |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.qs.serve.common.model; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/7/31 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class AmountDTO { |
||||
|
|
||||
|
private String id; |
||||
|
|
||||
|
private BigDecimal amount; |
||||
|
|
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
package com.qs.serve.common.model.annotation; |
||||
|
|
||||
|
import java.lang.annotation.*; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/4/25 |
||||
|
*/ |
||||
|
@Target({ElementType.FIELD}) |
||||
|
@Retention(RetentionPolicy.RUNTIME) |
||||
|
@Documented |
||||
|
public @interface BusinessDifference { |
||||
|
|
||||
|
/** |
||||
|
* 字段备注 |
||||
|
* @return |
||||
|
*/ |
||||
|
String value() default ""; |
||||
|
|
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
package com.qs.serve.common.model.chart; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/6/7 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BiCommonCounter { |
||||
|
|
||||
|
/** |
||||
|
* 横轴下标的ID |
||||
|
*/ |
||||
|
private String label; |
||||
|
|
||||
|
private Long counts; |
||||
|
|
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package com.qs.serve.common.model.chart; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/6/7 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BiMonthCounter { |
||||
|
|
||||
|
private String months; |
||||
|
private Long counts; |
||||
|
|
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
package com.qs.serve.common.model.chart; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/6/7 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class ChartAxisColumn { |
||||
|
|
||||
|
/** 列Id */ |
||||
|
String columnId; |
||||
|
|
||||
|
/** 列名 */ |
||||
|
String columnName; |
||||
|
|
||||
|
/** 系列坐标值合计 */ |
||||
|
Double total; |
||||
|
|
||||
|
public static List<ChartAxisColumn> buildMonthsOfYear(){ |
||||
|
List<ChartAxisColumn> axisColumnList = new ArrayList<>(); |
||||
|
for (long i = 1; i < 13; i++) { |
||||
|
ChartAxisColumn axisColumn = new ChartAxisColumn(); |
||||
|
if(i>9){ |
||||
|
axisColumn.setColumnId(i+""); |
||||
|
}else { |
||||
|
axisColumn.setColumnId("0"+i); |
||||
|
} |
||||
|
axisColumn.setColumnName(i+"月"); |
||||
|
axisColumnList.add(axisColumn); |
||||
|
} |
||||
|
return axisColumnList; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,148 @@ |
|||||
|
package com.qs.serve.common.model.chart; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/6/7 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class ChartDataVo { |
||||
|
|
||||
|
/** |
||||
|
* 列(饼状图的主要参数) |
||||
|
*/ |
||||
|
List<ChartAxisColumn> axisColumnList; |
||||
|
|
||||
|
/** |
||||
|
* 系列 |
||||
|
*/ |
||||
|
List<ChartSeriesItem> seriesItemList; |
||||
|
|
||||
|
/** |
||||
|
* 分组 |
||||
|
*/ |
||||
|
List<ChartGroupItem> groupItemList; |
||||
|
|
||||
|
|
||||
|
public void initAxisColumnTotal(){ |
||||
|
for (int i = 0; i < axisColumnList.size(); i++) { |
||||
|
ChartAxisColumn axisColumn = axisColumnList.get(i); |
||||
|
BigDecimal total = BigDecimal.ZERO; |
||||
|
if(seriesItemList!=null&&seriesItemList.size()>0){ |
||||
|
for (ChartSeriesItem seriesItem : seriesItemList) { |
||||
|
double value = seriesItem.getValues().get(i); |
||||
|
total = total.add(new BigDecimal(value+"")); |
||||
|
} |
||||
|
} |
||||
|
axisColumn.setTotal(total.doubleValue()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public static ChartDataVo buildStateChartData(List<BiCommonCounter> stateCounterList, Map<String,String> stateMap){ |
||||
|
ChartDataVo chartDataVo = new ChartDataVo(); |
||||
|
List<ChartAxisColumn> axisColumnList = new ArrayList<>(); |
||||
|
List<ChartSeriesItem> seriesItemList = new ArrayList<>(); |
||||
|
List<ChartGroupItem> groupItemList = new ArrayList<>(); |
||||
|
ChartGroupItem groupItem = new ChartGroupItem(); |
||||
|
groupItem.setGroupId(100L); |
||||
|
groupItem.setGroupName("默认"); |
||||
|
groupItemList.add(groupItem); |
||||
|
for (String stateNum : stateMap.keySet()) { |
||||
|
String label = stateMap.get(stateNum); |
||||
|
ChartAxisColumn axisColumn = new ChartAxisColumn(); |
||||
|
axisColumn.setColumnId(stateNum); |
||||
|
axisColumn.setColumnName(label); |
||||
|
axisColumnList.add(axisColumn); |
||||
|
} |
||||
|
List<Double> values = new ArrayList<>(); |
||||
|
for (ChartAxisColumn chartAxisColumn : axisColumnList) { |
||||
|
Double currVal = 0.0; |
||||
|
for (BiCommonCounter counter : stateCounterList) { |
||||
|
if(chartAxisColumn.getColumnId().equals(counter.getLabel())){ |
||||
|
currVal = counter.getCounts().doubleValue(); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
values.add(currVal); |
||||
|
} |
||||
|
ChartSeriesItem seriesItem = new ChartSeriesItem(); |
||||
|
seriesItem.setGroupId(groupItem.getGroupId()); |
||||
|
seriesItem.setGroupName(groupItem.getGroupName()); |
||||
|
seriesItem.setValues(values); |
||||
|
seriesItemList.add(seriesItem); |
||||
|
//更新total
|
||||
|
chartDataVo.setAxisColumnList(axisColumnList); |
||||
|
chartDataVo.setGroupItemList(groupItemList); |
||||
|
chartDataVo.setSeriesItemList(seriesItemList); |
||||
|
chartDataVo.initAxisColumnTotal(); |
||||
|
return chartDataVo; |
||||
|
} |
||||
|
|
||||
|
public void tes(){ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public void buildStateMap(Map<String,String> stateMap){ |
||||
|
init(); |
||||
|
for (String stateNum : stateMap.keySet()) { |
||||
|
String label = stateMap.get(stateNum); |
||||
|
ChartAxisColumn axisColumn = new ChartAxisColumn(); |
||||
|
axisColumn.setColumnId(stateNum); |
||||
|
axisColumn.setColumnName(label); |
||||
|
this.axisColumnList.add(axisColumn); |
||||
|
} |
||||
|
} |
||||
|
public void buildStateMapOfMonths(){ |
||||
|
init(); |
||||
|
this.axisColumnList = ChartAxisColumn.buildMonthsOfYear(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 先调用buildStateMap |
||||
|
* @param groupId |
||||
|
* @param groupName |
||||
|
* @param stateCounterList |
||||
|
*/ |
||||
|
public void addData(Long groupId,String groupName,List<BiCommonCounter> stateCounterList){ |
||||
|
ChartGroupItem groupItem = new ChartGroupItem(); |
||||
|
groupItem.setGroupId(groupId); |
||||
|
groupItem.setGroupName(groupName); |
||||
|
groupItemList.add(groupItem); |
||||
|
List<Double> values = new ArrayList<>(); |
||||
|
for (ChartAxisColumn chartAxisColumn : axisColumnList) { |
||||
|
Double currVal = 0.0; |
||||
|
for (BiCommonCounter counter : stateCounterList) { |
||||
|
if(chartAxisColumn.getColumnId().equals(counter.getLabel())){ |
||||
|
currVal = counter.getCounts().doubleValue(); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
values.add(currVal); |
||||
|
} |
||||
|
ChartSeriesItem seriesItem = new ChartSeriesItem(); |
||||
|
seriesItem.setGroupId(groupItem.getGroupId()); |
||||
|
seriesItem.setGroupName(groupItem.getGroupName()); |
||||
|
seriesItem.setValues(values); |
||||
|
seriesItemList.add(seriesItem); |
||||
|
this.initAxisColumnTotal(); |
||||
|
} |
||||
|
|
||||
|
private void init(){ |
||||
|
if(axisColumnList==null){ |
||||
|
axisColumnList = new ArrayList<>(); |
||||
|
} |
||||
|
if(seriesItemList==null){ |
||||
|
seriesItemList = new ArrayList<>(); |
||||
|
} |
||||
|
if(groupItemList==null){ |
||||
|
groupItemList = new ArrayList<>(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.qs.serve.common.model.chart; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/6/7 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class ChartGroupItem { |
||||
|
|
||||
|
/** 组id */ |
||||
|
private Long groupId; |
||||
|
|
||||
|
/** 组名 */ |
||||
|
private String groupName; |
||||
|
|
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
package com.qs.serve.common.model.chart; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/6/7 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class ChartSeriesItem { |
||||
|
|
||||
|
|
||||
|
/** 组id */ |
||||
|
Long groupId; |
||||
|
|
||||
|
/** 组名 */ |
||||
|
String groupName; |
||||
|
|
||||
|
/** |
||||
|
* 值列表(列对应axisColumns) |
||||
|
*/ |
||||
|
List<Double> values; |
||||
|
|
||||
|
} |
@ -0,0 +1,75 @@ |
|||||
|
package com.qs.serve.common.model.chart; |
||||
|
|
||||
|
import com.qs.serve.common.util.JsonUtil; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Random; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/2/17 |
||||
|
*/ |
||||
|
public class PrintChart { |
||||
|
|
||||
|
|
||||
|
public static void main(String[] args) { |
||||
|
|
||||
|
//eg. 统计最近5年入学人数,并区分男女数量
|
||||
|
ChartDataVo chartDataVo = new ChartDataVo(); |
||||
|
|
||||
|
List<ChartAxisColumn> axisColumnList = new ArrayList<>(); |
||||
|
List<ChartSeriesItem> seriesItemList = new ArrayList<>(); |
||||
|
List<ChartGroupItem> groupItemList = new ArrayList<>(); |
||||
|
|
||||
|
ChartGroupItem groupItem = new ChartGroupItem(); |
||||
|
groupItem.setGroupId(100L); |
||||
|
groupItem.setGroupName("男学生"); |
||||
|
groupItemList.add(groupItem); |
||||
|
|
||||
|
ChartGroupItem groupItem2 = new ChartGroupItem(); |
||||
|
groupItem2.setGroupId(200L); |
||||
|
groupItem2.setGroupName("女学生"); |
||||
|
groupItemList.add(groupItem2); |
||||
|
|
||||
|
for (long i = 1; i <= 5; i++) { |
||||
|
ChartAxisColumn axisColumn = new ChartAxisColumn(); |
||||
|
axisColumn.setColumnId(i+""); |
||||
|
axisColumn.setColumnName("202"+i+"年"); |
||||
|
axisColumnList.add(axisColumn); |
||||
|
} |
||||
|
|
||||
|
Random random = new Random(); |
||||
|
for (ChartGroupItem chartGroupItem : groupItemList) { |
||||
|
ChartSeriesItem seriesItem = new ChartSeriesItem(); |
||||
|
seriesItem.setGroupId(chartGroupItem.getGroupId()); |
||||
|
seriesItem.setGroupName(chartGroupItem.getGroupName()); |
||||
|
List<Double> values = new ArrayList<>(); |
||||
|
for (int i = 0; i < axisColumnList.size(); i++) { |
||||
|
double result = random.nextInt(1000)+3000; |
||||
|
values.add(result); |
||||
|
} |
||||
|
seriesItem.setValues(values); |
||||
|
seriesItemList.add(seriesItem); |
||||
|
} |
||||
|
//更新total
|
||||
|
for (int i = 0; i < axisColumnList.size(); i++) { |
||||
|
ChartAxisColumn axisColumn = axisColumnList.get(i); |
||||
|
BigDecimal total = BigDecimal.ZERO; |
||||
|
for (ChartSeriesItem seriesItem : seriesItemList) { |
||||
|
double value = seriesItem.getValues().get(i); |
||||
|
total = total.add(new BigDecimal(value+"")); |
||||
|
} |
||||
|
axisColumn.setTotal(total.doubleValue()); |
||||
|
} |
||||
|
chartDataVo.setAxisColumnList(axisColumnList); |
||||
|
chartDataVo.setGroupItemList(groupItemList); |
||||
|
chartDataVo.setSeriesItemList(seriesItemList); |
||||
|
String v = JsonUtil.objectToJson(chartDataVo); |
||||
|
System.out.println(v); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
package com.qs.serve.common.model.consts; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/9/19 |
||||
|
*/ |
||||
|
public interface ApplyTypeConst { |
||||
|
|
||||
|
String CostBill = "CostBill"; |
||||
|
String CheckCost = "CheckCost"; |
||||
|
String ReleasePolicy = "ReleasePolicy"; |
||||
|
|
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
package com.qs.serve.common.model.consts; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/1/30 |
||||
|
*/ |
||||
|
public interface BudgetLogRollbackFlag { |
||||
|
|
||||
|
/** 正常(标记为最新记录) */ |
||||
|
Integer State_0 = 0; |
||||
|
|
||||
|
/** 回退 */ |
||||
|
Integer State_1 = 1; |
||||
|
|
||||
|
/** 回退已处理 */ |
||||
|
Integer State_2 = 2; |
||||
|
|
||||
|
/** 删除已处理 */ |
||||
|
Integer State_3 = 3; |
||||
|
|
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
package com.qs.serve.common.model.consts; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/3/20 |
||||
|
*/ |
||||
|
public interface DSName { |
||||
|
|
||||
|
String QiSheng = "qisheng"; |
||||
|
|
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
package com.qs.serve.common.model.consts; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/2/15 |
||||
|
*/ |
||||
|
public interface ResultFlag { |
||||
|
|
||||
|
int OK = 1; |
||||
|
int NOT = 0; |
||||
|
|
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
package com.qs.serve.common.model.consts; |
||||
|
|
||||
|
/** |
||||
|
* 系统配置 |
||||
|
* @author YenHex |
||||
|
* @since 2022/11/12 |
||||
|
*/ |
||||
|
public interface SysConfigKey { |
||||
|
|
||||
|
/** 费用超支 */ |
||||
|
String TbsBudgetOverspend = "TbsBudgetOverspend"; |
||||
|
|
||||
|
/** 活动预计核销日期 */ |
||||
|
String ActivityPreCheckDays = "ActivityPreCheckDays"; |
||||
|
|
||||
|
String DateCheckApplyExcelYear = "DateCheckApplyExcelYear"; |
||||
|
|
||||
|
String PolicyDelayDays = "PolicyDelayDays"; |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.qs.serve.common.model.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/6/11 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class CommonIdsParam { |
||||
|
|
||||
|
private List<String> ids; |
||||
|
|
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package com.qs.serve.common.model.dto; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/6/5 |
||||
|
*/ |
||||
|
@Data |
||||
|
@NoArgsConstructor |
||||
|
@AllArgsConstructor |
||||
|
public class DateSplitDTO { |
||||
|
|
||||
|
Integer days; |
||||
|
|
||||
|
LocalDate startDate; |
||||
|
|
||||
|
LocalDate endDate; |
||||
|
|
||||
|
Integer yearMonth; |
||||
|
|
||||
|
Integer sort; |
||||
|
|
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package com.qs.serve.common.model.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/4/25 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class DiffFieldVal { |
||||
|
|
||||
|
String field; |
||||
|
String comment; |
||||
|
String orgValue; |
||||
|
String newValue; |
||||
|
|
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
package com.qs.serve.common.model.dto; |
||||
|
|
||||
|
import com.qs.serve.common.util.PageUtil; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/5/17 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class HeaderOption { |
||||
|
|
||||
|
private String name; |
||||
|
// private String width;
|
||||
|
// private String prefix;
|
||||
|
// private String suffix;
|
||||
|
private Boolean isSum; |
||||
|
private Integer decimalLength; |
||||
|
private String align; |
||||
|
private List<HeaderOption> children; |
||||
|
|
||||
|
public HeaderOption(String name){ |
||||
|
this.name = name; |
||||
|
} |
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
package com.qs.serve.common.model.dto; |
||||
|
|
||||
|
import com.qs.serve.common.util.PageUtil; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/5/17 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class RowParam { |
||||
|
|
||||
|
private Integer startIndex; |
||||
|
private Integer size; |
||||
|
|
||||
|
public RowParam(Integer startIndex, Integer size) { |
||||
|
this.startIndex = startIndex; |
||||
|
this.size = size; |
||||
|
} |
||||
|
|
||||
|
public RowParam(boolean pageable) { |
||||
|
this.size = PageUtil.getPageSize(); |
||||
|
this.startIndex = (PageUtil.getPageNum()-1)*size; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.qs.serve.common.model.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/8/29 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SimpleCountValue { |
||||
|
|
||||
|
String id; |
||||
|
|
||||
|
Long count; |
||||
|
|
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package com.qs.serve.common.model.dto; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/4/7 |
||||
|
*/ |
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
public class TargetDTO { |
||||
|
String targetId; |
||||
|
String targetCode; |
||||
|
String targetName; |
||||
|
|
||||
|
public TargetDTO(String targetId, String targetCode, String targetName) { |
||||
|
this.targetId = targetId; |
||||
|
this.targetCode = targetCode; |
||||
|
this.targetName = targetName; |
||||
|
} |
||||
|
|
||||
|
//拜访相关业务
|
||||
|
String localX; |
||||
|
String localY; |
||||
|
String address; |
||||
|
String mapAddress; |
||||
|
|
||||
|
} |
@ -0,0 +1,23 @@ |
|||||
|
package com.qs.serve.common.model.dto; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/4/7 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class TargetObjectDTO { |
||||
|
|
||||
|
String targetType; |
||||
|
String targetId; |
||||
|
|
||||
|
String targetCode; |
||||
|
String targetName; |
||||
|
|
||||
|
} |
@ -0,0 +1,91 @@ |
|||||
|
package com.qs.serve.common.model.enums; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Getter; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/1/30 |
||||
|
*/ |
||||
|
@Getter |
||||
|
@AllArgsConstructor |
||||
|
public enum BudgetLogOptFlag { |
||||
|
|
||||
|
/** 0-预算新增 */ |
||||
|
State_0(0,true), |
||||
|
|
||||
|
/** 1-费用申请(费用申请,预算调减) */ |
||||
|
State_1(1,false), |
||||
|
|
||||
|
/** 2-预算调增 */ |
||||
|
State_2(2,true), |
||||
|
|
||||
|
/** 3-预算调减 */ |
||||
|
State_3(3,false), |
||||
|
|
||||
|
/** 4-费用释放(预算调增) */ |
||||
|
State_4(4,true), |
||||
|
|
||||
|
/** 5-费用申请调增(费用申请,预算调增) */ |
||||
|
State_5(5,true), |
||||
|
|
||||
|
/** 6-费用申请调减(费用申请,预算调减) */ |
||||
|
State_6(6,false), |
||||
|
|
||||
|
/** 已取消 7-销售区域迁移调增 */ |
||||
|
State_7(7,false), |
||||
|
|
||||
|
/** 已取消 8-销售区域迁移调减 */ |
||||
|
State_8(8,false), |
||||
|
|
||||
|
/** 已取消 9-行政区域迁移调增 */ |
||||
|
State_9(9,false), |
||||
|
|
||||
|
/** 已取消 10-行政区域迁移调减 */ |
||||
|
State_10(10,false), |
||||
|
|
||||
|
/** 11-政策申请 */ |
||||
|
State_11(11,false), |
||||
|
|
||||
|
/** 12-政策申请调增(政策申请,预算调增) */ |
||||
|
State_12(12,true), |
||||
|
|
||||
|
/** 13-政策因费用申请调增(政策申请,预算转移) */ |
||||
|
State_13(13,true), |
||||
|
|
||||
|
/** 14-政策申请释放(被拒绝后,政策释放) */ |
||||
|
State_14(14,true), |
||||
|
|
||||
|
/** 15-费用申请释放(被拒绝后,预算增加) */ |
||||
|
State_15(15,true), |
||||
|
|
||||
|
/** 16-政策释放(释放操作,预算增加) */ |
||||
|
State_16(16,true); |
||||
|
|
||||
|
/** |
||||
|
* 编码 |
||||
|
*/ |
||||
|
private Integer code; |
||||
|
|
||||
|
/** |
||||
|
* 是否取反,添加预算 |
||||
|
*/ |
||||
|
private boolean addBudget; |
||||
|
|
||||
|
private final static List<Integer> finalBudgetOptFlag = Arrays.asList(0, 2, 3); |
||||
|
|
||||
|
public final static List<Integer> finalCostOptFlag = Arrays.asList(1,4,5,6); |
||||
|
|
||||
|
public final static List<Integer> finalPolicyOptFlag = Arrays.asList(11,12,13,14,15); |
||||
|
|
||||
|
/** |
||||
|
* 预算规划,状态0,2,3,新增、调增、调减 |
||||
|
*/ |
||||
|
public static List<Integer> getFinalBudgetOptFlag(){ |
||||
|
return finalBudgetOptFlag; |
||||
|
} |
||||
|
} |
@ -0,0 +1,40 @@ |
|||||
|
package com.qs.serve.common.model.enums; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/9/13 |
||||
|
*/ |
||||
|
public class MonthValues { |
||||
|
|
||||
|
public static final int[] Q1 = {1,2,3}; |
||||
|
public static final int[] Q2 = {4,5,6}; |
||||
|
public static final int[] Q3 = {7,8,9}; |
||||
|
public static final int[] Q4 = {10,11,12}; |
||||
|
|
||||
|
|
||||
|
|
||||
|
public static int[] getQArr(Integer val){ |
||||
|
for (int i = 0; i < Q1.length; i++) { |
||||
|
if(val==Q1[i]){ |
||||
|
return Q1; |
||||
|
} |
||||
|
} |
||||
|
for (int i = 0; i < Q2.length; i++) { |
||||
|
if(val==Q2[i]){ |
||||
|
return Q2; |
||||
|
} |
||||
|
} |
||||
|
for (int i = 0; i < Q3.length; i++) { |
||||
|
if(val==Q3[i]){ |
||||
|
return Q3; |
||||
|
} |
||||
|
} |
||||
|
for (int i = 0; i < Q4.length; i++) { |
||||
|
if(val==Q4[i]){ |
||||
|
return Q4; |
||||
|
} |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,42 @@ |
|||||
|
package com.qs.serve.common.model.oa; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/1/12 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class OaFormMainProcess { |
||||
|
|
||||
|
private String targetId; |
||||
|
|
||||
|
/** |
||||
|
* 上次文件 |
||||
|
*/ |
||||
|
private List<OaUploadFile> uploadFiles; |
||||
|
|
||||
|
/** |
||||
|
* data |
||||
|
*/ |
||||
|
private Object data; |
||||
|
|
||||
|
/** |
||||
|
* 员工号 |
||||
|
*/ |
||||
|
private String senderLoginName; |
||||
|
|
||||
|
/** |
||||
|
* 模板编码 |
||||
|
*/ |
||||
|
private String templateCode; |
||||
|
|
||||
|
private String userId; |
||||
|
|
||||
|
/** |
||||
|
* 模板编码 |
||||
|
*/ |
||||
|
private String tableName; |
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
package com.qs.serve.common.model.oa; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/1/12 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class OaUploadFile { |
||||
|
|
||||
|
/** |
||||
|
* 表单控件名称 |
||||
|
*/ |
||||
|
private String field; |
||||
|
|
||||
|
/** |
||||
|
* 附件文件名 |
||||
|
*/ |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 附件url |
||||
|
*/ |
||||
|
private String url; |
||||
|
|
||||
|
} |
@ -0,0 +1,119 @@ |
|||||
|
package com.qs.serve.common.model.tag; |
||||
|
|
||||
|
import cn.hutool.core.collection.CollUtil; |
||||
|
import com.qs.serve.common.util.StringUtils; |
||||
|
import com.qs.serve.modules.bms.entity.BmsSupplier; |
||||
|
import com.qs.serve.modules.goods.entity.GoodsSpu; |
||||
|
import com.qs.serve.modules.his.entity.HisUserSupplier; |
||||
|
import com.qs.serve.modules.tag.entity.so.TagQuery; |
||||
|
import com.qs.serve.modules.tbs.entity.TbsCostApply; |
||||
|
import com.qs.serve.modules.tbs.entity.so.VtbVerificationBatchQuery; |
||||
|
import com.qs.serve.modules.vtb.entity.VtbVerification; |
||||
|
import lombok.experimental.UtilityClass; |
||||
|
import org.jetbrains.annotations.NotNull; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/7/15 |
||||
|
*/ |
||||
|
@UtilityClass |
||||
|
public class TagFiledUtil { |
||||
|
|
||||
|
public final static Map<String,String> TbsCostApplyPageMap = new HashMap<String,String>(){{ |
||||
|
put("supplierId","tbs_cost_apply.supplier_id"); |
||||
|
}}; |
||||
|
|
||||
|
public final static Map<String,String> VtbVerificationPageMap = new HashMap<String,String>(){{ |
||||
|
put("supplierId","vtb_verification.supplier_id"); |
||||
|
}}; |
||||
|
|
||||
|
public final static Map<String,String> VtbVerificationBatchPageMap = new HashMap<String,String>(){{ |
||||
|
put("supplierId","vtb_verification_batch.supplier_id"); |
||||
|
}}; |
||||
|
|
||||
|
public final static Map<String,String> BmsSupplierPageMap = new HashMap<String,String>(){{ |
||||
|
put("id","bms_supplier.id"); |
||||
|
}}; |
||||
|
|
||||
|
public final static Map<String,String> HisSupplierPageMap = new HashMap<String,String>(){{ |
||||
|
put("id","his_user_supplier.supplier_id"); |
||||
|
}}; |
||||
|
|
||||
|
public final static Map<String,String> goodsSpuPageMap = new HashMap<String,String>(){{ |
||||
|
put("id","goods_spu.id"); |
||||
|
}}; |
||||
|
|
||||
|
public static void TbsCostApplyPage(TbsCostApply param){ |
||||
|
List<TagQuery> paramTagList = param.getTagQueryList(); |
||||
|
List<TagQuery> newList = getNewList(paramTagList,TbsCostApplyPageMap); |
||||
|
param.setTagQueryList(newList); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public static void VtbVerificationPage(VtbVerification param){ |
||||
|
List<TagQuery> paramTagList = param.getTagQueryList(); |
||||
|
List<TagQuery> newList = getNewList(paramTagList,VtbVerificationPageMap); |
||||
|
param.setTagQueryList(newList); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public static void VtbVerificationBatchPage(VtbVerificationBatchQuery param){ |
||||
|
List<TagQuery> paramTagList = param.getTagQueryList(); |
||||
|
List<TagQuery> newList = getNewList(paramTagList,VtbVerificationBatchPageMap); |
||||
|
param.setTagQueryList(newList); |
||||
|
} |
||||
|
|
||||
|
public static void BmsSupplierPage(BmsSupplier param){ |
||||
|
List<TagQuery> paramTagList = param.getTagQueryList(); |
||||
|
List<TagQuery> newList = getNewList(paramTagList,BmsSupplierPageMap); |
||||
|
param.setTagQueryList(newList); |
||||
|
} |
||||
|
|
||||
|
public static void GoodsSpuPage(GoodsSpu param){ |
||||
|
List<TagQuery> paramTagList = param.getTagQueryList(); |
||||
|
List<TagQuery> newList = getNewList(paramTagList,goodsSpuPageMap); |
||||
|
param.setTagQueryList(newList); |
||||
|
} |
||||
|
|
||||
|
public static void HisSupplierPage(HisUserSupplier param){ |
||||
|
List<TagQuery> paramTagList = param.getTagQueryList(); |
||||
|
List<TagQuery> newList = getNewList(paramTagList,HisSupplierPageMap); |
||||
|
param.setTagQueryList(newList); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 创建新的且有效性的查询参数(sql使用了非严谨写法,这里做了sql注入过滤) |
||||
|
* @param paramTagList |
||||
|
* @param columnMap |
||||
|
* @return |
||||
|
*/ |
||||
|
@NotNull |
||||
|
private static List<TagQuery> getNewList(List<TagQuery> paramTagList,Map<String,String> columnMap) { |
||||
|
List<TagQuery> newList = new ArrayList<>(); |
||||
|
if(paramTagList!=null){ |
||||
|
for (TagQuery tag : paramTagList) { |
||||
|
if(!StringUtils.hasText(tag.getTargetType())){ |
||||
|
continue; |
||||
|
} |
||||
|
if (StringUtils.hasText(tag.getTagName()) || CollUtil.isNotEmpty(tag.getTagIds())){ |
||||
|
String sqlColumn = columnMap.get(tag.getDataField()); |
||||
|
if(StringUtils.hasText(sqlColumn)){ |
||||
|
TagQuery newVal = new TagQuery(); |
||||
|
newVal.setTargetType(tag.getTargetType()); |
||||
|
newVal.setTagName(tag.getTagName()); |
||||
|
newVal.setTagIds(tag.getTagIds()); |
||||
|
newVal.setSqlColumn(sqlColumn); |
||||
|
newList.add(newVal); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return newList; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,156 @@ |
|||||
|
package com.qs.serve.common.util; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.alibaba.fastjson.support.config.FastJsonConfig; |
||||
|
import com.qs.serve.common.config.properties.ProjectProperties; |
||||
|
import com.qs.serve.common.model.consts.GySysConst; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.modules.tbs.entity.dto.TbsCostSubItem; |
||||
|
import lombok.experimental.UtilityClass; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.http.ParseException; |
||||
|
import org.apache.http.client.ClientProtocolException; |
||||
|
import org.apache.http.client.methods.CloseableHttpResponse; |
||||
|
import org.apache.http.client.methods.HttpGet; |
||||
|
import org.apache.http.client.methods.HttpPost; |
||||
|
import org.apache.http.entity.StringEntity; |
||||
|
import org.apache.http.impl.client.CloseableHttpClient; |
||||
|
import org.apache.http.impl.client.HttpClientBuilder; |
||||
|
import org.apache.http.impl.client.HttpClients; |
||||
|
import org.apache.http.protocol.HTTP; |
||||
|
import org.apache.http.util.EntityUtils; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletRequest; |
||||
|
import java.io.IOException; |
||||
|
import java.io.UnsupportedEncodingException; |
||||
|
import java.net.URLEncoder; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2022/11/23 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@UtilityClass |
||||
|
public class BirHttpUtil { |
||||
|
|
||||
|
/** |
||||
|
* 判断当前环境是否请求bir |
||||
|
* @return |
||||
|
*/ |
||||
|
public static boolean isRestBir(){ |
||||
|
ProjectProperties projectProperties = SpringUtils.getBean(ProjectProperties.class); |
||||
|
return projectProperties.getBirService().equals("true"); |
||||
|
} |
||||
|
|
||||
|
public static String getBaseUrl(){ |
||||
|
ProjectProperties projectProperties = SpringUtils.getBean(ProjectProperties.class); |
||||
|
return projectProperties.getBirServiceUrl(); |
||||
|
} |
||||
|
|
||||
|
public static R get(String action){ |
||||
|
return get(action,null); |
||||
|
} |
||||
|
|
||||
|
public static R get(String action,Object query){ |
||||
|
String baseUrl = getBaseUrl(); |
||||
|
String url = "/"+action; |
||||
|
if(query!=null){ |
||||
|
Map map = JsonUtil.objectToMap(query); |
||||
|
String params = HttpUtil.createUrl(map); |
||||
|
if(url.contains("?")){ |
||||
|
url = url+params; |
||||
|
}else { |
||||
|
url = url+"?"+params; |
||||
|
} |
||||
|
} |
||||
|
HashMap<String,String> hearders = new HashMap<>(); |
||||
|
HttpServletRequest request = ServletUtils.getRequest(); |
||||
|
String tenant = request.getHeader(GySysConst.TENANT_PROP); |
||||
|
String token = request.getHeader(GySysConst.AUTHORIZATION_PROP); |
||||
|
hearders.put(GySysConst.TENANT_PROP,tenant); |
||||
|
hearders.put(GySysConst.AUTHORIZATION_PROP,token); |
||||
|
//自动封装翻页参数
|
||||
|
if(!url.contains("?")){ |
||||
|
url += "?"; |
||||
|
} |
||||
|
if(PageUtil.getPageSize()!=null){ |
||||
|
url += "&pageSize="+PageUtil.getPageSize(); |
||||
|
} |
||||
|
if(PageUtil.getPageNum()!=null){ |
||||
|
url += "&pageNum="+PageUtil.getPageNum(); |
||||
|
} |
||||
|
url = baseUrl + url; |
||||
|
url = url.replace("//","/"); |
||||
|
url = url.replace("http:/","http://"); |
||||
|
url = url.replace("https:/","https://"); |
||||
|
log.debug("请求BIR中转URL:{}",url); |
||||
|
String result = HttpUtil.doGet(url,hearders); |
||||
|
log.debug("请求BIR中转URL:{}\n数据返回:{}",url,result); |
||||
|
JSONObject object = JSON.parseObject(result); |
||||
|
Integer status = object.getInteger("status"); |
||||
|
String msg = object.getString("msg"); |
||||
|
Object data = object.get("data"); |
||||
|
R r = R.ok(data); |
||||
|
r.setStatus(status); |
||||
|
r.setMsg(msg); |
||||
|
return r; |
||||
|
} |
||||
|
|
||||
|
public static R post(String action,Object query){ |
||||
|
String baseUrl = getBaseUrl(); |
||||
|
String url = baseUrl+"/"+action; |
||||
|
|
||||
|
HashMap<String,String> hearders = new HashMap<>(); |
||||
|
HttpServletRequest request = ServletUtils.getRequest(); |
||||
|
String tenant = request.getHeader(GySysConst.TENANT_PROP); |
||||
|
String token = request.getHeader(GySysConst.AUTHORIZATION_PROP); |
||||
|
hearders.put(GySysConst.TENANT_PROP,tenant); |
||||
|
hearders.put(GySysConst.AUTHORIZATION_PROP,token); |
||||
|
//自动封装翻页参数
|
||||
|
// if(!url.contains("?")){
|
||||
|
// url += "?";
|
||||
|
// }
|
||||
|
// if(PageUtil.getPageSize()!=null){
|
||||
|
// url += "&pageSize="+PageUtil.getPageSize();
|
||||
|
// }
|
||||
|
// if(PageUtil.getPageNum()!=null){
|
||||
|
// url += "&pageNum="+PageUtil.getPageNum();
|
||||
|
// }
|
||||
|
url = url.replace("//","/"); |
||||
|
url = url.replace("http:/","http://"); |
||||
|
url = url.replace("https:/","https://"); |
||||
|
log.debug("请求BIR中转URL:{}",url); |
||||
|
String json = JsonUtil.objectToJson(query); |
||||
|
log.debug("请求BIR中转Query:{}",json); |
||||
|
String result = HttpUtil.doPost(url,json,hearders); |
||||
|
log.debug("请求BIR中转URL:{}\n数据返回:{}",url,result); |
||||
|
JSONObject object = JSON.parseObject(result); |
||||
|
Integer status = object.getInteger("status"); |
||||
|
String msg = object.getString("msg"); |
||||
|
Object data = object.get("data"); |
||||
|
R r = R.ok(data); |
||||
|
r.setStatus(status); |
||||
|
r.setMsg(msg); |
||||
|
return r; |
||||
|
} |
||||
|
|
||||
|
public static TbsCostSubItem.CostCenterTranStr buildCostCenter(String centerType, String centerId, String centerName, String supplierCode){ |
||||
|
try { |
||||
|
Map<String,String> map = new HashMap<>(); |
||||
|
map.put("centerType",centerType); |
||||
|
map.put("centerId",centerId); |
||||
|
map.put("centerName",centerName); |
||||
|
map.put("supplierCode",supplierCode); |
||||
|
R<?> result = get("/bir/roiRate/getCostCenter",map); |
||||
|
String json = result.getData().toString(); |
||||
|
return JsonUtil.jsonToPojo(json,TbsCostSubItem.CostCenterTranStr.class); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,79 @@ |
|||||
|
package com.qs.serve.common.util; |
||||
|
|
||||
|
import com.qs.serve.common.framework.mybatis.join.annotations.BindEntity; |
||||
|
import com.qs.serve.common.model.annotation.BusinessDifference; |
||||
|
import com.qs.serve.common.model.dto.DiffFieldVal; |
||||
|
import com.qs.serve.modules.bms.entity.BmsSupplierContacts; |
||||
|
import com.qs.serve.modules.sys.entity.SysBusinessLog; |
||||
|
import lombok.SneakyThrows; |
||||
|
|
||||
|
import java.lang.annotation.Annotation; |
||||
|
import java.lang.reflect.Field; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/4/25 |
||||
|
*/ |
||||
|
public class BusinessDifferenceUtil { |
||||
|
|
||||
|
@SneakyThrows |
||||
|
public static <T> List<DiffFieldVal> getDifferenceList(T orgVal, T newVal){ |
||||
|
List<DiffFieldVal> diffFieldValList = new ArrayList<>(); |
||||
|
if(orgVal==null||newVal==null){ |
||||
|
return diffFieldValList; |
||||
|
} |
||||
|
Class<?> clazz = null; |
||||
|
try { |
||||
|
clazz = Class.forName(orgVal.getClass().getName()); |
||||
|
} catch (ClassNotFoundException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
if(clazz==null){return diffFieldValList;} |
||||
|
Field[] fields = clazz.getDeclaredFields(); |
||||
|
for (Field field : fields) { |
||||
|
for (Annotation annotation : field.getAnnotations()) { |
||||
|
if(annotation instanceof BusinessDifference){ |
||||
|
BusinessDifference busDiff = (BusinessDifference) annotation; |
||||
|
field.setAccessible(true); |
||||
|
Object orgValue = field.get(orgVal); |
||||
|
Object newValue = field.get(newVal); |
||||
|
if(newValue==null){ |
||||
|
continue; |
||||
|
} |
||||
|
if(orgValue==null){ |
||||
|
orgValue = ""; |
||||
|
} |
||||
|
if(!orgValue.equals(newValue)){ |
||||
|
DiffFieldVal fieldVal = new DiffFieldVal(); |
||||
|
fieldVal.setField(field.getName()); |
||||
|
fieldVal.setNewValue(newValue.toString()); |
||||
|
fieldVal.setOrgValue(orgValue.toString()); |
||||
|
fieldVal.setComment(busDiff.value()); |
||||
|
diffFieldValList.add(fieldVal); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return diffFieldValList; |
||||
|
} |
||||
|
|
||||
|
public static void main(String[] args) { |
||||
|
BmsSupplierContacts supplierContacts = new BmsSupplierContacts(); |
||||
|
supplierContacts.setContactsName("名称1"); |
||||
|
supplierContacts.setContactsPost("setContactsPost"); |
||||
|
|
||||
|
|
||||
|
BmsSupplierContacts supplierContacts2 = new BmsSupplierContacts(); |
||||
|
supplierContacts2.setContactsName("名称2"); |
||||
|
supplierContacts2.setContactsNumber("123456"); |
||||
|
supplierContacts2.setContactsPost("setContactsPost"); |
||||
|
|
||||
|
List<DiffFieldVal> diffFieldValList =BusinessDifferenceUtil.getDifferenceList(supplierContacts,supplierContacts2); |
||||
|
for (DiffFieldVal fieldVal : diffFieldValList) { |
||||
|
System.out.println(JsonUtil.objectToJson(fieldVal)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,147 @@ |
|||||
|
package com.qs.serve.common.util; |
||||
|
|
||||
|
import cn.hutool.core.util.IdUtil; |
||||
|
import com.qs.serve.common.config.DevEnvironmentConfig; |
||||
|
import com.qs.serve.common.framework.redis.RedisService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Getter; |
||||
|
import org.springframework.beans.BeansException; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
|
||||
|
/** |
||||
|
* 生成编号 |
||||
|
* @author YenHex |
||||
|
* @since 2023/6/25 |
||||
|
*/ |
||||
|
public class CodeGenUtil { |
||||
|
|
||||
|
@Getter |
||||
|
@AllArgsConstructor |
||||
|
public enum SourceKey{ |
||||
|
CostApply("cost_apply"), |
||||
|
SalePlan("SalePlan"), |
||||
|
Activity("activity"), |
||||
|
OmsOrder("OmsOrder"), |
||||
|
Verification("verification"), |
||||
|
VerificationBatch("verificationBatch"), |
||||
|
Policy("policy"), |
||||
|
Budget("Budget"), |
||||
|
BudgetChange("BudgetChange"), |
||||
|
BudgetBatch("BudgetBatch"), |
||||
|
AgreeCheck("AgreeCheck"), |
||||
|
PolicyItem("policy_item"); |
||||
|
private String code; |
||||
|
} |
||||
|
|
||||
|
@Getter |
||||
|
@AllArgsConstructor |
||||
|
public enum SourceDataKey{ |
||||
|
TagInfo("T","TagInfo"), |
||||
|
SaleRegion("S","SaleRegion"), |
||||
|
BizRegion("B","BizRegion"), |
||||
|
ActivityPayCondition("K","ActivityPayCondition"); |
||||
|
private String prefix; |
||||
|
private String code; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
private static final int split_num = 1000; |
||||
|
|
||||
|
|
||||
|
final static String[] digits2 = { |
||||
|
"A" , "B" , "C" , "D" , "E" , |
||||
|
"F" , "G" , "H" ,"J" , "K" , |
||||
|
"L" , "M" , "N" , "P" , |
||||
|
"Q" , "R" , "T" , "U" , "V" , "W" , |
||||
|
"X" , "Y" |
||||
|
}; |
||||
|
|
||||
|
public static synchronized Long getIdx(String key){ |
||||
|
RedisService redisService = SpringUtils.getBean(RedisService.class); |
||||
|
Long value = redisService.getLong(key); |
||||
|
if(value==null){ |
||||
|
redisService.set(key,1); |
||||
|
value = 1L; |
||||
|
}else { |
||||
|
value++; |
||||
|
} |
||||
|
redisService.set(key,value); |
||||
|
return value; |
||||
|
} |
||||
|
|
||||
|
public synchronized static String generate(SourceKey sourceKey){ |
||||
|
try { |
||||
|
LocalDate localDateTime = LocalDate.now(); |
||||
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMdd"); |
||||
|
String localTime = df.format(localDateTime); |
||||
|
localTime = localTime.substring(2); |
||||
|
String key = "code_index:"+sourceKey.getCode()+":"+localTime; |
||||
|
return localTime + getCommonValue(key); |
||||
|
} catch (BeansException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
return IdUtil.getSnowflakeNextIdStr(); |
||||
|
} |
||||
|
|
||||
|
public static String getCommonValue(String key){ |
||||
|
Long value = getIdx(key); |
||||
|
String digitsNum = ""; |
||||
|
String appendStr = value+""; |
||||
|
if(value>split_num){ |
||||
|
appendStr = (value%100)+""; |
||||
|
Long d = value/split_num; |
||||
|
digitsNum = digits2[d.intValue()]; |
||||
|
} |
||||
|
StringBuilder appendZeros = new StringBuilder(); |
||||
|
for (int i = (appendStr+digitsNum).length(); i < 3; i++) { |
||||
|
appendZeros.append("0"); |
||||
|
} |
||||
|
//用于区分测试环境数据
|
||||
|
String subflex = DevEnvironmentConfig.isDev()?"TEST":""; |
||||
|
return digitsNum + appendZeros + appendStr+subflex; |
||||
|
} |
||||
|
|
||||
|
public synchronized static String getDataCode(SourceDataKey dataKey){ |
||||
|
String key = "code_data_index:"+dataKey.getCode(); |
||||
|
String commonVal = getCommonValue(key); |
||||
|
return dataKey.getPrefix() + commonVal; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 32个字符,用来表示32进制 |
||||
|
*/ |
||||
|
final static char[] digits = { |
||||
|
'0' , '1' , '2' , '3' , '4' , '5' , |
||||
|
'6' , '7' , '8' , '9' , 'A' , 'B' , |
||||
|
'C' , 'D' , 'E' , 'F' , 'G' , 'H' , |
||||
|
'J' , 'K' , 'L' , 'M' , 'N' , 'P' , |
||||
|
'Q' , 'R' , 'T' , 'U' , 'V' , 'W' , |
||||
|
'X' , 'Y' |
||||
|
}; |
||||
|
|
||||
|
/** |
||||
|
* 10=>32 |
||||
|
* @param val |
||||
|
* @return |
||||
|
*/ |
||||
|
static String digits32(long val) { |
||||
|
// 32=2^5=二进制100000
|
||||
|
int shift = 5; |
||||
|
// numberOfLeadingZeros 获取long值从高位连续为0的个数,比如val=0,则返回64
|
||||
|
// 此处mag=long值二进制减去高位0之后的长度
|
||||
|
int mag = Long.SIZE - Long.numberOfLeadingZeros(val); |
||||
|
int len = Math.max(((mag + (shift - 1)) / shift), 1); |
||||
|
char[] buf = new char[len]; |
||||
|
do { |
||||
|
// &31相当于%32
|
||||
|
buf[--len] = digits[((int) val) & 31]; |
||||
|
val >>>= shift; |
||||
|
} while (val != 0 && len > 0); |
||||
|
return new String(buf); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,67 @@ |
|||||
|
package com.qs.serve.common.util; |
||||
|
|
||||
|
import com.qs.serve.common.model.dto.DateSplitDTO; |
||||
|
import lombok.experimental.UtilityClass; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Arrays; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 分割时间DTO工具类 |
||||
|
* @author YenHex |
||||
|
* @since 2023/6/5 |
||||
|
*/ |
||||
|
@UtilityClass |
||||
|
public class DateSplitUtil { |
||||
|
|
||||
|
public static List<DateSplitDTO> getSplitDto(LocalDate sDate, LocalDate eDate){ |
||||
|
int diffYear = eDate.getYear() - sDate.getYear(); |
||||
|
int diffMonthOfYear = eDate.getMonthValue() - sDate.getMonthValue(); |
||||
|
int diffMonth = diffYear * 12 + diffMonthOfYear; |
||||
|
//最后一个月的年月数
|
||||
|
int lastYearMonth = eDate.getYear()*100 + eDate.getMonthValue(); |
||||
|
int firstYearMonth = sDate.getYear()*100 + sDate.getMonthValue(); |
||||
|
if(diffMonth<1){ |
||||
|
//同一个月
|
||||
|
int days = eDate.getDayOfMonth() - sDate.getDayOfMonth() + 1; |
||||
|
DateSplitDTO splitDTO = new DateSplitDTO(days,sDate,eDate,lastYearMonth,1); |
||||
|
return Arrays.asList(splitDTO); |
||||
|
}else { |
||||
|
List<DateSplitDTO> dateSplitDTOS = new ArrayList<>(); |
||||
|
for (int i = 0; i < diffMonth+2; i++) { |
||||
|
int sort = i+1; |
||||
|
LocalDate newStartDate = sDate.plusMonths(i); |
||||
|
int currYearMonth = newStartDate.getYear()*100 + newStartDate.getMonthValue(); |
||||
|
//第一个月
|
||||
|
if(firstYearMonth==currYearMonth){ |
||||
|
int days = sDate.lengthOfMonth() - sDate.getDayOfMonth() + 1; |
||||
|
//当月最后一天
|
||||
|
LocalDate endLocalDate = LocalDate.of(sDate.getYear(),sDate.getMonth(),sDate.lengthOfMonth()); |
||||
|
DateSplitDTO splitDTO = new DateSplitDTO(days,sDate,endLocalDate,currYearMonth,sort); |
||||
|
dateSplitDTOS.add(splitDTO); |
||||
|
}else if(currYearMonth==lastYearMonth){ |
||||
|
int days = eDate.getDayOfMonth(); |
||||
|
//当月第一天
|
||||
|
LocalDate startDate = newStartDate.withDayOfMonth(1); |
||||
|
DateSplitDTO splitDTO = new DateSplitDTO(days,startDate,eDate,currYearMonth,sort); |
||||
|
dateSplitDTOS.add(splitDTO); |
||||
|
break; |
||||
|
}else { |
||||
|
int days = newStartDate.lengthOfMonth(); |
||||
|
//当月第一天
|
||||
|
LocalDate startDate = newStartDate.withDayOfMonth(1); |
||||
|
//当月最后一天
|
||||
|
LocalDate endLocalDate = LocalDate.of(newStartDate.getYear(),newStartDate.getMonth(),newStartDate.lengthOfMonth()); |
||||
|
DateSplitDTO splitDTO = new DateSplitDTO(days,startDate,endLocalDate,currYearMonth,sort); |
||||
|
dateSplitDTOS.add(splitDTO); |
||||
|
} |
||||
|
} |
||||
|
return dateSplitDTOS; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,164 @@ |
|||||
|
package com.qs.serve.common.util; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import lombok.experimental.UtilityClass; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.http.HttpEntity; |
||||
|
import org.apache.http.ParseException; |
||||
|
import org.apache.http.client.ClientProtocolException; |
||||
|
import org.apache.http.client.HttpClient; |
||||
|
import org.apache.http.client.config.RequestConfig; |
||||
|
import org.apache.http.client.methods.CloseableHttpResponse; |
||||
|
import org.apache.http.client.methods.HttpGet; |
||||
|
import org.apache.http.client.methods.HttpPost; |
||||
|
import org.apache.http.entity.StringEntity; |
||||
|
import org.apache.http.impl.client.CloseableHttpClient; |
||||
|
import org.apache.http.impl.client.HttpClientBuilder; |
||||
|
import org.apache.http.impl.client.HttpClients; |
||||
|
import org.apache.http.protocol.HTTP; |
||||
|
import org.apache.http.util.EntityUtils; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.io.UnsupportedEncodingException; |
||||
|
import java.net.URLEncoder; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2022/11/23 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@UtilityClass |
||||
|
public class HttpUtil { |
||||
|
|
||||
|
private final static String CONTENT_TYPE = "application/json"; |
||||
|
private final static String CHARSET = "UTF-8"; |
||||
|
private final static String EN_CONING = "UTF-8"; |
||||
|
|
||||
|
public static String doPost(String url, String jsonStr, HashMap<String,String> headers) { |
||||
|
CloseableHttpClient client = HttpClientBuilder.create().build(); |
||||
|
CloseableHttpResponse response = null; |
||||
|
String errorMsg = null; |
||||
|
try { |
||||
|
//设post请求
|
||||
|
HttpPost post = new HttpPost(url); |
||||
|
//创建请求实体传参
|
||||
|
if(jsonStr!=null){ |
||||
|
StringEntity postingString = new StringEntity(jsonStr,CHARSET); |
||||
|
postingString.setContentEncoding(EN_CONING); |
||||
|
//设置post请求参数
|
||||
|
post.setEntity(postingString); |
||||
|
} |
||||
|
post.addHeader(HTTP.CONTENT_TYPE,CONTENT_TYPE); |
||||
|
if (headers != null) { |
||||
|
for (String key : headers.keySet()) { |
||||
|
post.addHeader(key,headers.get(key)); |
||||
|
} |
||||
|
} |
||||
|
post.setConfig( |
||||
|
RequestConfig.custom() |
||||
|
// 连接超时30秒,减少数据库连接占用时长
|
||||
|
// 缩短时长,避免事务时间过长,占用数据库连接
|
||||
|
.setConnectTimeout(30*1000) |
||||
|
.build() |
||||
|
); |
||||
|
//执行post请求
|
||||
|
response = client.execute(post); |
||||
|
//访问成功状态码为200
|
||||
|
if (response.getStatusLine().getStatusCode() == 200) { |
||||
|
return EntityUtils.toString(response.getEntity()); |
||||
|
} |
||||
|
} catch (IOException e) { |
||||
|
errorMsg = e.getMessage(); |
||||
|
e.printStackTrace(); |
||||
|
}finally { |
||||
|
try { |
||||
|
client.close(); |
||||
|
if(response!=null){ |
||||
|
response.close(); |
||||
|
} |
||||
|
} catch (IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
return errorMsg; |
||||
|
} |
||||
|
|
||||
|
public static String doGet(String url, HashMap<String,String> headers) { |
||||
|
CloseableHttpClient httpclient = HttpClients.createDefault(); |
||||
|
try { |
||||
|
HttpGet httpget = new HttpGet(url); |
||||
|
httpget.addHeader(HTTP.CONTENT_TYPE,CONTENT_TYPE); |
||||
|
if (headers != null) { |
||||
|
for (String key : headers.keySet()) { |
||||
|
httpget.addHeader(key,headers.get(key)); |
||||
|
} |
||||
|
} |
||||
|
CloseableHttpResponse response = httpclient.execute(httpget); |
||||
|
try { |
||||
|
if (response.getStatusLine().getStatusCode() == 200) { |
||||
|
return EntityUtils.toString(response.getEntity()); |
||||
|
} |
||||
|
} finally { |
||||
|
response.close(); |
||||
|
} |
||||
|
} catch (ClientProtocolException e) { |
||||
|
e.printStackTrace(); |
||||
|
} catch (ParseException e) { |
||||
|
e.printStackTrace(); |
||||
|
} catch (IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
} finally { |
||||
|
try { |
||||
|
httpclient.close(); |
||||
|
} catch (IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
public static String createUrl(Map<String,Object> param){ |
||||
|
StringBuilder sb = new StringBuilder(); |
||||
|
for (String key : param.keySet()) { |
||||
|
String par = param.get(key).toString(); |
||||
|
try { |
||||
|
par = URLEncoder.encode(par,"UTF-8"); |
||||
|
} catch (UnsupportedEncodingException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
sb.append("&").append(key).append("=").append(par); |
||||
|
} |
||||
|
return sb.toString(); |
||||
|
} |
||||
|
|
||||
|
public static R<String> doGetResult(String url,HashMap<String,String> headers){ |
||||
|
String result = HttpUtil.doGet(url,headers); |
||||
|
log.debug("url:{},result:{}",url,result); |
||||
|
if(result==null){ |
||||
|
Assert.throwEx("远程服务连接失败"); |
||||
|
} |
||||
|
JSONObject jsonObject = JSONObject.parseObject(result); |
||||
|
Integer status = jsonObject.getInteger("status"); |
||||
|
String msg = jsonObject.getString("msg"); |
||||
|
String data = jsonObject.getString("data"); |
||||
|
return new R(status,msg,data); |
||||
|
} |
||||
|
|
||||
|
public static R<String> doPostResult(String url, String jsonStr, HashMap<String,String> headers){ |
||||
|
String result = HttpUtil.doPost(url,jsonStr,headers); |
||||
|
log.debug("url:{},result:{}",url,result); |
||||
|
if(result==null){ |
||||
|
log.warn("jsonStr:{}",jsonStr); |
||||
|
Assert.throwEx("远程服务连接失败"); |
||||
|
} |
||||
|
JSONObject jsonObject = JSONObject.parseObject(result); |
||||
|
Integer status = jsonObject.getInteger("status"); |
||||
|
String msg = jsonObject.getString("msg"); |
||||
|
String data = jsonObject.getString("data"); |
||||
|
return new R(status,msg,data); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,107 @@ |
|||||
|
package com.qs.serve.common.util; |
||||
|
|
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.util.StringUtils; |
||||
|
|
||||
|
import java.sql.*; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 原生JDBC工具类 |
||||
|
* @Author JcYen |
||||
|
* @Date 2021/6/4 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
public class JdbcUtil { |
||||
|
|
||||
|
private static final String[] FILTER_WORD = new String[]{"truncate","create","alter","eval","delete","sp_password"}; |
||||
|
|
||||
|
/** |
||||
|
* 执行SQL(为安全,拦截delete语句) |
||||
|
* @param username |
||||
|
* @param password |
||||
|
* @param url |
||||
|
* @param driverName |
||||
|
* @param sql |
||||
|
* @return |
||||
|
*/ |
||||
|
public static List<Map<String,Object>> query(String username, String password, String url, String driverName, String sql) { |
||||
|
//检查SQL,防止SQL执行DDL语句
|
||||
|
doSqlFilter(sql); |
||||
|
List<Map<String,Object>> list = new ArrayList(); |
||||
|
Connection conn = null; |
||||
|
Statement stmt = null; |
||||
|
ResultSet rs = null; |
||||
|
try { |
||||
|
Class.forName(driverName); |
||||
|
conn = DriverManager.getConnection(url, username, password); |
||||
|
stmt = conn.createStatement(); |
||||
|
log.debug("JDBC工具类 Preparing SQL: {}",url); |
||||
|
rs = stmt.executeQuery(sql); |
||||
|
ResultSetMetaData md = rs.getMetaData(); |
||||
|
int columnCount = md.getColumnCount(); |
||||
|
while (rs.next()) { |
||||
|
Map<String,Object> rowData = new HashMap<>(); |
||||
|
for (int i = 1; i <= columnCount; i++) { |
||||
|
rowData.put(md.getColumnName(i), rs.getObject(i)); |
||||
|
} |
||||
|
list.add(rowData); |
||||
|
} |
||||
|
} catch (ClassNotFoundException e) { |
||||
|
log.warn(e.getMessage()); |
||||
|
} catch (SQLException throwables) { |
||||
|
log.error(throwables.getMessage()); |
||||
|
}finally { |
||||
|
if(rs!=null){ |
||||
|
try { |
||||
|
rs.close(); |
||||
|
} catch (SQLException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
if (stmt!=null){ |
||||
|
try { |
||||
|
stmt.close(); |
||||
|
} catch (SQLException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
if(conn!=null){ |
||||
|
try { |
||||
|
conn.close(); |
||||
|
} catch (SQLException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
rs = null; |
||||
|
stmt = null; |
||||
|
conn = null; |
||||
|
} |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
private static void doSqlFilter(String sql){ |
||||
|
boolean unsafe = false; |
||||
|
String[] parts = sql.split(" "); |
||||
|
for (String part : parts) { |
||||
|
if(unsafe){ break; } |
||||
|
if(StringUtils.isEmpty(part)){ |
||||
|
continue; |
||||
|
} |
||||
|
part = part.trim(); |
||||
|
for (String filterWord : FILTER_WORD) { |
||||
|
if(part.equalsIgnoreCase(filterWord)){ |
||||
|
unsafe = true; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if(unsafe){ |
||||
|
//AssertUtil.("非法SQL被拦截 ==> "+sql);
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.qs.serve.common.util; |
||||
|
|
||||
|
import lombok.experimental.UtilityClass; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/6/8 |
||||
|
*/ |
||||
|
@UtilityClass |
||||
|
public class JumpToUtil { |
||||
|
|
||||
|
public static String getJumpUrl(String host, String templateCode, String targetId) { |
||||
|
return host + "/#/jump?jumpType=apiApproval" + |
||||
|
"&targetCode="+templateCode |
||||
|
+"&targetId="+targetId; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,157 @@ |
|||||
|
package com.qs.serve.common.util; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import com.microsoft.sqlserver.jdbc.SQLServerBulkCopy; |
||||
|
import com.microsoft.sqlserver.jdbc.SQLServerBulkCopyOptions; |
||||
|
import com.sun.rowset.CachedRowSetImpl; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.ibatis.type.JdbcType; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
|
||||
|
import java.lang.reflect.Field; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.sql.*; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* SQL Server工具类 |
||||
|
* @author Trouble |
||||
|
* @version 1.0 |
||||
|
* @since 2024-04-25 15:00 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
public class SqlServerUtil { |
||||
|
|
||||
|
/** |
||||
|
* 批量插入数据库 |
||||
|
* |
||||
|
* @param connectionUrl 数据库连接地址 |
||||
|
* @param list 要保存的对象集 |
||||
|
* @throws SQLException 插入对象失败 |
||||
|
*/ |
||||
|
public static <T> void batchInsert(String connectionUrl, List<T> list) throws SQLException, IllegalAccessException { |
||||
|
long start = System.currentTimeMillis(); |
||||
|
String tableName = null; |
||||
|
//获取表名
|
||||
|
for (T t : list) { |
||||
|
TableName tableNameAnnotation = t.getClass().getAnnotation(TableName.class); |
||||
|
tableName = tableNameAnnotation.value(); |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
CachedRowSetImpl crs = getCachedRowSet(connectionUrl, tableName); |
||||
|
// 将对象转化为行数据
|
||||
|
for (Object obj : list) { |
||||
|
// 以动指针到插入行(虚拟行)
|
||||
|
crs.moveToInsertRow(); |
||||
|
// 设置虚拟行相应的字段与数值;注意:字符串中的字段名与类型要与数据表中的一致
|
||||
|
Field[] declaredFields = obj.getClass().getDeclaredFields(); |
||||
|
for (Field field : declaredFields) { |
||||
|
|
||||
|
if(field.getName().equals("serialVersionUID")){ |
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
field.setAccessible(true); |
||||
|
|
||||
|
TableField tableField = field.getAnnotation(TableField.class); |
||||
|
String fieldName; |
||||
|
// 如果字段名不存在,则跳过
|
||||
|
// 如果字段名为空,则使用默认字段名称
|
||||
|
if (tableField != null) { |
||||
|
if (!tableField.exist()) { |
||||
|
continue; |
||||
|
} |
||||
|
fieldName = tableField.value(); |
||||
|
} else { |
||||
|
fieldName = field.getName(); |
||||
|
} |
||||
|
Object fieldValue = field.get(obj); |
||||
|
|
||||
|
if (tableField != null && tableField.jdbcType().equals(JdbcType.FLOAT)) { |
||||
|
crs.updateBigDecimal(fieldName, (BigDecimal) fieldValue); |
||||
|
} |
||||
|
else { |
||||
|
crs.updateObject(fieldName, fieldValue); |
||||
|
} |
||||
|
} |
||||
|
// 将虚拟行插入缓存
|
||||
|
crs.insertRow(); |
||||
|
// 将指针移动到当前行
|
||||
|
crs.moveToCurrentRow(); |
||||
|
} |
||||
|
saveRows(connectionUrl, tableName, crs, list.size()); |
||||
|
long end = System.currentTimeMillis(); |
||||
|
log.info("批量插入数据表{}成功,数量:{}条,耗时:{}ms", tableName, list.size(), end - start); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取数据表的结构 |
||||
|
* |
||||
|
* @param url 链接对象 |
||||
|
* @param tableName 表名字 |
||||
|
* @return 数据表字段初始化的数据对象 |
||||
|
* @throws SQLException 数据表字段初始化失败 |
||||
|
*/ |
||||
|
public static CachedRowSetImpl getCachedRowSet(String url, String tableName) throws SQLException { |
||||
|
// 链接方式固定(配置)
|
||||
|
Connection con = connection(url); |
||||
|
String sql = String.format("select * from %s where 1 = 0", tableName); |
||||
|
// 执行sql语句封装
|
||||
|
PreparedStatement ps = con.prepareStatement(sql); |
||||
|
// 执行语句
|
||||
|
ResultSet rs = ps.executeQuery(); |
||||
|
// 创建行操作对象
|
||||
|
CachedRowSetImpl crs = new CachedRowSetImpl(); |
||||
|
// 设置表字段
|
||||
|
crs.populate(rs); |
||||
|
// 关闭流资源
|
||||
|
rs.close(); |
||||
|
// 关闭数据库链接
|
||||
|
con.close(); |
||||
|
// 返回含有表字段的行操作对象
|
||||
|
return crs; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 连接数据库 |
||||
|
* |
||||
|
* @param connectionUrl 链接URL |
||||
|
* @return 链接对象 |
||||
|
* @throws SQLException 建立链接失败异常 |
||||
|
*/ |
||||
|
public static Connection connection(String connectionUrl) throws SQLException { |
||||
|
return DriverManager.getConnection(connectionUrl); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将数据插入数据库 |
||||
|
* |
||||
|
* @param connectionUrl 数据库连接地址 |
||||
|
* @param tableName 数据表名称 |
||||
|
* @param crs 数据行操作对象 |
||||
|
* @param size 数据量 |
||||
|
* @throws SQLException 插入数据失败异常 |
||||
|
*/ |
||||
|
public static void saveRows(String connectionUrl, String tableName, CachedRowSetImpl crs, int size) throws SQLException { |
||||
|
SQLServerBulkCopyOptions copyOptions = new SQLServerBulkCopyOptions(); |
||||
|
copyOptions.setKeepIdentity(true); |
||||
|
// 设置批量插入的数量
|
||||
|
copyOptions.setBatchSize(size); |
||||
|
// 开启事务
|
||||
|
copyOptions.setUseInternalTransaction(true); |
||||
|
// 配置url
|
||||
|
SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(connectionUrl); |
||||
|
// 设置批量操作参数
|
||||
|
bulkCopy.setBulkCopyOptions(copyOptions); |
||||
|
// 设置要操作的表名
|
||||
|
bulkCopy.setDestinationTableName(tableName); |
||||
|
// 将数据保存到数据库
|
||||
|
bulkCopy.writeToServer(crs); |
||||
|
// 释放资源
|
||||
|
crs.close(); |
||||
|
// 释放资源
|
||||
|
bulkCopy.close(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,48 @@ |
|||||
|
package com.qs.serve.common.util; |
||||
|
|
||||
|
import cn.hutool.crypto.digest.DigestUtil; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.io.UnsupportedEncodingException; |
||||
|
import java.net.URLEncoder; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/1/26 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
public class TianYiYunSmsUtil { |
||||
|
|
||||
|
private final static String url = "http://sms.189ek.com/yktsms/send?"; |
||||
|
|
||||
|
private final static String appId = "WIgWyCFn4DnHLtjKBIXBVyZbGevFg3J4"; |
||||
|
|
||||
|
private final static String appKey = "bjfsZlF01OZPUzyiCLSFOrOOnfsZhYZJ"; |
||||
|
|
||||
|
public static void sendMsg(String code){ |
||||
|
send("13286630016,15989082884,15913696250",code); |
||||
|
} |
||||
|
|
||||
|
public static void send(String phone,String code){ |
||||
|
//需要发送的手机号(多个号码以英文逗号 “,”分隔) 一次性最多 100 个号码
|
||||
|
String mobiles = phone; |
||||
|
String content = "【嘉士利】尊敬的用户,您预约来访已成功,"+code; |
||||
|
String sign = DigestUtil.md5Hex(appId+mobiles+content+appKey); |
||||
|
try { |
||||
|
String msg = URLEncoder.encode(content,"utf-8"); |
||||
|
String params = "appid="+ appId + |
||||
|
"&mobile="+ mobiles + |
||||
|
"&msg=" + msg + |
||||
|
"&sign=" + sign + |
||||
|
"&extPort="; |
||||
|
String result = HttpUtil.doPost(url+params,"{}",null); |
||||
|
log.debug("sms result = > {}",result); |
||||
|
} catch (UnsupportedEncodingException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,85 @@ |
|||||
|
package com.qs.serve.common.util; |
||||
|
|
||||
|
import com.qs.serve.common.framework.exception.BusinessException; |
||||
|
import lombok.experimental.UtilityClass; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.hibernate.validator.HibernateValidator; |
||||
|
import org.springframework.util.CollectionUtils; |
||||
|
|
||||
|
import javax.validation.ConstraintViolation; |
||||
|
import javax.validation.Validation; |
||||
|
import javax.validation.Validator; |
||||
|
import javax.validation.ValidatorFactory; |
||||
|
import java.util.List; |
||||
|
import java.util.Set; |
||||
|
/** |
||||
|
* validate方法中校验工具类 |
||||
|
* <p> |
||||
|
* 只要在实体中加上相应的validate的相关注解即可 |
||||
|
* </p> |
||||
|
* |
||||
|
* @author Zed |
||||
|
*/ |
||||
|
@UtilityClass |
||||
|
public class ValidateTools { |
||||
|
/** |
||||
|
* 初始化检查器 |
||||
|
*/ |
||||
|
private static final ValidatorFactory VALIDATOR_FACTORY = Validation.byProvider(HibernateValidator.class).configure().failFast(false).buildValidatorFactory(); |
||||
|
private static final Validator VALIDATOR = VALIDATOR_FACTORY.getValidator(); |
||||
|
/** |
||||
|
* 校验返回异常信息 |
||||
|
* |
||||
|
* @param t 实体 |
||||
|
* @param <T> 实体泛型 |
||||
|
*/ |
||||
|
public static <T> String validStr(T t) { |
||||
|
// 构造返回信息
|
||||
|
StringBuilder validMessage = new StringBuilder(); |
||||
|
// 检查实体T
|
||||
|
Set<ConstraintViolation<T>> set = VALIDATOR.validate(t); |
||||
|
// 循环set,获取检查结果
|
||||
|
for (ConstraintViolation<T> vo : set) { |
||||
|
validMessage.append(vo.getMessage()).append(";"); |
||||
|
} |
||||
|
return validMessage.toString(); |
||||
|
} |
||||
|
/** |
||||
|
* 校验实体抛出异常 |
||||
|
* |
||||
|
* @param t 实体 |
||||
|
* @param <T> 实体泛型 |
||||
|
*/ |
||||
|
public static <T> void valid(T t) { |
||||
|
String validStr = validStr(t); |
||||
|
// 抛出业务异常
|
||||
|
if (StringUtils.isNotBlank(validStr)) { |
||||
|
throw new BusinessException(validStr,500); |
||||
|
} |
||||
|
} |
||||
|
/** |
||||
|
* 校验集合抛出异常 |
||||
|
* |
||||
|
* @param list 列表 |
||||
|
* @param <T> 实体泛型 |
||||
|
*/ |
||||
|
public static <T> void valid(List<T> list) { |
||||
|
if (CollectionUtils.isEmpty(list)) { |
||||
|
throw new BusinessException("数据不存在!",500); |
||||
|
} |
||||
|
// 构造返回信息
|
||||
|
StringBuilder validMessageTotal = new StringBuilder(); |
||||
|
// 遍历
|
||||
|
for (int i = 0; i < list.size(); i++) { |
||||
|
String validStr = validStr(list.get(i)); |
||||
|
if (StringUtils.isNotBlank(validStr)) { |
||||
|
String msg = String.format("第%d条数据校验结果:[%s]\n", i + 1, validStr); |
||||
|
validMessageTotal.append(msg); |
||||
|
} |
||||
|
} |
||||
|
// 抛出业务异常
|
||||
|
if (StringUtils.isNotBlank(validMessageTotal.toString())) { |
||||
|
throw new BusinessException(validMessageTotal.toString(),500); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package com.qs.serve.common.util.bus; |
||||
|
|
||||
|
import com.qs.serve.common.util.Assert; |
||||
|
import com.qs.serve.modules.vtb.entity.so.VtbActivityCheckSo; |
||||
|
|
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.temporal.ChronoUnit; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/11/1 |
||||
|
*/ |
||||
|
public class QueryFilterUtil { |
||||
|
|
||||
|
public static void filterSubmitDate(LocalDateTime startDate,LocalDateTime endDate,int maxDays) { |
||||
|
filterDate(startDate,endDate,maxDays,"申请时间段"); |
||||
|
} |
||||
|
|
||||
|
public static void filterDate(LocalDateTime startDate,LocalDateTime endDate,int maxDays,String timeName) { |
||||
|
if(startDate==null||endDate==null){ |
||||
|
Assert.throwEx("请选择"+timeName); |
||||
|
} |
||||
|
long daysBetween = ChronoUnit.DAYS.between(startDate, endDate); |
||||
|
if(daysBetween > maxDays){ |
||||
|
Assert.throwEx(timeName+"跨度最大值(天):"+maxDays); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package com.qs.serve.common.util.model; |
||||
|
|
||||
|
import com.fasterxml.jackson.core.JacksonException; |
||||
|
import com.fasterxml.jackson.core.JsonParser; |
||||
|
import com.fasterxml.jackson.databind.DeserializationContext; |
||||
|
import com.fasterxml.jackson.databind.JsonDeserializer; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/7/25 |
||||
|
*/ |
||||
|
public class QsJsonLocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> { |
||||
|
|
||||
|
final DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
||||
|
|
||||
|
@Override |
||||
|
public LocalDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JacksonException { |
||||
|
String val = jsonParser.getText(); |
||||
|
if (val==null||val.isEmpty()){ |
||||
|
return null; |
||||
|
} |
||||
|
return LocalDateTime.parse(val,df); |
||||
|
} |
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
package com.qs.serve.controller.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/6/8 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SyLoginParam { |
||||
|
|
||||
|
/** |
||||
|
* 模板编码 |
||||
|
*/ |
||||
|
private String templateCode; |
||||
|
|
||||
|
/** |
||||
|
* 表单data的exsp5字段值 |
||||
|
*/ |
||||
|
private String key; |
||||
|
|
||||
|
/** |
||||
|
* 致远员工id |
||||
|
*/ |
||||
|
private String syId; |
||||
|
|
||||
|
} |
@ -0,0 +1,146 @@ |
|||||
|
package com.qs.serve.controller.util; |
||||
|
|
||||
|
import com.qs.serve.modules.tbs.common.TbsSeeYonConst; |
||||
|
import lombok.experimental.UtilityClass; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/6/12 |
||||
|
*/ |
||||
|
@UtilityClass |
||||
|
public class SyKeyLoginUtil { |
||||
|
|
||||
|
/** |
||||
|
* 获取待审批详情 |
||||
|
* @param templateCode |
||||
|
* @param targetId |
||||
|
* @param affairId |
||||
|
* @return |
||||
|
*/ |
||||
|
public static String getPreCheckUrl(String templateCode,String targetId,String affairId){ |
||||
|
if(templateCode.equals(TbsSeeYonConst.CostApplyConf.Code()) |
||||
|
||templateCode.equals(TbsSeeYonConst.CostApplyContractConf.Code())){ |
||||
|
return "my-expense-application-approval-pending-detail?expenseApplicationId="+targetId+"&approvalId="+affairId; |
||||
|
} |
||||
|
|
||||
|
if(templateCode.equals(TbsSeeYonConst.CheckCostAgreeConf.Code())){ |
||||
|
return "my-expense-application-agreement-terms-approval-pending-detail?agreementTermsId="+targetId+"&approvalId="+affairId; |
||||
|
} |
||||
|
|
||||
|
// if(templateCode.equals(TbsSeeYonConst.CostCheckConf.Code())){
|
||||
|
// return "my-expense-application-activity-write-off-approval-pending-detail?" +
|
||||
|
// "expenseApplicationId=382658" + //费用id
|
||||
|
// "&writeOffId=1936474" + //核销id
|
||||
|
// "&activityId=2277848" + //活动id
|
||||
|
// "&approvalId="+affairId;
|
||||
|
// }
|
||||
|
if(templateCode.equals(TbsSeeYonConst.PolicyConf.Code())){ |
||||
|
return "my-policy-application-approval-pending-detail?policyApplicationId=" + targetId + |
||||
|
"&approvalId="+affairId; |
||||
|
} |
||||
|
return "404"; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取核销待审批详情 |
||||
|
* @param costApplyId |
||||
|
* @param activityId |
||||
|
* @param verificationId |
||||
|
* @param affairId |
||||
|
* @return |
||||
|
*/ |
||||
|
public static String getPreCheckUrl4Verification(Long costApplyId, |
||||
|
Long activityId, |
||||
|
Long verificationId, |
||||
|
String affairId){ |
||||
|
return "my-expense-application-activity-write-off-approval-pending-detail?" + |
||||
|
"expenseApplicationId=" + costApplyId+ //费用id
|
||||
|
"&writeOffId=" + verificationId +//核销id
|
||||
|
"&activityId=" + activityId +//活动id
|
||||
|
"&approvalId="+affairId; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 获取已审批详情 |
||||
|
* @param templateCode |
||||
|
* @param targetId |
||||
|
* @return |
||||
|
*/ |
||||
|
public static String getCheckedDetailUrl(String templateCode,String targetId){ |
||||
|
if(templateCode.equals(TbsSeeYonConst.CostApplyConf.Code())){ |
||||
|
return "my-expense-application-approval-approved-detail?expenseApplicationId="+targetId |
||||
|
+"&approvalId=0"; |
||||
|
} |
||||
|
if(templateCode.equals(TbsSeeYonConst.PolicyConf.Code())){ |
||||
|
return "my-channel-discount-policy-application-approval-pending-detail?channelDiscountPolicyApplicationId="+targetId+"&approvalId=0"; |
||||
|
} |
||||
|
return "404"; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取核销待审批详情 |
||||
|
* @param costApplyId |
||||
|
* @param activityId |
||||
|
* @param verificationId |
||||
|
* @return |
||||
|
*/ |
||||
|
public static String getCheckedDetailUrl4Verification(Long costApplyId, |
||||
|
Long activityId, |
||||
|
Long verificationId){ |
||||
|
return "my-expense-application-activity-write-off-approval-approved-detail?" + |
||||
|
"expenseApplicationId=" + costApplyId+ //费用id
|
||||
|
"&writeOffId=" + verificationId +//核销id
|
||||
|
"&activityId=" + activityId +//活动id
|
||||
|
"&approvalId=0"; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取个人申请详情 |
||||
|
* @param templateCode |
||||
|
* @param targetId |
||||
|
* @return |
||||
|
*/ |
||||
|
public static String getMyDetailUrl(String templateCode,String targetId){ |
||||
|
if(templateCode.equals(TbsSeeYonConst.CostApplyConf.Code()) |
||||
|
|| templateCode.equals(TbsSeeYonConst.BatchCostCheckConf.Code()) |
||||
|
){ |
||||
|
return "my-expense-application-detail?id="+targetId; |
||||
|
} |
||||
|
if(templateCode.equals(TbsSeeYonConst.PolicyConf.Code())){ |
||||
|
return "my-policy-application-detail?id="+targetId; |
||||
|
} |
||||
|
return "404"; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 获取批量核销已审批详情 |
||||
|
* @param costApplyId |
||||
|
* @param batchId |
||||
|
* @param affairId |
||||
|
* @return |
||||
|
*/ |
||||
|
public static String getCheckedUrl4BatchVerification(Long costApplyId, String affairId,Long batchId){ |
||||
|
return "my-expense-application-activity-batch-write-off-approval-approved-detail?" + |
||||
|
"expenseApplicationId=" + costApplyId + |
||||
|
"&approvalId=" + affairId + |
||||
|
"&batchWriteOffId=" + batchId; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取批量核销已审批详情 |
||||
|
* @param costApplyId |
||||
|
* @param batchId |
||||
|
* @param affairId |
||||
|
* @return |
||||
|
*/ |
||||
|
public static String getUnCheckedUrl4BatchVerification(Long costApplyId, String affairId,Long batchId){ |
||||
|
return "my-expense-application-activity-batch-write-off-approval-pending-detail?" + |
||||
|
"expenseApplicationId=" + costApplyId + |
||||
|
"&approvalId=" + affairId + |
||||
|
"&batchWriteOffId=" + batchId; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,40 @@ |
|||||
|
package com.qs.serve.modules.base; |
||||
|
|
||||
|
import cn.hutool.crypto.digest.DigestUtil; |
||||
|
import com.qs.serve.common.config.properties.QiShengDsProperties; |
||||
|
import com.qs.serve.common.util.HttpUtil; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import javax.annotation.PostConstruct; |
||||
|
import java.io.UnsupportedEncodingException; |
||||
|
import java.net.URLEncoder; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/1/26 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
public class ErpDataBaseService { |
||||
|
|
||||
|
@Autowired |
||||
|
private QiShengDsProperties qiShengDsProperties; |
||||
|
|
||||
|
public static String erpJslGroupDbConnectionUrl; |
||||
|
|
||||
|
public static String getErpJslGroupDbConnectionUrl(){ |
||||
|
return erpJslGroupDbConnectionUrl; |
||||
|
} |
||||
|
|
||||
|
@PostConstruct |
||||
|
public void initErpJslGroupDbConnectionUrl() { |
||||
|
log.warn("数据库加载... ErpJslGroupDbConnectionUrl:{}",erpJslGroupDbConnectionUrl); |
||||
|
erpJslGroupDbConnectionUrl = qiShengDsProperties.getUrl() |
||||
|
+ ";user=" + qiShengDsProperties.getUsername() |
||||
|
+ ";password=" + qiShengDsProperties.getPassword(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,48 @@ |
|||||
|
package com.qs.serve.modules.base; |
||||
|
|
||||
|
import cn.hutool.crypto.digest.DigestUtil; |
||||
|
import com.qs.serve.common.util.HttpUtil; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.io.UnsupportedEncodingException; |
||||
|
import java.net.URLEncoder; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/1/26 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
public class TianYiYunSmsService { |
||||
|
|
||||
|
private final String url = "http://sms.189ek.com/yktsms/send?"; |
||||
|
|
||||
|
@Value("${tianyi.sms.appid}") |
||||
|
private String appId; |
||||
|
|
||||
|
@Value("${tianyi.sms.appKey}") |
||||
|
private String appKey; |
||||
|
|
||||
|
public void send(String phone,String code){ |
||||
|
//需要发送的手机号(多个号码以英文逗号 “,”分隔) 一次性最多 100 个号码
|
||||
|
String mobiles = phone; |
||||
|
String content = "【嘉士利】验证码"+code; |
||||
|
String sign = DigestUtil.md5Hex(appId+mobiles+content+appKey); |
||||
|
try { |
||||
|
String msg = URLEncoder.encode(content,"utf-8"); |
||||
|
String params = "appid="+ appId + |
||||
|
"&mobile="+ mobiles + |
||||
|
"&msg=" + msg + |
||||
|
"&sign=" + sign + |
||||
|
"&extPort="; |
||||
|
String result = HttpUtil.doPost(url+params,"{}",null); |
||||
|
log.debug("sms result = > {}",result); |
||||
|
} catch (UnsupportedEncodingException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,122 @@ |
|||||
|
package com.qs.serve.modules.base.controller; |
||||
|
|
||||
|
import cn.hutool.crypto.SecureUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.qs.serve.common.model.annotation.SysLog; |
||||
|
import com.qs.serve.common.model.consts.GySysConst; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.common.model.enums.BizType; |
||||
|
import com.qs.serve.common.model.enums.SystemModule; |
||||
|
import com.qs.serve.common.util.AuthContextUtils; |
||||
|
import com.qs.serve.common.util.CopierUtil; |
||||
|
import com.qs.serve.common.util.ValidateTools; |
||||
|
import com.qs.serve.modules.bms.entity.bo.BmsSupplierBatchBo; |
||||
|
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper; |
||||
|
import com.qs.serve.modules.bms.service.BmsSupplierService; |
||||
|
import com.qs.serve.modules.goods.entity.bo.GoodsSpuBatchTasteBo; |
||||
|
import com.qs.serve.modules.goods.service.GoodsSpuService; |
||||
|
import com.qs.serve.modules.sys.entity.SysUser; |
||||
|
import com.qs.serve.modules.sys.entity.bo.SysUserBatchBo; |
||||
|
import com.qs.serve.modules.sys.entity.bo.SysUserBo; |
||||
|
import com.qs.serve.modules.sys.service.SysRoleService; |
||||
|
import com.qs.serve.modules.sys.service.SysUserSalesService; |
||||
|
import com.qs.serve.modules.sys.service.SysUserService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
|
||||
|
/** |
||||
|
* 【嘉士利对接】 |
||||
|
* @author YenHex |
||||
|
* @since 2022/10/28 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
//@RestController
|
||||
|
//@RequestMapping("/jsl")
|
||||
|
public class JslApiController { |
||||
|
|
||||
|
private SysUserService sysUserService; |
||||
|
private SysRoleService sysRoleService; |
||||
|
private BmsSupplierService bmsSupplierService; |
||||
|
private SysUserSalesService sysUserSalesService; |
||||
|
private GoodsSpuService goodsSpuService; |
||||
|
|
||||
|
/** |
||||
|
* 客户档案 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
//@PostMapping("/supplier/editBatch")
|
||||
|
//@SysLog(module = SystemModule.BASE, title = "供应商", biz = BizType.INSERT)
|
||||
|
@PreAuthorize("hasRole('bms:supplier:insert')") |
||||
|
public R<?> editBatch(@RequestBody @Valid BmsSupplierBatchBo param){ |
||||
|
bmsSupplierService.editBatch(param); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 业务员档案 |
||||
|
* @param batchBo |
||||
|
* @return |
||||
|
*/ |
||||
|
//@SysLog(title = "人员",desc = "用户新增",biz = BizType.INSERT)
|
||||
|
//@PostMapping("/user/editBatch")
|
||||
|
//@PreAuthorize("hasRole('sys:user:insert')")
|
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public R<?> saveBatch(@RequestBody @Valid SysUserBatchBo batchBo){ |
||||
|
for (SysUserBo userBo : batchBo.getUserList()) { |
||||
|
SysUser dbData = sysUserService.getById(userBo.getId()); |
||||
|
SysUser param = CopierUtil.copy(userBo,dbData==null?new SysUser():dbData); |
||||
|
//设置普通管理员
|
||||
|
param.setSuperFlag(0); |
||||
|
param.setTenantId(AuthContextUtils.getTenant()); |
||||
|
param.setAccount(param.getMobile()); |
||||
|
param.setPassword(SecureUtil.md5(GySysConst.DEFAULT_PASSWORD)); |
||||
|
if(param.getMobile()!=null){ |
||||
|
param.setAccount(param.getMobile()); |
||||
|
} |
||||
|
//检查手机号是否已用
|
||||
|
LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>(); |
||||
|
wrapper.ne(SysUser::getId,userBo.getId()); |
||||
|
wrapper.eq(SysUser::getMobile,param.getMobile()); |
||||
|
Long count = sysUserService.count(wrapper); |
||||
|
if(count>0L){ |
||||
|
return R.error("手机号已被注册"); |
||||
|
} |
||||
|
if(dbData == null){ |
||||
|
sysUserService.save(param); |
||||
|
}else { |
||||
|
sysUserService.updateById(param); |
||||
|
} |
||||
|
// if(param.getId()!=null&& com.qs.serve.common.util.CollectionUtil.isNotEmpty(userBo.getRoleIds())){
|
||||
|
// sysRoleService.saveUserRole4Edit(userBo.getRoleIds(),param.getId());
|
||||
|
// }
|
||||
|
} |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* (批量)编辑口味品类SPU,建议每次小于50条 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
//@PostMapping("/saveBatchTasteSpu")
|
||||
|
//@SysLog(module = SystemModule.GOODS, title = "spu", biz = BizType.INSERT)
|
||||
|
//@PreAuthorize("hasRole('goods:spu:insert')")
|
||||
|
public R<?> saveBatchTasteSpu(@RequestBody GoodsSpuBatchTasteBo param){ |
||||
|
ValidateTools.valid(param.getTasteProducts()); |
||||
|
return R.ok(goodsSpuService.saveBatchTasteSpu(param)); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
package com.qs.serve.modules.baz.common; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/4/7 |
||||
|
*/ |
||||
|
public interface BazTargetTypeConsts { |
||||
|
|
||||
|
String POINT = "point"; |
||||
|
String CUSTOMER = "customer"; |
||||
|
|
||||
|
} |
@ -0,0 +1,148 @@ |
|||||
|
package com.qs.serve.modules.baz.controller; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.qs.serve.common.model.annotation.SysLog; |
||||
|
import com.qs.serve.common.model.dto.PageVo; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.common.model.enums.BizType; |
||||
|
import com.qs.serve.common.model.enums.SystemModule; |
||||
|
import com.qs.serve.common.util.PageUtil; |
||||
|
import com.qs.serve.common.util.CopierUtil; |
||||
|
import com.qs.serve.common.util.StringUtils; |
||||
|
import com.qs.serve.modules.baz.entity.BazVisitFlow; |
||||
|
import com.qs.serve.modules.baz.service.BazVisitFlowService; |
||||
|
import com.qs.serve.modules.bms.entity.BmsSupplierVisitForm; |
||||
|
import com.qs.serve.modules.bms.service.BmsSupplierVisitFormService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import com.qs.serve.modules.baz.entity.BazVisit; |
||||
|
import com.qs.serve.modules.baz.service.BazVisitService; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 拜访模块 拜访 |
||||
|
* @author YenHex |
||||
|
* @since 2023-04-07 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("baz/visit") |
||||
|
public class BazVisitController { |
||||
|
|
||||
|
private BazVisitService bazVisitService; |
||||
|
|
||||
|
private BazVisitFlowService bazVisitFlowService; |
||||
|
|
||||
|
private BmsSupplierVisitFormService bmsSupplierVisitFormService; |
||||
|
|
||||
|
/** |
||||
|
* 列表 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/list") |
||||
|
public R<List<BazVisit>> getList(BazVisit param){ |
||||
|
LambdaQueryWrapper<BazVisit> lqw = new LambdaQueryWrapper<>(param); |
||||
|
List<BazVisit> list = bazVisitService.list(lqw); |
||||
|
return R.ok(list); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 获取第一个流程 |
||||
|
* @param visitId |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/getFirstFlow/{visitId}") |
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访流程", biz = BizType.QUERY) |
||||
|
public R<BazVisitFlow> getFirstFlow(@PathVariable("visitId") String visitId){ |
||||
|
LambdaQueryWrapper<BazVisitFlow> lqw = new LambdaQueryWrapper<>(); |
||||
|
lqw.eq(BazVisitFlow::getFlowSort,1); |
||||
|
lqw.eq(BazVisitFlow::getVisitId,visitId); |
||||
|
BazVisitFlow bazVisitFlow = bazVisitFlowService.getOne(lqw,false); |
||||
|
if(bazVisitFlow.getFormId()!=null&&!bazVisitFlow.getFormId().equals(0L)){ |
||||
|
BmsSupplierVisitForm visitForm = bmsSupplierVisitFormService.getById(bazVisitFlow.getFormId()); |
||||
|
bazVisitFlow.setFormInfo(visitForm); |
||||
|
}else { |
||||
|
bazVisitFlow.setFormId(null); |
||||
|
} |
||||
|
return R.ok(bazVisitFlow); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 翻页 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
//@GetMapping("/page")
|
||||
|
@PreAuthorize("hasRole('baz:visit:query')") |
||||
|
public R<PageVo<BazVisit>> getPage(BazVisit param){ |
||||
|
LambdaQueryWrapper<BazVisit> lqw = new LambdaQueryWrapper<>(param); |
||||
|
PageUtil.startPage(); |
||||
|
List<BazVisit> list = bazVisitService.list(lqw); |
||||
|
return R.byPageHelperList(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* ID查询 |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
//@GetMapping("/getById/{id}")
|
||||
|
//@SysLog(module = SystemModule.BAZ, title = "拜访", biz = BizType.QUERY)
|
||||
|
@PreAuthorize("hasRole('baz:visit:query')") |
||||
|
public R<BazVisit> getById(@PathVariable("id") String id){ |
||||
|
BazVisit bazVisit = bazVisitService.getById(id); |
||||
|
return R.ok(bazVisit); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 更新 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
//@PostMapping("/updateById")
|
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访", biz = BizType.UPDATE) |
||||
|
@PreAuthorize("hasRole('baz:visit:update')") |
||||
|
public R<?> updateById(@RequestBody @Valid BazVisit param){ |
||||
|
boolean result = bazVisitService.updateById(param); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
//@PostMapping("/save")
|
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访", biz = BizType.INSERT) |
||||
|
@PreAuthorize("hasRole('baz:visit:insert')") |
||||
|
public R<?> save(@RequestBody @Valid BazVisit param){ |
||||
|
boolean result = bazVisitService.save(param); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除 |
||||
|
* @param ids |
||||
|
* @return |
||||
|
*/ |
||||
|
//@DeleteMapping("/deleteById/{ids}")
|
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访", biz = BizType.DELETE) |
||||
|
@PreAuthorize("hasRole('baz:visit:delete')") |
||||
|
public R<?> deleteById(@PathVariable("ids") String ids){ |
||||
|
List<Long> idsLong = StringUtils.splitIdLong(ids); |
||||
|
boolean result = bazVisitService.removeByIds(idsLong); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,153 @@ |
|||||
|
package com.qs.serve.modules.baz.controller; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.qs.serve.common.model.annotation.SysLog; |
||||
|
import com.qs.serve.common.model.dto.PageVo; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.common.model.enums.BizType; |
||||
|
import com.qs.serve.common.model.enums.SystemModule; |
||||
|
import com.qs.serve.common.util.PageUtil; |
||||
|
import com.qs.serve.common.util.CopierUtil; |
||||
|
import com.qs.serve.common.util.StringUtils; |
||||
|
import com.qs.serve.modules.baz.entity.bo.BazVisitFlowSortBo; |
||||
|
import com.qs.serve.modules.bms.entity.BmsSupplierVisitForm; |
||||
|
import com.qs.serve.modules.bms.service.BmsSupplierVisitFormService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import com.qs.serve.modules.baz.entity.so.BazVisitFlowSo; |
||||
|
import com.qs.serve.modules.baz.entity.bo.BazVisitFlowBo; |
||||
|
import com.qs.serve.modules.baz.entity.BazVisitFlow; |
||||
|
import com.qs.serve.modules.baz.service.BazVisitFlowService; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import java.util.Comparator; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 拜访模块 拜访流程 |
||||
|
* @author YenHex |
||||
|
* @since 2023-04-07 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("baz/visitFlow") |
||||
|
public class BazVisitFlowController { |
||||
|
|
||||
|
private BazVisitFlowService bazVisitFlowService; |
||||
|
private BmsSupplierVisitFormService visitFormService; |
||||
|
|
||||
|
/** |
||||
|
* 列表 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/list") |
||||
|
public R<List<BazVisitFlow>> getList(BazVisitFlowSo param){ |
||||
|
BazVisitFlow entity = CopierUtil.copy(param,new BazVisitFlow()); |
||||
|
LambdaQueryWrapper<BazVisitFlow> lqw = new LambdaQueryWrapper<>(entity); |
||||
|
lqw.orderByAsc(BazVisitFlow::getFlowSort); |
||||
|
List<BazVisitFlow> list = bazVisitFlowService.list(lqw); |
||||
|
return R.ok(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 翻页 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/page") |
||||
|
public R<PageVo<BazVisitFlow>> getPage(BazVisitFlowSo param){ |
||||
|
BazVisitFlow entity = CopierUtil.copy(param,new BazVisitFlow()); |
||||
|
LambdaQueryWrapper<BazVisitFlow> lqw = new LambdaQueryWrapper<>(entity); |
||||
|
PageUtil.startPage(); |
||||
|
lqw.orderByAsc(BazVisitFlow::getFlowSort); |
||||
|
List<BazVisitFlow> list = bazVisitFlowService.list(lqw); |
||||
|
return R.byPageHelperList(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* ID查询 |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/getById/{id}") |
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访流程", biz = BizType.QUERY) |
||||
|
public R<BazVisitFlow> getById(@PathVariable("id") String id){ |
||||
|
BazVisitFlow bazVisitFlow = bazVisitFlowService.getById(id); |
||||
|
if(bazVisitFlow.getFormId()!=null&&!bazVisitFlow.getFormId().equals(0L)){ |
||||
|
BmsSupplierVisitForm visitForm = visitFormService.getById(bazVisitFlow.getFormId()); |
||||
|
bazVisitFlow.setFormInfo(visitForm); |
||||
|
}else { |
||||
|
bazVisitFlow.setFormId(null); |
||||
|
} |
||||
|
return R.ok(bazVisitFlow); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 更新 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/updateById") |
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访流程", biz = BizType.UPDATE) |
||||
|
public R<?> updateById(@RequestBody @Valid BazVisitFlowBo param){ |
||||
|
if(param.getId()==null){ |
||||
|
return R.error2(); |
||||
|
} |
||||
|
bazVisitFlowService.modify(param); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/save") |
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访流程", biz = BizType.INSERT) |
||||
|
public R<?> save(@RequestBody @Valid BazVisitFlowBo param){ |
||||
|
param.setId(null); |
||||
|
BazVisitFlow visitFlow = bazVisitFlowService.modify(param); |
||||
|
return R.ok(visitFlow); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 更新排序 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/sort") |
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访流程", biz = BizType.INSERT) |
||||
|
public R<?> sort(@RequestBody @Valid BazVisitFlowSortBo param){ |
||||
|
List<BazVisitFlowSortBo.Item> items = param.getSortValues(); |
||||
|
items.sort(Comparator.comparingInt(BazVisitFlowSortBo.Item::getSortValue)); |
||||
|
for (int i = 0; i < items.size(); i++) { |
||||
|
BazVisitFlowSortBo.Item item = items.get(i); |
||||
|
BazVisitFlow visitFlow = new BazVisitFlow(); |
||||
|
visitFlow.setId(item.getId()); |
||||
|
visitFlow.setFlowSort(i+1); |
||||
|
bazVisitFlowService.updateById(visitFlow); |
||||
|
} |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除 |
||||
|
* @param ids |
||||
|
* @return |
||||
|
*/ |
||||
|
@DeleteMapping("/deleteById/{ids}") |
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访流程", biz = BizType.DELETE) |
||||
|
public R<?> deleteById(@PathVariable("ids") String ids){ |
||||
|
List<Long> idsLong = StringUtils.splitIdLong(ids); |
||||
|
boolean result = bazVisitFlowService.removeByIds(idsLong); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,162 @@ |
|||||
|
package com.qs.serve.modules.baz.controller; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.qs.serve.common.model.annotation.SysLog; |
||||
|
import com.qs.serve.common.model.dto.PageVo; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.common.model.enums.BizType; |
||||
|
import com.qs.serve.common.model.enums.SystemModule; |
||||
|
import com.qs.serve.common.util.AuthContextUtils; |
||||
|
import com.qs.serve.common.util.PageUtil; |
||||
|
import com.qs.serve.common.util.CopierUtil; |
||||
|
import com.qs.serve.common.util.StringUtils; |
||||
|
import com.qs.serve.modules.baz.entity.BazVisitInstanceFlow; |
||||
|
import com.qs.serve.modules.baz.service.BazVisitInstanceFlowService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import com.qs.serve.modules.baz.entity.so.BazVisitInstanceSo; |
||||
|
import com.qs.serve.modules.baz.entity.BazVisitInstance; |
||||
|
import com.qs.serve.modules.baz.service.BazVisitInstanceService; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 拜访模块 拜访实例 |
||||
|
* @author YenHex |
||||
|
* @since 2023-04-07 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("baz/visitInstance") |
||||
|
public class BazVisitInstanceController { |
||||
|
|
||||
|
private BazVisitInstanceService bazVisitInstanceService; |
||||
|
private BazVisitInstanceFlowService bazVisitInstanceFlowService; |
||||
|
|
||||
|
/** |
||||
|
* 翻页 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/page") |
||||
|
public R<PageVo<BazVisitInstance>> getPage(BazVisitInstanceSo param){ |
||||
|
BazVisitInstance query = CopierUtil.copy(param,new BazVisitInstance()); |
||||
|
if(param.getQueryStartDate()!=null){ |
||||
|
query.setQueryStartDate(param.getQueryStartDate().atStartOfDay()); |
||||
|
} |
||||
|
if(param.getQueryEndDate()!=null){ |
||||
|
query.setQueryEndDate(param.getQueryEndDate().atTime(23,59,59)); |
||||
|
} |
||||
|
PageUtil.startPage(); |
||||
|
List<BazVisitInstance> list = bazVisitInstanceService.selectBazVisitInstanceList(query); |
||||
|
return R.byPageHelperList(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 列表 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/list") |
||||
|
public R<List<BazVisitInstance>> getList(BazVisitInstanceSo param){ |
||||
|
BazVisitInstance query = CopierUtil.copy(param,new BazVisitInstance()); |
||||
|
if(param.getQueryStartDate()!=null){ |
||||
|
query.setQueryStartDate(param.getQueryStartDate().atStartOfDay()); |
||||
|
} |
||||
|
if(param.getQueryEndDate()!=null){ |
||||
|
query.setQueryEndDate(param.getQueryEndDate().atTime(23,59,59)); |
||||
|
} |
||||
|
List<BazVisitInstance> list = bazVisitInstanceService.selectBazVisitInstanceList(query); |
||||
|
|
||||
|
if(param.getLoadFlowList()!=null&¶m.getLoadFlowList().equals(1)){ |
||||
|
List<Long> ids = list.stream().map(BazVisitInstance::getId).collect(Collectors.toList()); |
||||
|
ids.add(-1L); |
||||
|
LambdaQueryWrapper<BazVisitInstanceFlow> lqw = new LambdaQueryWrapper<>(); |
||||
|
lqw.in(BazVisitInstanceFlow::getVisitInstanceId,ids); |
||||
|
List<BazVisitInstanceFlow> allFlowList = bazVisitInstanceFlowService.list(lqw); |
||||
|
Map<Long,List<BazVisitInstanceFlow>> flowListGroupByVisitInstanceId = allFlowList.stream() |
||||
|
.collect(Collectors.groupingBy(BazVisitInstanceFlow::getVisitInstanceId)); |
||||
|
for (BazVisitInstance instance : list) { |
||||
|
List<BazVisitInstanceFlow> fl = flowListGroupByVisitInstanceId.get(instance.getId()); |
||||
|
instance.setFlowList(fl); |
||||
|
} |
||||
|
} |
||||
|
return R.ok(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* ID查询 |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/getById/{id}") |
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访实例", biz = BizType.QUERY) |
||||
|
public R<BazVisitInstance> getById(@PathVariable("id") String id){ |
||||
|
BazVisitInstance bazVisitInstance = bazVisitInstanceService.getById(id); |
||||
|
LambdaQueryWrapper<BazVisitInstanceFlow> lqw = new LambdaQueryWrapper<>(); |
||||
|
lqw.eq(BazVisitInstanceFlow::getVisitInstanceId,id); |
||||
|
List<BazVisitInstanceFlow> flowList = bazVisitInstanceFlowService.list(lqw); |
||||
|
bazVisitInstance.setFlowList(flowList); |
||||
|
return R.ok(bazVisitInstance); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* ID查询(流程项) |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/getByFlowId/{id}") |
||||
|
public R<BazVisitInstanceFlow> getByFlowId(@PathVariable("id") String id){ |
||||
|
BazVisitInstanceFlow instanceFlow = bazVisitInstanceFlowService.getById(id); |
||||
|
BazVisitInstance visitInstance = bazVisitInstanceService.getById(instanceFlow.getVisitInstanceId()); |
||||
|
instanceFlow.setInstanceMainInfo(visitInstance); |
||||
|
return R.ok(instanceFlow); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 更新 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
//@PostMapping("/updateById")
|
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访实例", biz = BizType.UPDATE) |
||||
|
public R<?> updateById(@RequestBody @Valid BazVisitInstance param){ |
||||
|
boolean result = bazVisitInstanceService.updateById(param); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
//@PostMapping("/save")
|
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访实例", biz = BizType.INSERT) |
||||
|
public R<?> save(@RequestBody @Valid BazVisitInstance param){ |
||||
|
boolean result = bazVisitInstanceService.save(param); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除 |
||||
|
* @param ids |
||||
|
* @return |
||||
|
*/ |
||||
|
@DeleteMapping("/deleteById/{ids}") |
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访实例", biz = BizType.DELETE) |
||||
|
public R<?> deleteById(@PathVariable("ids") String ids){ |
||||
|
List<Long> idsLong = StringUtils.splitIdLong(ids); |
||||
|
boolean result = bazVisitInstanceService.removeByIds(idsLong); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,232 @@ |
|||||
|
package com.qs.serve.modules.baz.controller.my; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.qs.serve.common.model.annotation.SysLog; |
||||
|
import com.qs.serve.common.model.dto.PageVo; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.common.model.enums.BizType; |
||||
|
import com.qs.serve.common.model.enums.SystemModule; |
||||
|
import com.qs.serve.common.util.*; |
||||
|
import com.qs.serve.modules.baz.entity.BazVisit; |
||||
|
import com.qs.serve.modules.baz.entity.BazVisitInstance; |
||||
|
import com.qs.serve.modules.baz.entity.bo.BazCreateVisitInstanceBo; |
||||
|
import com.qs.serve.modules.baz.entity.bo.BazVisitInstanceFlowBo; |
||||
|
import com.qs.serve.modules.baz.entity.so.BazVisitInstanceSo; |
||||
|
import com.qs.serve.modules.baz.service.BazVisitInstanceService; |
||||
|
import com.qs.serve.modules.baz.service.BazVisitService; |
||||
|
import com.qs.serve.modules.sys.service.SysPostService; |
||||
|
import com.qs.serve.modules.sys.service.SysPostUserService; |
||||
|
import com.qs.serve.modules.sys.service.SysUserSalesService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import java.time.LocalDate; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 拜访模块 拜访实例(我的) |
||||
|
* @author YenHex |
||||
|
* @since 2023-04-07 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("baz/myVisitInstance") |
||||
|
public class BazMyVisitInstanceController { |
||||
|
|
||||
|
private BazVisitInstanceService bazVisitInstanceService; |
||||
|
private BazVisitService visitService; |
||||
|
private SysPostUserService postUserService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 翻页 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/page") |
||||
|
public R<PageVo<BazVisitInstance>> getPage(BazVisitInstanceSo param){ |
||||
|
BazVisitInstance entity = CopierUtil.copy(param,new BazVisitInstance()); |
||||
|
LambdaQueryWrapper<BazVisitInstance> lqw = new LambdaQueryWrapper<>(entity); |
||||
|
if(param.getQueryStartDate()!=null){ |
||||
|
lqw.ge(BazVisitInstance::getCreateTime,param.getQueryStartDate()); |
||||
|
} |
||||
|
if(param.getQueryEndDate()!=null){ |
||||
|
lqw.le(BazVisitInstance::getCreateTime,param.getQueryEndDate().atTime(23,59,59)); |
||||
|
} |
||||
|
PageUtil.startPage(); |
||||
|
lqw.eq(BazVisitInstance::getVisitorId, AuthContextUtils.getSysUserId()); |
||||
|
lqw.orderByDesc(BazVisitInstance::getCreateTime); |
||||
|
List<BazVisitInstance> list = bazVisitInstanceService.list(lqw); |
||||
|
return R.byPageHelperList(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 翻页(我的部下) |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/page4Under") |
||||
|
public R<PageVo<BazVisitInstance>> page4Under(BazVisitInstanceSo param){ |
||||
|
BazVisitInstance entity = CopierUtil.copy(param,new BazVisitInstance()); |
||||
|
LambdaQueryWrapper<BazVisitInstance> lqw = new LambdaQueryWrapper<>(entity); |
||||
|
if(param.getQueryStartDate()!=null){ |
||||
|
lqw.ge(BazVisitInstance::getCreateTime,param.getQueryStartDate()); |
||||
|
} |
||||
|
if(param.getQueryEndDate()!=null){ |
||||
|
lqw.le(BazVisitInstance::getCreateTime,param.getQueryEndDate().atTime(23,59,59)); |
||||
|
} |
||||
|
List<String> userIds = postUserService.listByChildIds(AuthContextUtils.getSysUserId()); |
||||
|
if(userIds.size()<1){ |
||||
|
return R.byEmptyList(); |
||||
|
} |
||||
|
String userId = AuthContextUtils.getSysUserId(); |
||||
|
PageUtil.startPage(); |
||||
|
lqw.in(BazVisitInstance::getVisitorId, userIds); |
||||
|
lqw.ne(BazVisitInstance::getVisitorId,userId); |
||||
|
lqw.orderByDesc(BazVisitInstance::getCreateTime); |
||||
|
List<BazVisitInstance> list = bazVisitInstanceService.list(lqw); |
||||
|
return R.byPageHelperList(list); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 列表 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/list") |
||||
|
public R<List<BazVisitInstance>> getList(BazVisitInstanceSo param){ |
||||
|
BazVisitInstance query = CopierUtil.copy(param,new BazVisitInstance()); |
||||
|
if(param.getQueryStartDate()!=null){ |
||||
|
query.setQueryEndDate(param.getQueryStartDate().atStartOfDay()); |
||||
|
} |
||||
|
if(param.getQueryEndDate()!=null){ |
||||
|
query.setQueryEndDate(param.getQueryEndDate().atTime(23,59,59)); |
||||
|
} |
||||
|
param.setVisitorId(AuthContextUtils.getSysUserId()); |
||||
|
List<BazVisitInstance> list = bazVisitInstanceService.selectBazVisitInstanceList(query); |
||||
|
return R.ok(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 列表(我的部下) |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/list4Under") |
||||
|
public R<List<BazVisitInstance>> list4Under(BazVisitInstanceSo param){ |
||||
|
BazVisitInstance query = CopierUtil.copy(param,new BazVisitInstance()); |
||||
|
if(param.getQueryStartDate()!=null){ |
||||
|
query.setQueryEndDate(param.getQueryStartDate().atStartOfDay()); |
||||
|
} |
||||
|
if(param.getQueryEndDate()!=null){ |
||||
|
query.setQueryEndDate(param.getQueryEndDate().atTime(23,59,59)); |
||||
|
} |
||||
|
List<String> userIds = postUserService.listByChildIds(AuthContextUtils.getSysUserId()); |
||||
|
if(userIds.size()<1){ |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
String userId = AuthContextUtils.getSysUserId(); |
||||
|
//PageUtil.startPage();
|
||||
|
query.setQueryUserIds(userIds); |
||||
|
query.setIgnoreUserId(userId); |
||||
|
List<BazVisitInstance> list = bazVisitInstanceService.selectBazVisitInstanceList(query); |
||||
|
return R.ok(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取用户未完成拜访数量 |
||||
|
* @param visitId 拜访id |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/getCounter") |
||||
|
public R<?> getPage(Long visitId){ |
||||
|
LambdaQueryWrapper<BazVisitInstance> lqw = new LambdaQueryWrapper<>(); |
||||
|
lqw.eq(BazVisitInstance::getVisitId,visitId); |
||||
|
lqw.eq(BazVisitInstance::getVisitorId,AuthContextUtils.getSysUserId()); |
||||
|
lqw.eq(BazVisitInstance::getVisitState,0); |
||||
|
long unFinished = bazVisitInstanceService.count(lqw); |
||||
|
Map<String,Object> map = new HashMap<>(); |
||||
|
map.put("unFinished",unFinished); |
||||
|
return R.ok(map,"ok"); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 统计创建数量(用于判断当天是否提交) |
||||
|
* @param visitId |
||||
|
* @param targetId |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/countCreate") |
||||
|
public R<?> getPage(String visitId,String targetId){ |
||||
|
BazVisit bazVisit = visitService.getById(visitId); |
||||
|
LambdaQueryWrapper<BazVisitInstance> limitVisitLqw = new LambdaQueryWrapper<>(); |
||||
|
limitVisitLqw.eq(BazVisitInstance::getVisitorId,AuthContextUtils.getSysUserId()); |
||||
|
limitVisitLqw.eq(BazVisitInstance::getTargetType,bazVisit.getTargetType()); |
||||
|
limitVisitLqw.eq(BazVisitInstance::getTargetId,targetId); |
||||
|
limitVisitLqw.ge(BazVisitInstance::getCreateTime, LocalDate.now()); |
||||
|
long count = bazVisitInstanceService.count(limitVisitLqw); |
||||
|
return R.ok(count); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 创建流程 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/create") |
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访实例", biz = BizType.INSERT) |
||||
|
public R<BazVisitInstance> save(@RequestBody @Valid BazCreateVisitInstanceBo param){ |
||||
|
BazVisitInstance result = bazVisitInstanceService.create(param); |
||||
|
return R.ok(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 提交流程 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/submitFlow") |
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访实例", biz = BizType.INSERT) |
||||
|
public R<BazVisitInstance> save(@RequestBody @Valid BazVisitInstanceFlowBo param){ |
||||
|
bazVisitInstanceService.submit(param); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 完成流程 |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/finished/{instanceId}") |
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访实例", biz = BizType.INSERT) |
||||
|
public R<BazVisitInstance> finished(@PathVariable("instanceId")Long id){ |
||||
|
bazVisitInstanceService.finished(id); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除 |
||||
|
* @param ids |
||||
|
* @return |
||||
|
*/ |
||||
|
@DeleteMapping("/deleteById/{ids}") |
||||
|
@SysLog(module = SystemModule.BAZ, title = "拜访实例", biz = BizType.DELETE) |
||||
|
public R<?> deleteById(@PathVariable("ids") String ids){ |
||||
|
List<Long> idsLong = StringUtils.splitIdLong(ids); |
||||
|
LambdaQueryWrapper<BazVisitInstance> lqw = new LambdaQueryWrapper<>(); |
||||
|
lqw.in(BazVisitInstance::getId,idsLong); |
||||
|
lqw.eq(BazVisitInstance::getVisitorId, AuthContextUtils.getSysUserId()); |
||||
|
boolean result = bazVisitInstanceService.remove(lqw); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue