gugu 3 týždňov pred
rodič
commit
d8dc703962

+ 10 - 0
src/main/java/org/example/controller/TerminalController.java

@@ -78,6 +78,16 @@ public class TerminalController {
     public Map<String, Object> addTerminal(@RequestBody Terminal terminal) {
         Map<String, Object> result = new HashMap<>();
         try {
+            // 检查IP地址是否重复
+            if (terminal.getIpAddress() != null && !terminal.getIpAddress().trim().isEmpty()) {
+                Terminal existingTerminal = terminalService.findByIpAddress(terminal.getIpAddress());
+                if (existingTerminal != null) {
+                    result.put("success", false);
+                    result.put("message", "IP地址存在重复");
+                    return result;
+                }
+            }
+            
             terminalService.addTerminal(terminal);
             result.put("success", true);
             result.put("message", "设备添加成功");

+ 11 - 0
src/main/java/org/example/entity/Terminal.java

@@ -1,5 +1,7 @@
 package org.example.entity;
 
+import java.util.Date;
+
 public class Terminal {
     private Long id;              // 主键ID
     private String terminalType;  // 设备类型
@@ -12,6 +14,7 @@ public class Terminal {
     private String gatewayAddress;// 默认网关
     private String macAddress;    // Mac地址
     private Boolean isOnline;     // 在线状态
+    private Date createTime;      // 创建时间
 
     // Constructors
     public Terminal() {}
@@ -120,6 +123,14 @@ public class Terminal {
         this.isOnline = isOnline;
     }
 
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
     @Override
     public String toString() {
         return "Terminal{" +

+ 2 - 28
src/main/java/org/example/mapper/HospitalBedMapper.java

@@ -1,6 +1,7 @@
 package org.example.mapper;
 
-import org.apache.ibatis.annotations.*;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 import org.example.entity.HospitalBed;
 
 import java.util.List;
@@ -12,7 +13,6 @@ public interface HospitalBedMapper {
      * 查询所有床位
      * @return 床位列表
      */
-    @Select("SELECT code, out_code AS outBed, name, bed_type AS type, belong_dept AS belongDept, belong_ward AS belongWard, belong_room AS belongRoom, doctor, nurse, used, sort, enabled, remark FROM tb_hospital_bed")
     List<HospitalBed> findAll();
     
     /**
@@ -20,7 +20,6 @@ public interface HospitalBedMapper {
      * @param code 床位代码
      * @return 床位信息
      */
-    @Select("SELECT code, out_code AS outBed, name, bed_type AS type, belong_dept AS belongDept, belong_ward AS belongWard, belong_room AS belongRoom, doctor, nurse, used, sort, enabled, remark FROM tb_hospital_bed WHERE code = #{code} LIMIT 1")
     HospitalBed findByCode(String code);
     
     /**
@@ -28,7 +27,6 @@ public interface HospitalBedMapper {
      * @param name 床位名称
      * @return 床位列表
      */
-    @Select("SELECT code, out_code AS outBed, name, bed_type AS type, belong_dept AS belongDept, belong_ward AS belongWard, belong_room AS belongRoom, doctor, nurse, used, sort, enabled, remark FROM tb_hospital_bed WHERE name LIKE CONCAT('%', #{name}, '%')")
     List<HospitalBed> findByNameContaining(String name);
     
     /**
@@ -36,7 +34,6 @@ public interface HospitalBedMapper {
      * @param belongDept 所属科室
      * @return 床位列表
      */
-    @Select("SELECT code, out_code AS outBed, name, bed_type AS type, belong_dept AS belongDept, belong_ward AS belongWard, belong_room AS belongRoom, doctor, nurse, used, sort, enabled, remark FROM tb_hospital_bed WHERE belong_dept LIKE CONCAT('%', #{belongDept}, '%')")
     List<HospitalBed> findByBelongDeptContaining(String belongDept);
     
     /**
@@ -44,7 +41,6 @@ public interface HospitalBedMapper {
      * @param belongWard 所属病区
      * @return 床位列表
      */
-    @Select("SELECT code, out_code AS outBed, name, bed_type AS type, belong_dept AS belongDept, belong_ward AS belongWard, belong_room AS belongRoom, doctor, nurse, used, sort, enabled, remark FROM tb_hospital_bed WHERE belong_ward LIKE CONCAT('%', #{belongWard}, '%')")
     List<HospitalBed> findByBelongWardContaining(String belongWard);
     
     /**
@@ -52,7 +48,6 @@ public interface HospitalBedMapper {
      * @param enabled 是否启用
      * @return 床位列表
      */
-    @Select("SELECT code, out_code AS outBed, name, bed_type AS type, belong_dept AS belongDept, belong_ward AS belongWard, belong_room AS belongRoom, doctor, nurse, used, sort, enabled, remark FROM tb_hospital_bed WHERE enabled = #{enabled}")
     List<HospitalBed> findByEnabled(Boolean enabled);
     
     /**
@@ -61,44 +56,23 @@ public interface HospitalBedMapper {
      * @param excludeCode 要排除的代码(更新时使用)
      * @return 床位列表
      */
-    @Select("SELECT code, out_code AS outBed, name, bed_type AS type, belong_dept AS belongDept, belong_ward AS belongWard, belong_room AS belongRoom, doctor, nurse, used, sort, enabled, remark FROM tb_hospital_bed WHERE code = #{code} AND code != #{excludeCode}")
     List<HospitalBed> findByCodeExcluding(String code, String excludeCode);
     
     /**
      * 插入新床位
      * @param bed 床位信息
      */
-    @Insert("INSERT INTO tb_hospital_bed(code, out_code, name, bed_type, belong_dept, belong_ward, belong_room, doctor, nurse, used, sort, enabled, remark) " +
-            "VALUES(#{code}, #{outBed}, #{name}, #{type}, #{belongDept}, #{belongWard}, #{belongRoom}, #{doctor}, #{nurse}, #{used}, #{sort}, #{enabled}, #{remark})")
     void insert(HospitalBed bed);
     
     /**
      * 更新床位信息
      * @param bed 床位信息
      */
-    @Update({"<script>",
-            "UPDATE tb_hospital_bed",
-            "SET code = #{bed.code}",
-            "<if test='bed.outBed != null'>, out_code = #{bed.outBed}</if>",
-            "<if test='bed.name != null'>, name = #{bed.name}</if>",
-            "<if test='bed.type != null'>, bed_type = #{bed.type}</if>",
-            "<if test='bed.belongDept != null'>, belong_dept = #{bed.belongDept}</if>",
-            "<if test='bed.belongWard != null'>, belong_ward = #{bed.belongWard}</if>",
-            "<if test='bed.belongRoom != null'>, belong_room = #{bed.belongRoom}</if>",
-            "<if test='bed.doctor != null'>, doctor = #{bed.doctor}</if>",
-            "<if test='bed.nurse != null'>, nurse = #{bed.nurse}</if>",
-            "<if test='bed.used != null'>, used = #{bed.used}</if>",
-            "<if test='bed.sort != null'>, sort = #{bed.sort}</if>",
-            "<if test='bed.enabled != null'>, enabled = #{bed.enabled}</if>",
-            "<if test='bed.remark != null'>, remark = #{bed.remark}</if>",
-            "WHERE code = #{originCode}",
-            "</script>"})
     void update(@Param("bed") HospitalBed bed, @Param("originCode") String originCode);
     
     /**
      * 根据床位代码删除床位
      * @param code 床位代码
      */
-    @Delete("DELETE FROM tb_hospital_bed WHERE code = #{code}")
     void deleteByCode(String code);
 }

+ 1 - 8
src/main/java/org/example/mapper/HospitalDeptMapper.java

@@ -1,6 +1,6 @@
 package org.example.mapper;
 
-import org.apache.ibatis.annotations.*;
+import org.apache.ibatis.annotations.Mapper;
 import org.example.entity.HospitalDept;
 
 import java.util.List;
@@ -12,7 +12,6 @@ public interface HospitalDeptMapper {
      * 查询所有科室
      * @return 科室列表
      */
-    @Select("SELECT code, out_code AS outCode, name, address, telephone, introduction, enabled, remark FROM tb_hospital_dept")
     List<HospitalDept> findAll();
     
     /**
@@ -20,29 +19,23 @@ public interface HospitalDeptMapper {
      * @param code 科室代码
      * @return 科室信息
      */
-    @Select("SELECT code, out_code AS outCode, name, address, telephone, introduction, enabled, remark FROM tb_hospital_dept WHERE code = #{code}")
     HospitalDept findByCode(String code);
     
     /**
      * 插入新科室
      * @param dept 科室信息
      */
-    @Insert("INSERT INTO tb_hospital_dept(code, out_code, name, address, telephone, introduction, enabled, remark) " +
-            "VALUES(#{code}, #{outCode}, #{name}, #{address}, #{telephone}, #{introduction}, #{enabled}, #{remark})")
     void insert(HospitalDept dept);
     
     /**
      * 更新科室信息
      * @param dept 科室信息
      */
-    @Update("UPDATE tb_hospital_dept SET out_code=#{outCode}, name=#{name}, address=#{address}, telephone=#{telephone}, " +
-            "introduction=#{introduction}, enabled=#{enabled}, remark=#{remark} WHERE code=#{code}")
     void update(HospitalDept dept);
     
     /**
      * 根据科室代码删除科室
      * @param code 科室代码
      */
-    @Delete("DELETE FROM tb_hospital_dept WHERE code = #{code}")
     void deleteByCode(String code);
 }

+ 3 - 32
src/main/java/org/example/mapper/HospitalRoomMapper.java

@@ -1,6 +1,7 @@
 package org.example.mapper;
 
-import org.apache.ibatis.annotations.*;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 import org.example.entity.HospitalRoom;
 
 import java.util.List;
@@ -12,7 +13,6 @@ public interface HospitalRoomMapper {
      * 查询所有病房
      * @return 病房列表
      */
-    @Select("SELECT code, out_code AS outCode, name, bed_count AS bedCount, belong_dept AS belongDept, belong_ward AS belongWard, sort, enabled, remark FROM tb_hospital_room")
     List<HospitalRoom> findAll();
     
     /**
@@ -23,16 +23,6 @@ public interface HospitalRoomMapper {
      * @param enabled 是否启用
      * @return 病房列表
      */
-    @Select({
-        "<script>",
-        "SELECT code, out_code AS outCode, name, bed_count AS bedCount, belong_dept AS belongDept, belong_ward AS belongWard, sort, enabled, remark FROM tb_hospital_room",
-        "WHERE 1=1",
-        "<if test='code != null and code != \"\"'> AND code = #{code}</if>",
-        "<if test='department != null and department != \"\"'> AND belong_dept LIKE CONCAT('%', #{department}, '%')</if>",
-        "<if test='ward != null and ward != \"\"'> AND belong_ward LIKE CONCAT('%', #{ward}, '%')</if>",
-        "<if test='enabled != null'> AND enabled = #{enabled}</if>",
-        "</script>"
-    })
     List<HospitalRoom> findByConditions(@Param("code") String code, 
                                       @Param("department") String department, 
                                       @Param("ward") String ward, 
@@ -43,7 +33,6 @@ public interface HospitalRoomMapper {
      * @param code 病房代码
      * @return 病房信息
      */
-    @Select("SELECT code, out_code AS outCode, name, bed_count AS bedCount, belong_dept AS belongDept, belong_ward AS belongWard, sort, enabled, remark FROM tb_hospital_room WHERE code = #{code} LIMIT 1")
     HospitalRoom findByCode(String code);
     
     /**
@@ -52,7 +41,6 @@ public interface HospitalRoomMapper {
      * @param belongWard 所属病区
      * @return 符合条件的病房数量
      */
-    @Select("SELECT COUNT(*) FROM tb_hospital_room WHERE code = #{code} AND belong_ward = #{belongWard}")
     int countByCodeAndWard(@Param("code") String code, @Param("belongWard") String belongWard);
     
     /**
@@ -62,40 +50,23 @@ public interface HospitalRoomMapper {
      * @param excludeCode 要排除的病房代码
      * @return 符合条件的病房数量
      */
-    @Select("SELECT COUNT(*) FROM tb_hospital_room WHERE code = #{code} AND belong_ward = #{belongWard} AND code != #{excludeCode}")
     int countByCodeAndWardExcluding(@Param("code") String code, @Param("belongWard") String belongWard, @Param("excludeCode") String excludeCode);
     
     /**
      * 根据病房代码删除病房
      * @param code 病房代码
      */
-    @Delete("DELETE FROM tb_hospital_room WHERE code = #{code}")
     void deleteByCode(String code);
     
     /**
      * 插入新病房
      * @param room 病房信息
      */
-    @Insert("INSERT INTO tb_hospital_room(code, out_code, name, bed_count, belong_dept, belong_ward, sort, enabled, remark) " +
-            "VALUES(#{code}, #{outCode}, #{name}, #{bedCount}, #{belongDept}, #{belongWard}, #{sort}, #{enabled}, #{remark})")
     void insert(HospitalRoom room);
     
     /**
      * 更新病房信息
      * @param room 病房信息
      */
-    @Update({"<script>",
-            "UPDATE tb_hospital_room",
-            "SET code = #{room.code}",
-            "<if test='room.outCode != null'>, out_code = #{room.outCode}</if>",
-            "<if test='room.name != null'>, name = #{room.name}</if>",
-            "<if test='room.bedCount != null'>, bed_count = #{room.bedCount}</if>",
-            "<if test='room.belongDept != null'>, belong_dept = #{room.belongDept}</if>",
-            "<if test='room.belongWard != null'>, belong_ward = #{room.belongWard}</if>",
-            "<if test='room.sort != null'>, sort = #{room.sort}</if>",
-            "<if test='room.enabled != null'>, enabled = #{room.enabled}</if>",
-            "<if test='room.remark != null'>, remark = #{room.remark}</if>",
-            "WHERE code = #{originCode}",
-            "</script>"})
     void update(@Param("room") HospitalRoom room, @Param("originCode") String originCode);
-}
+}

+ 3 - 28
src/main/java/org/example/mapper/HospitalWardMapper.java

@@ -1,6 +1,7 @@
 package org.example.mapper;
 
-import org.apache.ibatis.annotations.*;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 import org.example.entity.HospitalWard;
 
 import java.util.List;
@@ -12,7 +13,6 @@ public interface HospitalWardMapper {
      * 查询所有病区
      * @return 病区列表
      */
-    @Select("SELECT code, out_code AS outCode, name, address, glkeshi, telephone, director, head_nurse AS headNurse, bed_count AS bedCount, bed_open_count AS bedOpenCount, sort, enabled, remark FROM tb_hospital_ward")
     List<HospitalWard> findAll();
     
     /**
@@ -20,7 +20,6 @@ public interface HospitalWardMapper {
      * @param code 病区代码
      * @return 病区信息
      */
-    @Select("SELECT code, out_code AS outCode, name, address, glkeshi, telephone, director, head_nurse AS headNurse, bed_count AS bedCount, bed_open_count AS bedOpenCount, sort, enabled, remark FROM tb_hospital_ward WHERE code = #{code} LIMIT 1")
     HospitalWard findByCode(String code);
     
     /**
@@ -28,7 +27,6 @@ public interface HospitalWardMapper {
      * @param name 病区名称
      * @return 病区列表
      */
-    @Select("SELECT code, out_code AS outCode, name, address, glkeshi, telephone, director, head_nurse AS headNurse, bed_count AS bedCount, bed_open_count AS bedOpenCount, sort, enabled, remark FROM tb_hospital_ward WHERE name LIKE CONCAT('%', #{name}, '%')")
     List<HospitalWard> findByNameContaining(String name);
     
     /**
@@ -36,7 +34,6 @@ public interface HospitalWardMapper {
      * @param glkeshi 关联科室
      * @return 病区列表
      */
-    @Select("SELECT code, out_code AS outCode, name, address, glkeshi, telephone, director, head_nurse AS headNurse, bed_count AS bedCount, bed_open_count AS bedOpenCount, sort, enabled, remark FROM tb_hospital_ward WHERE glkeshi LIKE CONCAT('%', #{glkeshi}, '%')")
     List<HospitalWard> findByGlkeshiContaining(String glkeshi);
     
     /**
@@ -44,7 +41,6 @@ public interface HospitalWardMapper {
      * @param enabled 是否启用
      * @return 病区列表
      */
-    @Select("SELECT code, out_code AS outCode, name, address, glkeshi, telephone, director, head_nurse AS headNurse, bed_count AS bedCount, bed_open_count AS bedOpenCount, sort, enabled, remark FROM tb_hospital_ward WHERE enabled = #{enabled}")
     List<HospitalWard> findByEnabled(Boolean enabled);
     
     /**
@@ -53,44 +49,23 @@ public interface HospitalWardMapper {
      * @param excludeCode 要排除的代码(更新时使用)
      * @return 病区列表
      */
-    @Select("SELECT code, out_code AS outCode, name, address, glkeshi, telephone, director, head_nurse AS headNurse, bed_count AS bedCount, bed_open_count AS bedOpenCount, sort, enabled, remark FROM tb_hospital_ward WHERE code = #{code} AND code != #{excludeCode}")
     List<HospitalWard> findByCodeExcluding(String code, String excludeCode);
     
     /**
      * 插入新病区
      * @param ward 病区信息
      */
-    @Insert("INSERT INTO tb_hospital_ward(code, out_code, name, address, glkeshi, telephone, director, head_nurse, bed_count, bed_open_count, sort, enabled, remark) " +
-            "VALUES(#{code}, #{outCode}, #{name}, #{address}, #{glkeshi}, #{telephone}, #{director}, #{headNurse}, #{bedCount}, #{bedOpenCount}, #{sort}, #{enabled}, #{remark})")
     void insert(HospitalWard ward);
     
     /**
      * 更新病区信息
      * @param ward 病区信息
      */
-    @Update({"<script>",
-            "UPDATE tb_hospital_ward",
-            "SET code = #{ward.code}",
-            "<if test='ward.outCode != null'>, out_code = #{ward.outCode}</if>",
-            "<if test='ward.name != null'>, name = #{ward.name}</if>",
-            "<if test='ward.address != null'>, address = #{ward.address}</if>",
-            "<if test='ward.glkeshi != null'>, glkeshi = #{ward.glkeshi}</if>",
-            "<if test='ward.telephone != null'>, telephone = #{ward.telephone}</if>",
-            "<if test='ward.director != null'>, director = #{ward.director}</if>",
-            "<if test='ward.headNurse != null'>, head_nurse = #{ward.headNurse}</if>",
-            "<if test='ward.bedCount != null'>, bed_count = #{ward.bedCount}</if>",
-            "<if test='ward.bedOpenCount != null'>, bed_open_count = #{ward.bedOpenCount}</if>",
-            "<if test='ward.sort != null'>, sort = #{ward.sort}</if>",
-            "<if test='ward.enabled != null'>, enabled = #{ward.enabled}</if>",
-            "<if test='ward.remark != null'>, remark = #{ward.remark}</if>",
-            "WHERE code = #{originCode}",
-            "</script>"})
     void update(@Param("ward") HospitalWard ward, @Param("originCode") String originCode);
     
     /**
      * 根据病区代码删除病区
      * @param code 病区代码
      */
-    @Delete("DELETE FROM tb_hospital_ward WHERE code = #{code}")
     void deleteByCode(String code);
-}
+}

+ 3 - 56
src/main/java/org/example/mapper/PatientMapper.java

@@ -1,6 +1,7 @@
 package org.example.mapper;
 
-import org.apache.ibatis.annotations.*;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 import org.example.entity.Patient;
 
 import java.util.List;
@@ -12,40 +13,12 @@ public interface PatientMapper {
      * 查询所有患者
      * @return 患者列表
      */
-    @Select("SELECT admission_date_time AS admissionDateTime, inpatient_no AS inpatientNo, name, sex, age, " +
-            "medical_insurance_type AS medicalInsuranceType, dept_code AS deptCode, ward_code AS wardCode, room_no AS roomNo, bed_no AS bedNo, " +
-            "doctor_code AS doctorCode, nurse_code AS nurseCode, inpatient_serial_no AS inpatientSerialNo, " +
-            "dept_date_time AS deptDateTime, discharged_date_time AS dischargedDateTime, " +
-            "inpatient_status AS inpatientStatus, diagnose, condition_status AS conditionStatus, " +
-            "nurse_level AS nurseLevel, allergen, diet_type AS dietType, notice " +
-            "FROM tb_hospital_patient")
     List<Patient> findAll();
     
     /**
      * 根据条件查询患者
      * @return 患者列表
      */
-    @Select({
-        "<script>",
-        "SELECT admission_date_time AS admissionDateTime, inpatient_no AS inpatientNo, name, sex, age, " +
-        "medical_insurance_type AS medicalInsuranceType, dept_code AS deptCode, ward_code AS wardCode, room_no AS roomNo, bed_no AS bedNo, " +
-        "doctor_code AS doctorCode, nurse_code AS nurseCode, inpatient_serial_no AS inpatientSerialNo, " +
-        "dept_date_time AS deptDateTime, discharged_date_time AS dischargedDateTime, " +
-        "inpatient_status AS inpatientStatus, diagnose, condition_status AS conditionStatus, " +
-        "nurse_level AS nurseLevel, allergen, diet_type AS dietType, notice " +
-        "FROM tb_hospital_patient",
-        "WHERE 1=1",
-        "<if test='name != null and name != \"\"'> AND name LIKE CONCAT('%', #{name}, '%')</if>",
-        "<if test='department != null and department != \"\"'> AND dept_code = #{department}</if>",
-        "<if test='ward != null and ward != \"\"'> AND ward_code = #{ward}</if>",
-        "<if test='roomNo != null and roomNo != \"\"'> AND room_no = #{roomNo}</if>",
-        "<if test='bedNo != null and bedNo != \"\"'> AND bed_no = #{bedNo}</if>",
-        "<if test='inpatientNo != null and inpatientNo != \"\"'> AND inpatient_no LIKE CONCAT('%', #{inpatientNo}, '%')</if>",
-        "<if test='nurseLevel != null and nurseLevel != \"\"'> AND nurse_level = #{nurseLevel}</if>",
-        "<if test='status != null and status != \"\"'> AND inpatient_status = #{status}</if>",
-        "<if test='admissionDateTime != null and admissionDateTime != \"\"'> AND admission_date_time LIKE CONCAT('%', #{admissionDateTime}, '%')</if>",
-        "</script>"
-    })
     List<Patient> findWithConditions(@Param("name") String name, @Param("department") String department, 
                                   @Param("ward") String ward, @Param("roomNo") String roomNo, 
                                   @Param("bedNo") String bedNo, @Param("inpatientNo") String inpatientNo,
@@ -56,14 +29,12 @@ public interface PatientMapper {
      * 查询所有不同的护理级别
      * @return 护理级别列表
      */
-    @Select("SELECT DISTINCT nurse_level FROM tb_hospital_patient WHERE nurse_level IS NOT NULL AND nurse_level != ''")
     List<String> findDistinctNurseLevels();
     
     /**
      * 查询所有不同的在院状态
      * @return 在院状态列表
      */
-    @Select("SELECT DISTINCT inpatient_status FROM tb_hospital_patient WHERE inpatient_status IS NOT NULL AND inpatient_status != ''")
     List<String> findDistinctInpatientStatuses();
     
     /**
@@ -71,47 +42,23 @@ public interface PatientMapper {
      * @param inpatientNo 住院号
      * @return 患者信息
      */
-    @Select("SELECT admission_date_time AS admissionDateTime, inpatient_no AS inpatientNo, name, sex, age, " +
-            "medical_insurance_type AS medicalInsuranceType, dept_code AS deptCode, ward_code AS wardCode, room_no AS roomNo, bed_no AS bedNo, " +
-            "doctor_code AS doctorCode, nurse_code AS nurseCode, inpatient_serial_no AS inpatientSerialNo, " +
-            "dept_date_time AS deptDateTime, discharged_date_time AS dischargedDateTime, " +
-            "inpatient_status AS inpatientStatus, diagnose, condition_status AS conditionStatus, " +
-            "nurse_level AS nurseLevel, allergen, diet_type AS dietType, notice " +
-            "FROM tb_hospital_patient WHERE inpatient_no = #{inpatientNo}")
     Patient findByInpatientNo(String inpatientNo);
     
     /**
      * 插入新患者
      * @param patient 患者信息
      */
-    @Insert("INSERT INTO tb_hospital_patient(admission_date_time, inpatient_no, name, sex, age, " +
-            "medical_insurance_type, dept_code, ward_code, room_no, bed_no, " +
-            "doctor_code, nurse_code, inpatient_serial_no, dept_date_time, discharged_date_time, " +
-            "inpatient_status, diagnose, condition_status, nurse_level, allergen, diet_type, notice) " +
-            "VALUES(#{admissionDateTime}, #{inpatientNo}, #{name}, #{sex}, #{age}, " +
-            "#{medicalInsuranceType}, #{deptCode}, #{wardCode}, #{roomNo}, #{bedNo}, " +
-            "#{doctorCode}, #{nurseCode}, #{inpatientSerialNo}, #{deptDateTime}, #{dischargedDateTime}, " +
-            "#{inpatientStatus}, #{diagnose}, #{conditionStatus}, #{nurseLevel}, #{allergen}, #{dietType}, #{notice})")
     void insert(Patient patient);
     
     /**
      * 更新患者信息
      * @param patient 患者信息
      */
-    @Update("UPDATE tb_hospital_patient SET admission_date_time=#{admissionDateTime}, name=#{name}, sex=#{sex}, age=#{age}, " +
-            "medical_insurance_type=#{medicalInsuranceType}, dept_code=#{deptCode}, ward_code=#{wardCode}, " +
-            "room_no=#{roomNo}, bed_no=#{bedNo}, doctor_code=#{doctorCode}, nurse_code=#{nurseCode}, " +
-            "inpatient_serial_no=#{inpatientSerialNo}, dept_date_time=#{deptDateTime}, " +
-            "discharged_date_time=#{dischargedDateTime}, inpatient_status=#{inpatientStatus}, " +
-            "diagnose=#{diagnose}, condition_status=#{conditionStatus}, nurse_level=#{nurseLevel}, " +
-            "allergen=#{allergen}, diet_type=#{dietType}, notice=#{notice} " +
-            "WHERE inpatient_no=#{inpatientNo}")
     void update(Patient patient);
     
     /**
      * 根据住院号删除患者
      * @param inpatientNo 住院号
      */
-    @Delete("DELETE FROM tb_hospital_patient WHERE inpatient_no = #{inpatientNo}")
     void deleteByInpatientNo(String inpatientNo);
-}
+}

+ 7 - 0
src/main/java/org/example/mapper/TerminalMapper.java

@@ -56,6 +56,13 @@ public interface TerminalMapper {
      */
     List<Terminal> findByTerminalDescContaining(String terminalDesc);
 
+    /**
+     * 根据IP地址查询设备信息
+     * @param ipAddress IP地址
+     * @return 设备信息
+     */
+    Terminal findByIpAddress(String ipAddress);
+
     /**
      * 插入新设备
      * @param terminal 设备信息

+ 9 - 0
src/main/java/org/example/service/TerminalService.java

@@ -75,6 +75,15 @@ public class TerminalService {
         return terminalMapper.findByTerminalDescContaining(terminalDesc);
     }
 
+    /**
+     * 根据IP地址查询设备信息
+     * @param ipAddress IP地址
+     * @return 设备信息
+     */
+    public Terminal findByIpAddress(String ipAddress) {
+        return terminalMapper.findByIpAddress(ipAddress);
+    }
+
     /**
      * 添加新设备
      * @param terminal 设备信息

+ 99 - 0
src/main/resources/mapper/HospitalBedMapper.xml

@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.example.mapper.HospitalBedMapper">
+
+    <resultMap id="BedResultMap" type="org.example.entity.HospitalBed">
+        <id property="code" column="code"/>
+        <result property="outBed" column="out_code"/>
+        <result property="name" column="name"/>
+        <result property="type" column="bed_type"/>
+        <result property="belongDept" column="belong_dept"/>
+        <result property="belongWard" column="belong_ward"/>
+        <result property="belongRoom" column="belong_room"/>
+        <result property="doctor" column="doctor"/>
+        <result property="nurse" column="nurse"/>
+        <result property="used" column="used"/>
+        <result property="sort" column="sort"/>
+        <result property="enabled" column="enabled"/>
+        <result property="remark" column="remark"/>
+    </resultMap>
+
+    <!-- 查询所有床位 -->
+    <select id="findAll" resultMap="BedResultMap">
+        SELECT code, out_code, name, bed_type, belong_dept, belong_ward, belong_room, doctor, nurse, used, sort, enabled, remark
+        FROM tb_hospital_bed
+    </select>
+
+    <!-- 根据床位代码查询床位 -->
+    <select id="findByCode" parameterType="string" resultMap="BedResultMap">
+        SELECT code, out_code, name, bed_type, belong_dept, belong_ward, belong_room, doctor, nurse, used, sort, enabled, remark
+        FROM tb_hospital_bed
+        WHERE code = #{code} LIMIT 1
+    </select>
+
+    <!-- 根据床位名称模糊查询床位列表 -->
+    <select id="findByNameContaining" parameterType="string" resultMap="BedResultMap">
+        SELECT code, out_code, name, bed_type, belong_dept, belong_ward, belong_room, doctor, nurse, used, sort, enabled, remark
+        FROM tb_hospital_bed
+        WHERE name LIKE CONCAT('%', #{name}, '%')
+    </select>
+
+    <!-- 根据所属科室模糊查询床位列表 -->
+    <select id="findByBelongDeptContaining" parameterType="string" resultMap="BedResultMap">
+        SELECT code, out_code, name, bed_type, belong_dept, belong_ward, belong_room, doctor, nurse, used, sort, enabled, remark
+        FROM tb_hospital_bed
+        WHERE belong_dept LIKE CONCAT('%', #{belongDept}, '%')
+    </select>
+
+    <!-- 根据所属病区模糊查询床位列表 -->
+    <select id="findByBelongWardContaining" parameterType="string" resultMap="BedResultMap">
+        SELECT code, out_code, name, bed_type, belong_dept, belong_ward, belong_room, doctor, nurse, used, sort, enabled, remark
+        FROM tb_hospital_bed
+        WHERE belong_ward LIKE CONCAT('%', #{belongWard}, '%')
+    </select>
+
+    <!-- 根据启用状态查询床位列表 -->
+    <select id="findByEnabled" parameterType="boolean" resultMap="BedResultMap">
+        SELECT code, out_code, name, bed_type, belong_dept, belong_ward, belong_room, doctor, nurse, used, sort, enabled, remark
+        FROM tb_hospital_bed
+        WHERE enabled = #{enabled}
+    </select>
+
+    <!-- 检查是否存在指定代码的床位(用于唯一性检查) -->
+    <select id="findByCodeExcluding" resultMap="BedResultMap">
+        SELECT code, out_code, name, bed_type, belong_dept, belong_ward, belong_room, doctor, nurse, used, sort, enabled, remark
+        FROM tb_hospital_bed
+        WHERE code = #{code} AND code != #{excludeCode}
+    </select>
+
+    <!-- 插入新床位 -->
+    <insert id="insert" parameterType="org.example.entity.HospitalBed">
+        INSERT INTO tb_hospital_bed(code, out_code, name, bed_type, belong_dept, belong_ward, belong_room, doctor, nurse, used, sort, enabled, remark)
+        VALUES(#{code}, #{outBed}, #{name}, #{type}, #{belongDept}, #{belongWard}, #{belongRoom}, #{doctor}, #{nurse}, #{used}, #{sort}, #{enabled}, #{remark})
+    </insert>
+
+    <!-- 更新床位信息 -->
+    <update id="update" parameterType="map">
+        UPDATE tb_hospital_bed
+        SET code = #{bed.code}
+        <if test="bed.outBed != null">, out_code = #{bed.outBed}</if>
+        <if test="bed.name != null">, name = #{bed.name}</if>
+        <if test="bed.type != null">, bed_type = #{bed.type}</if>
+        <if test="bed.belongDept != null">, belong_dept = #{bed.belongDept}</if>
+        <if test="bed.belongWard != null">, belong_ward = #{bed.belongWard}</if>
+        <if test="bed.belongRoom != null">, belong_room = #{bed.belongRoom}</if>
+        <if test="bed.doctor != null">, doctor = #{bed.doctor}</if>
+        <if test="bed.nurse != null">, nurse = #{bed.nurse}</if>
+        <if test="bed.used != null">, used = #{bed.used}</if>
+        <if test="bed.sort != null">, sort = #{bed.sort}</if>
+        <if test="bed.enabled != null">, enabled = #{bed.enabled}</if>
+        <if test="bed.remark != null">, remark = #{bed.remark}</if>
+        WHERE code = #{originCode}
+    </update>
+
+    <!-- 根据床位代码删除床位 -->
+    <delete id="deleteByCode" parameterType="string">
+        DELETE FROM tb_hospital_bed WHERE code = #{code}
+    </delete>
+
+</mapper>

+ 48 - 0
src/main/resources/mapper/HospitalDeptMapper.xml

@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.example.mapper.HospitalDeptMapper">
+
+    <resultMap id="DeptResultMap" type="org.example.entity.HospitalDept">
+        <id property="code" column="code"/>
+        <result property="outCode" column="out_code"/>
+        <result property="name" column="name"/>
+        <result property="address" column="address"/>
+        <result property="telephone" column="telephone"/>
+        <result property="introduction" column="introduction"/>
+        <result property="enabled" column="enabled"/>
+        <result property="remark" column="remark"/>
+    </resultMap>
+
+    <!-- 查询所有科室 -->
+    <select id="findAll" resultMap="DeptResultMap">
+        SELECT code, out_code, name, address, telephone, introduction, enabled, remark
+        FROM tb_hospital_dept
+    </select>
+
+    <!-- 根据科室代码查询科室 -->
+    <select id="findByCode" parameterType="string" resultMap="DeptResultMap">
+        SELECT code, out_code, name, address, telephone, introduction, enabled, remark
+        FROM tb_hospital_dept
+        WHERE code = #{code}
+    </select>
+
+    <!-- 插入新科室 -->
+    <insert id="insert" parameterType="org.example.entity.HospitalDept">
+        INSERT INTO tb_hospital_dept(code, out_code, name, address, telephone, introduction, enabled, remark)
+        VALUES(#{code}, #{outCode}, #{name}, #{address}, #{telephone}, #{introduction}, #{enabled}, #{remark})
+    </insert>
+
+    <!-- 更新科室信息 -->
+    <update id="update" parameterType="org.example.entity.HospitalDept">
+        UPDATE tb_hospital_dept
+        SET out_code=#{outCode}, name=#{name}, address=#{address}, telephone=#{telephone},
+            introduction=#{introduction}, enabled=#{enabled}, remark=#{remark}
+        WHERE code=#{code}
+    </update>
+
+    <!-- 根据科室代码删除科室 -->
+    <delete id="deleteByCode" parameterType="string">
+        DELETE FROM tb_hospital_dept WHERE code = #{code}
+    </delete>
+
+</mapper>

+ 79 - 0
src/main/resources/mapper/HospitalRoomMapper.xml

@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.example.mapper.HospitalRoomMapper">
+
+    <resultMap id="RoomResultMap" type="org.example.entity.HospitalRoom">
+        <id property="code" column="code"/>
+        <result property="outCode" column="out_code"/>
+        <result property="name" column="name"/>
+        <result property="bedCount" column="bed_count"/>
+        <result property="belongDept" column="belong_dept"/>
+        <result property="belongWard" column="belong_ward"/>
+        <result property="sort" column="sort"/>
+        <result property="enabled" column="enabled"/>
+        <result property="remark" column="remark"/>
+    </resultMap>
+
+    <!-- 查询所有病房 -->
+    <select id="findAll" resultMap="RoomResultMap">
+        SELECT code, out_code, name, bed_count, belong_dept, belong_ward, sort, enabled, remark
+        FROM tb_hospital_room
+    </select>
+
+    <!-- 根据条件查询病房 -->
+    <select id="findByConditions" resultMap="RoomResultMap">
+        SELECT code, out_code, name, bed_count, belong_dept, belong_ward, sort, enabled, remark
+        FROM tb_hospital_room
+        WHERE 1=1
+        <if test="code != null and code != ''">AND code = #{code}</if>
+        <if test="department != null and department != ''">AND belong_dept LIKE CONCAT('%', #{department}, '%')</if>
+        <if test="ward != null and ward != ''">AND belong_ward LIKE CONCAT('%', #{ward}, '%')</if>
+        <if test="enabled != null">AND enabled = #{enabled}</if>
+    </select>
+
+    <!-- 根据病房代码查询病房 -->
+    <select id="findByCode" parameterType="string" resultMap="RoomResultMap">
+        SELECT code, out_code, name, bed_count, belong_dept, belong_ward, sort, enabled, remark
+        FROM tb_hospital_room
+        WHERE code = #{code} LIMIT 1
+    </select>
+
+    <!-- 根据病房代码和所属病区查询病房数量 -->
+    <select id="countByCodeAndWard" resultType="int">
+        SELECT COUNT(*) FROM tb_hospital_room
+        WHERE code = #{code} AND belong_ward = #{belongWard}
+    </select>
+
+    <!-- 根据病房代码和所属病区查询病房数量(排除指定病房) -->
+    <select id="countByCodeAndWardExcluding" resultType="int">
+        SELECT COUNT(*) FROM tb_hospital_room
+        WHERE code = #{code} AND belong_ward = #{belongWard} AND code != #{excludeCode}
+    </select>
+
+    <!-- 根据病房代码删除病房 -->
+    <delete id="deleteByCode" parameterType="string">
+        DELETE FROM tb_hospital_room WHERE code = #{code}
+    </delete>
+
+    <!-- 插入新病房 -->
+    <insert id="insert" parameterType="org.example.entity.HospitalRoom">
+        INSERT INTO tb_hospital_room(code, out_code, name, bed_count, belong_dept, belong_ward, sort, enabled, remark)
+        VALUES(#{code}, #{outCode}, #{name}, #{bedCount}, #{belongDept}, #{belongWard}, #{sort}, #{enabled}, #{remark})
+    </insert>
+
+    <!-- 更新病房信息 -->
+    <update id="update" parameterType="map">
+        UPDATE tb_hospital_room
+        SET code = #{room.code}
+        <if test="room.outCode != null">, out_code = #{room.outCode}</if>
+        <if test="room.name != null">, name = #{room.name}</if>
+        <if test="room.bedCount != null">, bed_count = #{room.bedCount}</if>
+        <if test="room.belongDept != null">, belong_dept = #{room.belongDept}</if>
+        <if test="room.belongWard != null">, belong_ward = #{room.belongWard}</if>
+        <if test="room.sort != null">, sort = #{room.sort}</if>
+        <if test="room.enabled != null">, enabled = #{room.enabled}</if>
+        <if test="room.remark != null">, remark = #{room.remark}</if>
+        WHERE code = #{originCode}
+    </update>
+
+</mapper>

+ 92 - 0
src/main/resources/mapper/HospitalWardMapper.xml

@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.example.mapper.HospitalWardMapper">
+
+    <resultMap id="WardResultMap" type="org.example.entity.HospitalWard">
+        <id property="code" column="code"/>
+        <result property="outCode" column="out_code"/>
+        <result property="name" column="name"/>
+        <result property="address" column="address"/>
+        <result property="glkeshi" column="glkeshi"/>
+        <result property="telephone" column="telephone"/>
+        <result property="director" column="director"/>
+        <result property="headNurse" column="head_nurse"/>
+        <result property="bedCount" column="bed_count"/>
+        <result property="bedOpenCount" column="bed_open_count"/>
+        <result property="sort" column="sort"/>
+        <result property="enabled" column="enabled"/>
+        <result property="remark" column="remark"/>
+    </resultMap>
+
+    <!-- 查询所有病区 -->
+    <select id="findAll" resultMap="WardResultMap">
+        SELECT code, out_code, name, address, glkeshi, telephone, director, head_nurse, bed_count, bed_open_count, sort, enabled, remark
+        FROM tb_hospital_ward
+    </select>
+
+    <!-- 根据病区代码查询病区 -->
+    <select id="findByCode" parameterType="string" resultMap="WardResultMap">
+        SELECT code, out_code, name, address, glkeshi, telephone, director, head_nurse, bed_count, bed_open_count, sort, enabled, remark
+        FROM tb_hospital_ward
+        WHERE code = #{code} LIMIT 1
+    </select>
+
+    <!-- 根据病区名称模糊查询病区列表 -->
+    <select id="findByNameContaining" parameterType="string" resultMap="WardResultMap">
+        SELECT code, out_code, name, address, glkeshi, telephone, director, head_nurse, bed_count, bed_open_count, sort, enabled, remark
+        FROM tb_hospital_ward
+        WHERE name LIKE CONCAT('%', #{name}, '%')
+    </select>
+
+    <!-- 根据关联科室模糊查询病区列表 -->
+    <select id="findByGlkeshiContaining" parameterType="string" resultMap="WardResultMap">
+        SELECT code, out_code, name, address, glkeshi, telephone, director, head_nurse, bed_count, bed_open_count, sort, enabled, remark
+        FROM tb_hospital_ward
+        WHERE glkeshi LIKE CONCAT('%', #{glkeshi}, '%')
+    </select>
+
+    <!-- 根据启用状态查询病区列表 -->
+    <select id="findByEnabled" parameterType="boolean" resultMap="WardResultMap">
+        SELECT code, out_code, name, address, glkeshi, telephone, director, head_nurse, bed_count, bed_open_count, sort, enabled, remark
+        FROM tb_hospital_ward
+        WHERE enabled = #{enabled}
+    </select>
+
+    <!-- 检查是否存在指定代码的病区(用于唯一性检查) -->
+    <select id="findByCodeExcluding" resultMap="WardResultMap">
+        SELECT code, out_code, name, address, glkeshi, telephone, director, head_nurse, bed_count, bed_open_count, sort, enabled, remark
+        FROM tb_hospital_ward
+        WHERE code = #{code} AND code != #{excludeCode}
+    </select>
+
+    <!-- 插入新病区 -->
+    <insert id="insert" parameterType="org.example.entity.HospitalWard">
+        INSERT INTO tb_hospital_ward(code, out_code, name, address, glkeshi, telephone, director, head_nurse, bed_count, bed_open_count, sort, enabled, remark)
+        VALUES(#{code}, #{outCode}, #{name}, #{address}, #{glkeshi}, #{telephone}, #{director}, #{headNurse}, #{bedCount}, #{bedOpenCount}, #{sort}, #{enabled}, #{remark})
+    </insert>
+
+    <!-- 更新病区信息 -->
+    <update id="update" parameterType="map">
+        UPDATE tb_hospital_ward
+        SET code = #{ward.code}
+        <if test="ward.outCode != null">, out_code = #{ward.outCode}</if>
+        <if test="ward.name != null">, name = #{ward.name}</if>
+        <if test="ward.address != null">, address = #{ward.address}</if>
+        <if test="ward.glkeshi != null">, glkeshi = #{ward.glkeshi}</if>
+        <if test="ward.telephone != null">, telephone = #{ward.telephone}</if>
+        <if test="ward.director != null">, director = #{ward.director}</if>
+        <if test="ward.headNurse != null">, head_nurse = #{ward.headNurse}</if>
+        <if test="ward.bedCount != null">, bed_count = #{ward.bedCount}</if>
+        <if test="ward.bedOpenCount != null">, bed_open_count = #{ward.bedOpenCount}</if>
+        <if test="ward.sort != null">, sort = #{ward.sort}</if>
+        <if test="ward.enabled != null">, enabled = #{ward.enabled}</if>
+        <if test="ward.remark != null">, remark = #{ward.remark}</if>
+        WHERE code = #{originCode}
+    </update>
+
+    <!-- 根据病区代码删除病区 -->
+    <delete id="deleteByCode" parameterType="string">
+        DELETE FROM tb_hospital_ward WHERE code = #{code}
+    </delete>
+
+</mapper>

+ 118 - 0
src/main/resources/mapper/PatientMapper.xml

@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.example.mapper.PatientMapper">
+
+    <resultMap id="PatientResultMap" type="org.example.entity.Patient">
+        <result property="admissionDateTime" column="admission_date_time"/>
+        <result property="inpatientNo" column="inpatient_no"/>
+        <result property="name" column="name"/>
+        <result property="sex" column="sex"/>
+        <result property="age" column="age"/>
+        <result property="medicalInsuranceType" column="medical_insurance_type"/>
+        <result property="deptCode" column="dept_code"/>
+        <result property="wardCode" column="ward_code"/>
+        <result property="roomNo" column="room_no"/>
+        <result property="bedNo" column="bed_no"/>
+        <result property="doctorCode" column="doctor_code"/>
+        <result property="nurseCode" column="nurse_code"/>
+        <result property="inpatientSerialNo" column="inpatient_serial_no"/>
+        <result property="deptDateTime" column="dept_date_time"/>
+        <result property="dischargedDateTime" column="discharged_date_time"/>
+        <result property="inpatientStatus" column="inpatient_status"/>
+        <result property="diagnose" column="diagnose"/>
+        <result property="conditionStatus" column="condition_status"/>
+        <result property="nurseLevel" column="nurse_level"/>
+        <result property="allergen" column="allergen"/>
+        <result property="dietType" column="diet_type"/>
+        <result property="notice" column="notice"/>
+    </resultMap>
+
+    <!-- 查询所有患者 -->
+    <select id="findAll" resultMap="PatientResultMap">
+        SELECT admission_date_time, inpatient_no, name, sex, age,
+               medical_insurance_type, dept_code, ward_code, room_no, bed_no,
+               doctor_code, nurse_code, inpatient_serial_no,
+               dept_date_time, discharged_date_time,
+               inpatient_status, diagnose, condition_status,
+               nurse_level, allergen, diet_type, notice
+        FROM tb_hospital_patient
+    </select>
+
+    <!-- 根据条件查询患者 -->
+    <select id="findWithConditions" resultMap="PatientResultMap">
+        SELECT admission_date_time, inpatient_no, name, sex, age,
+               medical_insurance_type, dept_code, ward_code, room_no, bed_no,
+               doctor_code, nurse_code, inpatient_serial_no,
+               dept_date_time, discharged_date_time,
+               inpatient_status, diagnose, condition_status,
+               nurse_level, allergen, diet_type, notice
+        FROM tb_hospital_patient
+        WHERE 1=1
+        <if test="name != null and name != ''">AND name LIKE CONCAT('%', #{name}, '%')</if>
+        <if test="department != null and department != ''">AND dept_code = #{department}</if>
+        <if test="ward != null and ward != ''">AND ward_code = #{ward}</if>
+        <if test="roomNo != null and roomNo != ''">AND room_no = #{roomNo}</if>
+        <if test="bedNo != null and bedNo != ''">AND bed_no = #{bedNo}</if>
+        <if test="inpatientNo != null and inpatientNo != ''">AND inpatient_no LIKE CONCAT('%', #{inpatientNo}, '%')</if>
+        <if test="nurseLevel != null and nurseLevel != ''">AND nurse_level = #{nurseLevel}</if>
+        <if test="status != null and status != ''">AND inpatient_status = #{status}</if>
+        <if test="admissionDateTime != null and admissionDateTime != ''">AND admission_date_time LIKE CONCAT('%', #{admissionDateTime}, '%')</if>
+    </select>
+
+    <!-- 查询所有不同的护理级别 -->
+    <select id="findDistinctNurseLevels" resultType="string">
+        SELECT DISTINCT nurse_level
+        FROM tb_hospital_patient
+        WHERE nurse_level IS NOT NULL AND nurse_level != ''
+    </select>
+
+    <!-- 查询所有不同的在院状态 -->
+    <select id="findDistinctInpatientStatuses" resultType="string">
+        SELECT DISTINCT inpatient_status
+        FROM tb_hospital_patient
+        WHERE inpatient_status IS NOT NULL AND inpatient_status != ''
+    </select>
+
+    <!-- 根据住院号查询患者 -->
+    <select id="findByInpatientNo" parameterType="string" resultMap="PatientResultMap">
+        SELECT admission_date_time, inpatient_no, name, sex, age,
+               medical_insurance_type, dept_code, ward_code, room_no, bed_no,
+               doctor_code, nurse_code, inpatient_serial_no,
+               dept_date_time, discharged_date_time,
+               inpatient_status, diagnose, condition_status,
+               nurse_level, allergen, diet_type, notice
+        FROM tb_hospital_patient
+        WHERE inpatient_no = #{inpatientNo}
+    </select>
+
+    <!-- 插入新患者 -->
+    <insert id="insert" parameterType="org.example.entity.Patient">
+        INSERT INTO tb_hospital_patient(admission_date_time, inpatient_no, name, sex, age,
+                                       medical_insurance_type, dept_code, ward_code, room_no, bed_no,
+                                       doctor_code, nurse_code, inpatient_serial_no, dept_date_time, discharged_date_time,
+                                       inpatient_status, diagnose, condition_status, nurse_level, allergen, diet_type, notice)
+        VALUES(#{admissionDateTime}, #{inpatientNo}, #{name}, #{sex}, #{age},
+               #{medicalInsuranceType}, #{deptCode}, #{wardCode}, #{roomNo}, #{bedNo},
+               #{doctorCode}, #{nurseCode}, #{inpatientSerialNo}, #{deptDateTime}, #{dischargedDateTime},
+               #{inpatientStatus}, #{diagnose}, #{conditionStatus}, #{nurseLevel}, #{allergen}, #{dietType}, #{notice})
+    </insert>
+
+    <!-- 更新患者信息 -->
+    <update id="update" parameterType="org.example.entity.Patient">
+        UPDATE tb_hospital_patient
+        SET admission_date_time=#{admissionDateTime}, name=#{name}, sex=#{sex}, age=#{age},
+            medical_insurance_type=#{medicalInsuranceType}, dept_code=#{deptCode}, ward_code=#{wardCode},
+            room_no=#{roomNo}, bed_no=#{bedNo}, doctor_code=#{doctorCode}, nurse_code=#{nurseCode},
+            inpatient_serial_no=#{inpatientSerialNo}, dept_date_time=#{deptDateTime},
+            discharged_date_time=#{dischargedDateTime}, inpatient_status=#{inpatientStatus},
+            diagnose=#{diagnose}, condition_status=#{conditionStatus}, nurse_level=#{nurseLevel},
+            allergen=#{allergen}, diet_type=#{dietType}, notice=#{notice}
+        WHERE inpatient_no=#{inpatientNo}
+    </update>
+
+    <!-- 根据住院号删除患者 -->
+    <delete id="deleteByInpatientNo" parameterType="string">
+        DELETE FROM tb_hospital_patient WHERE inpatient_no = #{inpatientNo}
+    </delete>
+
+</mapper>

+ 10 - 2
src/main/resources/mapper/TerminalMapper.xml

@@ -14,6 +14,7 @@
         <result property="gatewayAddress" column="gateway_address"/>
         <result property="macAddress" column="mac_address"/>
         <result property="isOnline" column="is_online"/>
+        <result property="createTime" column="create_time"/>
     </resultMap>
 
     <!-- 查询所有设备 -->
@@ -64,10 +65,17 @@
         WHERE terminal_desc LIKE CONCAT('%', #{terminalDesc}, '%')
     </select>
 
+    <!-- 根据IP地址查询设备 -->
+    <select id="findByIpAddress" parameterType="string" resultMap="TerminalResultMap">
+        SELECT id, terminal_type, terminal_number, terminal_desc, dept_code, ward_code, ip_address, subnet_mask, gateway_address, mac_address, is_online
+        FROM tb_terminal
+        WHERE ip_address = #{ipAddress} LIMIT 1
+    </select>
+
     <!-- 插入新设备 -->
     <insert id="insert" parameterType="org.example.entity.Terminal">
-        INSERT INTO tb_terminal(terminal_type, terminal_number, terminal_desc, dept_code, ward_code, ip_address, subnet_mask, gateway_address, mac_address, is_online)
-        VALUES(#{terminalType}, #{terminalNumber}, #{terminalDesc}, #{deptCode}, #{wardCode}, #{ipAddress}, #{subnetMask}, #{gatewayAddress}, #{macAddress}, #{isOnline})
+        INSERT INTO tb_terminal(terminal_type, terminal_number, terminal_desc, dept_code, ward_code, ip_address, subnet_mask, gateway_address, mac_address, is_online, create_time, create_user)
+        VALUES(#{terminalType}, #{terminalNumber}, #{terminalDesc}, #{deptCode}, #{wardCode}, #{ipAddress}, #{subnetMask}, #{gatewayAddress}, #{macAddress}, #{isOnline}, NOW(), 0)
     </insert>
 
     <!-- 更新设备信息 -->

+ 113 - 53
src/main/resources/static/home.html

@@ -1707,16 +1707,12 @@
                                         <label>所属科室:</label>
                                         <select id="equipmentDepartment" style="padding: 6px; border: 1px solid #ddd; border-radius: 4px; width: 120px;">
                                             <option value="">全部</option>
-                                            <option value="内科">内科</option>
-                                            <option value="外科">外科</option>
                                         </select>
                                     </div>
                                     <div>
                                         <label>所属病区:</label>
                                         <select id="equipmentWard" style="padding: 6px; border: 1px solid #ddd; border-radius: 4px; width: 120px;">
                                             <option value="">全部</option>
-                                            <option value="第一病区">第一病区</option>
-                                            <option value="第二病区">第二病区</option>
                                         </select>
                                     </div>
                                     <div>
@@ -1801,6 +1797,10 @@
                                         <label>Mac地址:</label>
                                         <input type="text" id="modalMacAddress" style="width: 100%; padding: 6px;">
                                     </div>
+                                    <div class="form-group">
+                                        <label>设备位置:</label>
+                                        <input type="text" id="modalLocation" style="width: 100%; padding: 6px;">
+                                    </div>
                                     <div class="form-group">
                                         <label>在线状态:</label>
                                         <select id="modalIsOnline" style="width: 100%; padding: 6px;">
@@ -2076,10 +2076,6 @@
             alert('显示新增患者表单');
         }
         
-        function showAddEquipmentForm() {
-            alert('显示新增设备表单');
-        }
-        
         document.addEventListener('DOMContentLoaded', function() {
             // 检查登录状态
             fetch('/shixian/api/status')
@@ -2761,13 +2757,17 @@
         
         // 加载设备数据
         function loadEquipmentData() {
-            fetch('/shixian/api/terminals')
-            .then(response => response.json())
-            .then(data => {
+            // 并行加载设备数据和科室数据
+            Promise.all([
+                fetch('/shixian/api/terminals').then(response => response.json()),
+                fetch('/shixian/api/departments').then(response => response.json())
+            ])
+            .then(([terminals, departments]) => {
+                // 更新设备表格
                 const tbody = document.getElementById('equipmentTableBody');
                 tbody.innerHTML = '';
                 
-                data.forEach(terminal => {
+                terminals.forEach(terminal => {
                     const row = document.createElement('tr');
                     const statusText = terminal.isOnline ? '在线' : '离线';
                     
@@ -2790,6 +2790,46 @@
                     `;
                     tbody.appendChild(row);
                 });
+                
+                // 更新科室下拉框
+                const departmentSelect = document.getElementById('equipmentDepartment');
+                const currentDepartmentValue = departmentSelect.value;
+                
+                // 保留默认选项
+                departmentSelect.innerHTML = '<option value="">全部</option>';
+                
+                // 获取设备中存在的唯一科室列表
+                const existingDepartments = [...new Set(terminals.map(t => t.deptCode).filter(dept => dept))];
+                
+                // 添加选项
+                existingDepartments.forEach(dept => {
+                    const option = document.createElement('option');
+                    option.value = dept;
+                    option.textContent = dept;
+                    departmentSelect.appendChild(option);
+                });
+                
+                departmentSelect.value = currentDepartmentValue;
+                
+                // 更新病区下拉框
+                const wardSelect = document.getElementById('equipmentWard');
+                const currentWardValue = wardSelect.value;
+                
+                // 保留默认选项
+                wardSelect.innerHTML = '<option value="">全部</option>';
+                
+                // 获取设备中存在的唯一病区列表
+                const existingWards = [...new Set(terminals.map(t => t.wardCode).filter(ward => ward))];
+                
+                // 添加选项
+                existingWards.forEach(ward => {
+                    const option = document.createElement('option');
+                    option.value = ward;
+                    option.textContent = ward;
+                    wardSelect.appendChild(option);
+                });
+                
+                wardSelect.value = currentWardValue;
             })
             .catch(error => {
                 console.error('加载设备数据失败:', error);
@@ -2820,9 +2860,12 @@
             
             url += params.join('&');
             
-            fetch(url)
-            .then(response => response.json())
-            .then(data => {
+            // 并行获取设备数据和科室数据
+            Promise.all([
+                fetch(url).then(response => response.json()),
+                fetch('/shixian/api/departments').then(response => response.json())
+            ])
+            .then(([data, departments]) => {
                 const tbody = document.getElementById('equipmentTableBody');
                 tbody.innerHTML = '';
                 
@@ -2852,6 +2895,46 @@
                     `;
                     tbody.appendChild(row);
                 });
+                
+                // 更新科室下拉框
+                const departmentSelect = document.getElementById('equipmentDepartment');
+                const currentDepartmentValue = departmentSelect.value;
+                
+                // 保留默认选项
+                departmentSelect.innerHTML = '<option value="">全部</option>';
+                
+                // 获取设备中存在的唯一科室列表
+                const existingDepartments = [...new Set(terminals.map(t => t.deptCode).filter(dept => dept))];
+                
+                // 添加选项
+                existingDepartments.forEach(dept => {
+                    const option = document.createElement('option');
+                    option.value = dept;
+                    option.textContent = dept;
+                    departmentSelect.appendChild(option);
+                });
+                
+                departmentSelect.value = currentDepartmentValue;
+                
+                // 更新病区下拉框
+                const wardSelect = document.getElementById('equipmentWard');
+                const currentWardValue = wardSelect.value;
+                
+                // 保留默认选项
+                wardSelect.innerHTML = '<option value="">全部</option>';
+                
+                // 获取设备中存在的唯一病区列表
+                const existingWards = [...new Set(terminals.map(t => t.wardCode).filter(ward => ward))];
+                
+                // 添加选项
+                existingWards.forEach(ward => {
+                    const option = document.createElement('option');
+                    option.value = ward;
+                    option.textContent = ward;
+                    wardSelect.appendChild(option);
+                });
+                
+                wardSelect.value = currentWardValue;
             })
             .catch(error => {
                 console.error('查询设备数据失败:', error);
@@ -2889,10 +2972,12 @@
                     document.getElementById('modalSubnetMask').value = terminal.subnetMask || '';
                     document.getElementById('modalGatewayAddress').value = terminal.gatewayAddress || '';
                     document.getElementById('modalMacAddress').value = terminal.macAddress || '';
+                    document.getElementById('modalLocation').value = '';
                     document.getElementById('modalIsOnline').value = terminal.isOnline ? 'true' : 'false';
                     
                     // 设置为只读模式
                     document.getElementById('modalTerminalType').readOnly = true;
+                    document.getElementById('modalTerminalNumberDisplay').readOnly = true;
                     document.getElementById('modalTerminalDesc').readOnly = true;
                     document.getElementById('modalDeptCode').readOnly = true;
                     document.getElementById('modalWardCode').readOnly = true;
@@ -2900,6 +2985,7 @@
                     document.getElementById('modalSubnetMask').readOnly = true;
                     document.getElementById('modalGatewayAddress').readOnly = true;
                     document.getElementById('modalMacAddress').readOnly = true;
+                    document.getElementById('modalLocation').readOnly = true;
                     document.getElementById('modalIsOnline').disabled = true;
                     document.getElementById('saveEquipmentBtn').style.display = 'none';
                     
@@ -2935,10 +3021,12 @@
                     document.getElementById('modalSubnetMask').value = terminal.subnetMask || '';
                     document.getElementById('modalGatewayAddress').value = terminal.gatewayAddress || '';
                     document.getElementById('modalMacAddress').value = terminal.macAddress || '';
+                    document.getElementById('modalLocation').value = '';
                     document.getElementById('modalIsOnline').value = terminal.isOnline ? 'true' : 'false';
                     
                     // 设置为可编辑模式
                     document.getElementById('modalTerminalType').readOnly = false;
+                    document.getElementById('modalTerminalNumberDisplay').readOnly = false;
                     document.getElementById('modalTerminalDesc').readOnly = false;
                     document.getElementById('modalDeptCode').readOnly = false;
                     document.getElementById('modalWardCode').readOnly = false;
@@ -2946,6 +3034,7 @@
                     document.getElementById('modalSubnetMask').readOnly = false;
                     document.getElementById('modalGatewayAddress').readOnly = false;
                     document.getElementById('modalMacAddress').readOnly = false;
+                    document.getElementById('modalLocation').readOnly = false;
                     document.getElementById('modalIsOnline').disabled = false;
                     document.getElementById('saveEquipmentBtn').style.display = 'inline-block';
                     
@@ -2979,6 +3068,7 @@
             
             // 设置为可编辑模式
             document.getElementById('modalTerminalType').readOnly = false;
+            document.getElementById('modalTerminalNumberDisplay').readOnly = false;
             document.getElementById('modalTerminalDesc').readOnly = false;
             document.getElementById('modalDeptCode').readOnly = false;
             document.getElementById('modalWardCode').readOnly = false;
@@ -3009,6 +3099,12 @@
                 isOnline: document.getElementById('modalIsOnline').value === 'true'
             };
             
+            // 验证必填字段
+            if (!terminalData.terminalNumber || terminalData.terminalNumber.trim() === '') {
+                alert('请输入设备编码');
+                return;
+            }
+            
             let url, method;
             if (terminalNumber) {
                 // 更新设备
@@ -3053,7 +3149,7 @@
                 .then(data => {
                     if (data.success) {
                         alert('删除成功');
-                        loadEquipmentData(); // 重新加载数据
+                        loadEquipmentData(); // 重新加载数据,确保下拉框同步更新
                     } else {
                         alert('删除失败: ' + data.message);
                     }
@@ -4727,43 +4823,7 @@
                 element.className = 'btn btn-primary';
             }
         }
-        
-        // 设备查询功能
-        /*
-        function searchEquipment() {
-            const equipmentName = document.getElementById('equipmentName').value;
-            const equipmentType = document.getElementById('equipmentType').value;
-            const equipmentDepartment = document.getElementById('equipmentDepartment').value;
-            const equipmentWard = document.getElementById('equipmentWard').value;
-            const equipmentStatus = document.getElementById('equipmentStatus').value;
-            
-            // 这里应该发送请求到后端查询设备数据
-            // 示例代码:
-            // fetch(`/api/equipment?name=${equipmentName}&type=${equipmentType}&department=${equipmentDepartment}&ward=${equipmentWard}&status=${equipmentStatus}`)
-            //     .then(response => response.json())
-            //     .then(data => {
-            //         // 更新表格数据
-            //     })
-            
-            alert(`查询条件:
-设备名称: ${equipmentName}
-设备类型: ${equipmentType}
-所属科室: ${equipmentDepartment}
-所属病区: ${equipmentWard}
-在线状态: ${equipmentStatus}`);
-        }
-        */
-        
-        // 清空设备查询条件
-        /*
-        function clearEquipmentSearch() {
-            document.getElementById('equipmentName').value = '';
-            document.getElementById('equipmentType').value = '';
-            document.getElementById('equipmentDepartment').value = '';
-            document.getElementById('equipmentWard').value = '';
-            document.getElementById('equipmentStatus').value = '';
-        }
-        */
+
         
     </script>
 </body>

BIN
src/main/resources/static/img/eb30a95b-095b-4092-8198-fabdce080254.jpg