新增发票确认实时同步

dev2.0
anthonywj 2 years ago
parent 7ed62f3b38
commit 2a790a07d7

@ -1,125 +0,0 @@
package com.glxp.api.config;
import com.alibaba.fastjson.JSON;
import com.glxp.api.entity.system.WebSocketEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.concurrent.CopyOnWriteArraySet;
@Component
@Slf4j
@Service
@ServerEndpoint("/api/websocket/{sid}")
public class WebSocketServer {
private static int onlineCount = 0;
private static CopyOnWriteArraySet<WebSocketServer> webSocketSet = new CopyOnWriteArraySet<WebSocketServer>();
private Session session;
private String sid = "";
/**
*
*/
@OnOpen
public void onOpen(Session session, @PathParam("sid") String sid) {
this.session = session;
webSocketSet.add(this); //加入set中
this.sid = sid;
addOnlineCount(); //在线数加1
try {
sendMessage(new WebSocketEntity("sys", "连接成功"));
log.info("有新窗口开始监听:" + sid + ",当前在线人数为:" + getOnlineCount());
} catch (IOException e) {
log.error("websocket IO Exception");
}
}
/**
*
*/
@OnClose
public void onClose() {
webSocketSet.remove(this); //从set中删除
subOnlineCount(); //在线数减1
//断开连接情况下,更新主板占用情况为释放
log.info("释放的sid为" + sid);
//这里写你 释放的时候,要处理的业务
log.info("有一连接关闭!当前在线人数为" + getOnlineCount());
}
/**
*
*
* @ Param message
*/
@OnMessage
public void onMessage(String message, Session session) {
log.info("收到来自窗口" + sid + "的信息:" + message);
//群发消息
for (WebSocketServer item : webSocketSet) {
try {
item.sendMessage(new WebSocketEntity("back", message));
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* @ Param session
* @ Param error
*/
@OnError
public void onError(Session session, Throwable error) {
log.error("发生错误");
error.printStackTrace();
}
/**
*
*/
public void sendMessage(WebSocketEntity webSocketEntity) throws IOException {
String message = JSON.toJSON(webSocketEntity).toString();
this.session.getBasicRemote().sendText(message);
}
public static void sendInfo(String message, String type) {
log.info("推送消息到窗口" + type + ",推送内容:" + message);
for (WebSocketServer item : webSocketSet) {
try {
if (type == null) {
item.sendMessage(new WebSocketEntity("sid", message));
} else {
item.sendMessage(new WebSocketEntity(type, message));
}
} catch (IOException e) {
continue;
}
}
}
public static synchronized int getOnlineCount() {
return onlineCount;
}
public static synchronized void addOnlineCount() {
WebSocketServer.onlineCount++;
}
public static synchronized void subOnlineCount() {
WebSocketServer.onlineCount--;
}
public static CopyOnWriteArraySet<WebSocketServer> getWebSocketSet() {
return webSocketSet;
}
}

@ -3,6 +3,12 @@ package com.glxp.api.constant;
public interface SocketMsgType {
String DL_ALL_DATA = "DL_ALL_DATA"; //生产入库
String DL_ALL_DATA = "DL_ALL_DATA"; //基础数据同步
String DL_NOTICE = "DL_NOTICE"; //通知类消息
/**
*
*/
String TASK_INVOICE_CONFIRM = "TASK_INVOICE_CONFIRM"; //发票确认
}

@ -14,13 +14,16 @@ import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BusinessType;
import com.glxp.api.constant.Constant;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.constant.SocketMsgType;
import com.glxp.api.controller.BaseController;
import com.glxp.api.controller.sync.SpsSyncWebSocket;
import com.glxp.api.entity.auth.AuthAdmin;
import com.glxp.api.entity.auth.InvBusUserEntity;
import com.glxp.api.entity.auth.InvWarehouseEntity;
import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
import com.glxp.api.entity.basic.EntrustReceEntity;
import com.glxp.api.entity.inout.*;
import com.glxp.api.entity.sync.SocketMsgEntity;
import com.glxp.api.req.auth.FilterInvBusUserRequest;
import com.glxp.api.req.basic.BasicEntrustRecRequest;
import com.glxp.api.req.inout.*;
@ -28,7 +31,6 @@ import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.req.udims.PostUdimsOrderRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.inout.IoOrderDetailBizResponse;
import com.glxp.api.res.inout.IoOrderDetailCodeResponse;
import com.glxp.api.res.inout.IoOrderResponse;
import com.glxp.api.res.inout.PdaBusOrderResponse;
import com.glxp.api.service.auth.InvBusUserService;
@ -45,13 +47,12 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.java_websocket.server.WebSocketServer;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@ -661,6 +662,7 @@ public class IoOrderController extends BaseController {
return orderService.submitToThrSys(billNo);
}
@AuthRuleAnnotation("")
@PostMapping("/udiwms/inout/order/updateOrderDetailBiz")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse updateOrderDetailBiz(@RequestBody IoOrderDetailBizEntity ioOrderDetailBizEntity) {
@ -672,14 +674,18 @@ public class IoOrderController extends BaseController {
return ResultVOUtils.success();
}
@AuthRuleAnnotation("")
@PostMapping("/udiwms/inout/order/updateOrder")
@Log(title = "单据管理", businessType = BusinessType.UPDATE)
public BaseResponse updateOrder(@RequestBody IoOrderEntity ioOrderEntity) {
ioOrderEntity.setUpdateTime(new Date());
orderService.updateByBillNo(ioOrderEntity);
webSocketServer.sendMessage(SocketMsgEntity.builder().type(SocketMsgType.TASK_INVOICE_CONFIRM).content(ioOrderEntity.getBillNo()).remark("发票确认").build(), null);
return ResultVOUtils.success();
}
@Resource
SpsSyncWebSocket webSocketServer;
// --------------------------------------------------------UDI_MS平台--------------------------------------------------------------------------------------
@ApiOperation("udims上传单据")
@ -803,12 +809,12 @@ public class IoOrderController extends BaseController {
//这个不等于空表示要查询发票对应的单据
if (filterOrderRequest.getInvoiceEncode() != null) {
//查询发票详情
QueryWrapper<IoOrderInvoiceEntity> ew=new QueryWrapper<IoOrderInvoiceEntity>();
ew.eq("invoiceEncode",filterOrderRequest.getInvoiceEncode());
QueryWrapper<IoOrderInvoiceEntity> ew = new QueryWrapper<IoOrderInvoiceEntity>();
ew.eq("invoiceEncode", filterOrderRequest.getInvoiceEncode());
List<IoOrderInvoiceEntity> ioOrderInvoiceEntity = orderInvoiceService.list(ew);
List<String> orderIds = ioOrderInvoiceEntity.stream().map(IoOrderInvoiceEntity::getOrderIdFk).collect(Collectors.toList());
filterOrderRequest.setOrderIds(orderIds);
if(CollectionUtils.isEmpty(orderIds)){
if (CollectionUtils.isEmpty(orderIds)) {
PageInfo<IoOrderResponse> pageInfo = new PageInfo<>();
return ResultVOUtils.page(pageInfo);
}
@ -864,4 +870,14 @@ public class IoOrderController extends BaseController {
}
@GetMapping("/udiwms/inout/order/findByBillNo")
public BaseResponse findByBillNo(@RequestParam("billNo") String billNo) {
if (StrUtil.isBlank(billNo)) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
IoOrderEntity orderEntity = orderService.findByBillNo(billNo);
return ResultVOUtils.success(orderEntity);
}
}

@ -1,9 +1,6 @@
package com.glxp.api.controller.sync;
import cn.hutool.core.util.StrUtil;
import com.glxp.api.entity.sync.SocketMsgEntity;
import com.glxp.api.exception.ServiceException;
import com.glxp.api.util.ByteArraySplitter;
import com.glxp.api.util.JsonUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
@ -13,7 +10,6 @@ import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -88,6 +84,9 @@ public class SpsSyncWebSocket {
* @param sessionId token
*/
public synchronized void sendMessage(SocketMsgEntity socketMsgEntity, String sessionId) {
if (sessionId == null) {
sessionId = "1:" + socketToken;
}
synchronized (this.getClass()) {
for (Map.Entry<String, SpsSyncWebSocket> stringMyWebSocketEntry : socketServersMap.entrySet()) {
try {

@ -5,7 +5,6 @@ import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.config.WebSocketServer;
import com.glxp.api.constant.BasicProcessStatus;
import com.glxp.api.constant.Constant;
import com.glxp.api.entity.sync.SyncDataSetEntity;
@ -20,6 +19,7 @@ import com.glxp.api.service.sync.SyncDataSetService;
import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.ExcelUtil;
import com.glxp.api.util.RedisUtil;
import org.java_websocket.server.WebSocketServer;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -45,7 +45,7 @@ public class ThrCorpsDlService {
ThrCorpExportLogService thrCorpExportLogService;
@Resource
private ThrCorpImportDetailService thrCorpImportDetailService;
// @Value("${SPSYNC_IP}")
// @Value("${SPSYNC_IP}")
// private String spsSyncUrl;
@Resource
ErpBasicClient erpBasicClient;
@ -66,7 +66,7 @@ public class ThrCorpsDlService {
public void importSelectCorps(String genKey, List<ThrCorpsResponse> thrCorpsResponseList, String thirdSys) {
ThrSystemDetailEntity piDetailEntity = thrSystemDetailService.selectByKey("corpUrl", thirdSys);
if (piDetailEntity == null || piDetailEntity.getValue() == null) {
WebSocketServer.sendInfo("往来单位接口未设置!", "sid");
// WebSocketServer.sendInfo("往来单位接口未设置!", "sid");
return;
}
ThrCorpImportLogEntity thrProductsImportLogEntity = thrCorpImportLogService.selectByGenKey(genKey);
@ -107,7 +107,7 @@ public class ThrCorpsDlService {
thrCorpService.insertThrCorpss(thrCorpEntities);
redisUtil.set(Constant.dlThrProducts, "false");
WebSocketServer.sendInfo("往来单位信息下载已完成,请刷新查看!", "sid");
// WebSocketServer.sendInfo("往来单位信息下载已完成,请刷新查看!", "sid");
thrProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrProductsImportLogEntity.setUpdateTime(new Date());
thrCorpImportLogService.updateImportLog(thrProductsImportLogEntity);
@ -119,7 +119,7 @@ public class ThrCorpsDlService {
public void importCorps(String genKey, ThrUnitMaintainFilterRequest thrUnitMaintainFilterRequest, String thirdSys) {
ThrSystemDetailEntity piDetailEntity = thrSystemDetailService.selectByKey("corpUrl", thirdSys);
if (piDetailEntity == null || piDetailEntity.getValue() == null) {
WebSocketServer.sendInfo("往来单位接口未设置!", "sid");
// WebSocketServer.sendInfo("往来单位接口未设置!", "sid");
return;
}
ThrCorpImportLogEntity thrProductsImportLogEntity = thrCorpImportLogService.selectByGenKey(genKey);
@ -147,7 +147,7 @@ public class ThrCorpsDlService {
thrCorpService.insertThrCorpss(data);
}
redisUtil.set(Constant.dlThrProducts, "false");
WebSocketServer.sendInfo("往来单位信息下载已完成,请刷新查看!", "sid");
// WebSocketServer.sendInfo("往来单位信息下载已完成,请刷新查看!", "sid");
thrProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrProductsImportLogEntity.setUpdateTime(new Date());
thrCorpImportLogService.updateImportLog(thrProductsImportLogEntity);
@ -353,9 +353,9 @@ public class ThrCorpsDlService {
public List<List<String>> genExcelData(FilterThrCorpRequest filterThrOrderRequest) {
List<List<String>> excelData = new ArrayList<>();
List<ThrCorpEntity> thrCorpEntityList=new ArrayList<>();
List<ThrCorpEntity> thrCorpEntityList = new ArrayList<>();
List<ThrCorpsResponse> thrCorpsResponseList = thrCorpService.filterThrCorps(filterThrOrderRequest);
if(thrCorpsResponseList.size()>0){
if (thrCorpsResponseList.size() > 0) {
thrCorpEntityList = thrCorpsResponseList.stream().map(
item -> {
ThrCorpEntity thrCorpEntity = new ThrCorpEntity();
@ -419,12 +419,12 @@ public class ThrCorpsDlService {
exportData.addAll(thrCorpEntities);
} else {
//根据查询条件一键导出数据库往来单位
List<ThrCorpEntity> thrCorpEntityList=new ArrayList<>();
List<ThrCorpEntity> thrCorpEntityList = new ArrayList<>();
FilterThrCorpRequest filterThrCorpRequest = new FilterThrCorpRequest();
BeanUtils.copyProperties(thrCorpExportRequest, filterThrCorpRequest);
filterThrCorpRequest.setPage(null);
List<ThrCorpsResponse> thrCorpsResponseList = thrCorpService.filterThrCorps(filterThrCorpRequest);
if(thrCorpsResponseList.size()>0){
if (thrCorpsResponseList.size() > 0) {
thrCorpEntityList = thrCorpsResponseList.stream().map(
item -> {
ThrCorpEntity thrCorpEntity = new ThrCorpEntity();
@ -476,12 +476,12 @@ public class ThrCorpsDlService {
exportData.addAll(thrCorpEntities);
} else {
//根据查询条件一键导出数据库往来单位
List<ThrCorpEntity> thrCorpEntityList=new ArrayList<>();
List<ThrCorpEntity> thrCorpEntityList = new ArrayList<>();
FilterThrCorpRequest filterThrCorpRequest = new FilterThrCorpRequest();
BeanUtils.copyProperties(thrCorpExportRequest, filterThrCorpRequest);
filterThrCorpRequest.setPage(null);
List<ThrCorpsResponse> thrCorpsResponseList = thrCorpService.filterThrCorps(filterThrCorpRequest);
if(thrCorpsResponseList.size()>0){
if (thrCorpsResponseList.size() > 0) {
thrCorpEntityList = thrCorpsResponseList.stream().map(
item -> {
ThrCorpEntity thrCorpEntity = new ThrCorpEntity();

@ -2,7 +2,6 @@ package com.glxp.api.service.thrsys;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.config.WebSocketServer;
import com.glxp.api.constant.BasicProcessStatus;
import com.glxp.api.constant.Constant;
import com.glxp.api.entity.thrsys.*;
@ -13,6 +12,7 @@ import com.glxp.api.res.thrsys.ThrInvProductResponse;
import com.glxp.api.service.auth.CustomerService;
import com.glxp.api.util.ExcelUtil;
import com.glxp.api.util.RedisUtil;
import org.java_websocket.server.WebSocketServer;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -48,7 +48,7 @@ public class ThrInvProductsDlService {
ThrInvProductsImportLogEntity thrInvProductsImportLogEntity = thrInvProductsImportLogService.selectByGenKey(genKey);
ThrSystemDetailEntity piDetailEntity = thrSystemDetailService.selectByKey("invPiUrl", thirdSys);
if (piDetailEntity == null || piDetailEntity.getValue() == null) {
WebSocketServer.sendInfo("库存产品信息接口未设置!", "sid");
// WebSocketServer.sendInfo("库存产品信息接口未设置!", "sid");
return;
}
@ -88,7 +88,7 @@ public class ThrInvProductsDlService {
).collect(Collectors.toList());
thrInvProductsService.insertThrInvProducts(thrInvProductsEntities);
redisUtil.set(Constant.dlThrProducts, "false");
WebSocketServer.sendInfo("库存产品信息下载已完成,请刷新查看!", "sid");
// WebSocketServer.sendInfo("库存产品信息下载已完成,请刷新查看!", "sid");
thrInvProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrInvProductsImportLogService.updateImportLog(thrInvProductsImportLogEntity);
@ -99,7 +99,7 @@ public class ThrInvProductsDlService {
public void importProducrs(String genKey, String thirdSys, ThrOnhandRequest thrOnhandRequest) {
ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("invPiUrl", thirdSys);
if (thrSystemDetailEntity == null || thrSystemDetailEntity.getValue() == null) {
WebSocketServer.sendInfo("库存产品信息接口未设置!", "sid");
// WebSocketServer.sendInfo("库存产品信息接口未设置!", "sid");
return;
}
ThrInvProductsImportLogEntity thrInvProductsImportLogEntity = thrInvProductsImportLogService.selectByGenKey(genKey);
@ -124,7 +124,7 @@ public class ThrInvProductsDlService {
).collect(Collectors.toList());
thrInvProductsService.insertThrInvProducts(thrInvProductsEntities);
redisUtil.set(Constant.dlThrProducts, "false");
WebSocketServer.sendInfo("库存产品信息下载已完成,请刷新查看!", "sid");
// WebSocketServer.sendInfo("库存产品信息下载已完成,请刷新查看!", "sid");
}
@Async

@ -3,8 +3,6 @@ package com.glxp.api.service.thrsys;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.config.WebSocketServer;
import com.glxp.api.constant.BasicProcessStatus;
import com.glxp.api.constant.Constant;
import com.glxp.api.entity.sync.SyncDataSetEntity;
@ -19,6 +17,7 @@ import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.thrsys.ThrOrderResponse;
import com.glxp.api.service.sync.SyncDataSetService;
import com.glxp.api.util.RedisUtil;
import org.java_websocket.server.WebSocketServer;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -70,12 +69,12 @@ public class ThrOrdersDlService {
ThrSystemDetailEntity thrSystemDetailEntity = iThrBusTypeOriginService.findSysByAction(action, "orderQueryUrl");
if (thrSystemDetailEntity == null || !thrSystemDetailEntity.getEnabled()) {
WebSocketServer.sendInfo("业务单据查询接口未设置!", "sid");
// WebSocketServer.sendInfo("业务单据查询接口未设置!", "sid");
return;
}
if (thrSystemDetailEntity.getThirdSysFk() == null) {
WebSocketServer.sendInfo("业务单据查询接口未设置!", "sid");
// WebSocketServer.sendInfo("业务单据查询接口未设置!", "sid");
return;
}
int page = 1;
@ -85,7 +84,7 @@ public class ThrOrdersDlService {
}
thrOrderImportLogService.importThrOrder(genKey);
redisUtil.set(Constant.dlThrProducts, "false");
WebSocketServer.sendInfo("业务单据信息下载已完成,请刷新查看!", "sid");
// WebSocketServer.sendInfo("业务单据信息下载已完成,请刷新查看!", "sid");
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrOrderImportLogService.updateImportLog(thrOrderImportLogEntity);
}
@ -117,7 +116,7 @@ public class ThrOrdersDlService {
}
}
redisUtil.set(Constant.dlThrProducts, "false");
WebSocketServer.sendInfo("业务单据信息下载已完成,请刷新查看!", "sid");
// WebSocketServer.sendInfo("业务单据信息下载已完成,请刷新查看!", "sid");
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrOrderImportLogService.updateImportLog(thrOrderImportLogEntity);
}

Loading…
Cancel
Save