|
@ -12,7 +12,6 @@ import com.yihu.jw.entity.wlyyinfo.OauthWlyyConfigDO;
|
|
|
import com.yihu.jw.hospital.HospitalDao;
|
|
|
import com.yihu.jw.hospital.healthCare.YlzMedicalRechargeDao;
|
|
|
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;
|
|
@ -32,7 +31,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.*;
|
|
|
|
|
|
@Service
|
|
@ -129,25 +127,25 @@ public class MedicineService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void synPhysicStorage(){
|
|
|
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)){
|
|
|
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")){
|
|
|
if (jsonObject != null && jsonObject.getString("status").equalsIgnoreCase("200")) {
|
|
|
JSONObject jsonObject1 = jsonObject.getJSONObject("data");
|
|
|
if (jsonObject1!=null && jsonObject1.getString("CODE").equalsIgnoreCase("1")){
|
|
|
if (jsonObject1 != null && jsonObject1.getString("CODE").equalsIgnoreCase("1")) {
|
|
|
JSONArray jsonArray = jsonObject1.getJSONArray("returnData");
|
|
|
if (jsonArray!=null&&jsonArray.size()!=0){
|
|
|
if (jsonArray != null && jsonArray.size() != 0) {
|
|
|
|
|
|
JSONArray array = jsonArray.getJSONArray(0);
|
|
|
logger.info("12321321321321:"+array.size());
|
|
|
for (int i=0;i<array.size();i++){
|
|
|
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);
|
|
|
logger.info("12321321321321:" + object);
|
|
|
MediicineDrugsNumber mediicineDrugsNumber = new MediicineDrugsNumber();
|
|
|
mediicineDrugsNumber.setOrgCode(dmHospitalDO.getCode());
|
|
|
mediicineDrugsNumber.setOrgName(dmHospitalDO.getName());
|
|
@ -157,7 +155,7 @@ public class MedicineService {
|
|
|
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.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());
|
|
@ -170,37 +168,37 @@ public class MedicineService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
logger.info("同步药品批号"+j+"条!");
|
|
|
logger.info("同步药品批号" + j + "条!");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询药品批号价格
|
|
|
*
|
|
|
* @param orgCode 机构编码
|
|
|
* @param lotNumber 批号
|
|
|
* @param orgCode 机构编码
|
|
|
* @param lotNumber 批号
|
|
|
* @param execOperator 发药人
|
|
|
* @return
|
|
|
*/
|
|
|
public String getPhysicStorageInfo(String orgCode,String lotNumber,String execOperator){
|
|
|
public String getPhysicStorageInfo(String orgCode, String lotNumber, String execOperator) {
|
|
|
OauthWlyyConfigDO oauthWlyyConfigDO = null;
|
|
|
if ("jwZnygProd".equals(springProfiles)){
|
|
|
if ("jwZnygProd".equals(springProfiles)) {
|
|
|
oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("getPhysicStorageInfo_OUT");
|
|
|
}else {
|
|
|
} else {
|
|
|
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");
|
|
|
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());
|
|
|
logger.info("getPhysicStorageInfo token :" + rsjson.toString());
|
|
|
|
|
|
Integer status = rsjson.getInteger("status");
|
|
|
if(status==10000){
|
|
|
if (status == 10000) {
|
|
|
|
|
|
//设置入参
|
|
|
List<NameValuePair> p = new ArrayList<>();
|
|
@ -208,10 +206,10 @@ public class MedicineService {
|
|
|
|
|
|
//设置头部
|
|
|
token = rsjson.getJSONObject("result").getString("accesstoken");
|
|
|
Map<String,Object> headerMap = new HashedMap();
|
|
|
headerMap.put("accesstoken",token);
|
|
|
Map<String, Object> headerMap = new HashedMap();
|
|
|
headerMap.put("accesstoken", token);
|
|
|
|
|
|
String rs = httpClientUtil.headerPost(oauthWlyyConfigDO.getUrl(),p,"UTF-8",headerMap);
|
|
|
String rs = httpClientUtil.headerPost(oauthWlyyConfigDO.getUrl(), p, "UTF-8", headerMap);
|
|
|
WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
|
|
|
wlyyHttpLogDO.setCode("getPhysicStorageInfo");
|
|
|
wlyyHttpLogDO.setRequest(p.toString());
|
|
@ -220,9 +218,9 @@ public class MedicineService {
|
|
|
wlyyHttpLogDO.setStatus("1");
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
wlyyHttpLogDao.save(wlyyHttpLogDO);
|
|
|
logger.info("getPhysicStorageInfo:"+rs);
|
|
|
logger.info("getPhysicStorageInfo:" + rs);
|
|
|
return rs;
|
|
|
}else {
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
@ -230,8 +228,8 @@ public class MedicineService {
|
|
|
public void syncPrescriptionStatus() {
|
|
|
List<Mediicineorder> mediicineorderList = mediicineorderDao.findMediicineorderBySellState("0");
|
|
|
mediicineorderList.addAll(mediicineorderDao.findMediicineorderBySellState("-5"));
|
|
|
int i=0;
|
|
|
for (Mediicineorder mediicineorder:mediicineorderList){
|
|
|
int i = 0;
|
|
|
for (Mediicineorder mediicineorder : mediicineorderList) {
|
|
|
//判断订单是否完成,
|
|
|
String sql = "SELECT\n" +
|
|
|
"\tcount(DISTINCT(id))\n" +
|
|
@ -245,34 +243,37 @@ public class MedicineService {
|
|
|
"FROM\n" +
|
|
|
"\tt_medicine_shipment_log\n" +
|
|
|
"WHERE\n" +
|
|
|
"\torder_id = '" + mediicineorder.getId() + "'\n" +
|
|
|
"\torder_id = '" + mediicineorder.getId() + "'\n" +
|
|
|
"AND `status` = 2";
|
|
|
//已出货
|
|
|
int shipped = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
if (Integer.compare(totalShipmentLog, shipped ) == 0) {
|
|
|
System.out.println("订单号PickUpNum:"+mediicineorder.getPickUpNum()+" 药柜已取药,状态已更新");
|
|
|
}else {
|
|
|
String result = getDataStatus(mediicineorder.getPickUpNum(),mediicineorder.getBelongCommunity());
|
|
|
if (StringUtils.isNoneBlank(result)){
|
|
|
if (Integer.compare(totalShipmentLog, shipped) == 0 && shipped > 0) {
|
|
|
System.out.println("t_medicine_shipment_log已出货数量:" + shipped
|
|
|
+ " 订单号PickUpNum: " + mediicineorder.getPickUpNum()
|
|
|
+ "applyNo:" + mediicineorder.getApplyNo()
|
|
|
+ " 药柜已取药,状态已更新");
|
|
|
} else {
|
|
|
String result = getDataStatus(mediicineorder.getPickUpNum(), mediicineorder.getBelongCommunity());
|
|
|
if (StringUtils.isNoneBlank(result)) {
|
|
|
JSONObject resObj = JSONObject.parseObject(result);
|
|
|
if (resObj.getString("status").equalsIgnoreCase("200")){
|
|
|
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")){
|
|
|
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")){
|
|
|
if (code.equalsIgnoreCase("5")) {
|
|
|
mediicineorder.setSellState("-1");
|
|
|
mediicineorder.setShippingEqu("线下药房");
|
|
|
mediicineorder.setShippingTime(new Date());
|
|
|
mediicineorderDao.save(mediicineorder);
|
|
|
i++;
|
|
|
}else if (code.equalsIgnoreCase("9")){
|
|
|
} else if (code.equalsIgnoreCase("9")) {
|
|
|
mediicineorder.setSellState("-2");
|
|
|
mediicineorder.setShippingEqu("线下作废");
|
|
|
mediicineorder.setShippingTime(new Date());
|
|
@ -289,15 +290,15 @@ public class MedicineService {
|
|
|
|
|
|
public void syncOnlinePrescriptionStatus() {
|
|
|
List<Mediicineorder> mediicineorderList = mediicineorderDao.findMediicineorderBySellState("0");
|
|
|
int i=0;
|
|
|
for (Mediicineorder mediicineorder:mediicineorderList){
|
|
|
int i = 0;
|
|
|
for (Mediicineorder mediicineorder : mediicineorderList) {
|
|
|
String result = getIJKPresStatus(mediicineorder.getPickUpNum());
|
|
|
if (StringUtils.isNoneBlank(result)){
|
|
|
if (StringUtils.isNoneBlank(result)) {
|
|
|
JSONObject resObj = JSONObject.parseObject(result);
|
|
|
if (resObj.getString("status").equalsIgnoreCase("200")){
|
|
|
if (resObj.getString("status").equalsIgnoreCase("200")) {
|
|
|
JSONObject object = resObj.getJSONObject("data");
|
|
|
String code = object.getString("status");
|
|
|
if (code.equalsIgnoreCase("-5")||code.equalsIgnoreCase("-4")){
|
|
|
if (code.equalsIgnoreCase("-5") || code.equalsIgnoreCase("-4")) {
|
|
|
mediicineorder.setSellState("-2");
|
|
|
mediicineorder.setShippingEqu("线下作废");
|
|
|
mediicineorder.setShippingTime(new Date());
|
|
@ -312,23 +313,24 @@ public class MedicineService {
|
|
|
|
|
|
/**
|
|
|
* 获取处方状态
|
|
|
*
|
|
|
* @param realOrder
|
|
|
* @return
|
|
|
*/
|
|
|
public String getDataStatus(String realOrder,String hospital){
|
|
|
public String getDataStatus(String realOrder, String hospital) {
|
|
|
OauthWlyyConfigDO oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("getDataStatus");
|
|
|
//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");
|
|
|
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("getDataStatus token :"+rsjson.toString());
|
|
|
logger.info("getDataStatus token :" + rsjson.toString());
|
|
|
|
|
|
Integer status = rsjson.getInteger("status");
|
|
|
if(status==10000){
|
|
|
if (status == 10000) {
|
|
|
|
|
|
//设置入参
|
|
|
List<NameValuePair> p = new ArrayList<>();
|
|
@ -337,10 +339,10 @@ public class MedicineService {
|
|
|
|
|
|
//设置头部
|
|
|
token = rsjson.getJSONObject("result").getString("accesstoken");
|
|
|
Map<String,Object> headerMap = new HashedMap();
|
|
|
headerMap.put("accesstoken",token);
|
|
|
Map<String, Object> headerMap = new HashedMap();
|
|
|
headerMap.put("accesstoken", token);
|
|
|
|
|
|
String rs = httpClientUtil.headerPost(oauthWlyyConfigDO.getUrl(),p,"UTF-8",headerMap);
|
|
|
String rs = httpClientUtil.headerPost(oauthWlyyConfigDO.getUrl(), p, "UTF-8", headerMap);
|
|
|
WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
|
|
|
wlyyHttpLogDO.setCode("getDataStatus");
|
|
|
wlyyHttpLogDO.setRequest(p.toString());
|
|
@ -349,9 +351,9 @@ public class MedicineService {
|
|
|
wlyyHttpLogDO.setStatus("1");
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
wlyyHttpLogDao.save(wlyyHttpLogDO);
|
|
|
logger.info("getDataStatus:"+rs);
|
|
|
logger.info("getDataStatus:" + rs);
|
|
|
return rs;
|
|
|
}else {
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@ -360,23 +362,24 @@ public class MedicineService {
|
|
|
|
|
|
/**
|
|
|
* 获取处方状态
|
|
|
*
|
|
|
* @param realOrder
|
|
|
* @return
|
|
|
*/
|
|
|
public String getIJKPresStatus(String realOrder){
|
|
|
public String getIJKPresStatus(String realOrder) {
|
|
|
OauthWlyyConfigDO oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("getIJKPresStatus");
|
|
|
//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");
|
|
|
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("getIJKPresStatus token :"+rsjson.toString());
|
|
|
logger.info("getIJKPresStatus token :" + rsjson.toString());
|
|
|
|
|
|
Integer status = rsjson.getInteger("status");
|
|
|
if(status==10000){
|
|
|
if (status == 10000) {
|
|
|
|
|
|
//设置入参
|
|
|
List<NameValuePair> p = new ArrayList<>();
|
|
@ -384,10 +387,10 @@ public class MedicineService {
|
|
|
|
|
|
//设置头部
|
|
|
token = rsjson.getJSONObject("result").getString("accesstoken");
|
|
|
Map<String,Object> headerMap = new HashedMap();
|
|
|
headerMap.put("accesstoken",token);
|
|
|
Map<String, Object> headerMap = new HashedMap();
|
|
|
headerMap.put("accesstoken", token);
|
|
|
|
|
|
String rs = httpClientUtil.headerPost(oauthWlyyConfigDO.getUrl(),p,"UTF-8",headerMap);
|
|
|
String rs = httpClientUtil.headerPost(oauthWlyyConfigDO.getUrl(), p, "UTF-8", headerMap);
|
|
|
WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
|
|
|
wlyyHttpLogDO.setCode("getIJKPresStatus");
|
|
|
wlyyHttpLogDO.setRequest(p.toString());
|
|
@ -396,9 +399,9 @@ public class MedicineService {
|
|
|
wlyyHttpLogDO.setStatus("1");
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
wlyyHttpLogDao.save(wlyyHttpLogDO);
|
|
|
logger.info("getIJKPresStatus:"+rs);
|
|
|
logger.info("getIJKPresStatus:" + rs);
|
|
|
return rs;
|
|
|
}else {
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@ -432,21 +435,21 @@ public class MedicineService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Async
|
|
|
public void hlwyyRechargeNotify(String outChargeNo){
|
|
|
public void hlwyyRechargeNotify(String outChargeNo) {
|
|
|
String url = "http://127.0.0.1:10020/baseOrder/open/hlwyyRechargeNotify";
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
JSONObject paramTmp = new JSONObject();
|
|
|
paramTmp.put("outChargeNo",outChargeNo);
|
|
|
paramTmp.put("outChargeNo", outChargeNo);
|
|
|
JSONObject paramTmpObj = new JSONObject();
|
|
|
paramTmpObj.put("param",paramTmp);
|
|
|
params.add(new BasicNameValuePair("responsStr",paramTmpObj.toJSONString()));
|
|
|
paramTmpObj.put("param", paramTmp);
|
|
|
params.add(new BasicNameValuePair("responsStr", paramTmpObj.toJSONString()));
|
|
|
httpClientUtil.post(url, params, "UTF-8");
|
|
|
}
|
|
|
}
|