From c57defc8002b74a4d5a829ffe3b4cf7355233a05 Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Mon, 7 Jun 2021 19:18:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A3=9F=E8=B0=B1?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/WebSocketController.java | 26 +-- .../java/com/stdiet/custom/utils/WsUtils.java | 2 + .../components/RecipesPlanDrawer/index.vue | 2 +- stdiet-ui/src/store/modules/message.js | 46 +++- .../custom/message/messageBrowser/Comment.vue | 1 + .../custom/message/messageBrowser/index.vue | 7 + .../views/custom/message/userInfo/index.vue | 61 +++-- .../custom/message/userInfo/recipesPlan.vue | 220 ++++++++++++++++++ 8 files changed, 328 insertions(+), 37 deletions(-) create mode 100644 stdiet-ui/src/views/custom/message/userInfo/recipesPlan.vue diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WebSocketController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WebSocketController.java index 4ae0335ec..4c2ec561d 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WebSocketController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WebSocketController.java @@ -2,8 +2,8 @@ package com.stdiet.web.controller.custom; import com.alibaba.fastjson.JSONObject; import com.stdiet.common.core.controller.BaseController; -import com.stdiet.custom.utils.WsUtils; import com.stdiet.custom.server.WebSocketServer; +import com.stdiet.custom.utils.WsUtils; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Controller; @@ -38,16 +38,16 @@ public class WebSocketController extends BaseController { } -// @Scheduled(fixedRate = 30000) -// public void boardCast() { -// try { -// JSONObject heartBeat = new JSONObject(); -// heartBeat.put("type", WsUtils.WS_TYPE_HEART_BEAT); -// heartBeat.put("msg", "ping"); -// -// WebSocketServer.sendInfo(heartBeat.toJSONString(), null); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// } + @Scheduled(fixedRate = 1800000) + public void boardCast() { + try { + JSONObject heartBeat = new JSONObject(); + heartBeat.put("type", WsUtils.WS_TYPE_SYSTEM_MESSAGE_CLEAN); + heartBeat.put("msg", "clean"); + + WebSocketServer.sendInfo(heartBeat.toJSONString(), null); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/utils/WsUtils.java b/stdiet-custom/src/main/java/com/stdiet/custom/utils/WsUtils.java index a1b2286bf..fb76c3526 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/utils/WsUtils.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/utils/WsUtils.java @@ -6,6 +6,8 @@ public class WsUtils { public static final String WS_TYPE_SYSTEM_MESSAGE = "WS_TYPE_SYSTEM_MESSAGE"; + public static final String WS_TYPE_SYSTEM_MESSAGE_CLEAN = "WS_TYPE_SYSTEM_MESSAGE_CLEAN"; + public static final String WS_TYPE_MESSAGE_COUNT = "WS_TYPE_MESSAGE_COUNT"; public static final String WS_TYPE_NEW_CUSTOMER_REPLY = "WS_TYPE_NEW_CUSTOMER_REPLY"; diff --git a/stdiet-ui/src/components/RecipesPlanDrawer/index.vue b/stdiet-ui/src/components/RecipesPlanDrawer/index.vue index 60e7b60b1..c024ae6e4 100644 --- a/stdiet-ui/src/components/RecipesPlanDrawer/index.vue +++ b/stdiet-ui/src/components/RecipesPlanDrawer/index.vue @@ -192,7 +192,7 @@ export default { }, methods: { showDrawer(data) { - // console.log(data); + console.log(data); this.data = data; if (!this.data) { return; diff --git a/stdiet-ui/src/store/modules/message.js b/stdiet-ui/src/store/modules/message.js index e3643e1c5..168bf4cbb 100644 --- a/stdiet-ui/src/store/modules/message.js +++ b/stdiet-ui/src/store/modules/message.js @@ -1,5 +1,9 @@ import { getCustomerPhysicalSignsByCusId } from "@/api/custom/customer"; import { dealHealthy } from "@/utils/healthyData"; +import { + listRecipesPlanByCusId, + updateRecipesPlan +} from "@/api/custom/recipesPlan"; import { fetchTopicList, @@ -16,7 +20,10 @@ const oriState = { healthyData: {}, healthDataLoading: false, healthyDataType: 0, - avoidFoodIds: [] + avoidFoodIds: [], + // + planList: [], + planListLoading: false }; const mutations = { @@ -71,12 +78,17 @@ const actions = { }, async fetchTopicDetailActions({ commit, dispatch, state }, payload) { const { topicId, id, uid } = payload; - const { healthyData } = state; + const { healthyData, planList } = state; commit("save", { selTopicId: topicId }); // 客户信息 if (healthyData.customerId !== parseInt(uid)) { dispatch("getHealthyData", { cusId: uid, callback: payload.callback }); } + // 食谱计划 + if (!planList.length || planList[0].cusId !== parseInt(uid)) { + dispatch("getRecipesPlanActions", { cusId: uid }); + } + // const result = await fetchTopicDetail({ topicId, id }); if (result.code === 200) { @@ -130,13 +142,39 @@ const actions = { obj => obj.id ); } - } else { - throw new Error(healthyDataResult.msg); } commit("save", { healthDataLoading: false, ...newState }); + }, + async getRecipesPlanActions({ commit }, payload) { + commit("save", { planListLoading: true, planList: [] }); + const result = await listRecipesPlanByCusId(payload.cusId); + let planList = []; + if (result.code === 200) { + planList = result.data; + } + commit("save", { + planList, + planListLoading: false + }); + }, + async updateRecipesPlanActions({ commit, state }, payload) { + const { id, sendFlag, callback } = payload; + const { planList } = state; + const result = await updateRecipesPlan({ id, sendFlag }); + if (result.code === 200) { + callback && callback("success", result.msg); + const newPlanList = JSON.parse(JSON.stringify(planList)); + const tarPlan = newPlanList.find(obj => obj.id === id); + if (tarPlan) { + tarPlan.sendFlag = sendFlag; + } + commit("save", { + planList: newPlanList + }); + } } }; diff --git a/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue b/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue index 94a390e71..e60aaa6f4 100644 --- a/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue +++ b/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue @@ -31,6 +31,7 @@ export default { dietician: "主任营养师", after_sale: "售后营养师", dietician_assistant: "营养师助理", + manager: "总经理", }, }; }, diff --git a/stdiet-ui/src/views/custom/message/messageBrowser/index.vue b/stdiet-ui/src/views/custom/message/messageBrowser/index.vue index dac7a0d1b..f90b80429 100644 --- a/stdiet-ui/src/views/custom/message/messageBrowser/index.vue +++ b/stdiet-ui/src/views/custom/message/messageBrowser/index.vue @@ -353,6 +353,13 @@ export default { .topic_detail_title { display: flex; cursor: pointer; + + & > :nth-child(1) { + flex: 0 0 40px; + } + & > :nth-child(2) { + flex: 1 0 0; + } } .comment_reply_item { diff --git a/stdiet-ui/src/views/custom/message/userInfo/index.vue b/stdiet-ui/src/views/custom/message/userInfo/index.vue index ba447aeb3..304299003 100644 --- a/stdiet-ui/src/views/custom/message/userInfo/index.vue +++ b/stdiet-ui/src/views/custom/message/userInfo/index.vue @@ -1,38 +1,61 @@ + diff --git a/stdiet-ui/src/views/custom/message/userInfo/recipesPlan.vue b/stdiet-ui/src/views/custom/message/userInfo/recipesPlan.vue new file mode 100644 index 000000000..1a4bfc80b --- /dev/null +++ b/stdiet-ui/src/views/custom/message/userInfo/recipesPlan.vue @@ -0,0 +1,220 @@ + + + From 02e5110d2c6fddf471d13c4db0a591528ca0036a Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Tue, 8 Jun 2021 18:26:00 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/SysServiceTopicController.java | 10 +- .../com/stdiet/custom/domain/SysCustomer.java | 8 ++ .../custom/mapper/SysServicesTopicMapper.java | 4 + .../stdiet/custom/server/WebSocketServer.java | 2 +- .../service/ISysServicesTopicService.java | 4 + .../impl/SysServicesTopicServiceImp.java | 9 ++ .../mapper/custom/SysCustomerMapper.xml | 82 +++++++------ .../mapper/custom/SysServicesTopicMapper.xml | 51 +++++++- stdiet-ui/src/api/custom/message.js | 8 ++ stdiet-ui/src/store/modules/message.js | 112 +++++++++++++----- .../custom/message/messageBrowser/Comment.vue | 4 +- .../custom/message/messageBrowser/index.vue | 76 +++++++++++- .../views/custom/message/userInfo/index.vue | 41 ++++++- 13 files changed, 332 insertions(+), 79 deletions(-) diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysServiceTopicController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysServiceTopicController.java index 45b74e292..399d4fefe 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysServiceTopicController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysServiceTopicController.java @@ -20,10 +20,16 @@ public class SysServiceTopicController extends BaseController { @GetMapping("/list") public TableDataInfo list(SysServicesTopic topic) { - startPage(); - return getDataTable(servicesTopicService.selectSysServicesTopicByUserIdAndRole(topic)); + return getDataTable(servicesTopicService.selectTopicListByUid(topic)); } + @GetMapping("/customers") + public TableDataInfo customers(SysServicesTopic topic) { + startPage(); + return getDataTable(servicesTopicService.selectCustomerListByUserIdAndRole(topic)); + } + + // @PutMapping("/update/status") // public AjaxResult status(@RequestBody SysServicesQuestion sysServicesQuestion) { // return toAjax(sysServicesQuestionService.updateSysServicesQuestionStatus(sysServicesQuestion)); diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomer.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomer.java index 072923305..a29e915ad 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomer.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomer.java @@ -71,18 +71,26 @@ public class SysCustomer extends BaseEntity /** 主营养师 */ @Excel(name = "主营养师") + private String dietitianName; + private Long mainDietitian; /** 营养师助理 */ @Excel(name = "营养师助理") + private String assDietitianName; + private Long assistantDietitian; /** 售后营养师 */ @Excel(name = "售后营养师") + private String afterDietitianName; + private Long afterDietitian; /** 销售人员 */ @Excel(name = "销售人员") + private String salesName; + private Long salesman; /** 负责人 */ diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysServicesTopicMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysServicesTopicMapper.java index 0217a94e8..eb910321f 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysServicesTopicMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysServicesTopicMapper.java @@ -7,6 +7,8 @@ import java.util.List; public interface SysServicesTopicMapper { List selectSysServicesTopicByUserIdAndRole(SysServicesTopic topic); + List selectCustomerListByUserIdAndRole(SysServicesTopic topic); + int insertSysServicesTopic(SysServicesTopic topic); int insertSysServicesTopicStatus(List topics); @@ -20,4 +22,6 @@ public interface SysServicesTopicMapper { List selectSysServicesTopicSessionByTopicId(String topicId); List selectUnreadTopicCount(List topics); + + List selectTopicListByUid(SysServicesTopic topic); } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/server/WebSocketServer.java b/stdiet-custom/src/main/java/com/stdiet/custom/server/WebSocketServer.java index 7bc506c04..0cc9f0217 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/server/WebSocketServer.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/server/WebSocketServer.java @@ -27,7 +27,7 @@ public class WebSocketServer { //private static ConcurrentHashMap websocketList = new ConcurrentHashMap<>(); // 与某个客户端的连接会话,需要通过它来给客户端发送数据 private Session session; - // 接收sid + // 接收sidw private String sid = ""; public static CopyOnWriteArraySet getWebSocketSet() { diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysServicesTopicService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysServicesTopicService.java index 054424584..e8059405e 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysServicesTopicService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysServicesTopicService.java @@ -8,6 +8,8 @@ public interface ISysServicesTopicService { List selectSysServicesTopicByUserIdAndRole(SysServicesTopic topic); + List selectCustomerListByUserIdAndRole(SysServicesTopic topic); + SysServicesTopic insertSysServicesTopic(SysServicesTopic topic); int updateSysServicesTopicStatus(SysServicesTopic topic); @@ -19,4 +21,6 @@ public interface ISysServicesTopicService { List selectSysServicesTopicSessionByTopicId(String topicId); List selectUnreadTopicCount(List topic); + + List selectTopicListByUid(SysServicesTopic topic); } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysServicesTopicServiceImp.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysServicesTopicServiceImp.java index 1e57ffabd..10496bdd3 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysServicesTopicServiceImp.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysServicesTopicServiceImp.java @@ -30,6 +30,10 @@ public class SysServicesTopicServiceImp implements ISysServicesTopicService { return servicesTopicMapper.selectSysServicesTopicByUserIdAndRole(topic); } + @Override + public List selectCustomerListByUserIdAndRole(SysServicesTopic topic) { + return servicesTopicMapper.selectCustomerListByUserIdAndRole(topic); + } @Override public SysServicesTopic insertSysServicesTopic(SysServicesTopic topic) { @@ -187,4 +191,9 @@ public class SysServicesTopicServiceImp implements ISysServicesTopicService { public List selectUnreadTopicCount(List statusList) { return servicesTopicMapper.selectUnreadTopicCount(statusList); } + + @Override + public List selectTopicListByUid(SysServicesTopic topic) { + return servicesTopicMapper.selectTopicListByUid(topic); + } } diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml index ff5a0fa16..756e76742 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml @@ -5,38 +5,50 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, name, phone, email, fans_time, fans_channel, address, pay_date, start_date, purchase_num, pay_total, main_dietitian, assistant_dietitian, after_dietitian, salesman, charge_person, follow_status, create_time, create_by, update_time, update_by, channel_id from sys_customer + SELECT DISTINCT(uid)AS uid, MAX(update_time) AS update_time, MIN(create_time) AS create_time, MIN(`read`) AS + `read`, role FROM ( + SELECT * FROM ( + SELECT topic_id, `read`, create_time, update_time, 'customer' AS role FROM sys_services_topic_status + + + WHERE role = 'dietician' + + + WHERE role = #{role} AND uid = #{uid} + + + + ) AS status + LEFT JOIN (SELECT topic_id, uid, del_flag FROM sys_services_topic ) AS topic USING(topic_id) + WHERE del_flag = 0 + ORDER BY `read` ASC, update_time DESC + ) AS userList GROUP BY uid + + + diff --git a/stdiet-ui/src/api/custom/message.js b/stdiet-ui/src/api/custom/message.js index 7b81d2223..a29d6772a 100644 --- a/stdiet-ui/src/api/custom/message.js +++ b/stdiet-ui/src/api/custom/message.js @@ -1,5 +1,13 @@ import request from "@/utils/request"; +export function fetchCustomerList(query) { + return request({ + url: "/services/topic/customers", + method: "get", + params: query + }); +} + export function fetchTopicList(query) { return request({ url: "/services/topic/list", diff --git a/stdiet-ui/src/store/modules/message.js b/stdiet-ui/src/store/modules/message.js index 168bf4cbb..5dbfcd752 100644 --- a/stdiet-ui/src/store/modules/message.js +++ b/stdiet-ui/src/store/modules/message.js @@ -1,4 +1,7 @@ -import { getCustomerPhysicalSignsByCusId } from "@/api/custom/customer"; +import { + getCustomerPhysicalSignsByCusId, + getCustomer +} from "@/api/custom/customer"; import { dealHealthy } from "@/utils/healthyData"; import { listRecipesPlanByCusId, @@ -6,6 +9,7 @@ import { } from "@/api/custom/recipesPlan"; import { + fetchCustomerList, fetchTopicList, postTopicReply, fetchTopicDetail, @@ -14,14 +18,24 @@ import { const oriState = { pageNum: 1, + cusLoading: false, + customerList: [], + selCusId: "", + // topicList: [], - detailData: {}, + topicLoading: false, selTopicId: "", + // + detailData: {}, + detailLoading: false, + // healthyData: {}, healthDataLoading: false, healthyDataType: 0, avoidFoodIds: [], // + customerData: {}, + // planList: [], planListLoading: false }; @@ -44,42 +58,71 @@ const mutations = { const actions = { async init({ dispatch }, payload) { - dispatch("fetchTopicListApi", {}); + dispatch("fetchCustomerListActions", {}); }, - async fetchTopicListApi({ dispatch, commit, rootGetters, state }, payload) { - const { - roles: [role], - userId - } = rootGetters; - const { detailData, pageNum, topicList } = state; - const result = await fetchTopicList({ + + async fetchCustomerListActions( + { dispatch, commit, rootGetters, state }, + payload + ) { + // prettier-ignore + const { roles: [role], userId } = rootGetters; + const { customerList, pageNum } = state; + commit("save", { cusLoading: true }); + const result = await fetchCustomerList({ role, uid: userId, pageSize: 20, pageNum }); - if (result.code === 200) { - if (!detailData.topicId) { - // 默认展示第一个 - const [defTopic] = result.rows; - dispatch("fetchTopicDetailActions", { - topicId: defTopic.topicId, - id: defTopic.id, - uid: defTopic.uid - }); - } - if (result.rows.length) { - commit("save", { - pageNum: pageNum + 1, - topicList: [...topicList, ...result.rows] - }); + let mPageNum = pageNum, + mCustomerList = customerList; + if (result.code === 200 && result.rows.length) { + // + if (!customerList.length) { + const [defCustomer] = result.rows; + dispatch("fetchTopicListApi", { fromUid: defCustomer.uid }); } + // + mPageNum += 1; + mCustomerList = [...customerList, ...result.rows]; } + commit("save", { + pageNum: mPageNum, + cusLoading: false, + customerList: mCustomerList + }); + }, + async fetchTopicListApi({ dispatch, commit, rootGetters, state }, payload) { + // prettier-ignore + const { roles: [role], userId } = rootGetters; + const { fromUid } = payload; + commit("save", { selCusId: fromUid, topicLoading: true }); + const result = await fetchTopicList({ + role, + uid: userId, + fromUid + }); + let mTopicList = []; + if (result.code === 200 && result.rows.length) { + // 默认展示第一个 + const [defTopic] = result.rows; + dispatch("fetchTopicDetailActions", { + topicId: defTopic.topicId, + id: defTopic.id, + uid: defTopic.uid + }); + mTopicList = result.rows; + } + commit("save", { + topicList: mTopicList, + topicLoading: false + }); }, async fetchTopicDetailActions({ commit, dispatch, state }, payload) { - const { topicId, id, uid } = payload; - const { healthyData, planList } = state; - commit("save", { selTopicId: topicId }); + const { topicId, id = 0, uid } = payload; + const { healthyData, planList, customerData } = state; + commit("save", { selTopicId: topicId, detailLoading: true }); // 客户信息 if (healthyData.customerId !== parseInt(uid)) { dispatch("getHealthyData", { cusId: uid, callback: payload.callback }); @@ -88,11 +131,20 @@ const actions = { if (!planList.length || planList[0].cusId !== parseInt(uid)) { dispatch("getRecipesPlanActions", { cusId: uid }); } - + // 客户档案 + if (customerData.id !== parseInt(uid)) { + dispatch("getCustomerFileActions", { cusId: uid }); + } // const result = await fetchTopicDetail({ topicId, id }); if (result.code === 200) { - commit("save", { detailData: result.data[0] }); + commit("save", { detailData: result.data[0], detailLoading: false }); + } + }, + async getCustomerFileActions({ commit }, payload) { + const result = await getCustomer(payload.cusId); + if (result.code === 200) { + commit("save", { customerData: result.data }); } }, async postTopicReplyActions( diff --git a/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue b/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue index e60aaa6f4..4ede7df5e 100644 --- a/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue +++ b/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue @@ -1,8 +1,8 @@