Ver código fonte

Merge branch 'dev' of liubing/wlyy2.0 into dev

liubing 3 anos atrás
pai
commit
ed28202416

+ 17 - 0
common/common-entity/sql记录

@ -867,3 +867,20 @@ CREATE TABLE `base_course_sales_order_record` (
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='课程销售订单记录表';
-- 2021-05-18
create table base_org_notice(
	id varchar(50) not null,
	org_code varchar(50) default null COMMENT '机构code',
	org_name varchar(50) default null COMMENT '机构名称',
	status tinyint(1) DEFAULT NULL COMMENT '状态(1待发布,2已发布)',
	del tinyint(1) DEFAULT '1' COMMENT '删除标志(1正常,0删除)',
	title VARCHAR(50) default null comment '通知标题',
	content text default null comment '通知内容',
	img VARCHAR(1000) default null COMMENT '附件',
	notice_time datetime default null COMMENT '通知时间',
	create_time datetime default null,
	PRIMARY KEY(id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='机构通知表';
ALTER table base_org_notice add column create_user varchar(50) DEFAULT NULL

+ 100 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/message/OrgNoticeDO.java

@ -0,0 +1,100 @@
package com.yihu.jw.entity.care.message;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Bing on 2021/5/18.
 * 通知实体
 */
@Entity
@Table(name="base_org_notice")
public class OrgNoticeDO extends UuidIdentityEntityWithCreateTime {
    private String orgCode ;
    private String orgName ;
    private Integer status ;//
    private Integer del ;
    private String title ;//通知标题
    private String content;//通知内容
    private String img ; //附件
    private Date noticeTime ;//通知时间
    private String createUser;
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getImg() {
        return img;
    }
    public void setImg(String img) {
        this.img = img;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getNoticeTime() {
        return noticeTime;
    }
    public void setNoticeTime(Date noticeTime) {
        this.noticeTime = noticeTime;
    }
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
}

+ 11 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/message/OrgNoticeDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.care.dao.message;
import com.yihu.jw.entity.care.message.OrgNoticeDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/5/18.
 */
public interface OrgNoticeDao extends PagingAndSortingRepository<OrgNoticeDO,String>, JpaSpecificationExecutor<OrgNoticeDO> {
}

+ 14 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/message/UserNoticeDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.care.dao.message;
import com.yihu.jw.entity.base.notice.UserNoticeDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 用户公告通知
 * @author yeshijie on 2018/9/30.
 */
public interface UserNoticeDao extends PagingAndSortingRepository<UserNoticeDO, String>, JpaSpecificationExecutor<UserNoticeDO> {
    UserNoticeDO findByNoticeIdAndUserIdAndDel(String noticeId,String userId,Integer del);
}

+ 33 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java

@ -133,4 +133,37 @@ public class DoctorEndpoint extends EnvelopRestEndpoint {
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "getTeacherChildren")
    @ApiOperation(value = "教师通讯录-我的儿童")
    public PageEnvelop getTeacherChildren(
            @ApiParam(name = "doctor", value = "doctor")
            @RequestParam(value = "doctor",required = true) String doctor,
            @ApiParam(name = "searchType", value = "0未入学 1已入学")
            @RequestParam(value = "searchType",defaultValue = "0") int searchType,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size
    ){
        try {
            return doctorService.getTeacherChildren(doctor,searchType,page,size);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "getTeacherChildrenCount")
    @ApiOperation(value = "教师通讯录-我的儿童数量获取")
    public Object getTeacherChildrenCount(
            @ApiParam(name = "doctor", value = "doctor")
            @RequestParam(value = "doctor",required = true) String doctor){
        try {
            return doctorService.getTeacherChildrenCount(doctor);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败");
        }
    }
}

+ 3 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/ChildrenExaminationEndpoint.java

@ -1,4 +1,4 @@
package com.yihu.jw.care.endpoint.patient;
package com.yihu.jw.care.endpoint.exam;
import com.yihu.jw.care.service.exam.ChildrenExaminationService;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -14,8 +14,8 @@ import org.springframework.web.bind.annotation.*;
 * Created by Bing on 2021/5/18.
 */
@RestController
@RequestMapping("patient/examationRecord")
@Api(description = "儿童体检")
@RequestMapping("patient/examinationRecord")
@Api(description = "居民端儿童体检")
public class ChildrenExaminationEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private ChildrenExaminationService examinationService;

+ 81 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/exam/DoctorChildrenExaminationEndpoint.java

@ -0,0 +1,81 @@
package com.yihu.jw.care.endpoint.exam;
import com.yihu.jw.care.service.exam.ChildrenExaminationService;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Bing on 2021/5/19.
 */
@RestController
@RequestMapping("doctor/examinationRecord")
@Api(description = "医生端-儿童体检")
public class DoctorChildrenExaminationEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private ChildrenExaminationService examinationService;
    @PostMapping("newRecord")
    @ApiOperation("居民居家自建记录添加")
    public ObjEnvelop newRecord(@ApiParam(name="patient",value ="儿童id")
                                @RequestParam(value = "patient",required = true)String patient,
                                @ApiParam(name="examTime",value ="体检日期 yyyy-mm-dd")
                                @RequestParam(value = "examTime",required = false)String examTime,
                                @ApiParam(name="monthAge",value ="月龄")
                                @RequestParam(value = "monthAge",required = false)String monthAge,
                                @ApiParam(name="height",value ="身高")
                                @RequestParam(value = "height",required = false)String height,
                                @ApiParam(name="weight",value ="体重")
                                @RequestParam(value = "weight",required = false)String weight,
                                @ApiParam(name="headCircumference",value ="头围")
                                @RequestParam(value = "headCircumference",required = false)String headCircumference){
        try {
            return ObjEnvelop.getSuccess("新建成功",examinationService.newRecord(patient,examTime,monthAge,height,weight,headCircumference)) ;
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("新建记录失败");
        }
    }
    @GetMapping("getRecordDetailById")
    @ApiOperation("获取居民体检详情")
    public ObjEnvelop getRecordDetailById(@ApiParam(name="recordId",value ="体检id")
                                          @RequestParam(value = "recordId",required = true)String recordId){
        try {
            return ObjEnvelop.getSuccess("查询成功",examinationService.getRecordDetailById(recordId));
        }catch (Exception e){
            e.printStackTrace();;
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping("getRecordList")
    @ApiOperation("获取居民体检记录")
    public PageEnvelop getRecordList(@ApiParam(name="patient",value ="儿童id")
                                     @RequestParam(value = "patient",required = true)String patient,
                                     @ApiParam(name="type",value = "体检类型 1机构体检 2居家自检")
                                     @RequestParam(value = "type",required = false)String type,
                                     @ApiParam(name="orgCode",value = "体检机构")
                                     @RequestParam(value = "orgCode",required = false)String orgCode,
                                     @ApiParam(name="startTime",value = "yyyy-MM-dd hh:mm:ss")
                                     @RequestParam(value = "startTime",required = false)String startTime,
                                     @ApiParam(name="endTime",value = "yyyy-MM-dd hh:mm:ss")
                                     @RequestParam(value = "endTime",required = false)String endTime,
                                     @ApiParam(name = "page")
                                     @RequestParam(value = "page",defaultValue = "1")int page,
                                     @ApiParam(name = "size")
                                     @RequestParam(value = "size",defaultValue = "15")int size){
        try {
            return examinationService.getRecordList(patient,type,orgCode,startTime,endTime,page,size);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败");
        }
    }
}

+ 56 - 6
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/DoctorMessageEndpoint.java

@ -1,18 +1,16 @@
package com.yihu.jw.care.endpoint.message;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.message.DoctorMessageService;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Bing on 2021/4/10.
@ -38,4 +36,56 @@ public class DoctorMessageEndpoint extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = "newOrgNotice")
    @ApiOperation("创建机构通知消息")
    public ObjEnvelop newOrgNotice(@ApiParam(name = "jsonDate", value = "消息通知json")
                               @RequestParam(value = "jsonDate", required = false) String jsonDate,
                               @ApiParam(name = "patients", value = "通知居民列表")
                               @RequestParam(value = "patients", required = false) String[] patients){
        try {
            JSONObject result = doctorMessageService.newOrgNotice(jsonDate,patients);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
            return ObjEnvelop.getSuccess("查询成功",result.getJSONObject(ResponseContant.resultMsg));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败"+e.getMessage());
        }
    }
    @PostMapping(value = "getOrgNoticeList")
    @ApiOperation("获取机构通知消息")
    public PageEnvelop getOrgNoticeList(@ApiParam(name = "orgCode", value = "机构code")
                                       @RequestParam(value = "orgCode", required = true) String orgCode,
                                        @ApiParam(name = "createUser", value = "通知创建者")
                                       @RequestParam(value = "createUser", required = false) String createUser,
                                        @ApiParam(name = "beginTime", value = "提醒开始时间")
                                       @RequestParam(value = "beginTime", required = false) String beginTime,
                                        @ApiParam(name = "endTime", value = "提醒结束时间")
                                       @RequestParam(value = "endTime", required = false) String endTime,
                                        @ApiParam(name = "page", value = "page")
                                       @RequestParam(value = "page", required = true,defaultValue = "1") int page,
                                        @ApiParam(name = "size", value = "size")
                                       @RequestParam(value = "size", required = true,defaultValue = "15") int size){
        try {
            return doctorMessageService.getOrgNoticeList(orgCode,createUser,beginTime,endTime,page,size);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败"+e.getMessage());
        }
    }
    @PostMapping(value = "orgNoticeDetail")
    @ApiOperation("获取机构通知消息详情")
    public ObjEnvelop orgNoticeDetail(@ApiParam(name = "noticeId", value = "通知id")
                                   @RequestParam(value = "noticeId", required = false) String noticeId){
        try {
            return ObjEnvelop.getSuccess("查询成功",doctorMessageService.orgNoticeDetail(noticeId));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败"+e.getMessage());
        }
    }
}

+ 60 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/PatientMessageEndpoint.java

@ -0,0 +1,60 @@
package com.yihu.jw.care.endpoint.message;
import com.yihu.jw.care.service.message.PatientMessageService;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Bing on 2021/5/19.
 */
@RestController
@RequestMapping("patient/message")
@Api(description = "居民端消息")
public class PatientMessageEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private PatientMessageService patientMessageService;
    @PostMapping(value = "getNoticeList")
    @ApiOperation("获取患者机构通知消息")
    public PageEnvelop getNoticeList(@ApiParam(name = "patient", value = "患者id")
                                        @RequestParam(value = "patient", required = true) String patient,
                                        @ApiParam(name = "beginTime", value = "提醒开始时间")
                                        @RequestParam(value = "beginTime", required = false) String beginTime,
                                        @ApiParam(name = "endTime", value = "提醒结束时间")
                                        @RequestParam(value = "endTime", required = false) String endTime,
                                        @ApiParam(name = "page", value = "page")
                                        @RequestParam(value = "page", required = true,defaultValue = "1") int page,
                                        @ApiParam(name = "size", value = "size")
                                        @RequestParam(value = "size", required = true,defaultValue = "15") int size){
        try {
            return patientMessageService.getNoticeList(patient,beginTime,endTime,page,size);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败"+e.getMessage());
        }
    }
    @PostMapping(value = "orgNoticeDetail")
    @ApiOperation("获取机构通知消息详情")
    public ObjEnvelop orgNoticeDetail(@ApiParam(name = "noticeId", value = "通知id")
                                      @RequestParam(value = "noticeId", required = false) String noticeId,
                                      @ApiParam(name = "patient", value = "patient")
                                      @RequestParam(value = "patient", required = false) String patient){
        try {
            return ObjEnvelop.getSuccess("查询成功",patientMessageService.orgNoticeDetail(noticeId,patient));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败"+e.getMessage());
        }
    }
}

+ 76 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java

@ -21,6 +21,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -170,7 +171,11 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
           sql+=" and org.type in(1,2) ";
        }
        else {
            sql+=" and org.type='"+orgType+"' ";
            if (isSearchDoctorOrgType&&doctorOrg.size()>0){
                sql += " and org.code = '"+doctorOrg.get(0)+"' and org.type='"+orgType+"'  ";
            }else {
                sql+=" and org.type='"+orgType+"' ";
            }
        }
        sql+=" ORDER BY org.`code` asc";
@ -218,4 +223,74 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        return result;
    }
    public PageEnvelop getTeacherChildren(String doctor,int searchType,int page,int size){
        page = page>0?page-1:0;
        List<Map<String,Object>> list = new ArrayList<>();
        //未入学
        String sql0 = "select Distinct sor.patient from base_course_sales_order_record sor INNER JOIN base_course bc on sor.course_id = bc.id " +
                " and bc.del=1 where bc.doctor ='"+doctor+"'  and sor.`status` =5 and not EXISTS (select DISTINCT rsr.patient " +
                " from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` and org.del=1 " +
                " INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where rsr.patient=sor.patient and " +
                " dh.doctor_code='"+doctor+"'   and rsr.del<>0  and rsr.`status` = 3  )";
        //已入学
        String sql1=" select DISTINCT rsr.patient from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` " +
                "and org.del=1 INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where dh.doctor_code='"+doctor+"' " +
                "and rsr.del<>0  and rsr.`status` = 3 GROUP BY dh.doctor_code  ";
        String sql = "select p.id,p.name,p.photo,p.sex,p.idcard,p.openid,p.mobile,group_concat( pd.category_code) deviceType from ( {sqlReplace} )tmp Inner JOIN base_patient p on tmp.patient  = p.id " +
                " LEFT JOIN wlyy_patient_device pd on pd.`user`=p.id and pd.category_code BETWEEN 1 and 2 GROUP BY p.id ";
        String sqlcpunt = "select count(Distinct p.id) from ( {sqlReplace} )tmp Inner JOIN base_patient p on tmp.patient  = p.id " +
                " LEFT JOIN wlyy_patient_device pd on pd.`user`=p.id and pd.category_code BETWEEN 1 and 2  ";
        Long count = 0L;
        if (0==searchType){
            list = jdbcTemplate.queryForList(sql.replace("{sqlReplace}",sql0));
            count = jdbcTemplate.queryForObject(sqlcpunt.replace("{sqlReplace}",sql0),Long.class);
        }
        if (1==searchType){//
            list = jdbcTemplate.queryForList(sql.replace("{sqlReplace}",sql1));
            count = jdbcTemplate.queryForObject(sqlcpunt.replace("{sqlReplace}",sql1),Long.class);
        }
        for (Map<String,Object>map:list){
            if (map.get("idcard")!=null){
                String idcard = map.get("idcard").toString();
                map.put("age", IdCardUtil.getAgeForIdcard(idcard));
            }else {
                map.put("age", null);
            }
            if (map.get("deviceType")!=null){
                if ("1,2".equals(map.get("deviceType").toString())){
                    map.put("deviceType",3);//deviceType 设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                }
                else {
                    map.put("deviceType",Integer.valueOf(map.get("deviceType").toString()));
                }
            }
            else {
                map.put("deviceType",0);
            }
        }
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    public Map<String,Long> getTeacherChildrenCount(String doctor){
        Map<String,Long> result = new HashMap<>();
        //未入学
        String sql0 = "select Distinct sor.patient from base_course_sales_order_record sor INNER JOIN base_course bc on sor.course_id = bc.id " +
                " and bc.del=1 where bc.doctor ='"+doctor+"'  and sor.`status` =5 and not EXISTS (select DISTINCT rsr.patient " +
                " from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` and org.del=1 " +
                " INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where rsr.patient=sor.patient and " +
                " dh.doctor_code='"+doctor+"'   and rsr.del<>0  and rsr.`status` = 3  )";
        //已入学
        String sql1=" select DISTINCT rsr.patient from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` " +
                "and org.del=1 INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where dh.doctor_code='"+doctor+"' " +
                "and rsr.del<>0  and rsr.`status` = 3 GROUP BY dh.doctor_code  ";
        String sqlcpunt = "select count(Distinct p.id) from ( {sqlReplace} )tmp Inner JOIN base_patient p on tmp.patient  = p.id " +
                " LEFT JOIN wlyy_patient_device pd on pd.`user`=p.id and pd.category_code BETWEEN 1 and 2  ";
        Long count = 0L;
        count = jdbcTemplate.queryForObject(sqlcpunt.replace("{sqlReplace}",sql0),Long.class);
        result.put("notEnrol",count);
        count = jdbcTemplate.queryForObject(sqlcpunt.replace("{sqlReplace}",sql1),Long.class);
        result.put("enrol",count);
        return result;
    }
}

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/exam/ChildrenExaminationService.java

@ -45,8 +45,8 @@ public class ChildrenExaminationService extends BaseJpaService<ChildrenExaminati
    public PageEnvelop getRecordList(String patient,String type,String orgCode,String startTime,String endTime,int page,int size){
        page=page>0?page-1:0;
        String sql = "select id,patient,type,exam_time examTime,org_code orgCode,org_name orgName,month_age monthAge,height,weight, " +
                "head_circumference headCircumference,create_time createTime from base_children_examination_record where patient ='"+patient+"' ";
        String sql = "select id,patient,type,DATE_FORMAT(exam_time,'%Y-%m-%d %H:%i:%S') examTime,org_code orgCode,org_name orgName,month_age monthAge,height,weight, " +
                "head_circumference headCircumference,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') createTime from base_children_examination_record where patient ='"+patient+"' ";
        String sqlCount = "select count(id) from base_children_examination_record where patient ='"+patient+"' ";
        String sqlCondition=" ";
        if (StringUtils.isNotBlank(type)){

+ 71 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/DoctorMessageService.java

@ -2,19 +2,25 @@ package com.yihu.jw.care.service.message;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.dao.apply.PatientBedApplyDao;
import com.yihu.jw.care.dao.message.OrgNoticeDao;
import com.yihu.jw.care.dao.message.UserNoticeDao;
import com.yihu.jw.care.dao.security.SecurityMonitoringOrderDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.notice.UserNoticeDO;
import com.yihu.jw.entity.care.message.OrgNoticeDO;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.EntityUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.persistence.criteria.CriteriaBuilder;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@ -35,6 +41,10 @@ public class DoctorMessageService {
    private PatientBedApplyDao patientBedApplyDao;
    @Autowired
    private SecurityMonitoringOrderDao securityMonitoringOrderDao;
    @Autowired
    private OrgNoticeDao orgNoticeDao;
    @Autowired
    private UserNoticeDao userNoticeDao;
    /**
     *
@ -150,7 +160,7 @@ public class DoctorMessageService {
                        "SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ,\n" +
                        "base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and \n" +
                        "r.service_package_id = i.service_package_id and  m.team_code = i.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' \n" +
                        "and m.doctor_code = '13' and m.del = '1') ";
                        "and m.doctor_code = '"+doctor+"' and m.del = '1') ";
            }
            List<Map<String,Object>> sqlResult  = jdbcTemplate.queryForList(sql);
@ -177,7 +187,7 @@ public class DoctorMessageService {
                        "SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ,\n" +
                        "base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and \n" +
                        "r.service_package_id = i.service_package_id and  m.team_code = i.team_code  and i.del = 1 and sr.`status`=1  and i.code='emergencyAssistance' \n" +
                        "and m.doctor_code = '13' and m.del = '1')";
                        "and m.doctor_code = '"+doctor+"' and m.del = '1')";
            }
            List<Map<String,Object>> sqlResult  = jdbcTemplate.queryForList(sql);
@ -211,4 +221,61 @@ public class DoctorMessageService {
        return result;
    }
    public JSONObject newOrgNotice(String jsonDate, String[] patients){
        JSONObject result = new JSONObject();
        OrgNoticeDO orgNoticeDO = new OrgNoticeDO();
        try{
            orgNoticeDO  = EntityUtils.jsonToEntity(jsonDate, OrgNoticeDO.class);
        }catch (Exception e){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "参数转换成JSON对象异常:" + e.getMessage();
            result.put(ResponseContant.resultMsg, failMsg);
            return result;
        }
        orgNoticeDao.save(orgNoticeDO);
        for(String user:patients){
            UserNoticeDO userNoticeDO = new UserNoticeDO();
            userNoticeDO.setUserId(user);
            userNoticeDO.setDel(1);
            userNoticeDO.setIsRead(0);
            userNoticeDO.setNoticeId(orgNoticeDO.getId());
            userNoticeDao.save(userNoticeDO);
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        JSONObject Msg = JSONObject.parseObject(JSON.toJSONStringWithDateFormat(orgNoticeDO,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
        result.put(ResponseContant.resultMsg, Msg);
        return result;
    }
    public PageEnvelop getOrgNoticeList(String orgCode,String createUser,String beginTime,String endTime,int page,int size){
        page = page>0?page-1:0;
        String sqlCount = "select count(id) from base_org_notice where del=1 ";
        String sql = "select id,title,org_code orgCode,org_name orgName,DATE_FORMAT(notice_time,'%Y-%m-%d %H:%i:%S') noticeTime,content,img from base_org_notice where del=1 ";
        String sqlCondition ="";
        if (StringUtils.isNotBlank(orgCode)){
            sqlCondition += " and org_code = '"+orgCode+"' ";
        }
        if (StringUtils.isNotBlank(createUser)){
            sqlCondition += " and create_user = '"+createUser+"' ";
        }
        if (StringUtils.isNotBlank(beginTime)){
            sqlCondition += " and notice_time >= '"+beginTime+"' ";
        }
        if (StringUtils.isNotBlank(endTime)){
            sqlCondition += " and notice_time <= '"+endTime+"' ";
        }
        if (StringUtils.isBlank(beginTime)&&StringUtils.isBlank(endTime)){
            String time = DateUtil.getStringDate();
            sqlCondition += " and notice_time <= '"+time+"' ";
        }
        Long count = jdbcTemplate.queryForObject(sqlCount+sqlCondition,Long.class);
        sqlCondition += " order by notice_time desc limit "+page*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+sqlCondition);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    public OrgNoticeDO orgNoticeDetail(String noticeId){
        return orgNoticeDao.findOne(noticeId);
    }
}

+ 67 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/PatientMessageService.java

@ -0,0 +1,67 @@
package com.yihu.jw.care.service.message;
import com.yihu.jw.care.dao.message.OrgNoticeDao;
import com.yihu.jw.care.dao.message.UserNoticeDao;
import com.yihu.jw.entity.base.notice.UserNoticeDO;
import com.yihu.jw.entity.care.message.OrgNoticeDO;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2021/5/19.
 */
@Service
public class PatientMessageService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private OrgNoticeDao orgNoticeDao;
    @Autowired
    private UserNoticeDao userNoticeDao;
    public PageEnvelop getNoticeList(String patient,String beginTime, String endTime, int page, int size){
        page = page>0?page-1:0;
        String sqlCount = "select count(t.id) from base_org_notice t INNER JOIN base_user_notice usno on t.id = CONVERT(usno.notice_id USING utf8) and usno.del=1 " +
                "where t.del=1 ";
        String sql = "select t.id,t.title,t.org_code orgCode,t.org_name orgName,DATE_FORMAT(t.notice_time,'%Y-%m-%d %H:%i:%S') noticeTime, " +
                "t.content,t.img,usno.is_read isRead from base_org_notice t INNER JOIN base_user_notice usno on t.id = CONVERT(usno.notice_id USING utf8) " +
                "and usno.del=1 where t.del=1 ";
        String sqlCondition ="";
        if (StringUtils.isNotBlank(patient)){
            sqlCondition += " and usno.user_id = '"+patient+"' ";
        }
        if (StringUtils.isNotBlank(beginTime)){
            sqlCondition += " and t.notice_time >= '"+beginTime+"' ";
        }
        if (StringUtils.isNotBlank(endTime)){
            sqlCondition += " and t.notice_time <= '"+endTime+"' ";
        }
        String time = DateUtil.getTime();
        sqlCondition += " and t.notice_time <= '"+time+"' ";
        Long count = jdbcTemplate.queryForObject(sqlCount+sqlCondition,Long.class);
        sqlCondition += " order by t.notice_time desc limit "+page*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+sqlCondition);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    public OrgNoticeDO orgNoticeDetail(String noticeId,String patient){
        OrgNoticeDO orgNoticeDO =  orgNoticeDao.findOne(noticeId);
        if (orgNoticeDO!=null){
            UserNoticeDO userNoticeDO =  userNoticeDao.findByNoticeIdAndUserIdAndDel(orgNoticeDO.getId(),patient,1);
            if (userNoticeDO!=null){
                userNoticeDO.setIsRead(1);
                userNoticeDao.save(userNoticeDO);
            }
        }
        return orgNoticeDO;
    }
}