Przeglądaj źródła

标签关联条目

zhoutg 5 lat temu
rodzic
commit
50ca36ca66

+ 21 - 1
doc/002.20200426第二版/qc_init.sql

@@ -37,7 +37,6 @@ CREATE TABLE `qc_question_info` (
   `add_line` tinyint(4) DEFAULT '0' COMMENT '换行(0:不换行,1:换行)',
   `bold` tinyint(4) DEFAULT '0' COMMENT '换行(0:不换行,1:加粗)',
   `position` tinyint(4) DEFAULT '0' COMMENT '显示位置(1:靠右显示)',
-  `cases_entry_ids` varchar(1000) NOT NULL DEFAULT '' COMMENT '质控条目id列表',
   `remark` varchar(300) DEFAULT NULL COMMENT '备注',
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='标签基础表';
@@ -62,6 +61,27 @@ CREATE TABLE `qc_question_mapping` (
   KEY `son_question` (`son_question`)
 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='标签映射表';
 
+
+-- ----------------------------
+-- Table structure for qc_question_entry
+-- ----------------------------
+DROP TABLE IF EXISTS `qc_question_entry`;
+CREATE TABLE `qc_question_entry` (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `is_deleted` char(1) NOT NULL DEFAULT 'N' COMMENT '是否删除,N:未删除,Y:删除',
+  `gmt_create` datetime NOT NULL DEFAULT '1970-01-01 12:00:00' COMMENT '记录创建时间',
+  `gmt_modified` datetime NOT NULL DEFAULT '1970-01-01 12:00:00' COMMENT '记录修改时间,如果时间是1970年则表示纪录未修改',
+  `creator` varchar(20) NOT NULL DEFAULT '0' COMMENT '创建人,0表示无创建人值',
+  `modifier` varchar(20) NOT NULL DEFAULT '0' COMMENT '修改人,如果为0则表示纪录未修改',
+  `question_id` bigint(20) DEFAULT NULL COMMENT 'question_id',
+  `cases_entry_id` bigint(20) DEFAULT NULL COMMENT 'cases_entry_id',
+  `order_no` int(11) NOT NULL DEFAULT '0' COMMENT '排序号',
+  `remark` varchar(300) DEFAULT NULL COMMENT '备注',
+  PRIMARY KEY (`id`),
+  KEY `question_id` (`question_id`),
+  KEY `cases_entry_id` (`cases_entry_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='标签条目映射表';
+
 -- ----------------------------
 -- Table structure for qc_module_info
 -- ----------------------------

+ 4 - 14
src/main/resources/mapper/QcQuestionInfoMapper.xml

@@ -45,23 +45,13 @@
     </select>
 
     <select id="getByCaseEntryIds" resultType="com.diagbot.dto.QuestionEntryDTO">
-        select * from (
-        select a.id,substring_index(substring_index(a.cases_entry_ids,',',b.help_topic_id+1),',',-1) cases_entry_id
-        from
-        qc_question_info a
-        join
-        <![CDATA[
-            mysql.help_topic b
-            on b.help_topic_id < (length(a.cases_entry_ids) - length(replace(a.cases_entry_ids,',',''))+1)
-        ]]>
-        where a.is_deleted = 'N'
+        SELECT q2.question_id id, q2.cases_entry_id FROM qc_question_info q1, qc_question_entry q2
+        where q1.is_deleted = 'N' and q2.is_deleted = 'N' and q1.id = q2.question_id
         <if test="hospitalId != null">
-            AND a.hospital_id = #{hospitalId}
+            AND q1.hospital_id = #{hospitalId}
         </if>
-        order by a.ID) t
-        where t.cases_entry_id != ''
         <if test="casesEntryIds != null and casesEntryIds.size > 0">
-            and t.cases_entry_id in
+            and q2.cases_entry_id in
             <foreach  collection="casesEntryIds" item="item" open="("  separator=","  close=")">
                 #{item}
             </foreach>