|
@ -0,0 +1,95 @@
|
|
|
package com.yihu.wlyy.service.app.prescription;
|
|
|
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionAdress;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionAdressDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import net.sf.json.JSON;
|
|
|
import net.sf.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Created by Trick on 2017/10/20.
|
|
|
*/
|
|
|
public class PrescriptionAdressService extends BaseService {
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private PrescriptionAdressDao prescriptionAdressDao;
|
|
|
|
|
|
//获取列表
|
|
|
public List<Map<String,Object>> getAdressList(String patient){
|
|
|
String sql = "SELECT ad.* FROM wlyy_prescription_adress ad WHERE ad.patient ='"+patient+"' ORDER BY ad.default_flag DESC";
|
|
|
List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
|
|
|
return rs;
|
|
|
}
|
|
|
//保存
|
|
|
public String saveAdress(String adressJosn){
|
|
|
JSONObject jsonObject = JSONObject.fromObject(adressJosn);
|
|
|
PrescriptionAdress p = (PrescriptionAdress) net.sf.json.JSONObject.toBean(jsonObject,PrescriptionAdress.class);
|
|
|
p.setCreateTime(new Date());
|
|
|
if(p.getDefaultFlag()==1){
|
|
|
String sql ="UPDATE wlyy_prescription_adress set defaultFlag = 0 WHERE patient ='"+p.getPatient()+"' ";
|
|
|
jdbcTemplate.execute(sql);
|
|
|
}
|
|
|
prescriptionAdressDao.save(p);
|
|
|
return "1";
|
|
|
}
|
|
|
//更新
|
|
|
public String updateAdress(String adressJson){
|
|
|
JSONObject jsonObject = JSONObject.fromObject(adressJson);
|
|
|
PrescriptionAdress p = (PrescriptionAdress) net.sf.json.JSONObject.toBean(jsonObject,PrescriptionAdress.class);
|
|
|
p.setCreateTime(new Date());
|
|
|
if(p.getDefaultFlag()==1){
|
|
|
String sql ="UPDATE wlyy_prescription_adress set defaultFlag = 0 WHERE patient ='"+p.getPatient()+"' ";
|
|
|
jdbcTemplate.execute(sql);
|
|
|
}
|
|
|
prescriptionAdressDao.save(p);
|
|
|
return "1";
|
|
|
}
|
|
|
|
|
|
//删除
|
|
|
public String delAdress(Long id){
|
|
|
prescriptionAdressDao.delete(id);
|
|
|
return "1";
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getProvince(){
|
|
|
String sql = "SELECT " +
|
|
|
" p.`code`, " +
|
|
|
" p.`name` " +
|
|
|
" FROM " +
|
|
|
" dm_province p";
|
|
|
List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getCityByProvince(String province){
|
|
|
String sql = "SELECT " +
|
|
|
" p.`code`, " +
|
|
|
" p.`name` " +
|
|
|
" FROM " +
|
|
|
" dm_city p " +
|
|
|
" WHERE p.province = '"+province+"'";
|
|
|
List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getTowmByCity(String city){
|
|
|
String sql = "SELECT " +
|
|
|
" p.`code`, " +
|
|
|
" p.`name` " +
|
|
|
" FROM " +
|
|
|
" dm_town p " +
|
|
|
" WHERE p.city = '"+city+"'";
|
|
|
List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|