|
@ -1,9 +1,27 @@
|
|
|
package com.yihu.jw.patient.service.servicePackage;
|
|
|
|
|
|
import com.yihu.jw.entity.base.servicePackage.ServicePackageDO;
|
|
|
import com.yihu.jw.patient.dao.servicePackage.ServicePackageDao;
|
|
|
import com.yihu.jw.patient.useragent.UserAgent;
|
|
|
import com.yihu.jw.restmodel.base.doctor.BaseDoctorOrgVO;
|
|
|
import com.yihu.jw.restmodel.base.org.OrgDistanceVO;
|
|
|
import com.yihu.jw.restmodel.patient.signPackage.ServicePackageVO;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
import com.yihu.jw.rm.base.BaseRequestMapping;
|
|
|
import com.yihu.jw.rm.patient.PatientRequestMapping;
|
|
|
import io.swagger.models.auth.In;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.protocol.RequestUserAgent;
|
|
|
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.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Created by Trick on 2018/11/27.
|
|
|
*/
|
|
@ -13,5 +31,153 @@ public class PackageService {
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@Autowired
|
|
|
private UserAgent userAgent;
|
|
|
|
|
|
@Autowired
|
|
|
private ServicePackageDao servicePackageDao;
|
|
|
|
|
|
public MixEnvelop findPackageService(String city,String labelCode,Integer page,Integer size){
|
|
|
|
|
|
String totalSql ="SELECT " +
|
|
|
" count(1) as total " +
|
|
|
" FROM " +
|
|
|
" base_service_package p " ;
|
|
|
if(StringUtils.isNotBlank(labelCode)){
|
|
|
totalSql +=" JION base_package_label_info l ON l.service_package_id = p.id ";
|
|
|
}
|
|
|
totalSql += " WHERE " +
|
|
|
" p.city_code = '"+city+"' ";
|
|
|
|
|
|
List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
|
|
|
Long count = 0L;
|
|
|
if (rstotal != null && rstotal.size() > 0) {
|
|
|
count = (Long) rstotal.get(0).get("total");
|
|
|
}
|
|
|
|
|
|
String sql ="SELECT " +
|
|
|
" p.id, " +
|
|
|
" p.saas_id AS saasId, " +
|
|
|
" p.province_code AS provinceCode, " +
|
|
|
" p.province_name AS provinceName, " +
|
|
|
" p.city_code AS cityCode, " +
|
|
|
" p.city_name AS cityName, " +
|
|
|
" p.introduce AS introduce, " +
|
|
|
" p.`name` , " +
|
|
|
" p.num , " +
|
|
|
" p.price, " +
|
|
|
" p.level " +
|
|
|
" FROM " +
|
|
|
" base_service_package p " ;
|
|
|
if(StringUtils.isNotBlank(labelCode)){
|
|
|
sql+=" JION base_package_label_info l ON l.service_package_id = p.id ";
|
|
|
}
|
|
|
sql+= " WHERE " +
|
|
|
" p.city_code = '"+city+"' " +
|
|
|
" LIMIT " + (page - 1) * size + "," + size + "";
|
|
|
List<ServicePackageVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(ServicePackageVO.class));
|
|
|
|
|
|
return MixEnvelop.getSuccessListWithPage(PatientRequestMapping.SignPackage.api_success, list, page, size, count);
|
|
|
}
|
|
|
|
|
|
public MixEnvelop findOrgByPackageId(String packageId,Double latitude,Double longitude,Integer page,Integer size){
|
|
|
|
|
|
String totalSql ="SELECT " +
|
|
|
" count(1) as total" +
|
|
|
" FROM " +
|
|
|
" base_org o " +
|
|
|
" JOIN base_package_org po ON o.`code` = po.org_code " +
|
|
|
" WHERE " +
|
|
|
" po.service_package_id = '"+packageId+"' " +
|
|
|
" AND o.del= '1' " ;
|
|
|
List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
|
|
|
Long count = 0L;
|
|
|
if (rstotal != null && rstotal.size() > 0) {
|
|
|
count = (Long) rstotal.get(0).get("total");
|
|
|
}
|
|
|
|
|
|
String sql ="SELECT " +
|
|
|
" o.code, " +
|
|
|
" o.name, ";
|
|
|
if(latitude!=null&&longitude!=null){
|
|
|
sql+= " ROUND( " +
|
|
|
" 6378.138 * 2 * ASIN( " +
|
|
|
" SQRT( " +
|
|
|
" POW( " +
|
|
|
" SIN( " +
|
|
|
" ( " +
|
|
|
" "+longitude+" * PI() / 180 - o.latitude * PI() / 180 " +
|
|
|
" ) / 2 " +
|
|
|
" ), " +
|
|
|
" 2 " +
|
|
|
" ) + COS("+longitude+" * PI() / 180) * COS(o.latitude * PI() / 180) * POW( " +
|
|
|
" SIN( " +
|
|
|
" ( " +
|
|
|
" "+latitude+" * PI() / 180 - o.longitude * PI() / 180 " +
|
|
|
" ) / 2 " +
|
|
|
" ), " +
|
|
|
" 2 " +
|
|
|
" ) " +
|
|
|
" ) " +
|
|
|
" ) * 1000 " +
|
|
|
" ) AS distance ";
|
|
|
}
|
|
|
sql+= " o.address, "+
|
|
|
" FROM " +
|
|
|
" base_org o " +
|
|
|
" JOIN base_package_org po ON o.`code` = po.org_code " +
|
|
|
" WHERE " +
|
|
|
" po.service_package_id = '"+packageId+"' " +
|
|
|
" AND o.del= '1' " ;
|
|
|
if(latitude!=null&&longitude!=null){
|
|
|
sql+=" ORDER BY distance ASC ";
|
|
|
}
|
|
|
sql+= " LIMIT " + (page - 1) * size + "," + size + "";
|
|
|
List<OrgDistanceVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(OrgDistanceVO.class));
|
|
|
|
|
|
return MixEnvelop.getSuccessListWithPage(PatientRequestMapping.SignPackage.api_success, list, page, size, count);
|
|
|
}
|
|
|
|
|
|
public MixEnvelop getDoctorByOrg(String org, Integer page, Integer size){
|
|
|
|
|
|
String totalSql ="SELECT " +
|
|
|
" count(1) as total" +
|
|
|
" FROM " +
|
|
|
" base_doctor d " +
|
|
|
" JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
|
|
|
" WHERE " +
|
|
|
" h.org_code = '"+org+"'";
|
|
|
List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
|
|
|
Long count = 0L;
|
|
|
if (rstotal != null && rstotal.size() > 0) {
|
|
|
count = (Long) rstotal.get(0).get("total");
|
|
|
}
|
|
|
|
|
|
String sql ="SELECT " +
|
|
|
" d.`name`, " +
|
|
|
" d.id, " +
|
|
|
" d.job_title_code AS jobTitleCode, " +
|
|
|
" d.job_title_name AS jobTitleName, " +
|
|
|
" h.dept_name AS deptName, " +
|
|
|
" h.dept_code AS deptCode, " +
|
|
|
" d.introduce," +
|
|
|
" d.photo " +
|
|
|
" FROM " +
|
|
|
" base_doctor d " +
|
|
|
" JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
|
|
|
" WHERE " +
|
|
|
" h.org_code = '"+org+"'";
|
|
|
sql+= " LIMIT " + (page - 1) * size + "," + size + "";
|
|
|
List<BaseDoctorOrgVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(OrgDistanceVO.class));
|
|
|
|
|
|
|
|
|
return MixEnvelop.getSuccessListWithPage(PatientRequestMapping.SignPackage.api_success, list, page, size, count);
|
|
|
}
|
|
|
|
|
|
public Envelop signPackage(ServicePackageDO servicePackageDO){
|
|
|
servicePackageDO.setCreater(userAgent.getUID());
|
|
|
servicePackageDO.setCreateTime(new Date());
|
|
|
servicePackageDao.save(servicePackageDO);
|
|
|
return Envelop.getSuccess(PatientRequestMapping.SignPackage.api_success);
|
|
|
}
|
|
|
}
|