Browse Source

微信端增加提交疫苗接种信息

peiguo 3 years ago
parent
commit
1d50833819

+ 104 - 49
whepi-ui/templates/home/ribao.ftl

@@ -642,7 +642,8 @@
                 </div>
             </div>
             <div id="rb_nav5" class="weui-tab__bd-item weui-cell ">
-
+                <input id="vacId" type="text" hidden="hidden" <#if vaccine?? && vaccine.vacId??>value="${vaccine.vacId}"
+                       <#else>value="0"</#if>/>
                 <div style="display:flex; display: -webkit-flex;flex-direction: row; -webkit-flex-direction: row;justify-content: space-between; -webkit-justify-content: space-between;margin-top: 5px;">
                     <div style="color: gray;height: 30px; line-height: 30px; flex: 8;-webkit-flex: 8;">
                         是否接种新冠疫苗
@@ -650,75 +651,129 @@
                     <div class="weui-cells_checkbox" style="flex: 7;-webkit-flex: 7;">
                         <label class="weui-radio weui-cell_active weui-check__label" for="s53"
                                style="padding: 10px 0 10px 10px;">
-                            <input type="radio" name="inoculate" value="1" class="weui-check" id="s53"
+                            <input type="radio" name="inoculate" value="1"
+                                   <#if vaccine?? && vaccine.inoculateStatus == 1>checked="checked"</#if>
+                                   class="weui-check" id="s53"
                                    style="width: 10%"/>
                             <i class="weui-icon-checked"></i>是
                         </label>
                         <label class="weui-radio weui-cell_active weui-check__label" for="s52"
                                style="padding: 10px 0 10px 10px;">
-                            <input type="radio" name="inoculate" value="0" class="weui-check" id="s52"
+                            <input type="radio" name="inoculate" value="0"
+                                   <#if vaccine?? && vaccine.inoculateStatus == 0>checked="checked"</#if>
+                                   class="weui-check" id="s52"
                                    style="width: 10%"/>
                             <i class="weui-icon-checked"></i>否
                         </label>
                     </div>
                 </div>
-                <div id="not_inoculate_view"
+                <div id="not_inoculate" hidden="hidden"
                      style="display:flex; display: -webkit-flex;flex-direction: row; -webkit-flex-direction: row;justify-content: space-between; -webkit-justify-content: space-between;margin-top: 5px;">
                     <div style="color: gray;height: 30px; line-height: 30px;width: 35%;">未接种原因</div>
-                    <textarea id="notInoculate" class="weui-textarea" placeholder="输入内容(300字内)" rows="2"
-                              style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; margin-top: 5px;"></textarea>
-                </div>
-<#--                <div id="weui-uploader"-->
-<#--                     style="display:flex; display: -webkit-flex;flex-direction: row; -webkit-flex-direction: row;justify-content: space-between; -webkit-justify-content: space-between;margin-top: 5px;">-->
-<#--                    <div style="color: gray;height: 30px; line-height: 30px;width: 35%;">图片上传</div>-->
-
-<#--                    <div class="weui-uploader__bd">-->
-<#--                        <div class="weui-uploader__input-box">-->
-<#--                            <input id="uploaderInput" class="weui-uploader__input" type="file" accept="image/*"-->
-<#--                                   multiple/>-->
-<#--                        </div>-->
-<#--                    </div>-->
-<#--                </div>-->
-
+                    <textarea id="reason" class="weui-textarea" placeholder="输入内容(300字内)" rows="4"
+                              style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; margin-top: 5px;"><#if vaccine?? && vaccine.reason??>${vaccine.reason}</#if></textarea>
+                    <#--                <div id="weui-uploader"-->
+                    <#--                     style="display:flex; display: -webkit-flex;flex-direction: row; -webkit-flex-direction: row;justify-content: space-between; -webkit-justify-content: space-between;margin-top: 5px;">-->
+                    <#--                    <div style="color: gray;height: 30px; line-height: 30px;width: 35%;">图片上传</div>-->
 
