Browse Source

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

# Conflicts:
#	common/common-entity/sql记录
yeshijie 3 years ago
parent
commit
dece4e32c7

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

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

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

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

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

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

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

@ -0,0 +1,20 @@
package com.yihu.jw.care.dao.course;
import com.yihu.jw.entity.care.course.CustomerServiceDO;
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/18
 * @Description:
 */
public interface CustomerServiceDao extends PagingAndSortingRepository<CustomerServiceDO, String>, JpaSpecificationExecutor<CustomerServiceDO> {
    List<CustomerServiceDO> findByOrgCode(String orgCode);
}

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

@ -0,0 +1,21 @@
package com.yihu.jw.care.dao.course;
import com.yihu.jw.entity.care.course.PatientOrderRefundDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/18
 * @Description:
 */
public interface PatientOrderRefundDao extends PagingAndSortingRepository<PatientOrderRefundDO, String>
        , JpaSpecificationExecutor<PatientOrderRefundDO> {
    PatientOrderRefundDO findByTypeAndOrderId(String type, String orderId);
}

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

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

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

@ -0,0 +1,20 @@
package com.yihu.jw.care.dao.course;
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
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/18
 * @Description:
 */
public interface RecruitStudentsRecordDao extends PagingAndSortingRepository<RecruitStudentsRecordDO, String>,
        JpaSpecificationExecutor<RecruitStudentsRecordDO> {
    List<RecruitStudentsRecordDO> findByRecruitStudentsIdAndStatus(String recruitStudentsId, String status);
}

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

@ -0,0 +1,20 @@
package com.yihu.jw.care.endpoint.course;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/18
 * @Description:
 */
@RestController
@RequestMapping("course" )
@Api(tags = "课程信息", description = "课程信息")
public class CourseEndpoint extends EnvelopRestEndpoint {
}

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

@ -0,0 +1,20 @@
package com.yihu.jw.care.endpoint.course;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/18
 * @Description:
 */
@RestController
@RequestMapping("doctor/course" )
@Api(tags = "医生课程信息", description = "医生课程信息")
public class DoctorCourseEndpoint extends EnvelopRestEndpoint {
}

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

@ -0,0 +1,47 @@
package com.yihu.jw.care.endpoint.course;
import com.yihu.jw.care.service.course.CourseService;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/18
 * @Description:
 */
@RestController
@RequestMapping("patient/course" )
@Api(tags = "居民课程信息", description = "居民课程信息")
public class PatientCourseEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private CourseService courseService;
    @GetMapping("topStatusBarNum")
    @ApiOperation(value = "顶部状态栏订单分类tab")
    public ObjEnvelop topStatusBarNum(
            @ApiParam(name = "patient", value = "居民code")
            @RequestParam(value = "patient", required = true) String patient) {
        try {
            Map<String, Integer> map = courseService.topStatusBarNum(patient);
            return ObjEnvelop.getSuccess("获取成功",map);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
}

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

@ -0,0 +1,157 @@
package com.yihu.jw.care.service.course;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.course.CourseCatalogueDao;
import com.yihu.jw.care.dao.course.CourseDao;
import com.yihu.jw.care.dao.course.CourseSalesOrderRecordDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.yihu.jw.rm.iot.IotRequestMapping.Common.hospital;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/18
 * @Description:
 */
@Service
public class CourseService {
    @Autowired
    private CourseDao courseDao;
    @Autowired
    private CourseCatalogueDao courseCatalogueDao;
    @Autowired
    private CourseSalesOrderRecordDao courseSalesOrderRecordDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 顶部状态栏订单各分类总条数
     * @param patient
     * @return
     */
    public Map<String, Integer> topStatusBarNum(String patient) {
        String sql = "SELECT a.`status`,COUNT(*) num from ( " +
                "SELECT `status` from base_recruit_students_record  where patient = '"+patient+"' " +
                "UNION ALL " +
                "SELECT `status` from base_course_sales_order_record where patient = '"+patient+"' ) a " +
                "GROUP BY a.`status` " ;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        Map<String, Integer> map = new HashMap<>();
        //状态 待服务 1、已完成 2 、已取消 -1
        map.put("1",0);
        map.put("2",0);
        map.put("3",0);
        map.put("4",0);
        map.put("5",0);
        int total = 0;
        if(list.size()>0){
            for (Map<String, Object> one:list){
                map.put(String.valueOf(one.get("status")), Integer.valueOf(String.valueOf(one.get("num"))));
                total+=Integer.valueOf(String.valueOf(one.get("num")));
            }
        }
        map.put("total", total);
        return map;
    }
    public JSONObject patientOrderList(String patient, Integer status, int page, int size) {
        JSONObject result = new JSONObject();
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : size;
        StringBuffer buffer = new StringBuffer();
        String sql = "SELECT " +
                "  p.name AS patientName, " +
                "  p.photo AS photo, " +
                "  p.idcard," +
                "  case p.sex  " +
                "  when 1 then '男'  " +
                "  when 2 then '女' " +
                "  end AS sex, " +
                "  TIMESTAMPDIFF(year,p.birthday,NOW()) AS age," +
                "  o.id as orderId, " +
                "  o.patient_phone as phone, " +
                "  o.proxy_patient as proxyPatient, " +
                "  o.patient as patient, " +
                "  o.number as number, " +
                "  o.patient_expected_serve_time as serveTime, o.doctor, o.doctor_name as doctorName, " +
                "  o.serve_address as address, " +
                "  o.type as type, " +
                "  o.serve_lon as lon, " +
                "  o.serve_lat as lat, " +
                "  o.`status` as status " +
                " FROM " +
                " ( base_life_care_order o " +
                " LEFT JOIN base_patient p ON o.patient = p.id ) "+
                " WHERE " +
                "  o.hospital = '{hospital}' and o.type != 3 " +buffer+
                " AND ( o.`status` = {status} OR -100 = {status} ) " +
                " ORDER BY o.create_time desc " +
                " LIMIT {start},{end};";
        String finalSql = sql.replace("{status}", String.valueOf(status))
                .replace("{start}", String.valueOf(start))
                .replace("{end}", String.valueOf(end));
        String countSql = "SELECT  " +
                "   count(o.id)  " +
                " FROM  " +
                "   base_life_care_order o  " +
                " LEFT JOIN base_patient p ON o.patient = p.id " +
                " WHERE  " +
                "  o.hospital = '{hospital}' " +buffer+
                " AND (o.`status` = {status} or -100 = {status})";
        String finqlCountSql = countSql.replace("{hospital}", hospital)
                .replace("{status}", String.valueOf(status));
        List<Map<String,Object>> sqlResultlist;
        try {
            sqlResultlist = jdbcTemplate.queryForList(finalSql);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "从数据库查询生活照料工单列表信息失败");
            return result;
        }
        Long count;
        try {
            count = jdbcTemplate.queryForObject(finqlCountSql, Long.class);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "从数据库统计生活照料工单数量失败" );
            return result;
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, sqlResultlist);
        JSONObject countItem = new JSONObject();
        countItem.put("count", count);
        result.putAll(countItem);
        return result;
    }
}