소스 검색

优化sql

lighter 3 년 전
부모
커밋
31c9459261

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>2</version>
+    <version>1</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
     <properties>

+ 1 - 2
src/main/java/thyyxxk/webserver/controller/casefrontsheet/CaseFrontSheetController.java

@@ -2,7 +2,6 @@ package thyyxxk.webserver.controller.casefrontsheet;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-import thyyxxk.webserver.config.auth.PassToken;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.casefrontsheet.*;
 import thyyxxk.webserver.entity.dictionary.PureCodeName;
@@ -81,7 +80,7 @@ public class CaseFrontSheetController {
     @PostMapping("/unArchiveBa")
     public ResultVo<String> unArchiveBa(@RequestBody OpCaseFrontsheet param) {
         param.setStaffId(TokenUtil.getTokenUserId());
-        return service.unArchiveBa(param);
+        return service.unArchiveSheet(param);
     }
 
     @PostMapping("/printVerify")

+ 15 - 403
src/main/java/thyyxxk/webserver/dao/his/casefrontsheet/BasSelectOverviewDao.java

@@ -49,56 +49,6 @@ public interface BasSelectOverviewDao extends BaseMapper<CaseFrontsheetSurgery>
             "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
             "lateDays=datediff(day, a.dis_date, b.sign_date), " +
             "disDate=convert(varchar(10), c.start_time, 21) " +
-            "from zy_actpatient a with(nolock), batj_ba2 b with(nolock), yz_act_order c with(nolock) " +
-            "where " +
-            "a.inpatient_no=#{bah} and " +
-            "a.inpatient_no=b.zyh and " +
-            "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "isnull(a.file_status, 0)=#{fileStatus} " +
-            "union " +
-            "select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
-            "bedNo=rtrim(a.bed_no), " +
-            "bah=rtrim(a.inpatient_no), " +
-            "times=rtrim(a.admiss_times), " +
-            "name=rtrim(a.name), " +
-            "a.sex, " +
-            "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dis_dept), " +
-            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=b.zyys), " +
-            "b.late_flag, " +
-            "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
-            "lateDays=datediff(day, a.dis_date, b.sign_date), " +
-            "disDate=convert(varchar(10), c.start_time, 21) " +
-            "from zy_actpatient a with(nolock), batj_ba2 b with(nolock), yz_inact_order c with(nolock) " +
-            "where " +
-            "a.inpatient_no=#{bah} and " +
-            "a.inpatient_no=b.zyh and " +
-            "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "isnull(a.file_status, 0)=#{fileStatus} " +
-            "union " +
-            "select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
-            "bedNo=rtrim(a.bed_no), " +
-            "bah=rtrim(a.inpatient_no), " +
-            "times=rtrim(a.admiss_times), " +
-            "name=rtrim(a.name), " +
-            "a.sex, " +
-            "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dis_dept), " +
-            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=b.zyys), " +
-            "b.late_flag, " +
-            "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
-            "lateDays=datediff(day, a.dis_date, b.sign_date), " +
-            "disDate=convert(varchar(10), c.start_time, 21) " +
             "from zy_inactpatient a with(nolock), batj_ba2 b with(nolock), yz_act_order c with(nolock) " +
             "where " +
             "a.inpatient_no=#{bah} and " +
@@ -150,56 +100,6 @@ public interface BasSelectOverviewDao extends BaseMapper<CaseFrontsheetSurgery>
             "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
             "lateDays=datediff(day, a.dis_date, b.sign_date), " +
             "disDate=convert(varchar(10), c.start_time, 21) " +