-                <div id="inoculate_type_view"
-                     style="display:flex; display: -webkit-flex;flex-direction: row; -webkit-flex-direction: row;justify-content: space-between; -webkit-justify-content: space-between;margin-top: 5px;">
-                    <div style="color: gray;height: 30px; line-height: 30px; width: 45%;">接种疫苗类别</div>
-                    <input id="inoculate_type" class="weui-input" autofocus="" type="text"
-                           placeholder="请选择"
-                           maxlength="20"
-                           style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 30px;"/>
+                    <#--                    <div class="weui-uploader__bd">-->
+                    <#--                        <div class="weui-uploader__input-box">-->
+                    <#--                            <input id="uploaderInput" class="weui-uploader__input" type="file" accept="image/*"-->
+                    <#--                                   multiple/>-->
+                    <#--                        </div>-->
+                    <#--                    </div>-->
+                    <#--                </div>-->
                 </div>
-                <div id="inoculate_type_view"
-                     style="display:flex; display: -webkit-flex;flex-direction: row; -webkit-flex-direction: row;justify-content: space-between; -webkit-justify-content: space-between;margin-top: 5px;">
-                    <div style="color: gray;height: 30px; line-height: 30px; width: 35%;">新冠疫苗接种记录</div>
+                <div id="yes_inoculate" hidden="hidden">
+                    <div style="display:flex; display: -webkit-flex;flex-direction: row; -webkit-flex-direction: row;justify-content: space-between; -webkit-justify-content: space-between;margin-top: 5px;">
+                        <div style="color: gray;height: 30px; line-height: 30px; width: 45%;">接种疫苗类别</div>
+                        <input id="vaccine_type" class="weui-input" autofocus="" type="text"
+                               <#if vaccine?? && vaccine.vaccineType == 1>value="腺病毒疫苗"
+                               <#elseif vaccine?? && vaccine.vaccineType == 2>value="灭活疫苗"
+                               <#elseif vaccine?? && vaccine.vaccineType == 3>value="重组亚单位疫苗"</#if>
+                               placeholder="请选择"
+                               maxlength="20"
+                               style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 30px;"/>
+                    </div>
+                    <div class="weui-loadmore weui-loadmore_line inoculate_yes"
+                         style="margin: 20px 0 0 0;width: 100%;height: 20px">
+                        <span class="weui-loadmore__tips">新冠疫苗接种记录</span>
+                    </div>
+                    <div class="weui-loadmore weui-loadmore_line inoculate_yes"
+                         style="margin: 20px 0 0 0;width: 100%;height: 20px">
+                        <span class="weui-loadmore__tips">第一剂</span>
+                    </div>
+                    <div class="inoculate_time_view"
+                         style="display:flex; display: -webkit-flex;flex-direction: row; -webkit-flex-direction: row;justify-content: space-between; -webkit-justify-content: space-between;margin-top: 5px;">
+                        <div style="color: gray;height: 30px; line-height: 30px; width: 35%;">接种日期</div>
+                        <div class="weui-cell__ft"></div>
+                        <input id="first_time" class="weui-input inoculate_time" type="text"
+                               placeholder="请选择"
+                               style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 30px;"/>
+                    </div>
+                    <div class="inoculate_hospital_view"
+                         style="display:flex; display: -webkit-flex;flex-direction: row; -webkit-flex-direction: row;justify-content: space-between; -webkit-justify-content: space-between;margin-top: 5px;">
+                        <div style="color: gray;height: 30px;line-height: 30px; width: 35%;">接种医院</div>
+                        <input id="first_hospital" class="weui-input" autofocus="" type="text"
+                               <#if vaccine?? && vaccine.firstHospital??>value="${vaccine.firstHospital}"</#if>
+                               placeholder="请选择"
+                               maxlength="20"
+                               style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 30px;"/>
+                    </div>
+                    <div class="weui-loadmore weui-loadmore_line inoculate_yes"
+                         style="margin: 20px 0 0 0;width: 100%;height: 20px">
+                        <span class="weui-loadmore__tips">第二剂</span>
+                    </div>
+                    <div class="inoculate_time_view"
+                         style="display:flex; display: -webkit-flex;flex-direction: row; -webkit-flex-direction: row;justify-content: space-between; -webkit-justify-content: space-between;margin-top: 5px;">
+                        <div style="color: gray;height: 30px; line-height: 30px; width: 35%;">接种日期</div>
+                        <div class="weui-cell__ft"></div>
+                        <input id="second_time" class="weui-input inoculate_time" type="text"
+                               placeholder="请选择"
+                               style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 30px;"/>
+                    </div>
+                    <div class="inoculate_hospital_view"
+                         style="display:flex; display: -webkit-flex;flex-direction: row; -webkit-flex-direction: row;justify-content: space-between; -webkit-justify-content: space-between;margin-top: 5px;">
+                        <div style="color: gray;height: 30px;line-height: 30px; width: 35%;">接种医院</div>
+                        <input id="second_hospital" class="weui-input" autofocus="" type="text"
+                               <#if vaccine?? && vaccine.secondHospital??>value="${vaccine.secondHospital}"</#if>
+                               placeholder="请选择"
+                               maxlength="20"
+                               style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 30px;"/>
+                    </div>
+                    <div class="weui-loadmore weui-loadmore_line inoculate_yes"
+                         style="margin: 20px 0 0 0;width: 100%;height: 20px">
+                        <span class="weui-loadmore__tips">第三剂</span>
+                    </div>
+                    <div class="inoculate_time_view"
+                         style="display:flex; display: -webkit-flex;flex-direction: row; -webkit-flex-direction: row;justify-content: space-between; -webkit-justify-content: space-between;margin-top: 5px;">
+                        <div style="color: gray;height: 30px; line-height: 30px; width: 35%;">接种日期</div>
+                        <div class="weui-cell__ft"></div>
+                        <input id="third_time" class="weui-input inoculate_time" type="text"
+                               placeholder="请选择"
+                               style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 30px;"/>
+                    </div>
+                    <div class="inoculate_hospital_view"
+                         style="display:flex; display: -webkit-flex;flex-direction: row; -webkit-flex-direction: row;justify-content: space-between; -webkit-justify-content: space-between;margin-top: 5px;">
+                        <div style="color: gray;height: 30px;line-height: 30px; width: 35%;">接种医院</div>
+                        <input id="third_hospital" class="weui-input" autofocus="" type="text"
+                               <#if vaccine?? && vaccine.thirdHospital??>value="${vaccine.thirdHospital}"</#if>
+                               placeholder="请选择"
+                               maxlength="20"
+                               style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 30px;"/>
+                    </div>
                 </div>
