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-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/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/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-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/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..5dbfcd752 100644 --- a/stdiet-ui/src/store/modules/message.js +++ b/stdiet-ui/src/store/modules/message.js @@ -1,7 +1,15 @@ -import { getCustomerPhysicalSignsByCusId } from "@/api/custom/customer"; +import { + getCustomerPhysicalSignsByCusId, + getCustomer +} from "@/api/custom/customer"; import { dealHealthy } from "@/utils/healthyData"; +import { + listRecipesPlanByCusId, + updateRecipesPlan +} from "@/api/custom/recipesPlan"; import { + fetchCustomerList, fetchTopicList, postTopicReply, fetchTopicDetail, @@ -10,13 +18,26 @@ import { const oriState = { pageNum: 1, + cusLoading: false, + customerList: [], + selCusId: "", + // topicList: [], - detailData: {}, + topicLoading: false, selTopicId: "", + // + detailData: {}, + detailLoading: false, + // healthyData: {}, healthDataLoading: false, healthyDataType: 0, - avoidFoodIds: [] + avoidFoodIds: [], + // + customerData: {}, + // + planList: [], + planListLoading: false }; const mutations = { @@ -37,50 +58,93 @@ 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 } = 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 }); } + // 食谱计划 + 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( @@ -130,13 +194,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..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 @@