-            "from zy_actpatient a with(nolock), batj_ba2 b with(nolock), yz_act_order c with(nolock) " +
-            "where " +
-            "a.inpatient_no=#{bah} and " +
-            "a.inpatient_no=b.zyh and " +
-            "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "isnull(a.file_status, 0)>=1 " +
-            "union " +
-            "select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
-            "bedNo=rtrim(a.bed_no), " +
-            "bah=rtrim(a.inpatient_no), " +
-            "times=rtrim(a.admiss_times), " +
-            "name=rtrim(a.name), " +
-            "a.sex, " +
-            "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dis_dept), " +
-            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=b.zyys), " +
-            "b.late_flag, " +
-            "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
-            "lateDays=datediff(day, a.dis_date, b.sign_date), " +
-            "disDate=convert(varchar(10), c.start_time, 21) " +
-            "from zy_actpatient a with(nolock), batj_ba2 b with(nolock), yz_inact_order c with(nolock) " +
-            "where " +
-            "a.inpatient_no=#{bah} and " +
-            "a.inpatient_no=b.zyh and " +
-            "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "isnull(a.file_status, 0)>=1 " +
-            "union " +
-            "select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
-            "bedNo=rtrim(a.bed_no), " +
-            "bah=rtrim(a.inpatient_no), " +
-            "times=rtrim(a.admiss_times), " +
-            "name=rtrim(a.name), " +
-            "a.sex, " +
-            "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dis_dept), " +
-            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=b.zyys), " +
-            "b.late_flag, " +
-            "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
-            "lateDays=datediff(day, a.dis_date, b.sign_date), " +
-            "disDate=convert(varchar(10), c.start_time, 21) " +
             "from zy_inactpatient a with(nolock), batj_ba2 b with(nolock), yz_act_order c with(nolock) " +
             "where " +
             "a.inpatient_no=#{bah} and " +
@@ -226,102 +126,15 @@ public interface BasSelectOverviewDao extends BaseMapper<CaseFrontsheetSurgery>
             "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
             "lateDays=datediff(day, a.dis_date, b.sign_date), " +
             "disDate=convert(varchar(10), a.dis_date, 21) " +
-            "from zy_inactpatient a with(nolock), batj_ba2 b with(nolock), yz_inact_order c with(nolock) " +
-            "where " +
-            "a.inpatient_no not like 'S%' and " +
-            "a.inpatient_no not like 'JT%' and " +
-            "a.inpatient_no=b.zyh and " +
-            "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "c.exec_unit = #{ward} and " +
-            "isnull(a.file_status, 0)=#{fileStatus} and " +
-            "charindex('$',a.inpatient_no)=0 " +
-            "union " +
-            "select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
-            "bedNo=rtrim(a.bed_no), " +
-            "bah=rtrim(a.inpatient_no), " +
-            "times=rtrim(a.admiss_times), " +
-            "name=rtrim(a.name), " +
-            "a.sex, " +
-            "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dis_dept), " +
-            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=b.zyys), " +
-            "b.late_flag, " +
-            "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
-            "lateDays=datediff(day, a.dis_date, b.sign_date), " +
-            "disDate=convert(varchar(10), c.start_time, 21) " +
-            "from zy_actpatient a with(nolock), batj_ba2 b with(nolock), yz_act_order c with(nolock) " +
-            "where " +
-            "a.inpatient_no not like 'S%' and " +
-            "a.inpatient_no not like 'JT%' and " +
-            "a.inpatient_no=b.zyh and " +
-            "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "c.exec_unit = #{ward} and " +
-            "isnull(a.file_status, 0)=#{fileStatus} and " +
-            "charindex('$',a.inpatient_no)=0 " +
-            "union " +
-            "select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
-            "bedNo=rtrim(a.bed_no), " +
-            "bah=rtrim(a.inpatient_no), " +
-            "times=rtrim(a.admiss_times), " +
-            "name=rtrim(a.name), " +
-            "a.sex, " +
-            "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dis_dept), " +
-            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=b.zyys), " +
-            "b.late_flag, " +
-            "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
-            "lateDays=datediff(day, a.dis_date, b.sign_date), " +
-            "disDate=convert(varchar(10), c.start_time, 21) " +
-            "from zy_actpatient a with(nolock), batj_ba2 b with(nolock), yz_inact_order c with(nolock) " +
+            "from zy_inactpatient a with(nolock), batj_ba2 b with(nolock) " +
             "where " +
             "a.inpatient_no not like 'S%' and " +
             "a.inpatient_no not like 'JT%' and " +
             "a.inpatient_no=b.zyh and " +
             "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "c.exec_unit = #{ward} and " +
