Просмотр исходного кода

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

wangjun 3 лет назад
Родитель
Сommit
a79a34f6f2

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

@ -867,6 +867,49 @@ CREATE TABLE `base_course_sales_order_record` (
  PRIMARY KEY (`id`)
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='课程销售订单记录表';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='课程销售订单记录表';
DROP TABLE IF EXISTS `base_patient_course_record`;
CREATE TABLE `base_patient_course_record` (
  `id` varchar(50) NOT NULL,
  `nursery_log_id` varchar(50) DEFAULT NULL COMMENT '托育日志id',
  `patient` varchar(50) DEFAULT NULL,
  `content` varchar(2000) DEFAULT NULL COMMENT '课程记录内容',
  `enclosure` varchar(2000) DEFAULT NULL COMMENT '附件',
  `record_date` varchar(20) DEFAULT NULL COMMENT '记录日期',
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='居民课程记录';
DROP TABLE IF EXISTS `base_patient_diet_record`;
CREATE TABLE `base_patient_diet_record` (
  `id` varchar(50) NOT NULL,
  `nursery_log_id` varchar(50) DEFAULT NULL COMMENT '托育日志id',
  `patient` varchar(50) DEFAULT NULL,
  `eat_food` varchar(1000) DEFAULT NULL COMMENT '食用食物json格式',
  `eat_type` varchar(255) DEFAULT NULL COMMENT '食用方式 1喂食 2自主进食',
  `intake` varchar(1) DEFAULT NULL COMMENT '摄入量 全部吃完 吃了1/3 吃了1/2 几乎没吃',
  `additional_notes` varchar(1000) DEFAULT NULL COMMENT '附加说明',
  `enclosure` varchar(2000) DEFAULT NULL COMMENT '附件',
  `record_date` varchar(20) DEFAULT NULL COMMENT '记录日期',
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='居民饮食记录';
DROP TABLE IF EXISTS `base_nursery_log`;
CREATE TABLE `base_nursery_log` (
  `id` varchar(50) NOT NULL,
  `patient` varchar(50) DEFAULT NULL,
  `patient_name` varchar(50) DEFAULT NULL,
  `doctor` varchar(50) DEFAULT NULL,
  `doctor_name` varchar(50) DEFAULT NULL,
  `org_code` varchar(50) DEFAULT NULL,
  `org_name` varchar(50) DEFAULT NULL,
  `record_date` varchar(20) DEFAULT NULL COMMENT '记录日期',
  `status` varchar(1) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique1` (`patient`,`record_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='托育日志记录';
-- 2021-05-18
-- 2021-05-18
create table base_org_notice(
create table base_org_notice(
	id varchar(50) not null,
	id varchar(50) not null,
@ -888,3 +931,12 @@ ALTER table base_org_notice add column create_user varchar(50) DEFAULT NULL
ALTER table base.base_security_monitoring_order add column `order_source` tinyint(4) DEFAULT '1' COMMENT '工单发起来源状态 1APP 2手环3居家报警'
ALTER table base.base_security_monitoring_order add column `order_source` tinyint(4) DEFAULT '1' COMMENT '工单发起来源状态 1APP 2手环3居家报警'
-- 2021-05-19
CREATE TABLE `base_course_catalogue_read_time` (
  `id` varchar(50) NOT NULL,
  `patient` varchar(50) DEFAULT NULL COMMENT '用户code',
  `course_catalogue_id` varchar(50) DEFAULT NULL COMMENT '课程目录id',
  `course_id` varchar(50) DEFAULT NULL COMMENT '课程id',
  `read_time` varchar(20) DEFAULT NULL COMMENT '阅读时间,保留时间戳格式,单位s',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='记录用户阅读课程时长';

+ 12 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/course/CourseCatalogueDO.java

@ -39,6 +39,10 @@ public class CourseCatalogueDO extends UuidIdentityEntityWithTime {
     * 视频url
     * 视频url
     */
     */
    private String videoUrl;
    private String videoUrl;
    /**
     * 排序字段
     */
    private Integer sort;
    @Column(name = "course_id")
    @Column(name = "course_id")
    public String getCourserId() {
    public String getCourserId() {
@ -89,4 +93,12 @@ public class CourseCatalogueDO extends UuidIdentityEntityWithTime {
        this.videoUrl = videoUrl;
        this.videoUrl = videoUrl;
    }
    }
    @Column(name = "sort")
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
}
}

+ 63 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/course/CourseCatalogueReadTimeDO.java

@ -0,0 +1,63 @@
package com.yihu.jw.entity.care.course;
import javax.persistence.Column;
/***
 * @ClassName: CourseCatalogueReadTimeDO
 * @Description: 记录用户阅读课程时长
 * @Auther: shi kejing
 * @Date: 2021/5/19 9:00
 */
public class CourseCatalogueReadTimeDO {
    private String id;
    private String patient;
    private String courseCatalogueId;
    private String courseId;
    private String readTime;
    @Column(name = "id")
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getCourseCatalogueId() {
        return courseCatalogueId;
    }
    public void setCourseCatalogueId(String courseCatalogueId) {
        this.courseCatalogueId = courseCatalogueId;
    }
    public String getCourseId() {
        return courseId;
    }
    public void setCourseId(String courseId) {
        this.courseId = courseId;
    }
    public String getReadTime() {
        return readTime;
    }
    public void setReadTime(String readTime) {
        this.readTime = readTime;
    }
}

+ 107 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/course/NurseryLogDO.java

@ -0,0 +1,107 @@
package com.yihu.jw.entity.care.course;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/20
 * @Description:
 */
@Entity
@Table(name="base_nursery_log")
public class NurseryLogDO extends UuidIdentityEntityWithCreateTime{
    private String patient;
    private String patientName;
    private String doctor;
    private String doctorName;
    private String orgCode;
    private String orgName;
    /**
     * '记录日期'
     */
    private String recordDate;
    /**
     * 状态 暂时没用
     */
    private String status;
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "patient_name")
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "org_code")
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    @Column(name = "org_name")
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    @Column(name = "record_date")
    public String getRecordDate() {
        return recordDate;
    }
    public void setRecordDate(String recordDate) {
        this.recordDate = recordDate;
    }
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
}

+ 82 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/course/PatientCourseRecordDO.java

@ -0,0 +1,82 @@
package com.yihu.jw.entity.care.course;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/20
 * @Description: '居民课程记录
 */
@Entity
@Table(name="base_patient_course_record")
public class PatientCourseRecordDO extends UuidIdentityEntityWithCreateTime{
    private String patient;
    /**
     * '托育日志id'
     */
    private String nurseryLogId;
    /**
     * '课程记录内容'
     */
    private String content;
    /**
     * '附件'
     */
    private String enclosure;
    /**
     * '记录日期'
     */
    private String recordDate;
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "nursery_log_id")
    public String getNurseryLogId() {
        return nurseryLogId;
    }
    public void setNurseryLogId(String nurseryLogId) {
        this.nurseryLogId = nurseryLogId;
    }
    @Column(name = "content")
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @Column(name = "enclosure")
    public String getEnclosure() {
        return enclosure;
    }
    public void setEnclosure(String enclosure) {
        this.enclosure = enclosure;
    }
    @Column(name = "record_date")
    public String getRecordDate() {
        return recordDate;
    }
    public void setRecordDate(String recordDate) {
        this.recordDate = recordDate;
    }
}

+ 121 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/course/PatientDietRecordDO.java

@ -0,0 +1,121 @@
package com.yihu.jw.entity.care.course;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/20
 * @Description: 居民饮食记录
 */
@Entity
@Table(name="base_patient_diet_record")
public class PatientDietRecordDO extends UuidIdentityEntityWithCreateTime{
    private String patient;
    /**
     * '托育日志id'
     */
    private String nurseryLogId;
    /**
     * '食用食物json格式'
     */
    private String eatFood;
    /**
     * '食用方式 1喂食 2自主进食
     */
    private String eatType;
    /**
     *'摄入量 全部吃完 吃了1/3 吃了1/2 几乎没吃'
     */
    private String intake;
    /**
     *'附加说明'
     */
    private String additionalNotes;
    /**
     *'附件'
     */
    private String enclosure;
    /**
     * '记录日期'
     */
    private String recordDate;
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "nursery_log_id")
    public String getNurseryLogId() {
        return nurseryLogId;
    }
    public void setNurseryLogId(String nurseryLogId) {
        this.nurseryLogId = nurseryLogId;
    }
    @Column(name = "eat_food")
    public String getEatFood() {
        return eatFood;
    }
    public void setEatFood(String eatFood) {
        this.eatFood = eatFood;
    }
    @Column(name = "eat_type")
    public String getEatType() {
        return eatType;
    }
    public void setEatType(String eatType) {
        this.eatType = eatType;
    }
    @Column(name = "intake")
    public String getIntake() {
        return intake;
    }
    public void setIntake(String intake) {
        this.intake = intake;
    }
    @Column(name = "additional_notes")
    public String getAdditionalNotes() {
        return additionalNotes;
    }
    public void setAdditionalNotes(String additionalNotes) {
        this.additionalNotes = additionalNotes;
    }
    @Column(name = "enclosure")
    public String getEnclosure() {
        return enclosure;
    }
    public void setEnclosure(String enclosure) {
        this.enclosure = enclosure;
    }
    @Column(name = "record_date")
    public String getRecordDate() {
        return recordDate;
    }
    public void setRecordDate(String recordDate) {
        this.recordDate = recordDate;
    }
}

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/BusinessSysDictService.java

@ -98,7 +98,7 @@ public class BusinessSysDictService extends BaseJpaService<BusinessSysDictDO, Bu
                " t.py_code  as \"pyCode\","+
                " t.py_code  as \"pyCode\","+
                " t.img_url  as \"imgUrl\","+
                " t.img_url  as \"imgUrl\","+
                " t.create_time as \"createTime\""+
                " t.create_time as \"createTime\""+
                " from base_business_sys_dict t where 1=1 ";
                " , t.ext1, t.ext2 from base_business_sys_dict t where 1=1 ";
        if (StringUtils.isNoneBlank(name)){
        if (StringUtils.isNoneBlank(name)){
            sql+=" and t.dict_name like '%"+name+"%'";
            sql+=" and t.dict_name like '%"+name+"%'";
        }
        }

+ 16 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/NurseryLogDao.java

@ -0,0 +1,16 @@
package com.yihu.jw.care.dao.course;
import com.yihu.jw.entity.care.course.NurseryLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/20
 * @Description:
 */
public interface NurseryLogDao extends PagingAndSortingRepository<NurseryLogDO, String>, JpaSpecificationExecutor<NurseryLogDO> {
}

+ 20 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/PatientCourseRecordDao.java

@ -0,0 +1,20 @@
package com.yihu.jw.care.dao.course;
import com.yihu.jw.entity.care.course.PatientCourseRecordDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/20
 * @Description:
 */
public interface PatientCourseRecordDao extends PagingAndSortingRepository<PatientCourseRecordDO, String>,
        JpaSpecificationExecutor<PatientCourseRecordDO> {
    List<PatientCourseRecordDO> findByNurseryLogId(String nurseryLogId);
}

+ 19 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/PatientDietRecordDao.java

@ -0,0 +1,19 @@
package com.yihu.jw.care.dao.course;
import com.yihu.jw.entity.care.course.PatientDietRecordDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/20
 * @Description:
 */
public interface PatientDietRecordDao extends PagingAndSortingRepository<PatientDietRecordDO, String>, JpaSpecificationExecutor<PatientDietRecordDO> {
    List<PatientDietRecordDO> findByNurseryLogId(String nurseryLogId);
}

+ 189 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/course/NurseryLogEndpoint.java

@ -0,0 +1,189 @@
package com.yihu.jw.care.endpoint.course;
import com.yihu.jw.care.service.course.NurseryLogService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
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 with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/20
 * @Description:
 */
@RestController
@RequestMapping("nursery" )
@Api(tags = "托育日志", description = "托育日志")
public class NurseryLogEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private NurseryLogService nurseryLogService;
    @GetMapping(value = "findNurseryLogByMonth")
    @ApiOperation("获取托育日志按月日历形式")
    public Envelop findNurseryLogByMonth(@ApiParam(name = "orgCode", value = "机构id")
                                      @RequestParam(value = "orgCode", required = true) String orgCode,
                                          @ApiParam(name = "patient", value = "居民")
                                      @RequestParam(value = "patient", required = false) String patient,
                                          @ApiParam(name = "patientName", value = "居民姓名")
                                      @RequestParam(value = "patientName", required = false) String patientName,
                                          @ApiParam(value = "开始时间,格式(yyyy-MM-dd)", name = "startDate",required = false)
                                      @RequestParam(value = "startDate", required = false) String startDate,
                                          @ApiParam(value = "结束时间,格式(yyyy-MM-dd)", name = "endDate",required = false)
                                      @RequestParam(value = "endDate", required = false) String endDate){
        try {
            return ObjEnvelop.getSuccess("操作成功!",nurseryLogService.findNurseryLogByMonth(orgCode,patient,patientName,startDate,endDate));
        }catch (Exception e){
            return  failedException(e);
        }
    }
    @GetMapping(value = "findNurseryLogList")
    @ApiOperation("获取托育日志列表-已填写")
    public Envelop findNurseryLogList(@ApiParam(name = "orgCode", value = "机构id")
                                            @RequestParam(value = "orgCode", required = true) String orgCode,
                                            @ApiParam(name = "recordDate", value = "时间")
                                            @RequestParam(value = "recordDate", required = false) String recordDate){
        try {
            return ObjEnvelop.getSuccess("操作成功!",nurseryLogService.findNurseryLogList(orgCode,recordDate));
        }catch (Exception e){
            return  failedException(e);
        }
    }
    @GetMapping(value = "nuseryLogUnFilledIn")
    @ApiOperation("获取未填写日志列表")
    public Envelop nuseryLogUnFilledIn(@ApiParam(name = "orgCode", value = "机构id")
                                         @RequestParam(value = "orgCode", required = true) String orgCode,
                                         @ApiParam(name = "recordDate", value = "时间")
                                         @RequestParam(value = "recordDate", required = false) String recordDate){
        try {
            return ObjEnvelop.getSuccess("操作成功!",nurseryLogService.nuseryLogUnFilledIn(orgCode,recordDate));
        }catch (Exception e){
            return  failedException(e);
        }
    }
    @PostMapping("addNurseryLog")
    @ApiOperation(value = "新增托育日志")
    public Envelop addNurseryLog(
            @ApiParam(name = "patient", value = "居民id") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "patientName", value = "居民姓名") @RequestParam(value = "patientName", required = true) String patientName,
            @ApiParam(name = "doctor", value = "医生id") @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(name = "doctorName", value = "医生姓名") @RequestParam(value = "doctorName", required = true) String doctorName,
            @ApiParam(name = "orgCode", value = "机构id") @RequestParam(value = "orgCode", required = true) String orgCode,
            @ApiParam(name = "orgName", value = "机构名称") @RequestParam(value = "orgName", required = true) String orgName,
            @ApiParam(name = "recordDate", value = "记录日期 格式 yyyy-MM-dd") @RequestParam(value = "recordDate", required = true) String recordDate) {
        try {
            return success("新增成功",nurseryLogService.addNurseryLog(patient, patientName, doctor, doctorName, orgCode, orgName, recordDate));
        } catch (Exception e) {
            return  failedException(e);
        }
    }
    @PostMapping("addCourseRecord")
    @ApiOperation(value = "新增课程记录")
    public Envelop addCourseRecord(
            @ApiParam(name = "id", value = "托育日志id") @RequestParam(value = "id", required = true) String id,
            @ApiParam(name = "content", value = "课程记录内容") @RequestParam(value = "content", required = true) String content,
            @ApiParam(name = "enclosure", value = "附件") @RequestParam(value = "enclosure", required = false) String enclosure) {
        try {
            return success("新增成功",nurseryLogService.addCourseRecord(id, content, enclosure));
        } catch (Exception e) {
            return  failedException(e);
        }
    }
    @PostMapping("addDietRecord")
    @ApiOperation(value = "新增饮食记录")
    public Envelop addDietRecord(
            @ApiParam(name = "id", value = "托育日志id") @RequestParam(value = "id", required = true) String id,
            @ApiParam(name = "eatFood", value = "食用食物") @RequestParam(value = "eatFood", required = true) String eatFood,
            @ApiParam(name = "eatType", value = "进食方式") @RequestParam(value = "eatType", required = true) String eatType,
            @ApiParam(name = "enclosure", value = "附件") @RequestParam(value = "enclosure", required = false) String enclosure,
            @ApiParam(name = "intake", value = "摄入量") @RequestParam(value = "intake", required = true) String intake,
            @ApiParam(name = "additionalNotes", value = "附加说明") @RequestParam(value = "additionalNotes", required = false) String additionalNotes) {
        try {
            return success("新增成功",nurseryLogService.addDietRecord(id, eatFood, eatType, enclosure, intake, additionalNotes));
        } catch (Exception e) {
            return  failedException(e);
        }
    }
    @GetMapping(value = "nurseryDetail")
    @ApiOperation("获取课程记录详情")
    public Envelop nurseryDetail(@ApiParam(name = "id", value = "id")
                                            @RequestParam(value = "id", required = true) String id){
        try {
            return ObjEnvelop.getSuccess("操作成功!",nurseryLogService.nurseryDetail(id));
        }catch (Exception e){
            return  failedException(e);
        }
    }
    @GetMapping(value = "findDictDiet")
    @ApiOperation("查找饮食字典")
    public Envelop findDictDiet(){
        try {
            return ObjEnvelop.getSuccess("操作成功!",nurseryLogService.findDictDiet());
        }catch (Exception e){
            return  failedException(e);
        }
    }
    @GetMapping(value = "findRecordByNurseryLogId")
    @ApiOperation("根据托育日志id查找")
    public Envelop findRecordByNurseryLogId(@ApiParam(name = "id", value = "托育日志id")
                                                   @RequestParam(value = "id", required = true) String id,
                                               @ApiParam(name = "type", value = "类型 diet饮食记录 course课程记录")
                                               @RequestParam(value = "type", required = true) String type){
        try {
            return nurseryLogService.findRecordByNurseryLogId(id,type);
        }catch (Exception e){
            return  failedException(e);
        }
    }
    @GetMapping(value = "findDietRecord")
    @ApiOperation("查找饮食记录")
    public Envelop findDietRecord(@ApiParam(name = "id", value = "id")
                                            @RequestParam(value = "id", required = true) String id){
        try {
            return nurseryLogService.findDietRecord(id);
        }catch (Exception e){
            return  failedException(e);
        }
    }
    @GetMapping(value = "findCourseRecord")
    @ApiOperation("查找课程记录记录")
    public Envelop findCourseRecord(@ApiParam(name = "id", value = "id")
                                            @RequestParam(value = "id", required = true) String id){
        try {
            return nurseryLogService.findCourseRecord(id);
        }catch (Exception e){
            return  failedException(e);
        }
    }
    @GetMapping(value = "findNurseryLogByPatient")
    @ApiOperation("获取托育日志按月日历形式 - 居民端")
    public Envelop findNurseryLogByPatient(@ApiParam(name = "patient", value = "居民")
                                         @RequestParam(value = "patient", required = true) String patient,
                                         @ApiParam(value = "开始时间,格式(yyyy-MM-dd)", name = "startDate",required = false)
                                         @RequestParam(value = "startDate", required = false) String startDate,
                                         @ApiParam(value = "结束时间,格式(yyyy-MM-dd)", name = "endDate",required = false)
                                         @RequestParam(value = "endDate", required = false) String endDate){
        try {
            return ObjEnvelop.getSuccess("操作成功!",nurseryLogService.findNurseryLogByPatient(patient,startDate,endDate));
        }catch (Exception e){
            return  failedException(e);
        }
    }
}

+ 164 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/course/PatientCourseEndpoint.java

@ -13,6 +13,7 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
@ -96,4 +97,167 @@ public class PatientCourseEndpoint extends EnvelopRestEndpoint {
            return Envelop.getError( "获取失败!" ,-1);
            return Envelop.getError( "获取失败!" ,-1);
        }
        }
    }
    }
    @GetMapping("getCourseByCourse")
    @ApiOperation(value = "在线报名-根据课程展示")
    public ObjEnvelop getCourseByCourse(
            @ApiParam(name = "longitude", value = "所在位置经度", defaultValue = "118.10388605") @RequestParam(value = "longitude", required = true) String longitude,
            @ApiParam(name = "latitude", value = "所在位置纬度", defaultValue = "24.48923061") @RequestParam(value = "latitude", required = true) String latitude,
            @ApiParam(name = "pageSize", value = "页面大小", defaultValue = "2") @RequestParam(value = "pageSize", required = true) int pageSize,
            @ApiParam(name = "currentPage", value = "当前页面", defaultValue = "1") @RequestParam(value = "currentPage", required = true) int currentPage) {
        try {
            JSONObject json = courseService.getCourseByCourse(longitude,latitude, pageSize, currentPage);
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getCourseByOrg")
    @ApiOperation(value = "在线报名-根据机构展示")
    public ObjEnvelop getCourseByOrg(
            @ApiParam(name = "longitude", value = "所在位置经度", defaultValue = "118.10388605") @RequestParam(value = "longitude", required = true) String longitude,
            @ApiParam(name = "latitude", value = "所在位置纬度", defaultValue = "24.48923061") @RequestParam(value = "latitude", required = true) String latitude
//            @ApiParam(name = "pageSize", value = "页面大小", defaultValue = "2") @RequestParam(value = "pageSize", required = true) int pageSize,
//            @ApiParam(name = "currentPage", value = "当前页面", defaultValue = "1") @RequestParam(value = "currentPage", required = true) int currentPage
    ) {
        try {
            JSONObject json = courseService.getCourseByOrg(longitude,latitude);//, pageSize, currentPage
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getCourseByteacher")
    @ApiOperation(value = "在线报名-根据教师展示")
    public ObjEnvelop getCourseByteacher(
            @ApiParam(name = "longitude", value = "所在位置经度", defaultValue = "118.10388605") @RequestParam(value = "longitude", required = true) String longitude,
            @ApiParam(name = "latitude", value = "所在位置纬度", defaultValue = "24.48923061") @RequestParam(value = "latitude", required = true) String latitude
//            @ApiParam(name = "pageSize", value = "页面大小", defaultValue = "2") @RequestParam(value = "pageSize", required = true) int pageSize,
//            @ApiParam(name = "currentPage", value = "当前页面", defaultValue = "1") @RequestParam(value = "currentPage", required = true) int currentPage
    ) {
        try {
            JSONObject json = courseService.getCourseByteacher(longitude,latitude);//, pageSize, currentPage
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getCourseInfo")
    @ApiOperation(value = "在线报名-获取课程详情")
    public ObjEnvelop getCourseInfo(
            @ApiParam(name = "id", value = "课程id", defaultValue = "808080eb7861c327017861d18d070011") @RequestParam(value = "id", required = true) String id
    ) {
        try {
            JSONObject json = courseService.getCourseInfo(id);//, pageSize, currentPage
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getCatalogue")
    @ApiOperation(value = "在线报名-获取课程目录")
    public ObjEnvelop getCatalogue(
            @ApiParam(name = "id", value = "课程id", defaultValue = "808080eb7861c327017861d18d070011") @RequestParam(value = "id", required = true) String id,
            @ApiParam(name = "patient", value = "居民code", defaultValue = "808080eb7955aa9301795b8bad3f0078") @RequestParam(value = "patient", required = true) String patient
    ) {
        try {
            JSONObject json = courseService.getCatalogue(id,patient);//, pageSize, currentPage
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getOrgInfoById")
    @ApiOperation(value = "在线报名-获取机构详情")
    public ObjEnvelop getOrgInfoById(
            @ApiParam(name = "id", value = "机构id", defaultValue = "808080eb7861c327017861d18d070011") @RequestParam(value = "id", required = true) String id
    ) {
        try {
            JSONObject json = courseService.getOrgInfoById(id);//, pageSize, currentPage
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getTecInfoById")
    @ApiOperation(value = "在线报名-获取教师详情(根据教师id)")
    public ObjEnvelop getTecInfoById(
            @ApiParam(name = "doctor", value = "教师id", defaultValue = "402803816babc778016babca89ea0032") @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(name = "orgCode", value = "机构code", defaultValue = "xm10086") @RequestParam(value = "orgCode", required = true) String orgCode,
            @ApiParam(name = "page", value = "page", defaultValue = "1") @RequestParam(value = "page", required = true) int page,
            @ApiParam(name = "size", value = "size", defaultValue = "10") @RequestParam(value = "size", required = true) int size
    ) {
        try {
            JSONObject json = courseService.getTecInfoById(doctor,orgCode,page,size);//, pageSize, currentPage
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getCoursrOrderStatusByPatient")
    @ApiOperation(value = "在线报名-获取居民订单(根据居民id)")
    public ObjEnvelop getCoursrOrderStatusByPatient(
            @ApiParam(name = "patient", value = "居民id", defaultValue = "3ae2673512154d5280d1dcf5ffa5626d") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "status", value = "status", defaultValue = "0") @RequestParam(value = "status", required = true) int status,
            @ApiParam(name = "page", value = "page", defaultValue = "1") @RequestParam(value = "page", required = true) int page,
            @ApiParam(name = "size", value = "size", defaultValue = "10") @RequestParam(value = "size", required = true) int size
    ) {
        try {
            JSONObject json = courseService.getCoursrOrderStatusByPatient(patient,status,page,size);//, pageSize, currentPage
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getOrderInfo")
    @ApiOperation(value = "在线报名-获取订单详情(根据orderId)")
    public Envelop getOrderInfo(
            @ApiParam(name = "orderId", value = "订单id", defaultValue = "3ae2673512154d5280d1dcf5ffa5626d") @RequestParam(value = "根据orderId", required = true) String orderId
    ) {
        try {
            return success(courseService.getOrderInfo(orderId));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    //购买课程
    @PostMapping("buyCourseOrder")
    @ApiOperation(value = "在线报名-购买课程")
    public Envelop buyCourseOrder(
            @ApiParam(name = "patient", value = "居民id", defaultValue = "3ae2673512154d5280d1dcf5ffa5626d") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "patientName", value = "居民name", defaultValue = "白海灵") @RequestParam(value = "patientName", required = true) String patientName,
            @ApiParam(name = "courseId", value = "课程id", defaultValue = "808080eb7983eb630179882b9a540034") @RequestParam(value = "courseId", required = true) String courseId,
            @ApiParam(name = "courseName", value = "课程name", defaultValue = "3") @RequestParam(value = "courseName", required = true) String courseName,
            @ApiParam(name = "orgCode", value = "机构code", defaultValue = "808080eb7861c327017861d18d070011") @RequestParam(value = "orgCode", required = true) String orgCode,
            @ApiParam(name = "orgName", value = "机构name", defaultValue = "厦门托育机构") @RequestParam(value = "orgName", required = true) String orgName,
            @ApiParam(name = "price", value = "价格", defaultValue = "110") @RequestParam(value = "price", required = true) BigDecimal price,
            @ApiParam(name = "payType", value = "1-微信支付,2-线下支付", defaultValue = "1") @RequestParam(value = "payType", required = true) String payType
    ) {
        try {
            return success(courseService.buyCourseOrder(patient,patientName,courseId,courseName,orgCode,orgName,price,payType));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    //申请退款
    //直播间
}
}

+ 362 - 19
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/course/CourseService.java

@ -1,5 +1,6 @@
package com.yihu.jw.care.service.course;
package com.yihu.jw.care.service.course;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -8,12 +9,20 @@ import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.care.course.CourseSalesOrderRecordDO;
import com.yihu.jw.entity.care.course.PatientOrderRefundDO;
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
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.care.course.*;
import com.yihu.jw.entity.care.course.*;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -21,6 +30,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.Date;
import java.util.Date;
import java.util.HashMap;
import java.util.HashMap;
import java.util.List;
import java.util.List;
@ -55,6 +66,10 @@ public class CourseService {
    @Autowired
    @Autowired
    private PatientOrderRefundDao patientOrderRefundDao;
    private PatientOrderRefundDao patientOrderRefundDao;
    @Autowired
    @Autowired
    private BaseOrgDao orgDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private ObjectMapper objectMapper;
    private ObjectMapper objectMapper;
    @Autowired
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
@ -121,26 +136,22 @@ public class CourseService {
        if(flag){
        if(flag){
            //支付信息
            //支付信息
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(id);
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(id);
            if(businessOrderDO!=null){
                JSONObject json = new JSONObject();
                json.put("payPrice",businessOrderDO.getPayPrice());
                json.put("payTime",DateUtil.dateToStrLong(businessOrderDO.getPayTime()));
                json.put("payType",businessOrderDO.getPayType());
                resJson.put("businessOrderDO",json);
            }
            JSONObject json = new JSONObject();
            json.put("payPrice",businessOrderDO.getPayPrice());
            json.put("payTime",businessOrderDO.getPayTime());
            json.put("payType",businessOrderDO.getPayType());
            resJson.put("businessOrderDO",json);
        }
        }
        if("5".equals(status)||"6".equals(status)){
        if("5".equals(status)||"6".equals(status)){
            //退款信息
            //退款信息
            PatientOrderRefundDO refundDO = patientOrderRefundDao.findByTypeAndOrderId(type,id);
            PatientOrderRefundDO refundDO = patientOrderRefundDao.findByTypeAndOrderId(type,id);
            if(refundDO!=null){
                JSONObject json = new JSONObject();
                json.put("createTime", DateUtil.dateToStrLong(refundDO.getCreateTime()));
                json.put("refundPrice",refundDO.getRefundPrice());
                json.put("status",refundDO.getStatus());
                json.put("refundDesc",refundDO.getRefundDesc());
                json.put("enclosure",refundDO.getEnclosure());
                resJson.put("refundDO",json);
            }
            JSONObject json = new JSONObject();
            json.put("createTime",refundDO.getCreateTime());
            json.put("refundPrice",refundDO.getRefundPrice());
            json.put("status",refundDO.getStatus());
            json.put("refundDesc",refundDO.getRefundDesc());
            json.put("enclosure",refundDO.getEnclosure());
            resJson.put("refundDO",json);
        }
        }
        return resJson;
        return resJson;
@ -321,14 +332,14 @@ public class CourseService {
            filter += " and status = "+ status +" ";
            filter += " and status = "+ status +" ";
        }
        }
        String sqlUnion = " SELECT id,`status`,recruit_name title,pay_type payType,price,1 type,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%s') createTime " +
        String sqlUnion = " SELECT id,`status`,recruit_name title,pay_type payType,price,1 type,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%s') createTtime " +
                " from base_recruit_students_record " + filter+
                " from base_recruit_students_record " + filter+
                " UNION ALL " +
                " UNION ALL " +
                " SELECT id,`status`,course_name title,pay_type payType,price,2 type,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%s') createTime  " +
                " SELECT id,`status`,course_name title,pay_type payType,price,2 type,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%s') createTtime  " +
                " from base_course_sales_order_record " + filter+" ";
                " from base_course_sales_order_record " + filter+" ";
        String sql = "SELECT * from ( " + sqlUnion + " ) a " +
        String sql = "SELECT * from ( " + sqlUnion + " ) a " +
                " ORDER BY a.createTime desc " +
                " ORDER BY a.createTtime desc " +
                " LIMIT {start},{end};";
                " LIMIT {start},{end};";
        String finalSql = sql.replace("{start}", String.valueOf(start))
        String finalSql = sql.replace("{start}", String.valueOf(start))
                .replace("{end}", String.valueOf(end));
                .replace("{end}", String.valueOf(end));
@ -361,4 +372,336 @@ public class CourseService {
        return result;
        return result;
    }
    }
    //根据机构坐标进行排序
    public JSONObject getCourseByCourse(String lon2,String lat2, int pageSize,int currentPage){
        JSONObject object = new JSONObject();
        String sql = "SELECT id,`name`,longitude,latitude FROM base.base_org where del = 1 and type = 4";
        List<Map<String , Object>> positionList = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> list = new ArrayList<>();
        List<Map<String , Object>> currentPageList = new ArrayList<>();
        if (positionList.size() > 0){
            for (int i=0;i<positionList.size();i++){
                String sql1 = "SELECT id,code,`name`,longitude,latitude ,funDistance("+positionList.get(i).get("latitude")+","+positionList.get(i).get("longitude")+","+lat2+","+lon2+") funDistance FROM base.base_org where id = '"+positionList.get(i).get("id")+"'";
                List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql1);
                JSONObject obj = new JSONObject();
                obj.put("id",mapList.get(0).get("id"));
                obj.put("name",mapList.get(0).get("name"));
                obj.put("longitude",mapList.get(0).get("longitude"));
                obj.put("latitude",mapList.get(0).get("latitude"));
                obj.put("funDistance",mapList.get(0).get("funDistance"));
                obj.put("code",mapList.get(0).get("code"));
                list.add(obj);
            }
            if (list.size() > 0){
                Collections.sort(list, new Comparator<Map<String, Object>>() {
                    public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                        return (Double) o1.get("funDistance") > (Double) o2.get("funDistance") ? 1 : ((Double) o1.get("funDistance") == (Double) o2.get("funDistance") ? 0 : -1);
                    }
                });
            }
            List<Map<String , Object>> aList = new ArrayList();
            if (list.size() > 0){
                for (int i =0;i<list.size();i++){
                    String sql1 = "SELECT * FROM base_course WHERE del = 1 AND org_code = '"+list.get(i).get("code")+"'" ;
                    List<Map<String , Object >> amapList = jdbcTemplate.queryForList(sql1);
                    if (amapList.size() > 0){
                        for (int j = 0;j<amapList.size();j++){
                            JSONObject o = new JSONObject();
                            o.put("id",amapList.get(j).get("id"));
                            o.put("name",amapList.get(j).get("name"));
                            o.put("orgCode",amapList.get(j).get("org_code"));
                            o.put("orgName",amapList.get(j).get("org_name"));
                            o.put("doctor",amapList.get(j).get("doctor"));
                            o.put("doctorName",amapList.get(j).get("doctor_name"));
                            o.put("liveTime",amapList.get(j).get("live_time"));
                            o.put("liveStatus",amapList.get(j).get("live_status"));
                            o.put("liveDuration",amapList.get(j).get("live_duration"));
                            o.put("courseCover",amapList.get(j).get("course_cover"));
                            o.put("status",amapList.get(j).get("status"));
                            o.put("fee",amapList.get(j).get("fee"));
                            o.put("introduction",amapList.get(j).get("introduction"));
                            aList.add(o);
                        }
                    }
                }
                if (aList.size() > 0 ){
                    if (aList != null && aList.size() > 0) {
                        int currIdx = (currentPage > 1 ? (currentPage - 1) * pageSize : 0);
                        for (int i = 0; i < pageSize && i < aList.size() - currIdx; i++) {
                            Map<String, Object> data = (Map<String, Object>) aList.get(currIdx + i);
                            currentPageList.add(data);
                        }
                    }
                }
            }
            object.put("object",currentPageList);
        }
        return object;
    }
    public JSONObject getCourseByOrg(String lon2,String lat2){ //, int pageSize,int currentPage
        JSONObject object = new JSONObject();
        String sql = "SELECT id,`name`,longitude,latitude FROM base.base_org where del = 1 and type = 4";
        List<Map<String , Object>> positionList = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> list = new ArrayList<>();
        if (positionList.size() > 0){
            for (int i=0;i<positionList.size();i++){
                String sql1 = "SELECT id,`name`,photo,address,longitude,latitude ,funDistance("+positionList.get(i).get("latitude")+","+positionList.get(i).get("longitude")+","+lat2+","+lon2+") funDistance FROM base.base_org where id = '"+positionList.get(i).get("id")+"'";
                List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql1);
                JSONObject obj = new JSONObject();
                obj.put("id",mapList.get(0).get("id"));
                obj.put("name",mapList.get(0).get("name"));
                obj.put("photo",mapList.get(0).get("photo"));
                obj.put("address",mapList.get(0).get("address"));
                obj.put("longitude",mapList.get(0).get("longitude"));
                obj.put("latitude",mapList.get(0).get("latitude"));
                obj.put("funDistance",mapList.get(0).get("funDistance"));
                list.add(obj);
            }
            if (list.size() > 0){
                Collections.sort(list, new Comparator<Map<String, Object>>() {
                    public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                        return (Double) o1.get("funDistance") > (Double) o2.get("funDistance") ? 1 : ((Double) o1.get("funDistance") == (Double) o2.get("funDistance") ? 0 : -1);
                    }
                });
            }
            object.put("object",list);
//            List<Map<String , Object>> currentPageList = new ArrayList<>();
//            if (list.size() > 0 ){
//                if (list != null && list.size() > 0) {
//                    int currIdx = (currentPage > 1 ? (currentPage - 1) * pageSize : 0);
//                    for (int i = 0; i < pageSize && i < list.size() - currIdx; i++) {
//                        Map<String, Object> data = list.get(currIdx + i);
//                        currentPageList.add(data);
//                    }
//                }
//            }
//            object.put("object",currentPageList);
        }
        return object;
    }
    public JSONObject getCourseByteacher(String lon2,String lat2){ //, int pageSize,int currentPage
        JSONObject object = new JSONObject();
        String sql = "SELECT id,`name`,longitude,latitude FROM base.base_org where del = 1 and type = 4";
        List<Map<String , Object>> positionList = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> list = new ArrayList<>();
        List<Map<String , Object>> currentPageList = new ArrayList<>();
        if (positionList.size() > 0){
            for (int i=0;i<positionList.size();i++){
                String sql1 = "SELECT id,code,`name`,longitude,latitude ,funDistance("+positionList.get(i).get("latitude")+","+positionList.get(i).get("longitude")+","+lat2+","+lon2+") funDistance FROM base.base_org where id = '"+positionList.get(i).get("id")+"'";
                List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql1);
                JSONObject obj = new JSONObject();
                obj.put("id",mapList.get(0).get("id"));
                obj.put("code",mapList.get(0).get("code"));
                obj.put("name",mapList.get(0).get("name"));
                obj.put("longitude",mapList.get(0).get("longitude"));
                obj.put("latitude",mapList.get(0).get("latitude"));
                obj.put("funDistance",mapList.get(0).get("funDistance"));
                list.add(obj);
            }
            if (list.size() > 0){
                Collections.sort(list, new Comparator<Map<String, Object>>() {
                    public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                        return (Double) o1.get("funDistance") > (Double) o2.get("funDistance") ? 1 : ((Double) o1.get("funDistance") == (Double) o2.get("funDistance") ? 0 : -1);
                    }
                });
            }
            List<Map<String , Object >> aList = new ArrayList<>();
            if (list.size() > 0){
                for (int i =0;i<list.size();i++){
                    String sql1 = "SELECT id,`name`,job_title_code,job_title_name,visit_hospital,visit_hospital_name FROM base_doctor WHERE doctor_level = 3 AND enabled = 1 AND locked = 0 AND del = 1 and  visit_hospital = '"+list.get(i).get("code")+"'" ;
                    List<Map<String , Object >> amapList = jdbcTemplate.queryForList(sql1);
                    if (amapList.size() > 0){
                        for (int j=0;j<amapList.size();j++){
                            JSONObject o = new JSONObject();
                            o.put("id",amapList.get(j).get("id"));
                            o.put("name",amapList.get(j).get("name"));
                            o.put("jobTitleCode",amapList.get(j).get("jobTitleCode"));
                            o.put("jobtitlename",amapList.get(j).get("jobtitlename"));
                            o.put("visithospital",amapList.get(j).get("visithospital"));
                            o.put("visitHospitalName",amapList.get(j).get("visitHospitalName"));
                            aList.add(o);
                        }
                    }
                }
            object.put("object",aList);
//                if (list.size() > 0 ){
//                    if (list != null && list.size() > 0) {
//                        int currIdx = (currentPage > 1 ? (currentPage - 1) * pageSize : 0);
//                        for (int i = 0; i < pageSize && i < list.size() - currIdx; i++) {
//                            Map<String, Object> data = list.get(currIdx + i);
//                            currentPageList.add(data);
//                        }
//                    }
//                }
            }
//            object.put("object",currentPageList);
        }
        return object;
    }
    public JSONObject getCourseInfo(String id){
        JSONObject object = new JSONObject();
        String sql = "SELECT * FROM base_course WHERE id = '"+id+"' AND del = 1 ";
        List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql);
        if (mapList.size() > 0){
            object.put("doctor",mapList.get(0).get("doctor"));
            object.put("doctorName",mapList.get(0).get("doctor_name"));
            List<BaseDoctorHospitalDO> baseDoctorHospitalDO = doctorHospitalDao.findByDoctorCode(mapList.get(0).get("doctor").toString());
            object.put("org",baseDoctorHospitalDO.get(0).getOrgCode());
            object.put("orgName",baseDoctorHospitalDO.get(0).getOrgName());
            object.put("jobTitleCode",baseDoctorHospitalDO.get(0).getDoctorDutyCode());
            object.put("jobTitleName",baseDoctorHospitalDO.get(0).getDoctorDutyName());
            object.put("introduction",mapList.get(0).get("introduction")); // 课程简介
        }
        return object;
    }
    public JSONObject getCatalogue(String id,String patient){
        JSONObject object = new JSONObject();
        String sql = "SELECT cc.* FROM base_course_catalogue cc,base_course c WHERE cc.course_id = '"+id+"' AND cc.course_id = c.id AND c.del = 1";
        List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql);
        JSONArray array = new JSONArray();
        if (mapList.size() > 0){
            for (int i = 0; i < mapList.size() ; i++){
                //  根据居民code,查询居民是否阅读过本课程
                String readSql = "SELECT read_time FROM base_course_catalogue_read_time WHERE course_id = '"+mapList.get(i).get("course_id")+"' AND course_catalogue_id = '"+id+"' AND patient = '"+patient+"'";
                List<Map<String , Object>> readMapList = jdbcTemplate.queryForList(readSql);
                if (readMapList.size() > 0){
                    mapList.add(readMapList.get(0));
                }
                array.add(mapList.get(i));
            }
        }
        object.put("object",array);
        return object;
    }
    public JSONObject getOrgInfoById(String id){
        JSONObject object = new JSONObject();
        String sql = "SELECT o.id,o.`code`,o.`name`,o.mobile,o.photo,o.address,o.intro,rs.start_time startTime,rs.end_time endTime,rs.num,rs.fee,rs.id rsId \n" +
                "FROM base_org o,base_recruit_students rs\n" +
                "WHERE o.id = '"+id+"' AND o.type = 4 AND o.del = 1 AND o.`code` = rs.org_code AND rs.del = 1";
        List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
        if (mapList.size() > 0){
            object.put("id",mapList.get(0).get("id"));//机构id
            object.put("name",mapList.get(0).get("name"));//机构名称
            object.put("mobile",mapList.get(0).get("mobile"));//机构联系方式
            object.put("photo",mapList.get(0).get("photo"));//机构图片
            object.put("address",mapList.get(0).get("address"));//机构地址
            object.put("intro",mapList.get(0).get("intro"));//机构简介
            object.put("startTime",mapList.get(0).get("startTime"));//招生开始时间
            object.put("endTime",mapList.get(0).get("endTime"));//招生结束时间
            object.put("num",mapList.get(0).get("num"));//招生名额
            object.put("fee",mapList.get(0).get("fee"));//报名费用
            String sql1 = "SELECT COUNT(*) count\n" +
                    "FROM base_org o,base_recruit_students_record rsr,base_recruit_students rs\n" +
                    "WHERE o.`code` = rsr.org_code AND rsr.recruit_students_id = '"+mapList.get(0).get("rsId")+"' AND o.`code` = '"+mapList.get(0).get("code")+"' AND (`status` = 3 OR `status` = 6);\n";
            Integer count = jdbcTemplate.queryForObject(sql1,Integer.class);
            String sql2 = "SELECT * FROM base_course WHERE del = 1 AND org_code = '"+mapList.get(0).get("code")+"'" ;
            List<Map<String , Object >> amapList = jdbcTemplate.queryForList(sql2);
            if (amapList.size() > 0){
                object.put("allCourse",amapList);//课程
            }else {
                object.put("allCourse","");//课程
            }
            String sql3 = "SELECT *  FROM base_doctor d,base_doctor_hospital dh\n" +
                    "WHERE d.doctor_level = 3 AND d.locked = 0 AND d.enabled = 1 AND d.del = 1 AND d.id = dh.doctor_code AND dh.del = 1 AND dh.org_code = '"+mapList.get(0).get("code")+"'" ;
            List<Map<String , Object >> bmapList = jdbcTemplate.queryForList(sql3);
            if (bmapList.size() > 0){
                object.put("allDoctor",bmapList);//教师
            }else {
                object.put("allDoctor","");//教师
            }
            object.put("count",count);//已报名人数
        }
        return object;
    }
    public JSONObject getTecInfoById(String doctor,String orgCode,int page,int size){
        JSONObject object = new JSONObject();
        //老师的基本信息
        String sql = "SELECT d.id,d.name,d.job_title_code jobTitleCode,d.job_title_name jobTitleName,dh.org_code orgCode,dh.org_name orgName\n" +
                "FROM base_doctor d,base_doctor_hospital dh\n" +
                "WHERE d.id = '"+doctor+"' AND dh.org_code = '"+orgCode+"' AND d.enabled = 1 AND d.locked = 0 AND d.del = 1 AND dh.del = 1 AND dh.doctor_code = d.id";
        List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql);
        object.put("doctorInfo",mapList.get(0));
        if (mapList.size() > 0){
            page = page - 1;
            size = (page+1)*size;
            String sql1 = "SELECT * FROM base_course WHERE doctor = '"+doctor+"' AND del = 1 limit "+page+","+size+"";
            List<Map<String , Object>> mapList1 = jdbcTemplate.queryForList(sql1);
            if (mapList1.size() > 0){
                object.put("allCourse",mapList1);
            }else {
                object.put("allCourse","");
            }
        }
        return  object;
    }
    public JSONObject getCoursrOrderStatusByPatient(String patient,int status,int page,int size){
        page = page - 1;
        size = (page+1)*10;
        JSONObject object = new JSONObject();
        String sql = "SELECT id,course_name courseName,buy_time buyTime,pay_type payType,status FROM base_course_sales_order_record WHERE patient = '"+patient+"'";
        if (status > 0){
            sql += " and status = "+status+" ";
        }
        sql += " order by create_time desc limit "+page+","+size+" ";
        List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
        String sql1 = "SELECT id,org_code orgCode,org_name orgName,pay_type payType,create_time createTime,status FROM base_recruit_students_record WHERE patient = '"+patient+"'";
        if (status > 0){
            sql1 += " and status = "+status+" ";
        }
        sql1 += " order by create_time desc limit "+page+","+size+"  ";
        List<Map<String,Object>> mapList1 = jdbcTemplate.queryForList(sql1);
        object.put("course",mapList);
        object.put("org",mapList1);
        return object;
    }
    public JSONObject getOrderInfo(String orderId){
        JSONObject object = new JSONObject();
        String sql = "SELECT id,course_name courseName,order_no orderNo,buy_time buyTime,pay_type payType,status orderStatus FROM base_course_sales_order_record WHERE id = '"+orderId+"'";
        List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql);
        if (mapList.size() < 0){
            sql = "SELECT id,org_code orgCode,org_name orgName,order_no orderNo,pay_type payType,create_time createTime,status FROM base_recruit_students_record WHERE patient = '"+orderId+"'";
            mapList = jdbcTemplate.queryForList(sql);
        }
        if (mapList.size() > 0 && mapList.get(0).get("orderStatus").equals(6)){
            String sql1 = "select status,create_time createTime,refund_price refundPrice,refund_desc refundDesc,enclosure from base_patient_order_refund where order_id = '"+mapList.get(0).get("id")+"' " ;
            List<Map<String , Object>> mapList1 = jdbcTemplate.queryForList(sql1);
            mapList.get(0).put("refundStatus",mapList1.get(0).get("status"));       //退款状态
            mapList.get(0).put("createTime",mapList1.get(0).get("createTime"));     //退款申请时间
            mapList.get(0).put("refundPrice",mapList1.get(0).get("refundPrice"));      //退款金额
            mapList.get(0).put("refundDesc",mapList1.get(0).get("refundDesc"));     //退款原因
            mapList.get(0).put("enclosure",mapList1.get(0).get("enclosure"));   //附件
        }
        object.put("object",mapList);
        return object;
    }
    public int buyCourseOrder(String patient, String patientName, String courseId, String courseName, String orgCode, String orgName, BigDecimal price,String payType){
        CourseSalesOrderRecordDO recordDO = new CourseSalesOrderRecordDO();
        recordDO.setBuyTime(new Date());
        recordDO.setPatient(patient);
        recordDO.setPatientName(patientName);
        recordDO.setCourseId(courseId);
        recordDO.setCourseName(courseName);
        recordDO.setOrgCode(orgCode);
        recordDO.setOrgName(orgName);
        recordDO.setPrice(price);
        recordDO.setPayType(payType);
        long  timeNew =  System.currentTimeMillis(); // 13位数的时间戳
        recordDO.setOrderNo(timeNew+"");
        courseSalesOrderRecordDao.save(recordDO);
        return 1;
    }
}
}

+ 374 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/course/NurseryLogService.java

@ -0,0 +1,374 @@
package com.yihu.jw.care.service.course;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.course.NurseryLogDao;
import com.yihu.jw.care.dao.course.PatientCourseRecordDao;
import com.yihu.jw.care.dao.course.PatientDietRecordDao;
import com.yihu.jw.entity.care.common.DictDietDO;
import com.yihu.jw.entity.care.course.NurseryLogDO;
import com.yihu.jw.entity.care.course.PatientCourseRecordDO;
import com.yihu.jw.entity.care.course.PatientDietRecordDO;
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/20
 * @Description:
 */
@Service
public class NurseryLogService {
    @Autowired
    private NurseryLogDao nurseryLogDao;
    @Autowired
    private PatientDietRecordDao patientDietRecordDao;
    @Autowired
    private PatientCourseRecordDao patientCourseRecordDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 查找饮食字典
     * @return
     */
    public List<DictDietDO> findDictDiet(){
        String sql = "select * from dict_diet ";
        List<DictDietDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(DictDietDO.class));
        return list;
    }
    /**
     * 根据托育日志id查找
     * @param id
     * @return
     */
    public ObjEnvelop findRecordByNurseryLogId(String id,String type){
        if("diet".equals(type)){
            List<PatientDietRecordDO> dietRecordDOs = patientDietRecordDao.findByNurseryLogId(id);
            if(dietRecordDOs.size()>0){
                return ObjEnvelop.getSuccess("查找成功",dietRecordDOs.get(0));
            }
        }else if("course".equals(type)){
            List<PatientCourseRecordDO> courseRecordDOs = patientCourseRecordDao.findByNurseryLogId(id);
            if(courseRecordDOs.size()>0){
                return ObjEnvelop.getSuccess("查找成功",courseRecordDOs.get(0));
            }
        }
        return ObjEnvelop.getError("未找到记录");
    }
    /**
     * 查找饮食记录
     * @param id
     * @return
     */
    public ObjEnvelop findDietRecord(String id){
        PatientDietRecordDO dietRecordDO = patientDietRecordDao.findOne(id);
        return ObjEnvelop.getSuccess("查找成功",dietRecordDO);
    }
    /**
     * 查找课程记录记录
     * @param id
     * @return
     */
    public ObjEnvelop findCourseRecord(String id){
        PatientCourseRecordDO courseRecordDO = patientCourseRecordDao.findOne(id);
        return ObjEnvelop.getSuccess("查找成功",courseRecordDO);
    }
    /**
     * 获取课程记录详情
     * @param id
     * @return
     */
    public JSONObject nurseryDetail(String id){
        JSONObject json = new JSONObject();
        NurseryLogDO nurseryLogDO = nurseryLogDao.findOne(id);
        json.put("nurseryLog",nurseryLogDO);
        List<PatientDietRecordDO> dietRecordDOs = patientDietRecordDao.findByNurseryLogId(id);
        List<PatientCourseRecordDO> courseRecordDOs = patientCourseRecordDao.findByNurseryLogId(id);
        json.put("diet",dietRecordDOs.size());
        json.put("course",courseRecordDOs.size());
        return json;
    }
    /**
     * 新增托育日志
     * @param patient
     * @param patientName
     * @param doctor
     * @param doctorName
     * @param orgCode
     * @param orgName
     * @param recordDate
     * @return
     */
    public NurseryLogDO addNurseryLog(String patient,String patientName, String doctor,String doctorName,String orgCode,String orgName,String recordDate) {
        NurseryLogDO nurseryLogDO = new NurseryLogDO();
        nurseryLogDO.setPatient(patient);
        nurseryLogDO.setPatientName(patientName);
        nurseryLogDO.setDoctorName(doctorName);
        nurseryLogDO.setDoctor(doctor);
        nurseryLogDO.setOrgName(orgName);
        nurseryLogDO.setOrgCode(orgCode);
        nurseryLogDO.setRecordDate(recordDate);
        nurseryLogDO.setStatus("0");
        nurseryLogDO.setCreateTime(new Date());
        nurseryLogDao.save(nurseryLogDO);
        return nurseryLogDO;
    }
    /**
     * 新增课程记录
     * @return
     */
    public PatientCourseRecordDO addCourseRecord(String id,String content, String enclosure) {
        PatientCourseRecordDO recordDO = new PatientCourseRecordDO();
        recordDO.setCreateTime(new Date());
        recordDO.setContent(content);
        recordDO.setEnclosure(enclosure);
        recordDO.setNurseryLogId(id);
        NurseryLogDO nurseryLogDO = nurseryLogDao.findOne(id);
        recordDO.setRecordDate(nurseryLogDO.getRecordDate());
        patientCourseRecordDao.save(recordDO);
        return recordDO;
    }
    /**
     * 新增饮食记录
     * @return
     */
    public PatientDietRecordDO addDietRecord(String id,String eatFood,String eatType, String enclosure,String intake,String additionalNotes) {
        PatientDietRecordDO recordDO = new PatientDietRecordDO();
        recordDO.setCreateTime(new Date());
        recordDO.setEnclosure(enclosure);
        recordDO.setNurseryLogId(id);
        recordDO.setEatFood(eatFood);
        recordDO.setEatType(eatType);
        recordDO.setIntake(intake);
        recordDO.setAdditionalNotes(additionalNotes);
        NurseryLogDO nurseryLogDO = nurseryLogDao.findOne(id);
        recordDO.setRecordDate(nurseryLogDO.getRecordDate());
        patientDietRecordDao.save(recordDO);
        return recordDO;
    }
    /**
     *获取托育日志列表
     * @param orgCode
     * @return
     * @throws Exception
     */
    public List<NurseryLogDO> findNurseryLogList(String orgCode, String recordDate){
        String sql = "select * from base_nursery_log wf ";
        sql+= " where wf.org_code = '"+orgCode+"'";
        if(!StringUtil.isEmpty(recordDate)){
            sql+=" and wf.record_date ='"+recordDate+"'";
        }
        sql+=" order by wf.create_time desc";
        List<NurseryLogDO> nurseryLogDOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(NurseryLogDO.class));
        return nurseryLogDOs;
    }
    /**
     * 获取未填写日志列表
     * @param orgCode
     */
    public JSONArray nuseryLogUnFilledIn(String orgCode,String recordDate){
        JSONArray jsonArray = new JSONArray();
        String sql ="SELECT * from base_recruit_students_record " +
                "where org_code = '"+orgCode+"' and `status` in ('3','6') and del =1";
        List<RecruitStudentsRecordDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(RecruitStudentsRecordDO.class));
        List<NurseryLogDO> nurseryLogDOs = findNurseryLogList(orgCode, recordDate);
        List<String> nurseryList = nurseryLogDOs.stream().map(NurseryLogDO::getPatient).collect(Collectors.toList());
        for(RecruitStudentsRecordDO recordDO:list){
            if(nurseryList.contains(recordDO.getPatient())){
                continue;
            }
            JSONObject json = new JSONObject();
            json.put("patient",recordDO.getPatient());
            json.put("patientName",recordDO.getPatientName());
            jsonArray.add(json);
        }
        return jsonArray;
    }
    /**
     *获取托育日志按月日历形式
     * @param orgCode
     * @param startTime
     * @param endTime
     * @return
     * @throws Exception
     */
    public Map<String,Object> findNurseryLogByMonth(String orgCode, String patient,  String patientName, String startTime, String endTime)throws Exception{
        String sql = "select * from base_nursery_log wf ";
        sql+= " where wf.org_code = '"+orgCode+"'";
        if(!StringUtil.isEmpty(patient)){
            sql+=" and wf.patient_code = '"+patient+"'";
        }
        if(!StringUtil.isEmpty(patientName)){
            sql+=" and wf.patient_name like '%"+patientName+"%'";
        }
        if(!StringUtil.isEmpty(startTime)){
            sql+=" and wf.record_date >='"+startTime+"'";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(endTime)){
            Date currentTime = DateUtil.strToDate(endTime + " 23:59:59");
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String dateString = formatter.format(currentTime);
            sql+=" and wf.record_date <='"+dateString+"'";
        }
        sql+=" order by wf.create_time desc";
        List<NurseryLogDO> nurseryLogDOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(NurseryLogDO.class));
        //按时间分组
        Map<String,Object> date = sortNurseryLogByDate(nurseryLogDOs);
        //统计每一天完成数与计划数目
        if(date!=null&&date.size()>0){
            for(String key : date.keySet()){
                //获取一天的数据
                Map<String,Object> d = (Map<String,Object>)date.get(key);
                // 获取一天随访数据
                List<NurseryLogDO> dateFollowups = (List<NurseryLogDO>)d.get("nurserys");
                //统计一天各项纬度指标
                List<Map<String,Object>> statistics = new ArrayList<>();
                //统计单条
                Map<String,Object> fs = sortNurseryLogList(dateFollowups);
                Integer count = (Integer)fs.get("count");
                if(count!=0){
                    statistics.add(fs);
                }
                d.put("statistics",statistics);
            }
        }
        return date;
    }
    public Map<String,Object> sortNurseryLogByDate(List<NurseryLogDO> nurseryLogDOs){
        //按时间分组
        Map<String,Object> date = new HashedMap();
        if(nurseryLogDOs!=null&&nurseryLogDOs.size()>0){
            Iterator it = nurseryLogDOs.iterator();
            while (it.hasNext()){
                NurseryLogDO nurseryLogDO = (NurseryLogDO)it.next();
                //1.获取日期分组
                Map<String,Object> dateNurserys = (Map<String,Object>)date.get(nurseryLogDO.getRecordDate());
                //判断随访时间是否已经创建分组
                if(dateNurserys!=null&&dateNurserys.size()>0){
                    //同一天时间已经有分组则加入list
                    List<NurseryLogDO> list = (List<NurseryLogDO>)dateNurserys.get("nurserys");
                    list.add(nurseryLogDO);
                }else{
                    //同一天的时间没有该分组则创建这天的随访计划List
                    Map<String,Object> newdateNursery = new HashedMap();
                    List<NurseryLogDO> dateNurseryLogs = new ArrayList<>();
                    dateNurseryLogs.add(nurseryLogDO);
                    newdateNursery.put("nurserys",dateNurseryLogs);
                    date.put(nurseryLogDO.getRecordDate(),newdateNursery);
                }
            }
        }
        return date;
    }
    public Map<String,Object> sortNurseryLogList(List<NurseryLogDO> nurseryLogDOs){
        //统计完成数
        Integer compeleCount = 0;
        //总数
        Integer count = 0;
        //迭代数组
        List<NurseryLogDO> rs = new ArrayList<>();
        if(nurseryLogDOs!=null&&nurseryLogDOs.size()>0){
            Iterator it = nurseryLogDOs.iterator();
            while (it.hasNext()){
                NurseryLogDO nurseryLogDO = (NurseryLogDO)it.next();
                rs.add(nurseryLogDO);
                if("1".equals(nurseryLogDO.getStatus())){
                    compeleCount++;
                }
            }
            //设置总数
            count = rs.size();
        }
        Map<String,Object> mapFollow =new HashedMap();
        mapFollow.put("compeleCount",compeleCount);
        mapFollow.put("count",count);
        return mapFollow;
    }
    /**
     *获取托育日志按月日历形式 - 居民端
     * @param patient
     * @param startTime
     * @param endTime
     * @return
     * @throws Exception
     */
    public Map<String,Object> findNurseryLogByPatient(String patient, String startTime, String endTime)throws Exception{
        String filter = " where patient = '"+patient+"'";
        if(!StringUtil.isEmpty(startTime)){
            filter+=" and record_date >='"+startTime+"'";
        }
        if(!StringUtil.isEmpty(endTime)){
            filter+=" and record_date <='"+endTime+"'";
        }
        String sql = "select * from (SELECT nursery_log_id nurseryLogId,record_date recordDate,patient,'diet' type  from base_patient_diet_record " +filter+
                " union all " +
                " SELECT nursery_log_id nurseryLogId,record_date recordDate,patient,'course' type from base_patient_course_record "+filter +" ) a";
        sql+=" order by recordDate desc";
        List<Map<String,Object>> nurseryLogDOs = jdbcTemplate.queryForList(sql);
        //按时间分组
        Map<String,Object> date = sortNurseryByDate(nurseryLogDOs);
        return date;
    }
    public Map<String,Object> sortNurseryByDate(List<Map<String,Object>> nurseryLogDOs){
        //按时间分组
        Map<String,Object> date = new HashedMap();
        if(nurseryLogDOs!=null&&nurseryLogDOs.size()>0){
            Iterator it = nurseryLogDOs.iterator();
            while (it.hasNext()){
                Map<String,Object> nurseryLogDO = (Map<String,Object>)it.next();
                //1.获取日期分组
                Map<String,Object> dateNurserys = (Map<String,Object>)date.get(String.valueOf(nurseryLogDO.get("recordDate")));
                //判断随访时间是否已经创建分组
                if(dateNurserys!=null&&dateNurserys.size()>0){
                    //同一天时间已经有分组则加入list
                    List<Map<String,Object>> list = (List<Map<String,Object>>)dateNurserys.get("nurserys");
                    list.add(nurseryLogDO);
                }else{
                    //同一天的时间没有该分组则创建这天的随访计划List
                    Map<String,Object> newdateNursery = new HashedMap();
                    List<Map<String,Object>> dateNurseryLogs = new ArrayList<>();
                    dateNurseryLogs.add(nurseryLogDO);
                    newdateNursery.put("nurserys",dateNurseryLogs);
                    date.put(String.valueOf(nurseryLogDO.get("recordDate")),newdateNursery);
                }
            }
        }
        return date;
    }
}