-
                 <div class="weui-loadmore weui-loadmore_line inoculate_yes"
                      style="margin: 20px 0 0 0;width: 100%;height: 20px">
-                    <span class="weui-loadmore__tips">第一剂</span>
-                </div>
-                <div id="inoculate_first_view"
-                     style="display:flex; display: -webkit-flex;flex-direction: row; -webkit-flex-direction: row;justify-content: space-between; -webkit-justify-content: space-between;margin-top: 5px;">
-                    <div style="color: gray;height: 30px; line-height: 30px; width: 35%;">接种日期</div>
-                    <div class="weui-cell__ft"></div>
-                    <input id="inoculate_first" onclick="setTime()" class="weui-input inoculate_time" autofocus="" type="text"
-                           placeholder="请选择"
-                           style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 30px;"/>
-                </div>
-                <div id="js_input_user_jirou_view"
-                     style="display:flex; display: -webkit-flex;flex-direction: row; -webkit-flex-direction: row;justify-content: space-between; -webkit-justify-content: space-between;margin-top: 5px;">
-                    <div style="color: gray;height: 30px;line-height: 30px; width: 35%;">接种医院</div>
-                    <input id="js_input_user_jirou" class="weui-input" autofocus="" type="text"
-                           placeholder="请选择"
-                           maxlength="20"
-                           style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 30px;"/>
-                </div>
+                    <div class="weui-form__opr-area">
+                        <a class="weui-btn weui-btn_primary" href="javascript:;"
+                           onclick="inoculateVacc();">提交</a>
+                    </div>
 
 
+                </div>
             </div>
         </div>
     </div>
