Browse Source

修复bug

lsw 1 month ago
parent
commit
6badc4fbe0

+ 9 - 8
admin-ui/src/views/work/follow/record/index.vue

@@ -21,12 +21,13 @@
     <el-table :data="response.rows" border @selection-change="selects" height="calc(100vh - 270px)">
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column :label="queryParams.type == 0 ? '提醒标题' : '模板名称'" align="left" prop="templateName" />
-      <el-table-column label="患者姓名" align="center" prop="patientName" width="160" />
-      <el-table-column label="住院号" align="center" prop="blh" width="160" />
-      <el-table-column label="随访状态" align="center" prop="state" width="140">
+      <el-table-column label="患者姓名" align="center" prop="patientName" width="100" />
+      <el-table-column label="住院号" align="center" prop="blh" width="120" />
+      <el-table-column :label="queryParams.type == 0 ? '提醒状态' : '随访状态'" align="center" prop="state" width="100">
         <template slot-scope="scope">
           <div v-if="queryParams.type == 0">
-            <el-tag type="success">已推送</el-tag>
+            <el-tag type="danger" v-if="scope.row.state == 0">待查看</el-tag>
+            <el-tag type="success" v-if="scope.row.state == 1">已阅</el-tag>
           </div>
           <div v-else>
             <el-tag type="danger" v-if="scope.row.state == 0">待回访</el-tag>
@@ -34,15 +35,15 @@
           </div>
         </template>
       </el-table-column>
-      <el-table-column label="随访时间" align="center" prop="returnTime" width="160" />
-      <el-table-column label="创建人" align="center" prop="createBy" width="160" />
+      <el-table-column :label="queryParams.type == 0 ? '查看时间' : '随访时间'" align="center" prop="returnTime" width="160" />
+      <el-table-column label="创建人" align="center" prop="createBy" width="120" />
       <el-table-column label="创建时间" align="center" prop="createTime" width="160" />
       <el-table-column label="所属科室" align="center" prop="deptName" width="160" />
       <el-table-column label="操作" align="center" width="180">
         <template slot-scope="scope">
           <el-button size="mini" type="text" icon="el-icon-view" @click="op('detail', scope.row)" v-hasPermi="['work:record:list', 'work:up:list']">查看</el-button>
-          <el-button size="mini" type="text" icon="el-icon-edit" @click="op('edit', scope.row)" v-hasPermi="['work:record:edit', 'work:up:edit']">编辑</el-button>
-          <el-button size="mini" type="text" icon="el-icon-delete" @click="del(scope.row)" v-hasPermi="['work:record:remove', 'work:up:remove']">删除</el-button>
+          <el-button size="mini" type="text" icon="el-icon-edit" @click="op('edit', scope.row)" v-hasPermi="['work:record:edit', 'work:up:edit']" v-if="scope.row.state != 1">编辑</el-button>
+          <el-button size="mini" type="text" icon="el-icon-delete" @click="del(scope.row)" v-hasPermi="['work:record:remove', 'work:up:remove']" v-if="scope.row.state != 1">删除</el-button>
         </template>
       </el-table-column>
       <template slot="empty">

+ 35 - 2
app/components/images/images.vue

@@ -7,7 +7,17 @@
 				<text class="icon del" @click.stop="del(item)" v-if="!read">&#xe8b6;</text>
 			</view>
 		</view>
-		<audio :src="ip + value[0]" v-if="type === '录音' && read" name="录音文件" controls></audio>
+		<!-- 	<audio :src="ip + value[0]" v-if="type === '录音' && read" name="录音文件" controls @click="playVoice()"></audio> -->
+		<view v-if="type === '录音' && read">
+			<button @click="playStop()" :disabled="!play">
+				<text class="icon">&#xe611;</text>
+				<text>停止</text>
+			</button>
+			<button @click="playVoice()" :disabled="play">
+				<text class="icon">&#xe628;</text>
+				<text>播放({{ duration }})</text>
+			</button>
+		</view>
 		<view class="uploads" v-if="type != '录音' && value.length < 3 && !read" @click.stop="chooseImage()">
 			<view class="bw" v-if="type == '图片'">
 				<view class="icon">&#xe696;</view>
