|
@@ -6,22 +6,22 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONPObject;
|
|
import com.alibaba.fastjson.JSONPObject;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.huimv.wine.common.EventWsErrUtil;
|
|
import com.huimv.wine.common.EventWsErrUtil;
|
|
-import com.huimv.wine.entity.Manager;
|
|
|
|
-import com.huimv.wine.entity.Warn;
|
|
|
|
|
|
+import com.huimv.wine.entity.*;
|
|
import com.huimv.wine.entity.vo.*;
|
|
import com.huimv.wine.entity.vo.*;
|
|
-import com.huimv.wine.mapper.WarnMapper;
|
|
|
|
-import com.huimv.wine.mapper.WineMapper;
|
|
|
|
-import com.huimv.wine.mapper.WorkerMapper;
|
|
|
|
-import com.huimv.wine.utils.Result;
|
|
|
|
-import com.huimv.wine.utils.SpringContextUtil;
|
|
|
|
-import com.huimv.wine.utils.WebsocketManagerUtil;
|
|
|
|
-import com.huimv.wine.utils.WebsocketWorkerUtil;
|
|
|
|
|
|
+import com.huimv.wine.mapper.*;
|
|
|
|
+import com.huimv.wine.utils.*;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.websocket.Session;
|
|
import javax.websocket.Session;
|
|
|
|
+import java.time.Duration;
|
|
|
|
+import java.time.LocalDateTime;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@Component
|
|
@Component
|
|
public class AdminWine {
|
|
public class AdminWine {
|
|
@@ -29,33 +29,40 @@ public class AdminWine {
|
|
public void handle(JSONObject message, Session session, Manager manager) {
|
|
public void handle(JSONObject message, Session session, Manager manager) {
|
|
String event = message.getString("event");
|
|
String event = message.getString("event");
|
|
JSONObject data = message.getJSONObject("data");
|
|
JSONObject data = message.getJSONObject("data");
|
|
|
|
+ WarnMapper warnMapper = SpringContextUtil.getBean(WarnMapper.class);
|
|
|
|
+ WorkerMapper workerMapper = SpringContextUtil.getBean(WorkerMapper.class);
|
|
|
|
+ ChangeMapper changeMapper = SpringContextUtil.getBean(ChangeMapper.class);
|
|
|
|
+ OperationMapper operationMapper = SpringContextUtil.getBean(OperationMapper.class);
|
|
|
|
+ WineMapper wineMapper = SpringContextUtil.getBean(WineMapper.class);
|
|
|
|
+ RedisTemplate redisTemplate = SpringContextUtil.getBean(RedisTemplate.class);
|
|
|
|
+
|
|
switch (event) {
|
|
switch (event) {
|
|
case "adminWineChangeQuery":
|
|
case "adminWineChangeQuery":
|
|
- query(session, manager, data);
|
|
|
|
|
|
+ query(session, manager, data,warnMapper);
|
|
break;
|
|
break;
|
|
case "adminWineChangeQueryWine":
|
|
case "adminWineChangeQueryWine":
|
|
- queryWine(session, message.getString("data"));
|
|
|
|
|
|
+ queryWine(session, message.getString("data"),wineMapper);
|
|
break;
|
|
break;
|
|
case "adminWineChangeQueryWorker":
|
|
case "adminWineChangeQueryWorker":
|
|
- queryWorker(session, manager, message.getString("data"));
|
|
|
|
|
|
+ queryWorker(session, manager, message.getString("data"),workerMapper);
|
|
break;
|
|
break;
|
|
case "adminWineChangeAssign":
|
|
case "adminWineChangeAssign":
|
|
- assign(session, manager, data);
|
|
|
|
|
|
+ assign(session, manager, data,warnMapper,workerMapper,changeMapper,operationMapper);
|
|
break;
|
|
break;
|
|
case "adminWineDeviceFix":
|
|
case "adminWineDeviceFix":
|
|
- deviceFix(session, manager, data);
|
|
|
|
|
|
+ deviceFix(session, manager, message.getString("data"),operationMapper,redisTemplate);
|
|
break;
|
|
break;
|
|
case "adminWineHistoryQueryWorker":
|
|
case "adminWineHistoryQueryWorker":
|
|
- historyQueryWorker(session, manager, data);
|
|
|
|
|
|
+ historyQueryWorker(session, manager, data,workerMapper);
|
|
break;
|
|
break;
|
|
case "adminWineHistoryQueryOrder":
|
|
case "adminWineHistoryQueryOrder":
|
|
- queryOrder(session, manager, data);
|
|
|
|
|
|
+ queryOrder(session, manager, data,changeMapper);
|
|
break;
|
|
break;
|
|
case "adminWineHistoryOrderUpdate":
|
|
case "adminWineHistoryOrderUpdate":
|
|
- orderUpdate(session, data);
|
|
|
|
|
|
+ orderUpdate(session, data, changeMapper, operationMapper);
|
|
break;
|
|
break;
|
|
case "adminWineHistoryOrderDelete":
|
|
case "adminWineHistoryOrderDelete":
|
|
- orderDelete(session, data);
|
|
|
|
|
|
+ orderDelete(session, message.getInteger("data"),changeMapper,operationMapper,warnMapper);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
WsEvent wsEvent = EventWsErrUtil.getWsErr("unrecognized event");
|
|
WsEvent wsEvent = EventWsErrUtil.getWsErr("unrecognized event");
|
|
@@ -64,8 +71,7 @@ public class AdminWine {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void query(Session session, Manager manager, JSONObject data) {
|
|
|
|
- WarnMapper warnMapper = SpringContextUtil.getBean(WarnMapper.class);
|
|
|
|
|
|
+ private void query(Session session, Manager manager, JSONObject data, WarnMapper warnMapper) {
|
|
AdminWineChangeQueryParam adminWineChangeQueryParam = JSONObject.toJavaObject(data,AdminWineChangeQueryParam.class);
|
|
AdminWineChangeQueryParam adminWineChangeQueryParam = JSONObject.toJavaObject(data,AdminWineChangeQueryParam.class);
|
|
Page<WarnQueryResult> page = new Page<>(adminWineChangeQueryParam.getPage(),adminWineChangeQueryParam.getLimit());
|
|
Page<WarnQueryResult> page = new Page<>(adminWineChangeQueryParam.getPage(),adminWineChangeQueryParam.getLimit());
|
|
String like = "%s"+adminWineChangeQueryParam.getCond()+"%s";
|
|
String like = "%s"+adminWineChangeQueryParam.getCond()+"%s";
|
|
@@ -91,59 +97,245 @@ public class AdminWine {
|
|
warnQueryResultVoPage.setCountId(warnQueryResultPage.getCountId());
|
|
warnQueryResultVoPage.setCountId(warnQueryResultPage.getCountId());
|
|
|
|
|
|
WsEvent wsEvent = new WsEvent("adminWineChangeQueryRes",Result.success(warnQueryResultVoPage));
|
|
WsEvent wsEvent = new WsEvent("adminWineChangeQueryRes",Result.success(warnQueryResultVoPage));
|
|
- WebsocketWorkerUtil.sendMessage(session,wsEvent);
|
|
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
}
|
|
}
|
|
|
|
|
|
- private void queryWine(Session session, String cond) {
|
|
|
|
- WineMapper wineMapper = SpringContextUtil.getBean(WineMapper.class);
|
|
|
|
|
|
+ private void queryWine(Session session, String cond, WineMapper wineMapper) {
|
|
String like = "%"+cond+"%s";
|
|
String like = "%"+cond+"%s";
|
|
List<WineWithIdNameVo> wineWithIdNameVos = wineMapper.WinesQueryByIdOrName(like);
|
|
List<WineWithIdNameVo> wineWithIdNameVos = wineMapper.WinesQueryByIdOrName(like);
|
|
WsEvent wsEvent = new WsEvent("adminWineChangeQueryWineRes",Result.success(wineWithIdNameVos));
|
|
WsEvent wsEvent = new WsEvent("adminWineChangeQueryWineRes",Result.success(wineWithIdNameVos));
|
|
- WebsocketWorkerUtil.sendMessage(session,wsEvent);
|
|
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
}
|
|
}
|
|
|
|
|
|
- private void queryWorker(Session session, Manager manager, String cond) {
|
|
|
|
- WorkerMapper workerMapper = SpringContextUtil.getBean(WorkerMapper.class);
|
|
|
|
|
|
+ private void queryWorker(Session session, Manager manager, String cond, WorkerMapper workerMapper) {
|
|
String like = "%"+cond+"%s";
|
|
String like = "%"+cond+"%s";
|
|
List<WorkerWithIdPhoneName> workerWithIdPhoneNames = workerMapper.WorkersQueryByPhoneOrName(manager.getId(),like);
|
|
List<WorkerWithIdPhoneName> workerWithIdPhoneNames = workerMapper.WorkersQueryByPhoneOrName(manager.getId(),like);
|
|
WsEvent wsEvent = new WsEvent("adminWineChangeQueryWorkerRes",Result.success(workerWithIdPhoneNames));
|
|
WsEvent wsEvent = new WsEvent("adminWineChangeQueryWorkerRes",Result.success(workerWithIdPhoneNames));
|
|
- WebsocketWorkerUtil.sendMessage(session,wsEvent);
|
|
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
}
|
|
}
|
|
|
|
|
|
- private void assign(Session session, Manager manager, JSONObject data) {
|
|
|
|
- WarnMapper warnMapper = SpringContextUtil.getBean(WarnMapper.class);
|
|
|
|
|
|
+ private void assign(Session session, Manager manager, JSONObject data, WarnMapper warnMapper, WorkerMapper workerMapper, ChangeMapper changeMapper, OperationMapper operationMapper) {
|
|
|
|
|
|
AdminWineAssignParam adminWineAssignParam = JSONObject.toJavaObject(data, AdminWineAssignParam.class);
|
|
AdminWineAssignParam adminWineAssignParam = JSONObject.toJavaObject(data, AdminWineAssignParam.class);
|
|
if (ObjectUtil.isEmpty(adminWineAssignParam.getWorker())){
|
|
if (ObjectUtil.isEmpty(adminWineAssignParam.getWorker())){
|
|
WsEvent wsEvent = new WsEvent("adminWineChangeAssignRes",Result.fail("请选择上酒工"));
|
|
WsEvent wsEvent = new WsEvent("adminWineChangeAssignRes",Result.fail("请选择上酒工"));
|
|
- WebsocketWorkerUtil.sendMessage(session,wsEvent);
|
|
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Worker worker = workerMapper.selectById(adminWineAssignParam.getWorker());
|
|
|
|
+ if (ObjectUtil.isEmpty(worker)){
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineChangeAssignRes",Result.fail("上酒工不存在"));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
Warn warn = warnMapper.selectById(adminWineAssignParam.getId());
|
|
Warn warn = warnMapper.selectById(adminWineAssignParam.getId());
|
|
if (ObjectUtil.isEmpty(warn)){
|
|
if (ObjectUtil.isEmpty(warn)){
|
|
WsEvent wsEvent = new WsEvent("adminWineChangeAssignRes",Result.fail("报警不存在"));
|
|
WsEvent wsEvent = new WsEvent("adminWineChangeAssignRes",Result.fail("报警不存在"));
|
|
- WebsocketWorkerUtil.sendMessage(session,wsEvent);
|
|
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ WineWithIdRemainVo[] old = adminWineAssignParam.getOld();
|
|
|
|
+ WineWithIdRemainVo[] now = adminWineAssignParam.getNow();
|
|
|
|
+ Change change = new Change();
|
|
|
|
+ change.setWid(warn.getId());
|
|
|
|
+ change.setDevice(warn.getDevice());
|
|
|
|
+ change.setManager(warn.getManager());
|
|
|
|
+ change.setWorker(adminWineAssignParam.getWorker());
|
|
|
|
+ change.setCode(Utils.randomString());
|
|
|
|
+
|
|
|
|
+ change.setWine1o(old[0].getId());
|
|
|
|
+ change.setRemain1o(old[0].getRemain());
|
|
|
|
+ change.setWine2o(old[1].getId());
|
|
|
|
+ change.setRemain2o(old[1].getRemain());
|
|
|
|
+ change.setWine3o(old[2].getId());
|
|
|
|
+ change.setRemain3o(old[2].getRemain());
|
|
|
|
+ change.setWine4o(old[3].getId());
|
|
|
|
+ change.setRemain4o(old[3].getRemain());
|
|
|
|
+ change.setWine1n(now[0].getId());
|
|
|
|
+ change.setRemain1n(now[0].getRemain());
|
|
|
|
+ change.setWine2n(now[1].getId());
|
|
|
|
+ change.setRemain2n(now[1].getRemain());
|
|
|
|
+ change.setWine3n(now[2].getId());
|
|
|
|
+ change.setRemain3n(now[2].getRemain());
|
|
|
|
+ change.setWine4n(now[3].getId());
|
|
|
|
+ change.setRemain4n(now[3].getRemain());
|
|
|
|
+
|
|
|
|
+ if (changeMapper.insert(change) != 1) {
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineChangeAssignRes",Result.fail("安排失败 01"));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ warn.setDeal(true);
|
|
|
|
+ if (warnMapper.updateById(warn) != 1) {
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineChangeAssignRes",Result.fail("安排失败 02"));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ worker.setTodo(worker.getTodo()+1);
|
|
|
|
+ if (workerMapper.updateById(worker) != 1) {
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineChangeAssignRes",Result.fail("安排失败 03"));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineChangeAssignRes",Result.success(null));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
+
|
|
|
|
+ Operation operation = new Operation(0,manager.getId(),0,0,String.format("管理员[%s]安排上酒工[%s]为设备[%s]换酒",manager.getName(),worker.getName(),warn.getDevice()));
|
|
|
|
+ operationMapper.insert(operation);
|
|
}
|
|
}
|
|
|
|
|
|
- private void deviceFix(Session session, Manager manager, JSONObject data) {
|
|
|
|
|
|
+ private void deviceFix(Session session, Manager manager, String deviceId, OperationMapper operationMapper, RedisTemplate redisTemplate) {
|
|
|
|
+ Map<String, Session> sessionMap = WebsocketSellerUtil.getSession();
|
|
|
|
+ if (sessionMap.containsKey(deviceId)){
|
|
|
|
+ String key = "Fix_" + deviceId + "_" + manager.getId();
|
|
|
|
+ String code;
|
|
|
|
+ if (redisTemplate.hasKey(key)) {
|
|
|
|
+ code = redisTemplate.opsForValue().get(key).toString();
|
|
|
|
+ redisTemplate.expire(key,300, TimeUnit.SECONDS);
|
|
|
|
+ }else {
|
|
|
|
+ code = Utils.randomString();
|
|
|
|
+ redisTemplate.opsForValue().set(key,code, Duration.ofSeconds(300));
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ Session deviceSession = sessionMap.get(deviceId);
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+ map.put("type","Fixing");
|
|
|
|
+ map.put("user_type","manager");
|
|
|
|
+ map.put("user_id",manager.getId());
|
|
|
|
+ WsEvent wsDeviceEvent = new WsEvent("openGate",Result.success(map));
|
|
|
|
+ WebsocketSellerUtil.sendMessage(deviceSession,wsDeviceEvent);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineDeviceFixRes",Result.success(code));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
+ Operation operation = new Operation(0,manager.getId(),0,1,String.format("管理员[%s]请求维修设备[%s]",manager.getName(),deviceId));
|
|
|
|
+ operationMapper.insert(operation);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineDeviceFixRes",Result.fail("设备离线"));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
}
|
|
}
|
|
|
|
|
|
- private void historyQueryWorker(Session session, Manager manager, JSONObject data) {
|
|
|
|
|
|
+ private void historyQueryWorker(Session session, Manager manager, JSONObject data, WorkerMapper workerMapper) {
|
|
|
|
+ AdminWineHistoryQueryWorkerParam queryWorkerParam = JSONObject.toJavaObject(data, AdminWineHistoryQueryWorkerParam.class);
|
|
|
|
+ Page<WorkerQueryForHistoryResult> page = new Page<>(queryWorkerParam.getPage(),queryWorkerParam.getLimit());
|
|
|
|
+ String like = "%" + queryWorkerParam.getCond() + "%";
|
|
|
|
+ Page<WorkerQueryForHistoryResult> resultPage = workerMapper.workerQueryForHistory(page,manager.getId(),like);
|
|
|
|
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineHistoryQueryWorkerRes",Result.success(resultPage));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
}
|
|
}
|
|
|
|
|
|
- private void queryOrder(Session session, Manager manager, JSONObject data) {
|
|
|
|
|
|
+ private void queryOrder(Session session, Manager manager, JSONObject data, ChangeMapper changeMapper) {
|
|
|
|
+ AdminWineHistoryQueryOrderParam queryOrderParam = JSONObject.toJavaObject(data, AdminWineHistoryQueryOrderParam.class);
|
|
|
|
+ Page<ChangeQueryResult> page = new Page<>(queryOrderParam.getPage(),queryOrderParam.getLimit());
|
|
|
|
+ Page<ChangeQueryResult> queryResultPage = changeMapper.changesQuery(page,manager.getId(),queryOrderParam.getWorker(),queryOrderParam.getCond(),queryOrderParam.getStatus());
|
|
|
|
+ Page<ChangeQueryResultVo> changeQueryResultVoPage = new Page<>();
|
|
|
|
+ List changeQueryResultVoList = new ArrayList<>();
|
|
|
|
+ for (ChangeQueryResult record : queryResultPage.getRecords()) {
|
|
|
|
+ ChangeQueryResultVo changeQueryResultVo = new ChangeQueryResultVo();
|
|
|
|
+ BeanUtil.copyProperties(record,changeQueryResultVo);
|
|
|
|
+ List<WineWithIdNameRemainVo> old = new ArrayList();
|
|
|
|
+ List<WineWithIdNameRemainVo> now = new ArrayList();
|
|
|
|
+
|
|
|
|
+ old.add(createWineWithIdNameRemain(record.getW1id(),record.getW1name(),record.getW1remain()));
|
|
|
|
+ old.add(createWineWithIdNameRemain(record.getW2id(),record.getW2name(),record.getW2remain()));
|
|
|
|
+ old.add(createWineWithIdNameRemain(record.getW3id(),record.getW3name(),record.getW3remain()));
|
|
|
|
+ old.add(createWineWithIdNameRemain(record.getW4id(),record.getW4name(),record.getW4remain()));
|
|
|
|
|
|
|
|
+ now.add(createWineWithIdNameRemain(record.getW5id(),record.getW5name(),record.getW5remain()));
|
|
|
|
+ now.add(createWineWithIdNameRemain(record.getW6id(),record.getW6name(),record.getW6remain()));
|
|
|
|
+ now.add(createWineWithIdNameRemain(record.getW7id(),record.getW7name(),record.getW7remain()));
|
|
|
|
+ now.add(createWineWithIdNameRemain(record.getW8id(),record.getW8name(),record.getW8remain()));
|
|
|
|
+
|
|
|
|
+ changeQueryResultVo.setOld(old);
|
|
|
|
+ changeQueryResultVo.setNow(now);
|
|
|
|
+ changeQueryResultVoList.add(changeQueryResultVo);
|
|
|
|
+ }
|
|
|
|
+ changeQueryResultVoPage.setRecords(changeQueryResultVoList);
|
|
|
|
+ changeQueryResultVoPage.setCurrent(queryResultPage.getCurrent());
|
|
|
|
+ changeQueryResultVoPage.setTotal(queryResultPage.getTotal());
|
|
|
|
+ changeQueryResultVoPage.setCountId(queryResultPage.getCountId());
|
|
|
|
+
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineHistoryQueryOrderRes",Result.success(changeQueryResultVoPage));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
}
|
|
}
|
|
|
|
|
|
- private void orderUpdate(Session session, JSONObject data) {
|
|
|
|
|
|
+ private void orderUpdate(Session session, JSONObject data, ChangeMapper changeMapper, OperationMapper operationMapper) {
|
|
|
|
+ AdminWineHistoryUpdateParam historyUpdateParam = JSONObject.toJavaObject(data, AdminWineHistoryUpdateParam.class);
|
|
|
|
+ Change change = changeMapper.selectById(historyUpdateParam.getId());
|
|
|
|
+ if (ObjectUtil.isEmpty(change)){
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineHistoryOrderUpdateRes",Result.fail("订单不存在"));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (change.getStatus() != 0){
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineHistoryOrderUpdateRes",Result.fail("订单不可修改"));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ WineWithIdRemainVo[] now = historyUpdateParam.getNow();
|
|
|
|
+ change.setWine1n(now[0].getId());
|
|
|
|
+ change.setRemain1n(now[0].getRemain());
|
|
|
|
+ change.setWine2n(now[1].getId());
|
|
|
|
+ change.setRemain2n(now[1].getRemain());
|
|
|
|
+ change.setWine3n(now[2].getId());
|
|
|
|
+ change.setRemain3n(now[2].getRemain());
|
|
|
|
+ change.setWine4n(now[3].getId());
|
|
|
|
+ change.setRemain4n(now[3].getRemain());
|
|
|
|
+ change.setPublish(LocalDateTime.now());
|
|
|
|
+
|
|
|
|
+ if (changeMapper.updateById(change) != 1) {
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineHistoryOrderUpdateRes",Result.fail("更新失败"));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineHistoryOrderUpdateRes",Result.success(null));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
|
|
|
|
+ Operation operation = new Operation(0,change.getManager(),1,0,"修改上酒订单信息");
|
|
|
|
+ operationMapper.insert(operation);
|
|
}
|
|
}
|
|
|
|
|
|
- private void orderDelete(Session session, JSONObject data) {
|
|
|
|
|
|
+ private void orderDelete(Session session, Integer id, ChangeMapper changeMapper, OperationMapper operationMapper, WarnMapper warnMapper) {
|
|
|
|
+ Change change = changeMapper.selectById(id);
|
|
|
|
+ if (ObjectUtil.isEmpty(change)){
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineHistoryOrderDeleteRes",Result.fail("订单不存在"));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (change.getStatus() != 0){
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineHistoryOrderDeleteRes",Result.fail("订单不可删除"));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Warn warn = warnMapper.selectById(change.getWid());
|
|
|
|
+ if (ObjectUtil.isEmpty(warn)){
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineHistoryOrderDeleteRes",Result.fail("报警信息错误"));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ warn.setDeal(false);
|
|
|
|
+ if (warnMapper.updateById(warn) != 1) {
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineHistoryOrderDeleteRes",Result.fail("重置报警信息失败"));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ int delete = changeMapper.deleteById(change);
|
|
|
|
+ if (delete != 1) {
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineHistoryOrderDeleteRes",Result.fail("删除失败"));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ WsEvent wsEvent = new WsEvent("adminWineHistoryOrderDeleteRes",Result.success("删除成功"));
|
|
|
|
+ WebsocketManagerUtil.sendMessage(session,wsEvent);
|
|
|
|
+
|
|
|
|
+ Operation operation = new Operation(0,change.getManager(),2,0,"取消上酒订单");
|
|
|
|
+ operationMapper.insert(operation);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|