Browse Source

号表增加删除功能

hurugang 5 years ago
parent
commit
fbf3cce60b

+ 31 - 1
src/main/java/cn/hnthyy/thmz/controller/MzyRequestController.java

@@ -247,7 +247,7 @@ public class MzyRequestController {
                 resultMap.put("message", "新增的号表信息重复");
                 return resultMap;
             }
-            resultMap.put("message", "保存号表数据失败");
+            resultMap.put("message", "保存号表数据失败,错误信息:"+e.getMessage());
             return resultMap;
         }
     }
@@ -440,4 +440,34 @@ public class MzyRequestController {
     }
 
 
+
+
+    /**
+     * 根据号表id删除号表
+     *
+     * @return
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/deleteRequestById", method = {RequestMethod.GET})
+    public Map<String, Object> deleteRequestById(@RequestParam("id") Long id) {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            if (id==null) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "号表id不能为空");
+                return resultMap;
+            }
+            mzyRequestService.removeMzyRequestById(id);
+            resultMap.put("code", 0);
+            resultMap.put("message", "根据号表id删除号表成功");
+            return resultMap;
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("根据号表id删除号表失败,错误信息{}", e.getMessage());
+            resultMap.put("code", -1);
+            resultMap.put("message", "根据号表id删除号表失败");
+            return resultMap;
+        }
+    }
+
 }

+ 1 - 2
src/main/java/cn/hnthyy/thmz/enums/PayMarkEnum.java

@@ -4,13 +4,12 @@ import java.util.Arrays;
 import java.util.List;
 
 /**
- * 退欠标记 0:收;1:退;2:作废;4:未收费 , 5 处方开立-未收费
+ * 退欠标记 0:收;1:退;2:作废; 5 处方开立-未收费
  */
 public enum PayMarkEnum {
     CHARGED("0","已收"),//收费
     RETURN_PREMIUM("1","退费"),
     CANCELLATION("2","作废"),
-    //原系统未收费,因为之前没有4这个状态,当将医技等数据转成收费明细时将收费状态变更为4
     NO_CHARGE("5","处方开立-未收费"),
     //此状态只做收入报表统计,不展示在收费列表
     BYJZ_CHARGED_ORI_DATA("9","本院记账已收费原数据");

+ 15 - 31
src/main/java/cn/hnthyy/thmz/mapper/his/MzyRequestMapper.java

@@ -1,10 +1,7 @@
 package cn.hnthyy.thmz.mapper.his;
 
 import cn.hnthyy.thmz.entity.his.MzyRequest;
-import org.apache.ibatis.annotations.Insert;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-import org.apache.ibatis.annotations.Update;
+import org.apache.ibatis.annotations.*;
 
 import java.util.Date;
 import java.util.List;
@@ -90,14 +87,6 @@ public interface MzyRequestMapper {
     int synchronizationRequest();
 
 
-//    /**
-//     * 查询最新的排班信息
-//     * @return
-//     */
-//    @Select("select request_day,ampm,unit_code,group_code,doctor_code,charge_type,op_id,total_num,left_num,bespeak_no,check_fee,sys_date,del_flag " +
-//            " from mzy_request where request_day >=(select top 1 request_day from mzy_request_new order by request_day desc ) and request_day <> '7019-10-27 00:00:00.000' order by request_day asc")
-//    List<MzyRequest> selectNewRequest();
-
 
     /**
      * 查询当天最新的排班信息
@@ -122,20 +111,12 @@ public interface MzyRequestMapper {
      *
      * @return
      */
-    @Insert("insert into mzy_request_new(request_day,ampm,unit_code,group_code,doctor_code,charge_type,op_id,total_num,left_num,bespeak_no,check_fee,sys_date,del_flag) " +
+    @Insert("if not exists (select id  from mzy_request_new where request_day=#{requestDay,jdbcType=DATE} and ampm = #{ampm,jdbcType=CHAR} and unit_code=#{unitCode} and group_code=#{groupCode} and charge_type=#{chargeType} and doctor_code=#{doctorCode} ) "+
+            "insert into mzy_request_new(request_day,ampm,unit_code,group_code,doctor_code,charge_type,op_id,total_num,left_num,bespeak_no,check_fee,sys_date,del_flag) " +
             "values(#{requestDay,jdbcType=DATE},#{ampm},#{unitCode},#{groupCode},#{doctorCode},#{chargeType},#{opId},#{totalNum},#{leftNum},#{bespeakNo},#{checkFee},#{sysDate,jdbcType=DATE},#{delFlag})")
     int insertRequest(MzyRequest mzyRequest);
 
 
-    /**
-     * 保存老系统排班表
-     *
-     * @return
-     */
-    @Insert("insert into mzy_request(request_day,ampm,unit_code,group_code,doctor_code,charge_type,op_id,total_num,left_num,bespeak_no,check_fee,sys_date,del_flag,total_req,left_req,web_no) " +
-            "values(#{requestDay,jdbcType=DATE},#{ampm},#{unitCode},#{groupCode},#{doctorCode},#{chargeType},#{opId},#{totalNum},#{leftNum},#{bespeakNo},#{checkFee},#{sysDate,jdbcType=DATE},#{delFlag},0,0,0)")
-    int insertOldRequest(MzyRequest mzyRequest);
-
 
     /**
      * 按日期和时间区间以及部门编码以及收费类型查询老排班表中的最新数据
@@ -193,18 +174,11 @@ public interface MzyRequestMapper {
      * @param mzyRequest
      * @return
      */
-    @Update("update mzy_request_new set request_day=#{requestDay,jdbcType=DATE},ampm=#{ampm},unit_code=#{unitCode},doctor_code=#{doctorCode},charge_type=#{chargeType},total_num=#{totalNum},left_num=#{leftNum,jdbcType=INTEGER}, bespeak_no=#{bespeakNo,jdbcType=SMALLINT},check_fee=#{checkFee} where id = #{id,jdbcType=BIGINT}")
+    @Update("if not exists (select id  from mzy_request_new where request_day=#{requestDay,jdbcType=DATE} and ampm = #{ampm,jdbcType=CHAR} and unit_code=#{unitCode} and group_code=#{groupCode} and charge_type=#{chargeType} and doctor_code=#{doctorCode} and id <> #{id,jdbcType=BIGINT} ) "+
+            "update mzy_request_new set request_day=#{requestDay,jdbcType=DATE},ampm=#{ampm},unit_code=#{unitCode},doctor_code=#{doctorCode},charge_type=#{chargeType},total_num=#{totalNum},left_num=#{leftNum,jdbcType=INTEGER}, bespeak_no=#{bespeakNo,jdbcType=SMALLINT},check_fee=#{checkFee} where id = #{id,jdbcType=BIGINT}")
     int updateMzyRequestNew(MzyRequest mzyRequest);
 
 
-    /**
-     * 更新老号表
-     *
-     * @param mzyRequest
-     * @return
-     */
-    @Update("update mzy_request set request_day=#{requestDay,jdbcType=DATE},ampm=#{ampm},unit_code=#{unitCode},doctor_code=#{doctorCode},charge_type=#{chargeType},total_num=#{totalNum},left_num=#{leftNum,jdbcType=INTEGER}, bespeak_no=#{bespeakNo,jdbcType=SMALLINT},check_fee=#{checkFee} where request_day=#{requestDayOld,jdbcType=DATE} and ampm=#{ampmOld} and unit_code=#{unitCodeOld}  and doctor_code=#{doctorCodeOld} and charge_type=#{chargeTypeOld} ")
-    int updateMzyRequestOld(MzyRequest mzyRequest);
 
     /**
      * 科室号源统计
@@ -258,4 +232,14 @@ public interface MzyRequestMapper {
             "</when>",
             "</script>"})
     List<Map<String,Object>> selectRequestByDateAndDeptAndDoctor(@Param("requestDay") Date requestDay, @Param("ampms") List<String> ampms, @Param("unitCode") String unitCode, @Param("doctorCode") String doctorCode);
+
+    /**
+     * 删除号表数据
+     * @param id
+     * @return
+     */
+
+    @Delete("delete from mzy_request_new where id=#{id,jdbcType=BIGINT}")
+    int  deleteMzyRequestById(@Param("id") Long id);
+
 }

+ 10 - 1
src/main/java/cn/hnthyy/thmz/service/his/MzyRequestService.java

@@ -95,7 +95,7 @@ public interface MzyRequestService {
      *
      * @return
      */
-    int saveRequest(List<MzyRequest> mzyRequests, String opId);
+    int saveRequest(List<MzyRequest> mzyRequests, String opId) throws MzException;
 
 
     /**
@@ -145,4 +145,13 @@ public interface MzyRequestService {
      */
     List<Map<String,Object>> queryRequestByDateAndDeptAndDoctor(Date requestDay,List<String> ampms, String unitCode, String doctorCode);
 
+
+
+    /**
+     * 删除号表数据
+     * @param id
+     * @return
+     */
+    int  removeMzyRequestById(Long id);
+
 }

+ 19 - 5
src/main/java/cn/hnthyy/thmz/service/impl/his/MzyRequestServiceImpl.java

@@ -137,8 +137,9 @@ public class MzyRequestServiceImpl implements MzyRequestService {
 
     @Override
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
-    public int saveRequest(List<MzyRequest> mzyRequests, String opId) {
+    public int saveRequest(List<MzyRequest> mzyRequests, String opId) throws MzException {
         Date now = new Date();
+        int index = 1;
         for (MzyRequest m : mzyRequests) {
             if (m != null) {
                 if (m.getChargeType() == null) {
@@ -150,6 +151,9 @@ public class MzyRequestServiceImpl implements MzyRequestService {
                 if(m.getDoctorCode()==null){
                     m.setDoctorCode("");
                 }
+                if(m.getGroupCode()==null){
+                    m.setGroupCode("");
+                }
                 m.setOpId(opId);
                 m.setSysDate(now);
                 if (m.getId() != null) {
@@ -159,14 +163,19 @@ public class MzyRequestServiceImpl implements MzyRequestService {
                     m.setUnitCodeOld(dbMzyRequest.getUnitCode());
                     m.setDoctorCodeOld(dbMzyRequest.getDoctorCode());
                     m.setChargeTypeOld(dbMzyRequest.getChargeType());
-                    mzyRequestMapper.updateMzyRequestNew(m);
-                    mzyRequestMapper.updateMzyRequestOld(m);
+                    int num= mzyRequestMapper.updateMzyRequestNew(m);
+                    if(num<=0){
+                        throw new MzException("第【"+index+"】条数据重复,请确认!");
+                    }
                 } else {
                     m.setGroupCode("");
                     m.setDelFlag(YesNoEnum.NO.code);
-                    mzyRequestMapper.insertRequest(m);
-                    mzyRequestMapper.insertOldRequest(m);
+                   int num=mzyRequestMapper.insertRequest(m);
+                   if(num<=0){
+                        throw new MzException("第【"+index+"】条数据重复,请确认!");
+                    }
                 }
+                index++;
             }
         }
         return mzyRequests.size();
@@ -196,4 +205,9 @@ public class MzyRequestServiceImpl implements MzyRequestService {
     public List<Map<String,Object>> queryRequestByDateAndDeptAndDoctor(Date requestDay, List<String> ampms, String unitCode, String doctorCode) {
         return mzyRequestMapper.selectRequestByDateAndDeptAndDoctor(requestDay,ampms,unitCode,doctorCode);
     }
+
+    @Override
+    public int removeMzyRequestById(Long id) {
+        return mzyRequestMapper.deleteMzyRequestById(id);
+    }
 }

+ 52 - 0
src/main/resources/static/js/request.js

@@ -233,6 +233,7 @@ function initSourceList() {
                 valign: 'middle',
                 formatter: function (value, row, index) {
                     var str = '<button type="button" class="btn btn-primary  btn-sm" onclick="updateRequest(' + row.id + ')">编辑</button>';
+                    str += '<button type="button" class="btn btn-danger  btn-sm" onclick="deleteRequest(' + row.id + ')">删除</button>';
                     return [str].join('');
                 }
             },
@@ -416,6 +417,7 @@ function initNewListCommon(url, newParams) {
                 valign: 'middle',
                 formatter: function (value, row, index) {
                     var str = '<button type="button" class="btn btn-primary  btn-sm" onclick="updateRequestByIndex(' + index + ')">编辑</button>';
+                    str+= '<button type="button" class="btn btn-danger  btn-sm" onclick="deleteRequestByIndex(' + index + ')">删除</button>';
                     return [str].join('');
                 }
             },
@@ -857,6 +859,40 @@ function updateRequest(id) {
     });
 }
 
+
+/**
+ * 删除号表信息
+ * @param id
+ */
+function deleteRequest(id) {
+    if (!confirm("确认要删除当前操作的号表信息吗?")) {
+        return;
+    }
+    $.ajax({
+        type: "GET",
+        url: '/thmz/deleteRequestById?id=' + id,
+        dataType: "json",
+        headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
+        success: function (res) {
+            if (res == '401' || res == 401) {
+                window.location.href = '/thmz/login/view'
+                return;
+            }
+            if (res.code == 0) {
+                successMesage(res);
+                var tableId = 'tb_table';
+                if (showTwoTable) {
+                    tableId = 'tb_table_1';
+                }
+                $('#' + tableId).bootstrapTable("refresh");
+            }else {
+                errorMesage(res);
+            }
+        }
+    });
+}
+
+
 /**
  * 临时新号表修改
  * @param index
@@ -880,3 +916,19 @@ function updateRequestByIndex(index) {
     $("#editModal").modal();
 }
 
+
+
+
+/**
+ * 临时新号表删除
+ * @param index
+ */
+function deleteRequestByIndex(index) {
+    if (!confirm("确认要删除当前操作的号表信息吗?")) {
+        return;
+    }
+    tempData.splice(index, 1);
+    var realParams = JSON.parse('{"mzyRequests":""}');
+    realParams.mzyRequests = tempData;
+    initNewListCommon("/thmz/formatRequest", realParams);
+}

+ 2 - 2
src/main/resources/static/js/schedule-of-medical-apply.js

@@ -159,9 +159,9 @@ function initList() {
                 formatter: function (value, row, index) {
                     var str = '';
                     if(row.status==0){
-                        str = '<button type="button" class="btn btn-primary  btn-sm" onclick="applyRequest(' + row.id + ')">预约</button>';
+                        str = '<button type="button" class="btn btn-success  btn-sm" onclick="applyRequest(' + row.id + ')">预约</button>';
                     }else  if(row.status==1){
-                        str = '<button type="button" class="btn btn-primary  btn-sm" onclick="cancelApplyRequest(' + row.id + ')">取消预约</button>';
+                        str = '<button type="button" class="btn btn-warning  btn-sm" onclick="cancelApplyRequest(' + row.id + ')">取消预约</button>';
                     }
                     return [str].join('');
                 }

+ 3 - 3
src/main/resources/static/js/schedule-of-medical.js

@@ -185,10 +185,10 @@ function initList() {
                     var str="";
                     if(row.status==0){
                         str += '<button type="button" class="btn btn-primary  btn-sm" onclick="updateRequest(' + row.id + ')">编辑</button>';
-                        str += '<button type="button" class="btn btn-primary  btn-sm" onclick="removeRequest(' + row.id + ')">删除</button>';
+                        str += '<button type="button" class="btn btn-danger  btn-sm" onclick="removeRequest(' + row.id + ')">删除</button>';
                     }else  if(row.status==1){
-                        str += '<button type="button" class="btn btn-primary  btn-sm" onclick="confirmRequest(' + row.id + ')">确认</button>';
-                        str += '<button type="button" class="btn btn-primary  btn-sm" onclick="rejectApplyRequest(' + row.id + ')">驳回</button>';
+                        str += '<button type="button" class="btn btn-success  btn-sm" onclick="confirmRequest(' + row.id + ')">确认</button>';
+                        str += '<button type="button" class="btn btn-warning  btn-sm" onclick="rejectApplyRequest(' + row.id + ')">驳回</button>';
                     }
                     return [str].join('');
                 }