@@ -63,13 +73,23 @@ export default {
 	},
 	data() {
 		return {
+			play: false,
 			stop: false,
 			ip: this.http.ip,
-			voicePath: ''
+			voicePath: '',
+			duration: ''
 		};
 	},
 	mounted() {
 		if (this.type === '录音') {
+			if (this.value.length > 0) {
+				this.voicePath = this.ip + this.value[0];
+				innerAudioContext.src = this.voicePath;
+				innerAudioContext.onCanplay(() => {
+					this.duration = innerAudioContext.duration + '秒';
+					console.log('音频时长:', innerAudioContext.duration, '秒');
+				});
+			}
 			recorderManager.onStop((res) => {
 				this.voicePath = res.tempFilePath;
 				uni.uploadFile({
@@ -188,9 +208,22 @@ export default {
 		},
 		playVoice() {
 			console.log('播放录音');
+			this.play = true;
 			if (this.voicePath) {
 				innerAudioContext.src = this.voicePath;
 				innerAudioContext.play();
+				innerAudioContext.onEnded((res) => {
+					console.log('播放完成');
+					this.play = false;
+				});
+			}
+		},
+		playStop() {
+			console.log('停止播放录音');
+			this.play = false;
+			if (this.voicePath) {
+				innerAudioContext.src = this.voicePath;
+				innerAudioContext.stop();
 			}
 		},
 		preview(item) {

+ 10 - 4
app/pages/user/index.vue

@@ -137,10 +137,16 @@ export default {
 				content: '确定切换就诊人',
 				success: (res) => {
 					if (res.confirm) {
-						this.http.request({
-							url: '/app/user/bind/change/' + e.id,
-							success: (res) => {
-								this.getUserInfo();
+						//通知模板订阅消息
+						uni.requestSubscribeMessage({
+							tmplIds: ['1Jvx8F22na-tG2Q6HFX_3vRtbiv7zZko6NwX8ICIFXc','S6JARkInVBjID8QMpgZdSHNyxeMDZQq7lur8YrNK0oY'],
+							complete: (c) => {
+								this.http.request({
+									url: '/app/user/bind/change/' + e.id,
+									success: (res) => {
+										this.getUserInfo();
+									}
+								});
 							}
 						});
 					}

+ 3 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/mapper/UserMapper.java

@@ -18,9 +18,12 @@ public interface UserMapper extends BaseMapper<User> {
 
     User selectByOpenId(@Param("openId") String openId);
 
+
     Map<String, Object> statistics(SysUser sysUser);
 
     User selectUser(User user);
 
+    User selectUserByPatientId( @Param("patientId") Long patientId);
+
     List<ExpertVoList>selectExpert();
 }

+ 7 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/IUserService.java

@@ -49,6 +49,13 @@ public interface IUserService extends IService<User> {
     AjaxResult info();
 
     /**
+     * 根据绑定的患者id查询用户
+     * @param patientId
+     * @return
+     */
+    User selectUserByPatientId(Long patientId);
+
+    /**
      * 启用或停用账户
      *
      * @param user

+ 25 - 17
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/FollowRecordServiceImpl.java

@@ -7,19 +7,24 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.annotation.DataScope;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.web.work.api.util.AppUtil;
 import com.ruoyi.web.work.domain.FollowRecord;
+import com.ruoyi.web.work.domain.User;
 import com.ruoyi.web.work.domain.dto.FollowRecordDto;
 import com.ruoyi.web.work.domain.dto.VisitDto;
 import com.ruoyi.web.work.domain.vo.FollowRecordVoList;
 import com.ruoyi.web.work.domain.vo.VisitVoList;
 import com.ruoyi.web.work.mapper.FollowRecordMapper;
+import com.ruoyi.web.work.mapper.UserMapper;
 import com.ruoyi.web.work.service.IFollowRecordService;
 import com.ruoyi.web.work.service.IUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Service;
 
+import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -39,7 +44,7 @@ public class FollowRecordServiceImpl extends ServiceImpl<FollowRecordMapper, Fol
     @Autowired
     private Environment env;
 
-    @DataScope(deptAlias = "k",userAlias = "k")
+    @DataScope(deptAlias = "k", userAlias = "k")
     @Override
     public List<FollowRecord> selectList(FollowRecord followRecord) {
         return followRecordMapper.selectList(followRecord);
@@ -97,6 +102,9 @@ public class FollowRecordServiceImpl extends ServiceImpl<FollowRecordMapper, Fol
         if (!saveBatch(followRecordList)) {
             throw new ServiceException("新增回访记录失败");
         }
+        followRecordList.forEach(e -> {
+            sendMessage(e);
+        });
         return AjaxResult.success();
     }
 
@@ -107,6 +115,7 @@ public class FollowRecordServiceImpl extends ServiceImpl<FollowRecordMapper, Fol
             return AjaxResult.error("复诊提醒不存在或非法操作");
         }
         followRecord.setState(1);
+        followRecord.setReturnTime(new Date());
         updateById(followRecord);
         return AjaxResult.success();
     }
@@ -117,26 +126,25 @@ public class FollowRecordServiceImpl extends ServiceImpl<FollowRecordMapper, Fol
         JSONObject body = new JSONObject();
         body.set("appid", env.getProperty("wx.appid"));
         JSONObject content = new JSONObject();
-        //复诊提醒
+        User user = userService.selectUserByPatientId(record.getPatientId());
+        if (user == null) {
+            return;
+        }
+        body.set("touser", user.getOpenId());
+        body.set("page", "pages/user/index?patientId="+record.getPatientId());
+        //复查提醒
         if (record.getType() == 0) {
-           /* User user = userService.getById(record.getPatientId);
-            body.set("touser", user.getOpenId());
-            body.set("template_id", "PtdKbqfzmpvGsJPx_YekDX4-cljbhOXcvoUB3XJaVLg");
-            body.set("page", "pages/user/money/index");
-            content.set("amount3", new JSONObject().set("value", pay.getMoney() + "元"));//提现金额
-            content.set("character_string4", new JSONObject().set("value", pay.getNums()));//交易单号
-            content.set("time2", new JSONObject().set("value", DateUtils.getTime())); //提现时间*/
+            body.set("template_id", "S6JARkInVBjID8QMpgZdSHNyxeMDZQq7lur8YrNK0oY");
+            content.set("thing1", new JSONObject().set("value", record.getTemplateName()));//复查提醒名称
+            content.set("thing3", new JSONObject().set("value", "岑溪人民医院"));//复查机构
+            content.set("thing6", new JSONObject().set("value", StringUtils.truncateTo12Chars(record.getOp())));//备注
         }
         //随访提醒
         if (record.getType() == 1) {
-           /* User user = userService.getById(pay.getUserId());
-            body.set("touser", user.getOpenId());
-            body.set("template_id", "NIqSQq0j765o9Iz9gMiSelnuxMgPIPeCnk3lvEnWJlo");
-            body.set("page", "pages/user/money/index");
-            content.set("amount3", new JSONObject().set("value", pay.getMoney() + "元"));//提现金额
-            content.set("character_string4", new JSONObject().set("value", pay.getNums()));//交易单号
-            content.set("thing5", new JSONObject().set("value", pay.getMsg())); //失败原因
-            content.set("time2", new JSONObject().set("value", DateUtils.getTime())); //提现时间*/
+            body.set("template_id", "1Jvx8F22na-tG2Q6HFX_3vRtbiv7zZko6NwX8ICIFXc");
+            content.set("thing11", new JSONObject().set("value", record.getTemplateName()));//随访名称
+            content.set("thing2", new JSONObject().set("value", "岑溪人民医院"));//随访机构
+            content.set("phrase3", new JSONObject().set("value", record.getPatientName()));//就诊人
         }
         body.set("data", content);
         String result = HttpUtil.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + jsonObject.getStr("access_token"), body.toString());

+ 4 - 0
ruoyi-admin/src/main/resources/mapper/work/UserMapper.xml

@@ -40,4 +40,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT user_id,avatar,nick_name FROM sys_user WHERE shows=1 AND status='0' ORDER BY views ASC LIMIT 10
     </select>
 
+    <select id="selectUserByPatientId" resultType="com.ruoyi.web.work.domain.User">
+        SELECT * FROM tb_user WHERE patient_id=#{patientId}
+    </select>
+
 </mapper>

+ 16 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java

@@ -519,6 +519,22 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
     }
 
     /**
+     * 截取字符串最多12个字符
+     *
+     * @param input 原始字符串
+     * @return 截取后的字符串,如果原始字符串长度小于等于12,则返回原始字符串
+     */
+    public static String truncateTo12Chars(String input) {
+        if (input == null) {
+            return "";
+        }
+        if (input.length() > 17) {
+            return input.substring(0, 17) + "...";
+        }
+        return input;
+    }
+
+    /**
      * 获取文本中的img标签的src属性值
      *
      * @param htmlStr