-</div>
 
 

+ 153 - 35
whepi-ui/templates/home/ribao.js

@@ -470,7 +470,7 @@ function ribao_init() {
             }]
     });
 
-    $("#inoculate_type").select({
+    $("#vaccine_type").select({
         title: "请选择接种疫苗类别",
         items: [
             {
@@ -486,27 +486,63 @@ function ribao_init() {
                 value: "3",
             }]
     });
-    // $("#inoculate_first").datetimePicker({
-    //     times: function () {
-    //         return [{values: ['&nbsp;']}];
-    //     }, value: new Date().format("yyyy-MM-dd") + ' ',
-    // })
-    $('.inoculate_time').click(function(event) {
-        var _this = this;
-        weui.datePicker({
-            start: new Date(),
-            end: 2030,
-            defaultValue: [new Date().getFullYear(), new Date().getMonth()+1, new Date().getDate()],
-            onConfirm: function(result){
-                // 二级调用:时间
-                $('.ma_expect_date_picker .weui-picker').on('animationend webkitAnimationEnd', function() {
-                    show_expect_time_picker(_this, result);
-                });
-            },
-            id: 'ma_expect_date',
-            className: 'ma_expect_date_picker'
-        });
-    });
+    let firstTime = new Date().format("yyyy-MM-dd") + ' ';
+    <#if vaccine?? && vaccine.firstTime??>firstTime="${vaccine.firstTime?string("yyyy-MM-dd")}" + " "</#if>
+    $("#first_time").datetimePicker({
+        times: function () {
+            return [{values: ['']}];
+        },
+        onClose: function (picker) {
+            if (!picker.value) {
+                picker.setValue([new Date().getFullYear() + '', (new Date().getMonth() + 1) + '', new Date().getDate() + '', ''])
+            }
+        },
+        value: firstTime,
+    })
+    let secondTime = new Date().format("yyyy-MM-dd") + ' ';
+    <#if vaccine?? && vaccine.secondTime??>secondTime="${vaccine.secondTime?string("yyyy-MM-dd")}" + " "</#if>
+    $("#second_time").datetimePicker({
+        times: function () {
+            return [{values: ['']}];
+        },
+        onClose: function (picker) {
+            if (!picker.value) {
+                picker.setValue([new Date().getFullYear() + '', (new Date().getMonth() + 1) + '', new Date().getDate() + '', ''])
+            }
+        },
+        value: secondTime,
+    })
+    let thirdTime = new Date().format("yyyy-MM-dd") + ' ';
+    <#if vaccine?? && vaccine.thirdTime??>thirdTime="${vaccine.thirdTime?string("yyyy-MM-dd")}" + " "</#if>
+    $("#third_time").datetimePicker({
+        times: function () {
+            return [{values: ['']}];
+        },
+        onClose: function (picker) {
+            if (!picker.value) {
+                picker.setValue([new Date().getFullYear() + '', (new Date().getMonth() + 1) + '', new Date().getDate() + '', ''])
+            }
+        },
+        value: thirdTime,
+    })
+
+    // $('.inoculate_time').click(function(event) {
+    //     console.log($('#inoculate_first').datetimePicker)
+    //     // var _this = this;
+    //     // $(this).datePicker({
+    //     //     start: new Date(),
+    //     //     end: 2030,
+    //     //     defaultValue: [new Date().getFullYear(), new Date().getMonth()+1, new Date().getDate()],
+    //     //     onConfirm: function(result){
+    //     //         // 二级调用:时间
+    //     //         $('.ma_expect_date_picker .weui-picker').on('animationend webkitAnimationEnd', function() {
+    //     //             show_expect_time_picker(_this, result);
+    //     //         });
+    //     //     },
+    //     //     id: 'ma_expect_date',
+    //     //     className: 'ma_expect_date_picker'
+    //     // });
+    // });
     // updateSuspected({
     //   userName : 'www',
     //   grender : 2,
@@ -2802,6 +2838,18 @@ function initRadioEvent() {
         var state = this.value
         resetTiwen(state == 0)
     })
+
+    let inoculateStatus = $('input[name="inoculate"]:checked').val();
+    if (inoculateStatus == undefined) {
+        $("#yes_inoculate").hide('fast');
+        $("#not_inoculate").hide('fast');
+    } else {
+        resetInoculate(inoculateStatus == 0)
+    }
+    //接种疫苗
+    $('input[name="inoculate"]').on('change', function () {
+        resetInoculate(this.value == 0)
+    })
 }
 
 function resetTiwen(bool) {
@@ -2814,23 +2862,93 @@ function resetTiwen(bool) {
     }
 }
 
+function resetInoculate(bool) {
+    if (bool) {
+        $("#yes_inoculate").hide('fast');
+        $("#not_inoculate").show('fast');
+    } else {
+        $("#yes_inoculate").show('fast');
+        $("#not_inoculate").hide('fast');
+    }
+}
+
+function inoculateVacc() {
+    let inoculateStatus = $('input[name="inoculate"]:checked').val();
+    let date = {};
+    date.vacId = $("#vacId").val();
+    date.userId = $("#userId").val();
+    date.inoculateStatus = inoculateStatus;
+    if (inoculateStatus == 0) {
+        date.reason = $("#reason").val().trim();
+        if (date.reason == "") {
+            $.alert("未接种疫苗请提交未接种原因")
+            return;
+        }
+        if (date.reason.length > 300) {
+            $.alert("未接种疫苗原因不能超过300字")
+            return;
+        }
+        $("#vaccine_type").val("");
+        $("#first_time").val(new Date().format("yyyy-MM-dd") + ' ');
+        $("#firstHospital").val("");
+        $("#second_time").val(new Date().format("yyyy-MM-dd") + ' ');
+        $("#secondHospital").val("");
+        $("#third_time").val(new Date().format("yyyy-MM-dd") + ' ');
+        $("#thirdHospital").val("");
+    } else if (inoculateStatus == 1) {
+        let vaccineType = $("#vaccine_type").val();
+        if (!vaccineType || vaccineType == "") {
+            $.alert("请选择疫苗接种类型")
+            return;
+        }
+        if (vaccineType == "腺病毒疫苗") {
+            date.vaccineType = 1
+        } else if (vaccineType == "灭活疫苗") {
+            date.vaccineType = 2
+        } else if (vaccineType == "重组亚单位疫苗") {
+            date.vaccineType = 3
+        }
+        date.firstTime = $("#first_time").val();
+        date.firstHospital = $("#first_hospital").val().trim();
+        date.secondTime = $("#second_time").val();
+        date.secondHospital = $("#second_hospital").val().trim();
+        date.thirdTime = $("#third_time").val();
+        date.thirdHospital = $("#third_hospital").val().trim();
+        $("#reason").val("");
+    } else {
+        $.alert("请选择是否接种新冠疫苗")
+        return;
+    }
+    $.ajax({
+        url: '/home/addVaccine',
+        type: "post",
+        dataType: "json",
+        contentType: "application/json",
+        data: JSON.stringify(date),
+        success: function (data) {
+            if (data.success) {
+                $.alert("提交成功");
+            }
+        },
+    });
+}
 
-Date.prototype.format = function(fmt) {
+Date.prototype.format = function (fmt) {
     var o = {
-        "M+" : this.getMonth()+1,                 //月份
-        "d+" : this.getDate(),                    //日
-        "h+" : this.getHours(),                   //小时
-        "m+" : this.getMinutes(),                 //分
-        "s+" : this.getSeconds(),                 //秒
-        "q+" : Math.floor((this.getMonth()+3)/3), //季度
-        "S"  : this.getMilliseconds()             //毫秒
+        "M+": this.getMonth() + 1,                 //月份
+        "d+": this.getDate(),                    //日
+        "h+": this.getHours(),                   //小时
+        "m+": this.getMinutes(),                 //分
+        "s+": this.getSeconds(),                 //秒
+        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
+        "S": this.getMilliseconds()             //毫秒
     };
-    if(/(y+)/.test(fmt)) {
-        fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
+    if (/(y+)/.test(fmt)) {
+        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
     }
-    for(var k in o) {
-        if(new RegExp("("+ k +")").test(fmt)){
-            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
+    for (var k in o) {
+        if (new RegExp("(" + k + ")").test(fmt)) {
+            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
         }
     }
     return fmt;

+ 14 - 0
whepi-web/src/main/java/com/bofeng/dao/VaccineMapper.java

@@ -0,0 +1,14 @@
+package com.bofeng.dao;
+
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import com.bofeng.entity.Vaccine;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+@Mapper
+public interface VaccineMapper extends BaseMapper<Vaccine> {
+
+    @Select("select * from ms_vaccine where user_id = #{userId}")
+    Vaccine selectByUserId(@Param("userId") Long userId);
+}

+ 90 - 0
whepi-web/src/main/java/com/bofeng/entity/Vaccine.java

@@ -0,0 +1,90 @@
+package com.bofeng.entity;
+
+import com.baomidou.mybatisplus.annotations.TableField;
+import com.baomidou.mybatisplus.annotations.TableId;
+import com.baomidou.mybatisplus.annotations.TableName;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/**
+ * 疫苗接种表
+ */
+@Getter
+@Setter
+@TableName("ms_vaccine")
+public class Vaccine {
+
+    @TableId("vac_id")
+    private Long vacId;
+
+    @TableField("user_id")
+    private Long userId;
+
+    /**
+     * 接种状态 0:未接种, 1:已接种
+     */
+    @TableField("inoculate_status")
+    private Integer inoculateStatus;
+
+    /**
+     * 疫苗类别
+     */
+    @TableField("vaccine_type")
+    private Integer vaccineType;
+
+    /**
+     * 未接种原因
+     */
+    @TableField("reason")
+    private String reason;
+
+    /**
+     * 第一剂接种日期
+     */
+    @TableField("first_time")
+    private Date firstTime;
+
+    /**
+     * 第一剂接种医院
+     */
+    @TableField("first_hospital")
+    private String firstHospital;
+
+    /**
+     * 第二剂接种日期
+     */
+    @TableField("second_time")
+    private Date secondTime;
+
+    /**
+     * 第二剂接种医院
+     */
+    @TableField("second_hospital")
+    private String secondHospital;
+
+    /**
+     * 第三剂接种日期
+     */
+    @TableField("third_time")
+    private Date thirdTime;
+
+    /**
+     * 第三剂接种医院
+     */
+    @TableField("third_hospital")
+    private String thirdHospital;
+
+    /**
+     * 新增时间
+     */
+    @TableField("time_create")
+    private Date timeCreate;
+
+    /**
+     * 新增时间
+     */
+    @TableField("time_update")
+    private Date timeUpdate;
+}

+ 34 - 4
whepi-web/src/main/java/com/bofeng/service/MsReportService.java

@@ -5,15 +5,11 @@ import com.baomidou.mybatisplus.toolkit.IdWorker;
 import com.bofeng.dao.*;
 import com.bofeng.entity.*;
 import com.yvan.platform.Conv;
-import io.swagger.models.auth.In;
-import javassist.expr.NewArray;
-import org.apache.commons.lang3.tuple.Triple;
 import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.servlet.ModelAndView;
 
 import java.math.BigDecimal;
 import java.text.ParseException;
@@ -38,6 +34,8 @@ public class MsReportService {
     private MsTripMapper msTripMapper;
     @Autowired
     private UptownUnitMapper uptownUnitMapper;
+    @Autowired
+    private VaccineMapper vaccineMapper;
 
     public List<MsSuspected> getByReportId(Long reportId) {
         List<MsSuspected> listSuspected = null;
@@ -776,4 +774,36 @@ public class MsReportService {
         return "";
     }
 
+    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
+    public int addVaccine(Vaccine vaccine) {
+        Date now = new Date();
+        Vaccine v = vaccineMapper.selectByUserId(vaccine.getUserId());
+        if (v != null && v.getVacId() != 0) {
+            vaccine.setVacId(v.getVacId());
+        }
+        changeVaccine(vaccine);
+        if (vaccine.getVacId() == 0) {
+            vaccine.setVacId(IdWorker.getId());
+            vaccine.setTimeCreate(now);
+            vaccine.setTimeUpdate(now);
+            return vaccineMapper.insert(vaccine);
+        } else {
+            vaccine.setTimeUpdate(now);
+            return vaccineMapper.updateById(vaccine);
+        }
+    }
+
+    private void changeVaccine(Vaccine vaccine) {
+        if (vaccine.getInoculateStatus() == 0) {
+            vaccine.setVaccineType(0);
+            vaccine.setFirstTime(null);
+            vaccine.setFirstHospital("");
+            vaccine.setSecondTime(null);
+            vaccine.setSecondHospital("");
+            vaccine.setThirdTime(null);
+            vaccine.setThirdHospital("");
+        } else if (vaccine.getInoculateStatus() == 1) {
+            vaccine.setReason("");
+        }
+    }
 }

+ 11 - 1
whepi-web/src/main/java/com/bofeng/wx/controller/MsReportController.java

@@ -1,7 +1,10 @@
 package com.bofeng.wx.controller;
 
 
-import com.bofeng.entity.*;
+import com.bofeng.entity.MsReport;
+import com.bofeng.entity.MsSuspected;
+import com.bofeng.entity.MsTripDet;
+import com.bofeng.entity.Vaccine;
 import com.bofeng.service.MsReportService;
 import com.bofeng.service.MsSuspectedService;
 import com.bofeng.service.MsTripService;
@@ -13,6 +16,7 @@ import com.yvan.springmvc.HttpParameterParser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
@@ -157,6 +161,12 @@ public class MsReportController {
         return ModelOps.newFail("上报错误");
     }
 
+    //提交疫苗接种信息
+    @PostMapping("/home/addVaccine")
+    public ModelOps addVaccine(HttpServletRequest request, @RequestBody Vaccine vaccine) {
+        return ModelOps.newSuccess(msReportService.addVaccine(vaccine));
+    }
+
     //根据日期获取家人
     @GetMapping("/home/home/queryRibaoReportDate")
     public Model<List<MsSuspected>> queryRibaoReportDate(@Pd(name = "reportDate") String reportDate, @Pd(name = "userCreate") Long userCreate) {

+ 4 - 0
whepi-web/src/main/java/com/bofeng/wx/controller/UserOpenController.java

@@ -59,6 +59,8 @@ public class UserOpenController {
     private MsReportService msReportService;
     @Autowired
     private RbMapper rbMapper;
+    @Autowired
+    private VaccineMapper vaccineMapper;
 
     @ApiOperation("登陆首页")
     @ApiImplicitParams({@ApiImplicitParam(name = "userId", value = "用户ID", required = false, dataType = "Long", paramType = "query"),
@@ -100,6 +102,8 @@ public class UserOpenController {
                 }
             }
 
+            // 新冠疫苗接种情况
+            model.put("vaccine", vaccineMapper.selectByUserId(userId));
 
             if (list.size() == 0) {
                 return new ModelAndView("/user/home.ftl", model);