-            "isnull(a.file_status, 0)=#{fileStatus} and " +
-            "charindex('$',a.inpatient_no)=0 " +
-            "union " +
-            "select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
-            "bedNo=rtrim(a.bed_no), " +
-            "bah=rtrim(a.inpatient_no), " +
-            "times=rtrim(a.admiss_times), " +
-            "name=rtrim(a.name), " +
-            "a.sex, " +
-            "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dis_dept), " +
-            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=b.zyys), " +
-            "b.late_flag, " +
-            "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
-            "lateDays=datediff(day, a.dis_date, b.sign_date), " +
-            "disDate=convert(varchar(10), c.start_time, 21) " +
-            "from zy_inactpatient a with(nolock), batj_ba2 b with(nolock), yz_act_order c with(nolock) " +
-            "where " +
-            "a.inpatient_no not like 'S%' and " +
-            "a.inpatient_no not like 'JT%' and " +
-            "a.inpatient_no=b.zyh and " +
-            "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "c.exec_unit = #{ward} and " +
+            "a.dis_date>=#{start} and " +
+            "a.dis_date<=#{end} and " +
+            "a.zk_ward = #{ward} and " +
             "isnull(a.file_status, 0)=#{fileStatus} and " +
             "charindex('$',a.inpatient_no)=0 ")
     List<SheetOverview> selectPatientsForBasByWard(GetOutSheet param);
@@ -339,102 +152,15 @@ public interface BasSelectOverviewDao extends BaseMapper<CaseFrontsheetSurgery>
             "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
             "lateDays=datediff(day, a.dis_date, b.sign_date), " +
             "disDate=convert(varchar(10), a.dis_date, 21) " +
-            "from zy_inactpatient a with(nolock), batj_ba2 b with(nolock), yz_inact_order c with(nolock) " +
-            "where " +
-            "a.inpatient_no not like 'S%' and " +
-            "a.inpatient_no not like 'JT%' and " +
-            "a.inpatient_no=b.zyh and " +
-            "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "c.exec_unit = #{ward} and " +
-            "isnull(a.file_status, 0)>=1 and " +
-            "charindex('$',a.inpatient_no)=0 " +
-            "union " +
-            "select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
-            "bedNo=rtrim(a.bed_no), " +
-            "bah=rtrim(a.inpatient_no), " +
-            "times=rtrim(a.admiss_times), " +
-            "name=rtrim(a.name), " +
-            "a.sex, " +
-            "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dis_dept), " +
-            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=b.zyys), " +
-            "b.late_flag, " +
-            "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
-            "lateDays=datediff(day, a.dis_date, b.sign_date), " +
-            "disDate=convert(varchar(10), c.start_time, 21) " +
-            "from zy_actpatient a with(nolock), batj_ba2 b with(nolock), yz_act_order c with(nolock) " +
-            "where " +
-            "a.inpatient_no not like 'S%' and " +
-            "a.inpatient_no not like 'JT%' and " +
-            "a.inpatient_no=b.zyh and " +
-            "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "c.exec_unit = #{ward} and " +
-            "isnull(a.file_status, 0)>=1 and " +
-            "charindex('$',a.inpatient_no)=0 " +
-            "union " +
-            "select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
-            "bedNo=rtrim(a.bed_no), " +
-            "bah=rtrim(a.inpatient_no), " +
-            "times=rtrim(a.admiss_times), " +
-            "name=rtrim(a.name), " +
-            "a.sex, " +
-            "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dis_dept), " +
-            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=b.zyys), " +
-            "b.late_flag, " +
-            "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
-            "lateDays=datediff(day, a.dis_date, b.sign_date), " +
-            "disDate=convert(varchar(10), c.start_time, 21) " +
-            "from zy_actpatient a with(nolock), batj_ba2 b with(nolock), yz_inact_order c with(nolock) " +
-            "where " +
-            "a.inpatient_no not like 'S%' and " +
-            "a.inpatient_no not like 'JT%' and " +
-            "a.inpatient_no=b.zyh and " +
-            "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "c.exec_unit = #{ward} and " +
-            "isnull(a.file_status, 0)>=1 and " +
-            "charindex('$',a.inpatient_no)=0 " +
-            "union " +
-            "select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
-            "bedNo=rtrim(a.bed_no), " +
-            "bah=rtrim(a.inpatient_no), " +
-            "times=rtrim(a.admiss_times), " +
-            "name=rtrim(a.name), " +
-            "a.sex, " +
-            "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dis_dept), " +
-            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=b.zyys), " +
-            "b.late_flag, " +
-            "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
-            "lateDays=datediff(day, a.dis_date, b.sign_date), " +
-            "disDate=convert(varchar(10), c.start_time, 21) " +
-            "from zy_inactpatient a with(nolock), batj_ba2 b with(nolock), yz_act_order c with(nolock) " +
+            "from zy_inactpatient a with(nolock), batj_ba2 b with(nolock) " +
             "where " +
             "a.inpatient_no not like 'S%' and " +
             "a.inpatient_no not like 'JT%' and " +
             "a.inpatient_no=b.zyh and " +
             "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "c.exec_unit = #{ward} and " +
