|
@ -2,13 +2,19 @@ package com.yihu.jw.service.channel;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.entity.a1entity.MediicineDrugsNumber;
|
|
|
import com.yihu.jw.entity.a1entity.Mediicinedrugs;
|
|
|
import com.yihu.jw.entity.a1entity.Mediicineorder;
|
|
|
import com.yihu.jw.entity.hospital.DmHospitalDO;
|
|
|
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
|
|
|
import com.yihu.jw.entity.wlyyinfo.OauthWlyyConfigDO;
|
|
|
import com.yihu.jw.hospital.HospitalDao;
|
|
|
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
|
|
|
|
|
|
import com.yihu.jw.repository.job.MediicinedrugsDao;
|
|
|
import com.yihu.jw.repository.job.MediicinedrugsNumberDao;
|
|
|
import com.yihu.jw.repository.job.MediicineorderDao;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
import com.yihu.jw.wlyy.dao.OauthWlyyConfigDao;
|
|
|
import com.yihu.jw.wlyy.wlyyhttp.WlyyHttpService;
|
|
@ -41,6 +47,10 @@ public class MedicineService {
|
|
|
private OauthWlyyConfigDao oauthWlyyConfigDao;
|
|
|
@Autowired
|
|
|
private WlyyHttpLogDao wlyyHttpLogDao;
|
|
|
@Autowired
|
|
|
private HospitalDao hospitalDao;
|
|
|
@Autowired
|
|
|
private MediicinedrugsNumberDao mediicinedrugsNumberDao;
|
|
|
|
|
|
|
|
|
public void getOrgPhysicDict(String orgCode, String name, String orgName, String physicCode) {
|
|
@ -110,6 +120,98 @@ public class MedicineService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void synPhysicStorage(){
|
|
|
List<DmHospitalDO> dmHospitalDOS = hospitalDao.findByLevel(2);
|
|
|
mediicinedrugsNumberDao.deleteAll();
|
|
|
int j =0;
|
|
|
for (DmHospitalDO dmHospitalDO:dmHospitalDOS){
|
|
|
String result = getPhysicStorageInfo(dmHospitalDO.getCode(),null,null);
|
|
|
if (StringUtils.isNoneBlank(result)){
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
if (jsonObject!=null&&jsonObject.getString("status").equalsIgnoreCase("200")){
|
|
|
JSONObject jsonObject1 = jsonObject.getJSONObject("data");
|
|
|
if (jsonObject1!=null && jsonObject1.getString("CODE").equalsIgnoreCase("1")){
|
|
|
JSONArray jsonArray = jsonObject1.getJSONArray("returnData");
|
|
|
if (jsonArray!=null&&jsonArray.size()!=0){
|
|
|
|
|
|
JSONArray array = jsonArray.getJSONArray(0);
|
|
|
logger.info("12321321321321:"+array.size());
|
|
|
for (int i=0;i<array.size();i++){
|
|
|
JSONObject object = array.getJSONObject(i);
|
|
|
logger.info("12321321321321:"+object);
|
|
|
MediicineDrugsNumber mediicineDrugsNumber = new MediicineDrugsNumber();
|
|
|
mediicineDrugsNumber.setOrgCode(dmHospitalDO.getCode());
|
|
|
mediicineDrugsNumber.setOrgName(dmHospitalDO.getName());
|
|
|
mediicineDrugsNumber.setBatchNo(object.getString("BATCH_NO"));
|
|
|
mediicineDrugsNumber.setLotNumber(object.getString("LOT_NUMBER"));
|
|
|
mediicineDrugsNumber.setPhysicCode(object.getString("PHYSIC_CODE"));
|
|
|
mediicineDrugsNumber.setPhysicName(object.getString("PHYSIC_NAME"));
|
|
|
mediicineDrugsNumber.setStorageDept(object.getString("STORAGE_DEPT"));
|
|
|
mediicineDrugsNumber.setStorageDeptName(object.getString("STORAGE_DEPT_NAME"));
|
|
|
mediicineDrugsNumber.setValidTime(object.get("VALID_TIME")==null?null: DateUtil.strToDateLong(object.getString("VALID_TIME")));
|
|
|
mediicineDrugsNumber.setRetailPrice(object.getString("RETAIL_PRICE"));
|
|
|
mediicineDrugsNumber.setCreateTime(new Date());
|
|
|
mediicineDrugsNumber.setUpdateTime(new Date());
|
|
|
mediicinedrugsNumberDao.save(mediicineDrugsNumber);
|
|
|
logger.info("12321321321321321321321");
|
|
|
j++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
logger.info("同步药品批号"+j+"条!");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询药品批号价格
|
|
|
*
|
|
|
* @param orgCode 机构编码
|
|
|
* @param lotNumber 批号
|
|
|
* @param execOperator 发药人
|
|
|
* @return
|
|
|
*/
|
|
|
public String getPhysicStorageInfo(String orgCode,String lotNumber,String execOperator){
|
|
|
OauthWlyyConfigDO oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("getPhysicStorageInfo");
|
|
|
//token获取accesstoken
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
params.add(new BasicNameValuePair("appid", oauthWlyyConfigDO.getAppId()));
|
|
|
params.add(new BasicNameValuePair("appSecret",oauthWlyyConfigDO.getAppSecret()));
|
|
|
String res = httpClientUtil.post(oauthWlyyConfigDO.getTokenUrl(),params,"UTF-8");
|
|
|
String token = null;
|
|
|
JSONObject rsjson = JSONObject.parseObject(res);
|
|
|
|
|
|
logger.info("getPhysicStorageInfo token :"+rsjson.toString());
|
|
|
|
|
|
Integer status = rsjson.getInteger("status");
|
|
|
if(status==10000){
|
|
|
|
|
|
//设置入参
|
|
|
List<NameValuePair> p = new ArrayList<>();
|
|
|
p.add(new BasicNameValuePair("orgCode", orgCode));
|
|
|
|
|
|
//设置头部
|
|
|
token = rsjson.getJSONObject("result").getString("accesstoken");
|
|
|
Map<String,Object> headerMap = new HashedMap();
|
|
|
headerMap.put("accesstoken",token);
|
|
|
|
|
|
String rs = httpClientUtil.headerPost(oauthWlyyConfigDO.getUrl(),p,"UTF-8",headerMap);
|
|
|
WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
|
|
|
wlyyHttpLogDO.setCode("getPhysicStorageInfo");
|
|
|
wlyyHttpLogDO.setRequest(p.toString());
|
|
|
wlyyHttpLogDO.setResponse(rs);
|
|
|
wlyyHttpLogDO.setName("更新取药码状态");
|
|
|
wlyyHttpLogDO.setStatus("1");
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
wlyyHttpLogDao.save(wlyyHttpLogDO);
|
|
|
logger.info("getPhysicStorageInfo:"+rs);
|
|
|
return rs;
|
|
|
}else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void syncPrescriptionStatus() {
|
|
|
List<Mediicineorder> mediicineorderList = mediicineorderDao.findMediicineorderBySellState("0");
|
|
|
int i=0;
|
|
@ -120,6 +222,14 @@ public class MedicineService {
|
|
|
if (resObj.getString("status").equalsIgnoreCase("200")){
|
|
|
JSONObject object = resObj.getJSONObject("data");
|
|
|
String code = object.getString("RECIPE_STATUS_CODE");
|
|
|
String chargeCode = object.getString("CHARGE_STATUS_CODE");
|
|
|
if (chargeCode.equalsIgnoreCase("0")){
|
|
|
mediicineorder.setSellState("-1");
|
|
|
mediicineorder.setShippingEqu("线下药房");
|
|
|
mediicineorder.setShippingTime(new Date());
|
|
|
mediicineorderDao.save(mediicineorder);
|
|
|
i++;
|
|
|
}
|
|
|
if (code.equalsIgnoreCase("5")){
|
|
|
mediicineorder.setSellState("-1");
|
|
|
mediicineorder.setShippingEqu("线下药房");
|