123
This commit is contained in:
parent
2b3bfda7e3
commit
867d36b4b4
2
pom.xml
2
pom.xml
@ -130,7 +130,7 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<version>3.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -49,5 +49,5 @@ public class OrderController {
|
||||
public void downloadTemplate(HttpServletResponse response) {this.orderService.downloadTemplate(response);}
|
||||
|
||||
@RequestMapping(path = "/uploadBatch", method = RequestMethod.POST)
|
||||
public void uploadBatch(@RequestParam("file") MultipartFile file) {this.orderService.uploadBatch(file);}
|
||||
public R<JSONObject> uploadBatch(@RequestParam("file") MultipartFile file) {return this.orderService.uploadBatch(file);}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class WebSocketController {
|
||||
this.userId = userId;
|
||||
//加入map
|
||||
webSocketMap.put(userId, this);
|
||||
R<String> stringR = webSocketService.addVerify(userId);
|
||||
R<JSONObject> stringR = webSocketService.addVerify(userId,this);
|
||||
sendMessageByUserId(userId, stringR);
|
||||
}
|
||||
@OnClose
|
||||
@ -73,9 +73,9 @@ public class WebSocketController {
|
||||
log.error("用户{}不在线",userId);
|
||||
}
|
||||
}
|
||||
@Scheduled(fixedRate = 10000)
|
||||
@Scheduled(fixedRate = 1000)
|
||||
public void verifyTime(){
|
||||
List<String> expireTimes = webSocketService.getExpireTimes();
|
||||
List<String> expireTimes = webSocketService.getExpireTimes(webSocketMap.keys());
|
||||
expireTimes.forEach(e -> {
|
||||
if(webSocketMap.containsKey(e)){
|
||||
webSocketMap.get(e).sendMessage(JSON.toJSONString(R.success(new JSONObject().fluentPut("info","当前登录用户已过期"))));
|
||||
|
@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serial;
|
||||
@ -22,264 +23,61 @@ import java.util.Date;
|
||||
*/
|
||||
@TableName("shop_order")
|
||||
@ExcelIgnoreUnannotated
|
||||
@Accessors(chain = true)
|
||||
@Data
|
||||
public class Order implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ExcelIgnore
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@ExcelProperty({"订单号"})
|
||||
@TableField("order_no")
|
||||
private String orderNo;
|
||||
@ExcelProperty({"下单时间"})
|
||||
@TableField("order_time")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date orderTime;
|
||||
@ExcelProperty({"订单状态"})
|
||||
@TableField("order_status")
|
||||
private String orderStatus;
|
||||
@ExcelProperty({"旺旺号"})
|
||||
@TableField("wang_no")
|
||||
private String wangNo;
|
||||
@ExcelProperty({"微信|qq账号"})
|
||||
@TableField("wechat_no")
|
||||
private String wechatNo;
|
||||
@ExcelProperty({"支付宝账号"})
|
||||
@TableField("alipay_no")
|
||||
private String alipayNo;
|
||||
@ExcelProperty({"付款金额"})
|
||||
@TableField("pay_amt")
|
||||
private Double payAmt;
|
||||
@ExcelProperty({"店铺名称"})
|
||||
@TableField("store_id")
|
||||
private Integer storeId;
|
||||
@ExcelProperty({"佣金"})
|
||||
@TableField("commission")
|
||||
private Double commission;
|
||||
@ExcelProperty({"支付宝名称"})
|
||||
@TableField("alipay_name")
|
||||
private String alipayName;
|
||||
@ExcelProperty({"放单人"})
|
||||
@TableField("rp_name")
|
||||
private String rpName;
|
||||
@ExcelProperty({"放单人微信名"})
|
||||
@TableField("rp_wechat_name")
|
||||
private String rpWechatName;
|
||||
@ExcelProperty({"备注"})
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
@ExcelProperty({"买家电话"})
|
||||
@TableField("phone_number")
|
||||
private String phoneNumber;
|
||||
@ExcelProperty({"银行卡号"})
|
||||
@TableField("card_no")
|
||||
private String cardNo;
|
||||
@ExcelProperty({"插旗"})
|
||||
@TableField("flag")
|
||||
private Integer flag;
|
||||
@ExcelProperty({"插旗备注"})
|
||||
@TableField("flag_remark")
|
||||
private String flagRemark;
|
||||
@ExcelProperty({"付款时间"})
|
||||
@TableField("pay_time")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date payTime;
|
||||
@ExcelProperty({"收货地址"})
|
||||
@TableField("address")
|
||||
private String address;
|
||||
@ExcelProperty({"商品id"})
|
||||
@TableField("shop_id")
|
||||
private Integer shopId;
|
||||
@ExcelProperty({"sku"})
|
||||
@TableField("sku")
|
||||
private String sku;
|
||||
@ExcelIgnore
|
||||
@TableField(exist = false)
|
||||
private String storeName;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getOrderNo() {
|
||||
return orderNo;
|
||||
}
|
||||
|
||||
public void setOrderNo(String orderNo) {
|
||||
this.orderNo = orderNo;
|
||||
}
|
||||
|
||||
public Date getOrderTime() {
|
||||
return orderTime;
|
||||
}
|
||||
|
||||
public void setOrderTime(Date orderTime) {
|
||||
this.orderTime = orderTime;
|
||||
}
|
||||
|
||||
public String getOrderStatus() {
|
||||
return orderStatus;
|
||||
}
|
||||
|
||||
public void setOrderStatus(String orderStatus) {
|
||||
this.orderStatus = orderStatus;
|
||||
}
|
||||
|
||||
public String getWangNo() {
|
||||
return wangNo;
|
||||
}
|
||||
|
||||
public void setWangNo(String wangNo) {
|
||||
this.wangNo = wangNo;
|
||||
}
|
||||
|
||||
public String getWechatNo() {
|
||||
return wechatNo;
|
||||
}
|
||||
|
||||
public void setWechatNo(String wechatNo) {
|
||||
this.wechatNo = wechatNo;
|
||||
}
|
||||
|
||||
public String getAlipayNo() {
|
||||
return alipayNo;
|
||||
}
|
||||
|
||||
public void setAlipayNo(String alipayNo) {
|
||||
this.alipayNo = alipayNo;
|
||||
}
|
||||
|
||||
public Double getPayAmt() {
|
||||
return payAmt;
|
||||
}
|
||||
|
||||
public void setPayAmt(Double payAmt) {
|
||||
this.payAmt = payAmt;
|
||||
}
|
||||
|
||||
public Integer getStoreId() {
|
||||
return storeId;
|
||||
}
|
||||
|
||||
public void setStoreId(Integer storeId) {
|
||||
this.storeId = storeId;
|
||||
}
|
||||
|
||||
public Double getCommission() {
|
||||
return commission;
|
||||
}
|
||||
|
||||
public void setCommission(Double commission) {
|
||||
this.commission = commission;
|
||||
}
|
||||
|
||||
public String getAlipayName() {
|
||||
return alipayName;
|
||||
}
|
||||
|
||||
public void setAlipayName(String alipayName) {
|
||||
this.alipayName = alipayName;
|
||||
}
|
||||
|
||||
public String getRpName() {
|
||||
return rpName;
|
||||
}
|
||||
|
||||
public void setRpName(String rpName) {
|
||||
this.rpName = rpName;
|
||||
}
|
||||
|
||||
public String getRpWechatName() {
|
||||
return rpWechatName;
|
||||
}
|
||||
|
||||
public void setRpWechatName(String rpWechatName) {
|
||||
this.rpWechatName = rpWechatName;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public String getCardNo() {
|
||||
return cardNo;
|
||||
}
|
||||
|
||||
public void setCardNo(String cardNo) {
|
||||
this.cardNo = cardNo;
|
||||
}
|
||||
|
||||
public Integer getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(Integer flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public String getFlagRemark() {
|
||||
return flagRemark;
|
||||
}
|
||||
|
||||
public void setFlagRemark(String flagRemark) {
|
||||
this.flagRemark = flagRemark;
|
||||
}
|
||||
|
||||
public Date getPayTime() {
|
||||
return payTime;
|
||||
}
|
||||
|
||||
public void setPayTime(Date payTime) {
|
||||
this.payTime = payTime;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public Integer getShopId() {
|
||||
return shopId;
|
||||
}
|
||||
|
||||
public void setShopId(Integer shopId) {
|
||||
this.shopId = shopId;
|
||||
}
|
||||
|
||||
public String getSku() {
|
||||
return sku;
|
||||
}
|
||||
|
||||
public void setSku(String sku) {
|
||||
this.sku = sku;
|
||||
}
|
||||
|
||||
public String getStoreName() {
|
||||
return storeName;
|
||||
}
|
||||
|
||||
public void setStoreName(String storeName) {
|
||||
this.storeName = storeName;
|
||||
}
|
||||
}
|
||||
|
67
src/main/java/top/xinsin/pojo/OrderByExcel.java
Normal file
67
src/main/java/top/xinsin/pojo/OrderByExcel.java
Normal file
@ -0,0 +1,67 @@
|
||||
package top.xinsin.pojo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author xinsin
|
||||
* Created On 2023/6/9 09:25
|
||||
* @version 1.0
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode
|
||||
@ExcelIgnoreUnannotated
|
||||
public class OrderByExcel {
|
||||
@ExcelProperty("订单号")
|
||||
private String orderNo;
|
||||
@ExcelProperty("下单时间")
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
private String orderTime;
|
||||
@ExcelProperty("订单状态")
|
||||
private String orderStatus;
|
||||
@ExcelProperty("旺旺号")
|
||||
private String wangNo;
|
||||
@ExcelProperty("微信|qq账号")
|
||||
private String wechatNo;
|
||||
@ExcelProperty("支付宝账号")
|
||||
private String alipayNo;
|
||||
@ExcelProperty("付款金额")
|
||||
private String payAmt;
|
||||
@ExcelProperty("店铺名称")
|
||||
private String storeId;
|
||||
@ExcelProperty("佣金")
|
||||
private String commission;
|
||||
@ExcelProperty("支付宝名称")
|
||||
private String alipayName;
|
||||
@ExcelProperty("放单人")
|
||||
private String rpName;
|
||||
@ExcelProperty("放单人微信名")
|
||||
private String rpWechatName;
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
@ExcelProperty("买家电话")
|
||||
private String phoneNumber;
|
||||
@ExcelProperty("银行卡号")
|
||||
private String cardNo;
|
||||
@ExcelProperty("插旗")
|
||||
private String flag;
|
||||
@ExcelProperty("插旗备注")
|
||||
private String flagRemark;
|
||||
@ExcelProperty("付款时间")
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
private String payTime;
|
||||
@ExcelProperty("收货地址")
|
||||
private String address;
|
||||
@ExcelProperty("商品id")
|
||||
private String shopId;
|
||||
@ExcelProperty("sku")
|
||||
private String sku;
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
package top.xinsin.service;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.read.listener.PageReadListener;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import top.xinsin.enums.OrderStatus;
|
||||
import top.xinsin.enums.SearchType;
|
||||
@ -21,9 +20,8 @@ import top.xinsin.mapper.OrderMapper;
|
||||
import top.xinsin.mapper.StoreMapper;
|
||||
import top.xinsin.pojo.Commission;
|
||||
import top.xinsin.pojo.Order;
|
||||
import top.xinsin.pojo.OrderByExcel;
|
||||
import top.xinsin.pojo.Store;
|
||||
import top.xinsin.pojo.vo.OrderVO;
|
||||
import top.xinsin.util.ExcelParserUtil;
|
||||
import top.xinsin.util.HttpCodes;
|
||||
import top.xinsin.util.R;
|
||||
|
||||
@ -31,8 +29,14 @@ import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* @author xinsin
|
||||
@ -169,11 +173,48 @@ public class OrderService extends ServiceImpl<OrderMapper,Order> implements Orde
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public void uploadBatch(MultipartFile file) {
|
||||
try {
|
||||
EasyExcel.read(file.getInputStream(), Order.class, new ExcelParserUtil(this)).headRowNumber(2).sheet().doRead();
|
||||
} catch (Throwable var3) {
|
||||
throw var3;
|
||||
}
|
||||
@Transactional
|
||||
public R<JSONObject> uploadBatch(MultipartFile file) {
|
||||
DateFormat fmt =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
AtomicInteger total = new AtomicInteger();
|
||||
AtomicBoolean status = new AtomicBoolean(false);
|
||||
EasyExcel.read(file.getInputStream(),OrderByExcel.class,new PageReadListener<OrderByExcel>(list -> {
|
||||
list.remove(0);
|
||||
total.addAndGet(list.size());
|
||||
List<Order> orders = new ArrayList<>();
|
||||
list.forEach(e -> {
|
||||
try {
|
||||
orders.add(new Order()
|
||||
.setOrderNo(e.getOrderNo())
|
||||
.setOrderTime(e.getOrderTime() != null ? fmt.parse(e.getOrderTime()) : null)
|
||||
.setOrderStatus(e.getOrderStatus())
|
||||
.setWangNo(e.getWangNo())
|
||||
.setWechatNo(e.getWechatNo())
|
||||
.setAlipayNo(e.getAlipayNo())
|
||||
.setPayAmt(e.getPayAmt() != null ? Double.parseDouble(e.getPayAmt()) : null)
|
||||
.setStoreId(e.getStoreId() != null ? Integer.parseInt(e.getStoreId()) : null)
|
||||
.setCommission(e.getCommission() != null ? Double.parseDouble(e.getCommission()) : null)
|
||||
.setAlipayName(e.getAlipayName())
|
||||
.setRpName(e.getRpName())
|
||||
.setRpWechatName(e.getRpWechatName())
|
||||
.setRemark(e.getRemark())
|
||||
.setPhoneNumber(e.getPhoneNumber())
|
||||
.setCardNo(e.getCardNo())
|
||||
.setFlag(e.getFlag() != null ? Integer.parseInt(e.getFlag()) : null)
|
||||
.setFlagRemark(e.getFlagRemark())
|
||||
.setPayTime(e.getPayTime() != null ? fmt.parse(e.getPayTime()) : null)
|
||||
.setAddress(e.getAddress())
|
||||
.setShopId(e.getShopId() != null ? Integer.parseInt(e.getStoreId()) : null)
|
||||
.setSku(e.getSku())
|
||||
);
|
||||
} catch (ParseException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
log.info(" ==> 解析一条数据: {}", JSONObject.toJSONString(e));
|
||||
});
|
||||
log.info(" ==> 共全部数据: {}",total.get());
|
||||
status.set(this.saveBatch(orders));
|
||||
})).sheet().doRead();
|
||||
return R.success(new JSONObject().fluentPut("total",total.get()).fluentPut("status",status.get()));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package top.xinsin.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
@ -17,15 +18,10 @@ import top.xinsin.util.HttpCodes;
|
||||
import top.xinsin.util.R;
|
||||
import top.xinsin.util.StringConstant;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.apache.naming.SelectorContext.prefix;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class WebSocketService {
|
||||
@ -34,30 +30,48 @@ public class WebSocketService {
|
||||
@Autowired
|
||||
private VerifyMapper verifyMapper;
|
||||
|
||||
public R<String> addVerify(String userId){
|
||||
private Map<String,WebSocketController> adminBYStoreId = new HashMap<>();
|
||||
|
||||
public R<JSONObject> addVerify(String userId, WebSocketController session){
|
||||
RedisSerializer<String> stringSerializer = new StringRedisSerializer();
|
||||
redisTemplate.setValueSerializer(stringSerializer);
|
||||
redisTemplate.setKeySerializer(stringSerializer);
|
||||
if (userId.equals("-114514")){
|
||||
return R.success("检测为管理员登录");
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if (userId.startsWith("-114514_")){
|
||||
adminBYStoreId.put(userId.replace("-114514_",""),session);
|
||||
// 筛选出当前过期的数据
|
||||
Set<String> noVerify = redisTemplate.keys(StringConstant.NO_VERIFY_PRE + "*");
|
||||
Set<String> verify = redisTemplate.keys(StringConstant.VERIFY_PRE + "*");
|
||||
List<String> list = new ArrayList<>();
|
||||
assert noVerify != null;
|
||||
noVerify.forEach(e -> list.add(e.replace(StringConstant.NO_VERIFY_PRE, "")));
|
||||
assert verify!= null;
|
||||
List<String> list2 = new ArrayList<>();
|
||||
verify.forEach(e -> list2.add(e.replace(StringConstant.VERIFY_PRE, "")));
|
||||
List<String> list1 = list.stream().filter(e -> !list2.contains(e)).toList();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
Arrays.stream(userId.replace("-114514_", "").split(",")).filter(list1::contains).forEach(jsonArray::add);
|
||||
jsonObject.fluentPut("expire",jsonArray);
|
||||
return R.success(jsonObject.fluentPut("info","检测为管理员登录"));
|
||||
}
|
||||
Object o = redisTemplate.opsForValue().get(StringConstant.VERIFY_PRE + userId);
|
||||
Object o1 = redisTemplate.opsForValue().get(StringConstant.VERIFY_PRE + userId + "_no");
|
||||
System.out.println(o == null);
|
||||
System.out.println(o1 == null);
|
||||
Object o1 = redisTemplate.opsForValue().get(StringConstant.NO_VERIFY_PRE + userId);
|
||||
if (o == null && o1 == null){
|
||||
Verify verify = verifyMapper.selectOne(new LambdaQueryWrapper<Verify>().eq(Verify::getStoreId, userId));
|
||||
if (verify != null){
|
||||
if(userId.equals(String.valueOf(verify.getStoreId()))) {
|
||||
redisTemplate.opsForValue().set(StringConstant.VERIFY_PRE + userId, String.valueOf(verify.getNum()), verify.getCountdown(), TimeUnit.SECONDS);
|
||||
redisTemplate.opsForValue().set(StringConstant.VERIFY_PRE + userId + "_no", String.valueOf(verify.getNum()));
|
||||
return R.success("已将该用户过期时间存入");
|
||||
redisTemplate.opsForValue().set(StringConstant.NO_VERIFY_PRE + userId, String.valueOf(verify.getNum()));
|
||||
jsonObject.fluentPut("info","已将该用户过期时间存入");
|
||||
return R.success(jsonObject);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return R.success("当前用户已存在");
|
||||
jsonObject.fluentPut("info","当前用户已存在");
|
||||
return R.success(jsonObject);
|
||||
}
|
||||
return R.failed(HttpCodes.HTTP_CODES500,"不存在该用户");
|
||||
jsonObject.fluentPut("info","不存在该用户");
|
||||
return R.failed(HttpCodes.HTTP_CODES500,jsonObject);
|
||||
}
|
||||
public R<JSONObject> parseMessage(String userId, String message, ConcurrentHashMap<String, WebSocketController> webSocketMap){
|
||||
JSONObject parse = JSONObject.parse(message);
|
||||
@ -83,7 +97,7 @@ public class WebSocketService {
|
||||
String verifyResult = String.valueOf(parse.get("verifyResult"));
|
||||
String userId = String.valueOf(parse.get("userId"));
|
||||
|
||||
int i = Integer.parseInt(String.valueOf(redisTemplate.opsForValue().get(StringConstant.VERIFY_PRE + userId + "_no")));
|
||||
int i = Integer.parseInt(String.valueOf(redisTemplate.opsForValue().get(StringConstant.NO_VERIFY_PRE + userId)));
|
||||
System.out.println(i);
|
||||
Verify verify = new Verify();
|
||||
verify.setVerifyResult(verifyResult);
|
||||
@ -100,7 +114,7 @@ public class WebSocketService {
|
||||
}else{
|
||||
if (webSocketMap.containsKey(userId)){
|
||||
webSocketMap.get(userId).sendMessage(JSON.toJSONString(new JSONObject().fluentPut("info","管理员已同意你的验证信息,请重新登录")));
|
||||
redisTemplate.delete(StringConstant.VERIFY_PRE + userId + "_no");
|
||||
redisTemplate.delete(StringConstant.NO_VERIFY_PRE + userId);
|
||||
Verify verify1 = new Verify();
|
||||
verify.setVerifyPhone("");
|
||||
verify.setVerifyName("");
|
||||
@ -114,7 +128,7 @@ public class WebSocketService {
|
||||
Long expire = redisTemplate.getExpire(StringConstant.VERIFY_PRE + userId);
|
||||
assert expire != null;
|
||||
if (expire.equals(-2L)){
|
||||
Object o = redisTemplate.opsForValue().get(StringConstant.VERIFY_PRE + userId + "_no");
|
||||
Object o = redisTemplate.opsForValue().get(StringConstant.NO_VERIFY_PRE + userId);
|
||||
if (o != null){
|
||||
return R.success(new JSONObject().fluentPut("info","当前用户登录已过期"));
|
||||
}
|
||||
@ -126,7 +140,7 @@ public class WebSocketService {
|
||||
|
||||
private R<JSONObject> addVerifyInfo(String userId, JSONObject parse) {
|
||||
Long expire = redisTemplate.getExpire(StringConstant.VERIFY_PRE + userId);
|
||||
Object o = redisTemplate.opsForValue().get(StringConstant.VERIFY_PRE + userId + "_no");
|
||||
Object o = redisTemplate.opsForValue().get(StringConstant.NO_VERIFY_PRE + userId);
|
||||
assert expire != null;
|
||||
if (expire.equals(-2L) && o != null){
|
||||
Object verifyName = parse.get("verifyName");
|
||||
@ -143,19 +157,22 @@ public class WebSocketService {
|
||||
private R<JSONObject> ping(String userId) {
|
||||
return R.success(new JSONObject().fluentPut("info","pong").fluentPut("time",redisTemplate.getExpire(StringConstant.VERIFY_PRE + userId)));
|
||||
}
|
||||
public List<String> getExpireTimes(){
|
||||
public List<String> getExpireTimes(Enumeration<String> keys){
|
||||
List<String> expireUser = new ArrayList<>();
|
||||
Set<String> keys = redisTemplate.keys(prefix.concat(StringConstant.VERIFY_PRE + "*"));
|
||||
|
||||
// Set<String> keys = redisTemplate.keys(StringConstant.VERIFY_PRE + "*");
|
||||
assert keys != null;
|
||||
keys.forEach(e -> {
|
||||
Iterator<String> iterator = keys.asIterator();
|
||||
while (iterator.hasNext()){
|
||||
String e = StringConstant.VERIFY_PRE + iterator.next();
|
||||
if (Objects.equals(redisTemplate.getExpire(e), -1L)){
|
||||
expireUser.add(e);
|
||||
redisTemplate.delete(e);
|
||||
}else if (Objects.equals(redisTemplate.getExpire(e),-2L)){
|
||||
expireUser.add(e);
|
||||
redisTemplate.delete(e);
|
||||
}
|
||||
});
|
||||
// log.info("{}",keys);
|
||||
}
|
||||
return expireUser;
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,16 @@ import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.alibaba.excel.exception.ExcelDataConvertException;
|
||||
import com.alibaba.excel.read.processor.AnalysisEventProcessor;
|
||||
import com.alibaba.excel.util.ListUtils;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import top.xinsin.mapper.OrderMapper;
|
||||
import top.xinsin.pojo.Order;
|
||||
import top.xinsin.pojo.OrderByExcel;
|
||||
import top.xinsin.service.OrderService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -19,7 +22,7 @@ import java.util.List;
|
||||
* @version 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
public class ExcelParserUtil extends AnalysisEventListener<Order> {
|
||||
public class ExcelParserUtil extends AnalysisEventListener<OrderByExcel> {
|
||||
/**
|
||||
* 每次读取的最大数据条数
|
||||
*/
|
||||
@ -33,7 +36,7 @@ public class ExcelParserUtil extends AnalysisEventListener<Order> {
|
||||
/**
|
||||
* 可接收任何参数的泛型List集合
|
||||
*/
|
||||
List<Order> list = new ArrayList<>();
|
||||
List<OrderByExcel> list = ListUtils.newArrayListWithExpectedSize(MAX_BATCH_COUNT);
|
||||
|
||||
List<Order> total = new ArrayList<>();
|
||||
|
||||
@ -48,7 +51,7 @@ public class ExcelParserUtil extends AnalysisEventListener<Order> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(Order data, AnalysisContext analysisContext) {
|
||||
public void invoke(OrderByExcel data, AnalysisContext analysisContext) {
|
||||
log.info(" ==> 解析一条数据: {}", data);
|
||||
list.add(data);
|
||||
if (list.size() > MAX_BATCH_COUNT) {
|
||||
@ -74,7 +77,11 @@ public class ExcelParserUtil extends AnalysisEventListener<Order> {
|
||||
*/
|
||||
private void saveData() {
|
||||
log.info(" ==> 数据保存开始: {}", list.size());
|
||||
dynamicService.saveBatch(list);
|
||||
list.forEach(e -> {
|
||||
|
||||
System.out.println(e.getOrderNo());
|
||||
});
|
||||
// dynamicService.saveBatch(list);
|
||||
log.info(" ==> 数据保存结束 <==");
|
||||
}
|
||||
|
||||
|
@ -7,4 +7,5 @@ public class StringConstant {
|
||||
public static final String ID_REGEX = "[0-9]*";
|
||||
|
||||
public static final String VERIFY_PRE = "verify_";
|
||||
public static final String NO_VERIFY_PRE = "no_verify_";
|
||||
}
|
||||
|
@ -2,12 +2,12 @@ server:
|
||||
port: 8001
|
||||
spring:
|
||||
datasource:
|
||||
username: commerce
|
||||
password: Jix656dzD6St4YCn_
|
||||
# username: commerce_system
|
||||
# password: Jix656dzD6St4YCn
|
||||
url: jdbc:mysql://localhost:3306/commerce_system?serverTimezone=UTC-8
|
||||
# url: jdbc:mysql://wzpmc.cn:3306/commerce_system?serverTimezone=UTC-8
|
||||
# username: commerce
|
||||
# password: Jix656dzD6St4YCn_
|
||||
username: commerce_system
|
||||
password: Jix656dzD6St4YCn
|
||||
# url: jdbc:mysql://localhost:3306/commerce_system?serverTimezone=UTC-8
|
||||
url: jdbc:mysql://wzpmc.cn:3306/commerce_system?serverTimezone=UTC-8
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# druid配置
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user