+            "a.dis_date>=#{start} and " +
+            "a.dis_date<=#{end} and " +
+            "a.zk_ward = #{ward} and " +
             "isnull(a.file_status, 0)>=1 and " +
             "charindex('$',a.inpatient_no)=0 ")
     List<SheetOverview> selectPatientsForBasByWard2(GetOutSheet param);
@@ -452,103 +178,19 @@ public interface BasSelectOverviewDao extends BaseMapper<CaseFrontsheetSurgery>
             "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
             "lateDays=datediff(day, a.dis_date, b.sign_date), " +
             "disDate=convert(varchar(10), a.dis_date, 21) " +
-            "from zy_inactpatient a with(nolock), batj_ba2 b with(nolock), yz_inact_order c with(nolock) " +
-            "where " +
-            "a.inpatient_no not like 'S%' and " +
-            "a.inpatient_no not like 'JT%' and " +
-            "a.inpatient_no=b.zyh and " +
-            "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "isnull(a.file_status, 0)=#{fileStatus} and " +
-            "charindex('$',a.inpatient_no)=0 " +
-            "union " +
-            "select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
-            "bedNo=rtrim(a.bed_no), " +
-            "bah=rtrim(a.inpatient_no), " +
-            "times=rtrim(a.admiss_times), " +
-            "name=rtrim(a.name), " +
-            "a.sex, " +
-            "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dis_dept), " +
-            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=b.zyys), " +
-            "b.late_flag, " +
-            "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
-            "lateDays=datediff(day, a.dis_date, b.sign_date), " +
-            "disDate=convert(varchar(10), c.start_time, 21) " +
-            "from zy_inactpatient a with(nolock), batj_ba2 b with(nolock), yz_act_order c with(nolock) " +
+            "from zy_inactpatient a with(nolock), batj_ba2 b with(nolock) " +
             "where " +
             "a.inpatient_no not like 'S%' and " +
             "a.inpatient_no not like 'JT%' and " +
             "a.inpatient_no=b.zyh and " +
             "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
+            "a.dis_date>=#{start} and " +
+            "a.dis_date<=#{end} and " +
             "isnull(a.file_status, 0)=#{fileStatus} and " +
             "charindex('$',a.inpatient_no)=0 ")
     List<SheetOverview> selectPatientsForBasByFileStatus(GetOutSheet param);
 
     @Select("select " +
-            " signDate=(convert(varchar(10), b.sign_date, 21)), " +
-            "bedNo=rtrim(a.bed_no), " +
-            "bah=rtrim(a.inpatient_no), " +
-            "times=rtrim(a.admiss_times), " +
-            "name=rtrim(a.name), " +
-            "a.sex, " +
-            "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dis_dept), " +
-            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=b.zyys), " +
-            "b.late_flag, " +
-            "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
-            "lateDays=datediff(day, a.dis_date, b.sign_date), " +
-            "disDate=convert(varchar(10), a.dis_date, 21) " +
-            "from zy_inactpatient a with(nolock), batj_ba2 b with(nolock), yz_inact_order c with(nolock) " +
-            "where " +
-            "a.inpatient_no not like 'S%' and " +
-            "a.inpatient_no not like 'JT%' and " +
-            "a.inpatient_no=b.zyh and " +
-            "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "isnull(a.file_status, 0)>=1 and " +
-            "charindex('$',a.inpatient_no)=0 " +
-            "union " +
-            "select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
-            "bedNo=rtrim(a.bed_no), " +
-            "bah=rtrim(a.inpatient_no), " +
-            "times=rtrim(a.admiss_times), " +
-            "name=rtrim(a.name), " +
-            "a.sex, " +
-            "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dis_dept), " +
-            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=b.zyys), " +
-            "b.late_flag, " +
-            "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
-            "lateDays=datediff(day, a.dis_date, b.sign_date), " +
-            "disDate=convert(varchar(10), c.start_time, 21) " +
-            "from zy_actpatient a with(nolock), batj_ba2 b with(nolock), yz_act_order c with(nolock) " +
-            "where " +
-            "a.inpatient_no not like 'S%' and " +
-            "a.inpatient_no not like 'JT%' and " +
-            "a.inpatient_no=b.zyh and " +
-            "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "isnull(a.file_status, 0)>=1 and " +
-            "charindex('$',a.inpatient_no)=0 " +
-            "union " +
-            "select " +
             "signDate=(convert(varchar(10), b.sign_date, 21)), " +
             "bedNo=rtrim(a.bed_no), " +
             "bah=rtrim(a.inpatient_no), " +
@@ -560,45 +202,15 @@ public interface BasSelectOverviewDao extends BaseMapper<CaseFrontsheetSurgery>
             "b.late_flag, " +
             "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
             "lateDays=datediff(day, a.dis_date, b.sign_date), " +
-            "disDate=convert(varchar(10), c.start_time, 21) " +
-            "from zy_actpatient a with(nolock), batj_ba2 b with(nolock), yz_inact_order c with(nolock) " +
-            "where " +
-            "a.inpatient_no not like 'S%' and " +
-            "a.inpatient_no not like 'JT%' and " +
-            "a.inpatient_no=b.zyh and " +
-            "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
-            "isnull(a.file_status, 0)>=1 and " +
-            "charindex('$',a.inpatient_no)=0 " +
-            "union " +
-            "select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
-            "bedNo=rtrim(a.bed_no), " +
-            "bah=rtrim(a.inpatient_no), " +
-            "times=rtrim(a.admiss_times), " +
-            "name=rtrim(a.name), " +
-            "a.sex, " +
-            "deptName=(select rtrim(name) from zd_unit_code with(nolock) where code=a.dis_dept), " +
-            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=b.zyys), " +
-            "b.late_flag, " +
-            "lateCount=(select count(*) from batj_ba2 with(nolock) where late_flag=1 and zyys=b.zyys), " +
-            "lateDays=datediff(day, a.dis_date, b.sign_date), " +
-            "disDate=convert(varchar(10), c.start_time, 21) " +
-            "from zy_inactpatient a with(nolock), batj_ba2 b with(nolock), yz_act_order c with(nolock) " +
+            "disDate=convert(varchar(10), a.dis_date, 21) " +
+            "from zy_inactpatient a with(nolock), batj_ba2 b with(nolock) " +
             "where " +
             "a.inpatient_no not like 'S%' and " +
             "a.inpatient_no not like 'JT%' and " +
             "a.inpatient_no=b.zyh and " +
             "a.admiss_times=b.zycs and " +
-            "a.inpatient_no=c.inpatient_no and " +
-            "a.admiss_times=c.admiss_times and " +
-            "c.start_time>=#{start} and " +
-            "c.start_time<=#{end} and " +
-            "c.order_code in ('06026','06053','06027', '05973') and " +
+            "a.dis_date>=#{start} and " +
+            "a.dis_date<=#{end} and " +
             "isnull(a.file_status, 0)>=1 and " +
             "charindex('$',a.inpatient_no)=0 ")
     List<SheetOverview> selectPatientsForBasByFileStatus2(GetOutSheet param);

+ 16 - 7
src/main/java/thyyxxk/webserver/service/casefrontsheet/CaseFrontSheetService.java

@@ -238,9 +238,8 @@ public class CaseFrontSheetService {
         if (dao.getDeathOrder(bah, times) > 0) {
             sheet.setZyDismissWay("4");
         }
-        Integer days = VerifyCaseFrontSheet.getInstance()
-                .betweenDays(sheet.getDismissDate(), sheet.getAdmissDate());
-        if (null != days && 0 == days) {
+        Integer days = DateUtil.daysBetween(sheet.getDismissDate(), sheet.getAdmissDate());
+        if (0 == days) {
             days = 1;
         }
         sheet.setAdmissDays(String.valueOf(days));
@@ -294,10 +293,12 @@ public class CaseFrontSheetService {
         final String bah = sheet.getBah();
         final int times = sheet.getAdmissTimes();
         dao.writeBaOpLog(param.getOpType(), param.getStaffId(), bah, times);
-        return param.getOpType() == 1 ? saveSheet(sheet, bah, times) : signSheet(sheet, bah, times);
+        return param.getOpType() == 1 ? saveSheet(sheet) : archiveSheet(sheet);
     }
 
-    private ResultVo<List<PureCodeName>> saveSheet(CaseFrontsheetMain sheet, String bah, int times) {
+    private ResultVo<List<PureCodeName>> saveSheet(CaseFrontsheetMain sheet) {
+        String bah = sheet.getBah();
+        int times = sheet.getAdmissTimes();
         dao.updateAPatientMi(sheet);
         dao.updateZyActPatient(bah, times, sheet.getAutopsy(), sheet.getDiagConform1(),
                 sheet.getDiagConform2(), sheet.getDiagConform3(), sheet.getDiagConform4(),
@@ -342,7 +343,9 @@ public class CaseFrontSheetService {
         return ResultVoUtil.success();
     }
 
-    private ResultVo<List<PureCodeName>> signSheet(CaseFrontsheetMain sheet, String bah, int times) {
+    private ResultVo<List<PureCodeName>> archiveSheet(CaseFrontsheetMain sheet) {
+        String bah = sheet.getBah();
+        int times = sheet.getAdmissTimes();
         if (userDao.getUserRoles(TokenUtil.getTokenUserId()).contains(7)) {
             if (isLateSubmit(sheet.getDismissDate()) > 8) {
                 sheet.setLateFlag(1);
@@ -384,7 +387,7 @@ public class CaseFrontSheetService {
     }
 
     @Transactional(rollbackFor = Exception.class)
-    public synchronized ResultVo<String> unArchiveBa(OpCaseFrontsheet param) {
+    public synchronized ResultVo<String> unArchiveSheet(OpCaseFrontsheet param) {
         CaseFrontsheetMain sheet = param.getSheet();
         if (sheet.getFileStatus() == 2) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "已打印的病案首页无法解除签收!");
@@ -470,6 +473,12 @@ public class CaseFrontSheetService {
         if (sheet.getFileStatus() == 2) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "已最终归档病案首页无法打印!");
         }
+        ResultVo<List<PureCodeName>> save = saveSheet(param.getSheet());
+        if (save.getCode() != ExceptionEnum.SUCCESS.getCode()) {
+            Map<String, List<PureCodeName>> map = new HashMap<>();
+            map.put("force", save.getData());
+            return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, "校验未通过。", map);
+        }
         List<PureCodeName> force = VerifyCaseFrontSheet.getInstance().printVerify(sheet);
         List<PureCodeName> advice = new ArrayList<>();
         JSONObject powersi = qualityControl(sheet);