|
@ -4,7 +4,6 @@ package com.yihu.jw.base.service.a3service;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.sun.org.apache.xpath.internal.operations.Bool;
|
|
|
import com.yihu.jw.base.dao.a2dao.*;
|
|
|
import com.yihu.jw.base.dao.equipment.WlyyUserAreaDao;
|
|
|
import com.yihu.jw.base.dao.role.RoleDao;
|
|
@ -18,29 +17,21 @@ import com.yihu.jw.entity.equipment.WlyyUserAreaDO;
|
|
|
import com.yihu.jw.entity.hospital.DmHospitalDO;
|
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
|
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
|
|
|
import com.yihu.jw.entity.hospital.httplog.YlzHttpLogDO;
|
|
|
import com.yihu.jw.entity.wlyyinfo.OauthWlyyConfigDO;
|
|
|
import com.yihu.jw.hospital.HospitalDao;
|
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
|
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
|
|
|
import com.yihu.jw.hospital.prescription.dao.OauthCaConfigDao;
|
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.rm.base.BaseRequestMapping;
|
|
|
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
|
import com.yihu.jw.wlyy.dao.OauthWlyyConfigDao;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import com.ylzinfo.onepay.sdk.utils.StringUtil;
|
|
|
import jxl.format.VerticalAlignment;
|
|
|
import jxl.write.*;
|
|
|
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.collections4.IterableUtils;
|
|
|
import org.apache.http.NameValuePair;
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@ -51,19 +42,16 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.awt.print.Pageable;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.lang.Boolean;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.logging.Logger;
|
|
|
import java.util.regex.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static jxl.biff.BaseCellFeatures.logger;
|
|
|
|
|
|
/**
|
|
|
* Created by Bing on 2021/9/23.
|
|
|
*/
|
|
@ -221,10 +209,10 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
|
|
|
//orderNum, equNum, contact, startTime, endTime, sellState, orderState, dispensingWindow
|
|
|
public JSONObject queryOrderListFullInfo(String content,String orderNum, String equNum, String contact,
|
|
|
public JSONObject queryOrderListFullInfo(String content, String orderNum, String equNum, String contact,
|
|
|
String startTime, String endTime, String sellState,
|
|
|
String orderState,String reviewerState, String dispensingWindow, String community,String town,
|
|
|
String userId, int page, int size, String wechatId,String timeSort) throws Exception {
|
|
|
String orderState, String reviewerState, String dispensingWindow, String community, String town,
|
|
|
String userId, int page, int size, String wechatId, String timeSort) throws Exception {
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
@ -236,7 +224,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
UserDO user = userDao.findOne(userId);
|
|
|
RoleDO role = roleDao.findOne(user.getRoleId());
|
|
|
if (role==null){
|
|
|
if (role == null) {
|
|
|
throw new Exception("角色为空!");
|
|
|
}
|
|
|
//订单列表
|
|
@ -357,8 +345,8 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
if (!StringUtils.isEmpty(community)) {
|
|
|
conditionSql += " and t.belong_community = '" + community + "'";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(town)){
|
|
|
conditionSql += "AND t.belong_community IN(SELECT d.code FROM dm_hospital d where d.town = '"+town+"' )\n ";
|
|
|
if (!StringUtils.isEmpty(town)) {
|
|
|
conditionSql += "AND t.belong_community IN(SELECT d.code FROM dm_hospital d where d.town = '" + town + "' )\n ";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(orderNum)) {
|
|
|
conditionSql += " and t.order_num = '" + orderNum + "'";
|
|
@ -379,19 +367,19 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
if (!StringUtils.isEmpty(orderState)) {
|
|
|
conditionSql += " and t.order_state = '" + orderState + "'";
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(reviewerState)){
|
|
|
conditionSql += " and t.reviewer_state='"+reviewerState+"' ";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(reviewerState)) {
|
|
|
conditionSql += " and t.reviewer_state='" + reviewerState + "' ";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(dispensingWindow)) {
|
|
|
conditionSql += " and t.dispensing_window = '" + dispensingWindow + "'";
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(timeSort)){
|
|
|
if ("1".equals(timeSort)){
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(timeSort)) {
|
|
|
if ("1".equals(timeSort)) {
|
|
|
sencodSql = sencodSql + conditionSql + " order by t.prescribe_time asc ";
|
|
|
}else {
|
|
|
} else {
|
|
|
sencodSql = sencodSql + conditionSql + " order by t.prescribe_time desc ";
|
|
|
}
|
|
|
}else {
|
|
|
} else {
|
|
|
sencodSql = sencodSql + conditionSql + " order by t.sell_state asc,t.prescribe_time desc ";
|
|
|
}
|
|
|
|
|
@ -514,7 +502,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject updateOrderToWaitOut(String orderId,String userId){
|
|
|
public JSONObject updateOrderToWaitOut(String orderId, String userId) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
/*String sql = " select count(id) from wlyy_hospital_sys_dict where dict_name='updateOrderToWaitOut' " +
|
|
|
" and dict_code='updateOrderToWaitOut' " +
|
|
@ -873,7 +861,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public JSONObject updateOrderOutStatus(String shipmentLogId, String status, String msg,Integer shippingType) {
|
|
|
public JSONObject updateOrderOutStatus(String shipmentLogId, String status, String msg, Integer shippingType) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
if (shipmentLogId == null || StringUtils.isEmpty(shipmentLogId)) {
|
|
|
result.put("msg", "shipmentLogId is null or empty");
|
|
@ -917,12 +905,12 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
Mediicineorder order = orderDao.findOne(medicineShipmentLog.getOrderId());
|
|
|
order.setSellState("1");
|
|
|
order.setShippingType(shippingType);
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(order.getApplyNo())){
|
|
|
Boolean flag = sickPhysicDosage(order.getBelongCommunity(),order.getApplyNo(),medicineShipmentLog.getEquNum());
|
|
|
logger.info("flag"+flag);
|
|
|
}else {
|
|
|
Boolean flag = scanQrdispensaryCode(order.getPickUpNum(),medicineShipmentLog.getEquNum());
|
|
|
logger.info("flag"+flag);
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(order.getApplyNo())) {
|
|
|
Boolean flag = sickPhysicDosage(order.getBelongCommunity(), order.getApplyNo(), medicineShipmentLog.getEquNum());
|
|
|
logger.info("flag" + flag);
|
|
|
} else {
|
|
|
Boolean flag = scanQrdispensaryCode(order.getPickUpNum(), medicineShipmentLog.getEquNum());
|
|
|
logger.info("flag" + flag);
|
|
|
}
|
|
|
|
|
|
orderDao.save(order);
|
|
@ -937,7 +925,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
medicineShipmentLog.setDescription(msg);
|
|
|
}
|
|
|
|
|
|
Logger.getAnonymousLogger().info("更新出货单出货状态----"+ "订单号为:" +medicineShipmentLog.getOrderId() + "----下的出货单号为:"+medicineShipmentLog.getId()+ "----更新了出货状态----"+status+"----附加信息为----"+msg);
|
|
|
Logger.getAnonymousLogger().info("更新出货单出货状态----" + "订单号为:" + medicineShipmentLog.getOrderId() + "----下的出货单号为:" + medicineShipmentLog.getId() + "----更新了出货状态----" + status + "----附加信息为----" + msg);
|
|
|
shipmentLogDao.save(medicineShipmentLog);
|
|
|
|
|
|
Mediicineorder mediicineorder = orderDao.findOne(medicineShipmentLog.getOrderId());
|
|
@ -948,7 +936,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
medicineShipmentLog.getDeviceId(), //equNum
|
|
|
medicineShipmentLog.getLayerNo(),
|
|
|
medicineShipmentLog.getWayerNo().split(",")[0]);
|
|
|
inventory.setQty((Integer.parseInt(inventory.getQty()) - 1<0 ? "0" :String.valueOf((Integer.parseInt(inventory.getQty()) - 1))));
|
|
|
inventory.setQty((Integer.parseInt(inventory.getQty()) - 1 < 0 ? "0" : String.valueOf((Integer.parseInt(inventory.getQty()) - 1))));
|
|
|
InventoryDO inventoryDO = new InventoryDO();
|
|
|
inventoryDO.setDrugCode(inventory.getDrugCode());
|
|
|
inventoryDO.setOrgCode(inventory.getOrgCode());
|
|
@ -964,7 +952,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
//更新设备缺货状态
|
|
|
// updateDeviceState(medicineShipmentLog);
|
|
|
}
|
|
|
if ("3".equals(status)){//出药过程失败,封锁订单
|
|
|
if ("3".equals(status)) {//出药过程失败,封锁订单
|
|
|
mediicineorder.setSellState("-5");
|
|
|
orderDao.save(mediicineorder);
|
|
|
}
|
|
@ -978,7 +966,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
*/
|
|
|
public void updateDeviceState(String cargoId, InventoryDO inventoryDO) {
|
|
|
//包含原来药品信息
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(cargoId);
|
|
|
MediicinecabinetInventory inventory = inventoryDao.findOne(cargoId);
|
|
|
String sql = "SELECT\n" +
|
|
|
"\tsum(qty) AS qty,\n" +
|
|
|
"\tdrug_id AS drugId,\n" +
|
|
@ -988,9 +976,9 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
"FROM\n" +
|
|
|
"\tt_mediicinecabinet_inventory\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tid_device = '"+inventory.getIdDevice()+"'\n" +
|
|
|
"\tid_device = '" + inventory.getIdDevice() + "'\n" +
|
|
|
"AND (state = '1' OR state = '21')\n" +
|
|
|
"AND id != '"+ cargoId +"'\n" +
|
|
|
"AND id != '" + cargoId + "'\n" +
|
|
|
"AND drug_code IS NOT NULL\n" +
|
|
|
"AND org_code IS NOT NULL\n" +
|
|
|
"GROUP BY\n" +
|
|
@ -1042,7 +1030,8 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
// deviceDao.save(mediicinedevice);
|
|
|
// }
|
|
|
//bug:end
|
|
|
quit:for (MedicineWarrayRule rule : rules) {
|
|
|
quit:
|
|
|
for (MedicineWarrayRule rule : rules) {
|
|
|
for (Map<String, Object> stringObjectMap : collect) {
|
|
|
if (isExit) {
|
|
|
if (inventoryDO.getDrugCode() != null && inventoryDO.getOrgCode() != null) {
|
|
@ -1165,7 +1154,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
return result;
|
|
|
}
|
|
|
String tempSql = "select IFNULL((select count(distinct(id)) from t_medicine_shipment_log where order_id = '"+orderId+"'), 0)";
|
|
|
String tempSql = "select IFNULL((select count(distinct(id)) from t_medicine_shipment_log where order_id = '" + orderId + "'), 0)";
|
|
|
int count = jdbcTemplate.queryForObject(tempSql, Integer.class);
|
|
|
if (count == 0) {
|
|
|
result.put("msg", "订单未生成出货单(订单异常)");
|
|
@ -1199,23 +1188,23 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
public String getEhcCardInfo(String ehealthCode) throws Exception {
|
|
|
OauthWlyyConfigDO oauthWlyyConfigDO = null;
|
|
|
if ("jwZnygProd".equals(springProfiles)){
|
|
|
oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("EHCVerify_OUT");
|
|
|
}else {
|
|
|
if ("jwZnygProd".equals(springProfiles)) {
|
|
|
oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("EHCVerify_OUT");
|
|
|
} else {
|
|
|
oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("EHCVerify");
|
|
|
}
|
|
|
//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("checkWlyyDoctor token :"+rsjson.toString());
|
|
|
logger.info("checkWlyyDoctor token :" + rsjson.toString());
|
|
|
|
|
|
Integer status = rsjson.getInteger("status");
|
|
|
if(status==10000){
|
|
|
if (status == 10000) {
|
|
|
|
|
|
//设置入参
|
|
|
List<NameValuePair> p = new ArrayList<>();
|
|
@ -1223,10 +1212,10 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
//设置头部
|
|
|
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("EHCVerify");
|
|
|
wlyyHttpLogDO.setRequest(p.toString());
|
|
@ -1235,27 +1224,28 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
wlyyHttpLogDO.setStatus("1");
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
httpLogDao.save(wlyyHttpLogDO);
|
|
|
logger.info("checkWlyyDoctor EHCVerify :"+rs);
|
|
|
if (rs!=null&&rs!=""){
|
|
|
logger.info("checkWlyyDoctor EHCVerify :" + rs);
|
|
|
if (rs != null && rs != "") {
|
|
|
JSONObject ehc = JSONObject.parseObject(rs);
|
|
|
|
|
|
if (ehc.getString("ret_code").equalsIgnoreCase("0000")){
|
|
|
if (ehc.getString("ret_code").equalsIgnoreCase("0000")) {
|
|
|
JSONObject biz = ehc.getJSONObject("biz_content");
|
|
|
String cardNo = biz.getString("card_no");
|
|
|
if (cardNo!=null&&cardNo!=""){
|
|
|
if (cardNo != null && cardNo != "") {
|
|
|
return cardNo;
|
|
|
}else {
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
}if (ehc.getString("ret_code").equalsIgnoreCase("2006")){
|
|
|
throw new Exception(ehc.getString("ret_msg")+"请重新刷新电子健康卡");
|
|
|
}else {
|
|
|
throw new Exception(ehc.getString("ret_msg")+"请重新刷新电子健康卡");
|
|
|
}
|
|
|
}else {
|
|
|
if (ehc.getString("ret_code").equalsIgnoreCase("2006")) {
|
|
|
throw new Exception(ehc.getString("ret_msg") + "请重新刷新电子健康卡");
|
|
|
} else {
|
|
|
throw new Exception(ehc.getString("ret_msg") + "请重新刷新电子健康卡");
|
|
|
}
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
}else {
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
@ -1263,28 +1253,29 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
/**
|
|
|
* 取药成功回调接口
|
|
|
*
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean scanQrdispensaryCode(String code,String deviceNum){
|
|
|
OauthWlyyConfigDO oauthWlyyConfigDO=null;
|
|
|
if ("jwZnygProd".equals(springProfiles)){
|
|
|
oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("scanQrdispensaryCode_OUT");
|
|
|
}else {
|
|
|
oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("scanQrdispensaryCode");
|
|
|
public boolean scanQrdispensaryCode(String code, String deviceNum) {
|
|
|
OauthWlyyConfigDO oauthWlyyConfigDO = null;
|
|
|
if ("jwZnygProd".equals(springProfiles)) {
|
|
|
oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("scanQrdispensaryCode_OUT");
|
|
|
} else {
|
|
|
oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("scanQrdispensaryCode");
|
|
|
}
|
|
|
//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("checkWlyyDoctor token :"+rsjson.toString());
|
|
|
logger.info("checkWlyyDoctor token :" + rsjson.toString());
|
|
|
|
|
|
Integer status = rsjson.getInteger("status");
|
|
|
if(status==10000){
|
|
|
if (status == 10000) {
|
|
|
|
|
|
//设置入参
|
|
|
List<NameValuePair> p = new ArrayList<>();
|
|
@ -1293,10 +1284,10 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
//设置头部
|
|
|
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("scanQrdispensaryCode");
|
|
|
wlyyHttpLogDO.setRequest(p.toString());
|
|
@ -1305,16 +1296,16 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
wlyyHttpLogDO.setStatus("1");
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
httpLogDao.save(wlyyHttpLogDO);
|
|
|
logger.info("scanQrdispensaryCode:"+rs);
|
|
|
if (rs!=null&&rs!=""){
|
|
|
logger.info("scanQrdispensaryCode:" + rs);
|
|
|
if (rs != null && rs != "") {
|
|
|
JSONObject ehc = JSONObject.parseObject(rs);
|
|
|
if (ehc.getString("status").equalsIgnoreCase("200")){
|
|
|
if (ehc.getString("status").equalsIgnoreCase("200")) {
|
|
|
return true;
|
|
|
}
|
|
|
}else {
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
}else {
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
return false;
|
|
@ -1329,20 +1320,20 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
* @param execOperator
|
|
|
* @return
|
|
|
*/
|
|
|
public String getPhysicStorageInfo(String orgCode,String lotNumber,String execOperator){
|
|
|
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");
|
|
|
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<>();
|
|
@ -1350,10 +1341,10 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
//设置头部
|
|
|
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());
|
|
@ -1362,9 +1353,9 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
wlyyHttpLogDO.setStatus("1");
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
httpLogDao.save(wlyyHttpLogDO);
|
|
|
logger.info("getPhysicStorageInfo:"+rs);
|
|
|
return rs;
|
|
|
}else {
|
|
|
logger.info("getPhysicStorageInfo:" + rs);
|
|
|
return rs;
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
@ -1373,32 +1364,31 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
/**
|
|
|
* 线下订单药柜取药回调发药
|
|
|
* 线上续方 可只传处方号
|
|
|
线下续方 无处方号 机构、单据号必传
|
|
|
* 线下续方 无处方号 机构、单据号必传
|
|
|
*
|
|
|
* @param orgCode
|
|
|
* @param applyNo
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean sickPhysicDosage(String orgCode,String applyNo,String deviceNum){
|
|
|
public boolean sickPhysicDosage(String orgCode, String applyNo, String deviceNum) {
|
|
|
OauthWlyyConfigDO oauthWlyyConfigDO = null;
|
|
|
if ("jwZnygProd".equals(springProfiles)){
|
|
|
if ("jwZnygProd".equals(springProfiles)) {
|
|
|
oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("sickPhysicDosage_OUT");
|
|
|
}else {
|
|
|
} else {
|
|
|
oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("sickPhysicDosage");
|
|
|
}
|
|
|
//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("sickPhysicDosage token :"+rsjson.toString());
|
|
|
logger.info("sickPhysicDosage token :" + rsjson.toString());
|
|
|
|
|
|
Integer status = rsjson.getInteger("status");
|
|
|
if(status==10000){
|
|
|
if (status == 10000) {
|
|
|
|
|
|
//设置入参
|
|
|
List<NameValuePair> p = new ArrayList<>();
|
|
@ -1408,10 +1398,10 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
//设置头部
|
|
|
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("sickPhysicDosage");
|
|
|
wlyyHttpLogDO.setRequest(p.toString());
|
|
@ -1420,16 +1410,16 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
wlyyHttpLogDO.setStatus("1");
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
httpLogDao.save(wlyyHttpLogDO);
|
|
|
logger.info("sickPhysicDosage:"+rs);
|
|
|
if (rs!=null&&rs!=""){
|
|
|
logger.info("sickPhysicDosage:" + rs);
|
|
|
if (rs != null && rs != "") {
|
|
|
JSONObject ehc = JSONObject.parseObject(rs);
|
|
|
if (ehc.getString("status").equalsIgnoreCase("200")){
|
|
|
if (ehc.getString("status").equalsIgnoreCase("200")) {
|
|
|
return true;
|
|
|
}
|
|
|
}else {
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
}else {
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
return false;
|
|
@ -1438,37 +1428,38 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
/**
|
|
|
* 线下订单同步
|
|
|
* 线上续方 可只传处方号
|
|
|
线下续方 无处方号 机构、病人卡号都必传
|
|
|
* 线下续方 无处方号 机构、病人卡号都必传
|
|
|
*
|
|
|
* @param deviceId
|
|
|
* @param cardNo
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean getPhysicApplyWaitExecList(String deviceId,String cardNo,String patientName){
|
|
|
public boolean getPhysicApplyWaitExecList(String deviceId, String cardNo, String patientName) {
|
|
|
Mediicinedevice mediicinedevice = deviceDao.findMediicinedeviceByEquNum(deviceId);
|
|
|
String orgCode = "";
|
|
|
String community = "";
|
|
|
if (mediicinedevice!=null){
|
|
|
if (mediicinedevice != null) {
|
|
|
orgCode = mediicinedevice.getBelongCommunity();
|
|
|
community = mediicinedevice.getCommunity();
|
|
|
}
|
|
|
OauthWlyyConfigDO oauthWlyyConfigDO = null;
|
|
|
if ("jwZnygProd".equals(springProfiles)){
|
|
|
if ("jwZnygProd".equals(springProfiles)) {
|
|
|
oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("getPhysicApplyWaitExecList_OUT");
|
|
|
}else{
|
|
|
oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("getPhysicApplyWaitExecList");
|
|
|
} else {
|
|
|
oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("getPhysicApplyWaitExecList");
|
|
|
}
|
|
|
//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("getPhysicApplyWaitExecList token :"+rsjson.toString());
|
|
|
logger.info("getPhysicApplyWaitExecList token :" + rsjson.toString());
|
|
|
|
|
|
Integer status = rsjson.getInteger("status");
|
|
|
if(status==10000){
|
|
|
if (status == 10000) {
|
|
|
|
|
|
//设置入参
|
|
|
List<NameValuePair> p = new ArrayList<>();
|
|
@ -1478,10 +1469,10 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
//设置头部
|
|
|
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("getPhysicApplyWaitExecList");
|
|
|
wlyyHttpLogDO.setRequest(p.toString());
|
|
@ -1491,24 +1482,24 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
httpLogDao.save(wlyyHttpLogDO);
|
|
|
|
|
|
logger.info("getPhysicApplyWaitExecList:"+rs);
|
|
|
if (rs!=null&&rs!=""){
|
|
|
logger.info("getPhysicApplyWaitExecList:" + rs);
|
|
|
if (rs != null && rs != "") {
|
|
|
JSONObject ehc = JSONObject.parseObject(rs);
|
|
|
if (ehc.getString("status").equalsIgnoreCase("200")){
|
|
|
if (ehc.getString("status").equalsIgnoreCase("200")) {
|
|
|
JSONObject data = ehc.getJSONObject("data");
|
|
|
String code = data.getString("CODE");
|
|
|
if (code.equalsIgnoreCase("1")){
|
|
|
String sql = " update t_mediicine_order set sell_state=-4 where social_security_card_num='"+cardNo+"' and sell_state=0 and belong_community='"+mediicinedevice.getBelongCommunity()+"' ";
|
|
|
if (code.equalsIgnoreCase("1")) {
|
|
|
String sql = " update t_mediicine_order set sell_state=-4 where social_security_card_num='" + cardNo + "' and sell_state=0 and belong_community='" + mediicinedevice.getBelongCommunity() + "' ";
|
|
|
jdbcTemplate.execute(sql);
|
|
|
JSONArray array = data.getJSONArray("returnData");
|
|
|
if (array!=null&&array.size()!=0){
|
|
|
if (array != null && array.size() != 0) {
|
|
|
JSONArray jsonArray = array.getJSONArray(0);
|
|
|
for (int i=0;i<jsonArray.size();i++){
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
String realOrder = jsonObject.getString("RECIPE_NO");
|
|
|
String alyNo = jsonObject.getString("APPLY_NO");
|
|
|
Mediicineorder mediicineorder = orderDao.findByOrderNum(realOrder);
|
|
|
if (mediicineorder==null) {
|
|
|
if (mediicineorder == null) {
|
|
|
mediicineorder = new Mediicineorder();
|
|
|
mediicineorder.setOrderNum(realOrder);
|
|
|
mediicineorder.setApplyNo(alyNo);
|
|
@ -1563,7 +1554,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
mediicineorderdetail.setSocialSecurityCardNum(cardNo);
|
|
|
orderdetailDao.save(mediicineorderdetail);
|
|
|
}
|
|
|
}else if ("-4".equals(mediicineorder.getSellState())){//订单还能获取到切状态为过期,改为待取药状态
|
|
|
} else if ("-4".equals(mediicineorder.getSellState())) {//订单还能获取到切状态为过期,改为待取药状态
|
|
|
mediicineorder.setSellState("0");
|
|
|
orderDao.save(mediicineorder);
|
|
|
}
|
|
@ -1572,10 +1563,10 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
}else {
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
}else {
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
return false;
|
|
@ -1602,20 +1593,20 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 取货预警发送模板消息
|
|
|
*
|
|
|
* @param hospital
|
|
|
*/
|
|
|
public void yjSendMessage(String hospital,String deviceName){
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(hospital)){
|
|
|
public void yjSendMessage(String hospital, String deviceName) {
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(hospital)) {
|
|
|
List<WlyyUserAreaDO> userAreaDOList = userAreaDao.findAllByHospital(hospital);
|
|
|
for (WlyyUserAreaDO userAreaDO:userAreaDOList){
|
|
|
for (WlyyUserAreaDO userAreaDO : userAreaDOList) {
|
|
|
UserDO userDO = userDao.findById(userAreaDO.getUserId());
|
|
|
if (userDO!=null){
|
|
|
if (userDO != null) {
|
|
|
RoleDO roleDO = roleDao.findOne(userDO.getRoleId());
|
|
|
if (!roleDO.getCode().equalsIgnoreCase("replenisher")){
|
|
|
sendDoctorTemplates(userDO.getIdcard(),"9","","您好,您的设备药品库存已达到预警值,请及时补充药品。",deviceName,"缺货预警,"+userAreaDO.getHospitalName()+","+userDO.getName());
|
|
|
if (!roleDO.getCode().equalsIgnoreCase("replenisher")) {
|
|
|
sendDoctorTemplates(userDO.getIdcard(), "9", "", "您好,您的设备药品库存已达到预警值,请及时补充药品。", deviceName, "缺货预警," + userAreaDO.getHospitalName() + "," + userDO.getName());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -1624,42 +1615,44 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
/**
|
|
|
* 待审核发送模板消息
|
|
|
*
|
|
|
* @param hospital
|
|
|
*/
|
|
|
public void reviewRemindSendMessage(String hospital,String patientName){
|
|
|
public void reviewRemindSendMessage(String hospital, String patientName) {
|
|
|
try {
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(hospital)){
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(hospital)) {
|
|
|
List<WlyyUserAreaDO> userAreaDOList = userAreaDao.findAllByHospital(hospital);
|
|
|
for (WlyyUserAreaDO userAreaDO:userAreaDOList){
|
|
|
for (WlyyUserAreaDO userAreaDO : userAreaDOList) {
|
|
|
UserDO userDO = userDao.findById(userAreaDO.getUserId());
|
|
|
if (userDO!=null){
|
|
|
if (userDO != null) {
|
|
|
RoleDO roleDO = roleDao.findOne(userDO.getRoleId());
|
|
|
if (roleDO.getCode().equalsIgnoreCase("replenisher")
|
|
|
||roleDO.getCode().equalsIgnoreCase("communityAdmin")){
|
|
|
sendDoctorTemplates(userDO.getIdcard(),"9","","您好,您有1位患者的续方待审方,请前往审核。","居民:"+patientName,"审方提醒,"+userAreaDO.getHospitalName()+","+userDO.getName());
|
|
|
|| roleDO.getCode().equalsIgnoreCase("communityAdmin")) {
|
|
|
sendDoctorTemplates(userDO.getIdcard(), "9", "", "您好,您有1位患者的续方待审方,请前往审核。", "居民:" + patientName, "审方提醒," + userAreaDO.getHospitalName() + "," + userDO.getName());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 温度、在线离线发送模板消息
|
|
|
*
|
|
|
* @param hospital
|
|
|
*/
|
|
|
public void wdOrSdSendMessage(String hospital,String deviceName,Integer flage){
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(hospital)){
|
|
|
public void wdOrSdSendMessage(String hospital, String deviceName, Integer flage) {
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(hospital)) {
|
|
|
List<WlyyUserAreaDO> userAreaDOList = userAreaDao.findAllByHospital(hospital);
|
|
|
for (WlyyUserAreaDO userAreaDO:userAreaDOList){
|
|
|
for (WlyyUserAreaDO userAreaDO : userAreaDOList) {
|
|
|
UserDO userDO = userDao.findById(userAreaDO.getUserId());
|
|
|
if (userDO!=null){
|
|
|
if (flage==1){
|
|
|
sendDoctorTemplates(userDO.getIdcard(),"9","","您好,您的设备温湿度异常,请及时处理,预防药品损坏。",deviceName,"温湿度预警,"+userAreaDO.getHospitalName()+","+userDO.getName());
|
|
|
}else if (flage==2){
|
|
|
sendDoctorTemplates(userDO.getIdcard(),"9","","您好,您的设备正处于离线状态,请及时处理,如您正常操作请忽略。",deviceName,"离线预警,"+userAreaDO.getHospitalName()+","+userDO.getName());
|
|
|
if (userDO != null) {
|
|
|
if (flage == 1) {
|
|
|
sendDoctorTemplates(userDO.getIdcard(), "9", "", "您好,您的设备温湿度异常,请及时处理,预防药品损坏。", deviceName, "温湿度预警," + userAreaDO.getHospitalName() + "," + userDO.getName());
|
|
|
} else if (flage == 2) {
|
|
|
sendDoctorTemplates(userDO.getIdcard(), "9", "", "您好,您的设备正处于离线状态,请及时处理,如您正常操作请忽略。", deviceName, "离线预警," + userAreaDO.getHospitalName() + "," + userDO.getName());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -1667,34 +1660,33 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param idcard 医生身份证
|
|
|
* @param type 固定传9
|
|
|
* @param jumpUrl jumpUrl 点击链接不跳转就传“”
|
|
|
* @param first 消息头
|
|
|
* @param remark 消息尾
|
|
|
* @param idcard 医生身份证
|
|
|
* @param type 固定传9
|
|
|
* @param jumpUrl jumpUrl 点击链接不跳转就传“”
|
|
|
* @param first 消息头
|
|
|
* @param remark 消息尾
|
|
|
* @param keywords 消息体
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean sendDoctorTemplates(String idcard,String type,String jumpUrl,String first,String remark,String keywords){
|
|
|
public boolean sendDoctorTemplates(String idcard, String type, String jumpUrl, String first, String remark, String keywords) {
|
|
|
OauthWlyyConfigDO oauthWlyyConfigDO = null;
|
|
|
if ("jwZnygProd".equals(springProfiles)){
|
|
|
if ("jwZnygProd".equals(springProfiles)) {
|
|
|
oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("sendDoctorTemplates_OUT");
|
|
|
}else {
|
|
|
} else {
|
|
|
oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("sendDoctorTemplates");
|
|
|
}
|
|
|
//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("checkWlyyDoctor token :"+rsjson.toString());
|
|
|
logger.info("checkWlyyDoctor token :" + rsjson.toString());
|
|
|
|
|
|
Integer status = rsjson.getInteger("status");
|
|
|
if(status==10000){
|
|
|
if (status == 10000) {
|
|
|
|
|
|
//设置入参
|
|
|
List<NameValuePair> p = new ArrayList<>();
|
|
@ -1707,10 +1699,10 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
//设置头部
|
|
|
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("sendDoctorTemplates");
|
|
|
wlyyHttpLogDO.setRequest(p.toString());
|
|
@ -1719,16 +1711,16 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
wlyyHttpLogDO.setStatus("1");
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
httpLogDao.save(wlyyHttpLogDO);
|
|
|
logger.info("sendDoctorTemplates:"+rs);
|
|
|
if (rs!=null&&rs!=""){
|
|
|
logger.info("sendDoctorTemplates:" + rs);
|
|
|
if (rs != null && rs != "") {
|
|
|
JSONObject ehc = JSONObject.parseObject(rs);
|
|
|
if (ehc.getString("status").equalsIgnoreCase("200")){
|
|
|
if (ehc.getString("status").equalsIgnoreCase("200")) {
|
|
|
return true;
|
|
|
}
|
|
|
}else {
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
}else {
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
return false;
|
|
@ -1866,25 +1858,25 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
List<Map<String, Object>> tempList = hibenateUtils.createSQLQuery(tempSql);
|
|
|
jsonObject.put("community", dmHospitalDO == null ? "" : dmHospitalDO.getName());
|
|
|
MedicineDevicePrintMessage devicePrintMessage = printMessageDao.findDeviceId(deviceId);
|
|
|
if (devicePrintMessage==null){
|
|
|
if (devicePrintMessage == null) {
|
|
|
WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("printSys");
|
|
|
if (hospitalSysDictDO!=null){
|
|
|
if (hospitalSysDictDO != null) {
|
|
|
JSONObject object = JSONObject.parseObject(hospitalSysDictDO.getDictValue());
|
|
|
jsonObject.put("phone", object.getString("phone"));
|
|
|
jsonObject.put("remark",object.getString("remark"));
|
|
|
jsonObject.put("remark", object.getString("remark"));
|
|
|
jsonObject.put("qrCodeContent", object.getString("qrCodeContent"));
|
|
|
jsonObject.put("info", object.getString("info"));
|
|
|
}else {
|
|
|
} else {
|
|
|
jsonObject.put("phone", "123456");
|
|
|
jsonObject.put("remark", "若未取到货物,请您扫描小票二维码申请退款。\n谢谢慢走,祝您生活愉快!");
|
|
|
jsonObject.put("qrCodeContent", "谢谢慢走,祝您生活愉快!");
|
|
|
jsonObject.put("info","community,phone,equNum,shipTime");
|
|
|
jsonObject.put("info", "community,phone,equNum,shipTime");
|
|
|
}
|
|
|
}else {
|
|
|
jsonObject.put("phone",devicePrintMessage.getPhone());
|
|
|
jsonObject.put("remark",devicePrintMessage.getRemark());
|
|
|
} else {
|
|
|
jsonObject.put("phone", devicePrintMessage.getPhone());
|
|
|
jsonObject.put("remark", devicePrintMessage.getRemark());
|
|
|
jsonObject.put("qrCodeContent", devicePrintMessage.getPicture());
|
|
|
jsonObject.put("info",devicePrintMessage.getInfo());
|
|
|
jsonObject.put("info", devicePrintMessage.getInfo());
|
|
|
}
|
|
|
|
|
|
jsonObject.put("num", mediicineorder.getPrescribeNum());
|
|
@ -2179,12 +2171,13 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
/**
|
|
|
* 通过取药码获取卡号
|
|
|
*
|
|
|
* @param pickUpNum
|
|
|
* @return
|
|
|
*/
|
|
|
public String getCardNum(String pickUpNum) throws Exception {
|
|
|
Mediicineorder mediicineorder = orderDao.findMediicineorderByPickUpNum(pickUpNum);
|
|
|
if (null==mediicineorder){
|
|
|
if (null == mediicineorder) {
|
|
|
throw new Exception("二维码(取药码)错误");
|
|
|
}
|
|
|
return mediicineorder.getSocialSecurityCardNum();
|
|
@ -2193,13 +2186,14 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
/**
|
|
|
* 检查订单并且返回订单列表
|
|
|
*
|
|
|
* @param deviceId
|
|
|
* @param pickUpNum
|
|
|
* @param cardNum
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public JSONObject checkOrderAndReturnOrderList(String deviceId, String pickUpNum, String cardNum,String patientName) {
|
|
|
public JSONObject checkOrderAndReturnOrderList(String deviceId, String pickUpNum, String cardNum, String patientName) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
if (deviceId == null || StringUtils.isEmpty(deviceId)) {
|
|
|
result.put("msg", "parameter deviceId is null or empty");
|
|
@ -2221,10 +2215,10 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
//订单列表
|
|
|
List<Mediicineorder> orders = new ArrayList<>();
|
|
|
if (!StringUtils.isEmpty(pickUpNum)) {
|
|
|
mediicineorder = orderDao.findMediicineorderByPickUpNumAndSellStateAndBelongCommunity(pickUpNum, "0",mediicinedevice.getBelongCommunity());
|
|
|
mediicineorder = orderDao.findMediicineorderByPickUpNumAndSellStateAndBelongCommunity(pickUpNum, "0", mediicinedevice.getBelongCommunity());
|
|
|
if (mediicineorder == null) {
|
|
|
//已取药
|
|
|
mediicineorder = orderDao.findMediicineorderByPickUpNumAndSellStateAndBelongCommunity(pickUpNum, "1",mediicinedevice.getBelongCommunity());
|
|
|
mediicineorder = orderDao.findMediicineorderByPickUpNumAndSellStateAndBelongCommunity(pickUpNum, "1", mediicinedevice.getBelongCommunity());
|
|
|
if (mediicineorder != null) {
|
|
|
result.put("msg", "二维码(取药码)已使用");
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
@ -2236,8 +2230,8 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
}
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(cardNum)) {
|
|
|
orders.addAll(orderDao.findMediicineordersBySocialSecurityCardNumAndSellStateAndBelongCommunity(cardNum, "0",mediicinedevice.getBelongCommunity()));
|
|
|
orders.addAll(orderDao.findMediicineordersBySocialSecurityCardNumAndSellStateAndBelongCommunity(cardNum, "-5",mediicinedevice.getBelongCommunity()));
|
|
|
orders.addAll(orderDao.findMediicineordersBySocialSecurityCardNumAndSellStateAndBelongCommunity(cardNum, "0", mediicinedevice.getBelongCommunity()));
|
|
|
orders.addAll(orderDao.findMediicineordersBySocialSecurityCardNumAndSellStateAndBelongCommunity(cardNum, "-5", mediicinedevice.getBelongCommunity()));
|
|
|
}
|
|
|
orders = orders.stream().distinct().collect(Collectors.toList());
|
|
|
if (orders == null || orders.size() == 0) {
|
|
@ -2245,12 +2239,12 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
return result;
|
|
|
}
|
|
|
List<Map<String , Object>> orderList = new ArrayList<>();
|
|
|
List<Map<String, Object>> orderList = new ArrayList<>();
|
|
|
//遍历所有订单
|
|
|
List<Mediicineorder> orderSetName = new ArrayList<>();
|
|
|
for (Mediicineorder order : orders) {
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(order.getName())){
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(patientName)){
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(order.getName())) {
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(patientName)) {
|
|
|
order.setName(patientName);
|
|
|
orderSetName.add(order);
|
|
|
}
|
|
@ -2263,35 +2257,35 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
return result;
|
|
|
}
|
|
|
MedicineDevicePrintMessage devicePrintMessage = printMessageDao.findDeviceId(deviceId);
|
|
|
if (devicePrintMessage==null){
|
|
|
if (devicePrintMessage == null) {
|
|
|
WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("printSys");
|
|
|
if (hospitalSysDictDO!=null){
|
|
|
if (hospitalSysDictDO != null) {
|
|
|
JSONObject object = JSONObject.parseObject(hospitalSysDictDO.getDictValue());
|
|
|
map.put("phone", object.getString("phone"));
|
|
|
map.put("remark",object.getString("remark"));
|
|
|
map.put("remark", object.getString("remark"));
|
|
|
map.put("qrCodeContent", object.getString("qrCodeContent"));
|
|
|
map.put("info", object.getString("info"));
|
|
|
}else {
|
|
|
} else {
|
|
|
map.put("phone", "123456");
|
|
|
map.put("remark", "若未取到货物,请您扫描小票二维码申请退款。\n谢谢慢走,祝您生活愉快!");
|
|
|
map.put("qrCodeContent", "谢谢慢走,祝您生活愉快!");
|
|
|
map.put("info","community,phone,equNum,shipTime");
|
|
|
map.put("info", "community,phone,equNum,shipTime");
|
|
|
}
|
|
|
}else {
|
|
|
map.put("phone",devicePrintMessage.getPhone());
|
|
|
map.put("remark",devicePrintMessage.getRemark()+"\n"+devicePrintMessage.getRemarkEnd());
|
|
|
} else {
|
|
|
map.put("phone", devicePrintMessage.getPhone());
|
|
|
map.put("remark", devicePrintMessage.getRemark() + "\n" + devicePrintMessage.getRemarkEnd());
|
|
|
map.put("qrCodeContent", devicePrintMessage.getPicture());
|
|
|
map.put("info",devicePrintMessage.getInfo());
|
|
|
map.put("info", devicePrintMessage.getInfo());
|
|
|
}
|
|
|
map.put("doctorName",order.getDoctorName());
|
|
|
map.put("prescriptionDate",DateUtil.dateToStrLong(order.getPrescribeTime()));
|
|
|
map.put("doctorName", order.getDoctorName());
|
|
|
map.put("prescriptionDate", DateUtil.dateToStrLong(order.getPrescribeTime()));
|
|
|
map.put("orderId", order.getId());
|
|
|
map.put("prescribeNum", order.getPrescribeNum());
|
|
|
map.put("community", dmHospitalDO == null ? "" : dmHospitalDO.getName());
|
|
|
map.put("num", order.getPrescribeNum());
|
|
|
map.put("date", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
|
|
|
map.put("time", DateUtil.dateToStr(new Date(), "HH:mm:ss"));
|
|
|
map.put("name",order.getName());
|
|
|
map.put("name", order.getName());
|
|
|
if ("1".equals(order.getSellState())) {
|
|
|
map.put("status", 1);
|
|
|
map.put("statusName", "已取药");
|
|
@ -2333,10 +2327,10 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
orderList.add(map);
|
|
|
continue;
|
|
|
}
|
|
|
if ("-5".equals(order.getSellState())){
|
|
|
if ("-5".equals(order.getSellState())) {
|
|
|
map.put("status", -5);
|
|
|
map.put("statusName", "出药异常订单已被锁定");
|
|
|
}else {
|
|
|
} else {
|
|
|
map.put("status", 0);
|
|
|
map.put("statusName", "未取药");
|
|
|
}
|
|
@ -2351,14 +2345,14 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
for (Mediicineorderdetail mediicineorderdetail : list) {
|
|
|
//cargo_state = 1,货道开启的,药品才计入统计
|
|
|
//求出该药品已出的数量
|
|
|
String yichuyaoSql = " select count(id) from t_medicine_shipment_log where order_id='"+order.getId()+"' " +
|
|
|
" and `status`=2 and drug_code='"+mediicineorderdetail.getDrugCode()+"' and order_detail_id='"+mediicineorderdetail.getId()+"' ";
|
|
|
Integer yichuyao = jdbcTemplate.queryForObject(yichuyaoSql,Integer.class);
|
|
|
Integer weiquyaoTotal = Integer.parseInt(mediicineorderdetail.getQuantity())-yichuyao;
|
|
|
if (weiquyaoTotal>0){
|
|
|
Mediicineorderdetail waitForTaking= new Mediicineorderdetail();
|
|
|
BeanUtils.copyProperties(mediicineorderdetail,waitForTaking);
|
|
|
waitForTaking.setQuantity(weiquyaoTotal+"");
|
|
|
String yichuyaoSql = " select count(id) from t_medicine_shipment_log where order_id='" + order.getId() + "' " +
|
|
|
" and `status`=2 and drug_code='" + mediicineorderdetail.getDrugCode() + "' and order_detail_id='" + mediicineorderdetail.getId() + "' ";
|
|
|
Integer yichuyao = jdbcTemplate.queryForObject(yichuyaoSql, Integer.class);
|
|
|
Integer weiquyaoTotal = Integer.parseInt(mediicineorderdetail.getQuantity()) - yichuyao;
|
|
|
if (weiquyaoTotal > 0) {
|
|
|
Mediicineorderdetail waitForTaking = new Mediicineorderdetail();
|
|
|
BeanUtils.copyProperties(mediicineorderdetail, waitForTaking);
|
|
|
waitForTaking.setQuantity(weiquyaoTotal + "");
|
|
|
String secondSql = "SELECT\n" +
|
|
|
"\tifnull(\n" +
|
|
|
"\t\t(\n" +
|
|
@ -2445,12 +2439,12 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
for (Mediicineorderdetail mediicineorderdetail : list) {
|
|
|
Mediicinedrugs mediicinedrugs = drugsDao.findByDrugCodeAndOrgCode(mediicineorderdetail.getDrugCode(), mediicineorderdetail.getOrgCode());
|
|
|
|
|
|
String yichuyaoSql = " select count(id) from t_medicine_shipment_log where order_id='"+order.getId()+"' " +
|
|
|
" and `status`=2 and drug_code='"+mediicineorderdetail.getDrugCode()+"' and order_detail_id='"+mediicineorderdetail.getId()+"' ";//求出该药品已出的数量
|
|
|
Integer yichuyao = jdbcTemplate.queryForObject(yichuyaoSql,Integer.class);
|
|
|
String yichuyaoSql = " select count(id) from t_medicine_shipment_log where order_id='" + order.getId() + "' " +
|
|
|
" and `status`=2 and drug_code='" + mediicineorderdetail.getDrugCode() + "' and order_detail_id='" + mediicineorderdetail.getId() + "' ";//求出该药品已出的数量
|
|
|
Integer yichuyao = jdbcTemplate.queryForObject(yichuyaoSql, Integer.class);
|
|
|
|
|
|
//订单药品数目
|
|
|
Integer qty = Integer.parseInt(String.valueOf(mediicineorderdetail.getQuantity()))-yichuyao;
|
|
|
Integer qty = Integer.parseInt(String.valueOf(mediicineorderdetail.getQuantity())) - yichuyao;
|
|
|
//库存集合
|
|
|
List<Map<String, Object>> tempList = hibenateUtils.createSQLQuery(
|
|
|
"SELECT\n" +
|
|
@ -2467,13 +2461,14 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
"AND t.cargo_state = '1'\n" +
|
|
|
"AND CONCAT(IFNULL(t.`id_device`,''), IFNULL(t.`equ_num`,'')) like '%" + deviceId + "%'\n" +
|
|
|
"AND ( t.state = '1' or t.state = '21')\n" +
|
|
|
"and t.qty > 0\n"+
|
|
|
"and t.qty > 0\n" +
|
|
|
"ORDER BY\n" +
|
|
|
"cast(t.layer_no AS UNSIGNED),cast(t.wayer_no AS UNSIGNED)"
|
|
|
);
|
|
|
|
|
|
|
|
|
head:for (Map<String, Object> stringObjectMap : tempList) {
|
|
|
head:
|
|
|
for (Map<String, Object> stringObjectMap : tempList) {
|
|
|
int number = Integer.parseInt(stringObjectMap.get("qty").toString());
|
|
|
for (int j = 0; j < number; j++) {
|
|
|
if (qty == 0) {
|
|
@ -2498,20 +2493,23 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
shipmentLog.setPrice(mediicinedrugs.getPrice());
|
|
|
shipmentLog.setSpecif(mediicinedrugs.getSpecif());
|
|
|
shipmentLog.setUnit(mediicineorderdetail.getUnit());
|
|
|
System.out.println("打印");
|
|
|
System.out.println("数据[mediicineorderdetail.getQuantityUnit()]==>" + mediicineorderdetail.getQuantityUnit());
|
|
|
|
|
|
shipmentLog.setQuantityUnit(mediicineorderdetail.getQuantityUnit());
|
|
|
String drugSql = " select quantity_unit,pack_unit from t_mediicine_drugs where org_code='"+mediicinedrugs.getOrgCode()+"' and drug_code='"+mediicinedrugs.getDrugCode()+"' ";
|
|
|
List<Map<String,Object>> drugTmps = jdbcTemplate.queryForList(drugSql);
|
|
|
if (drugTmps.size()>0){
|
|
|
shipmentLog.setPackUnit(drugTmps.get(0).get("pack_unit")==null?"":drugTmps.get(0).get("pack_unit").toString());
|
|
|
String drugSql = " select quantity_unit,pack_unit from t_mediicine_drugs where org_code='" + mediicinedrugs.getOrgCode() + "' and drug_code='" + mediicinedrugs.getDrugCode() + "' ";
|
|
|
List<Map<String, Object>> drugTmps = jdbcTemplate.queryForList(drugSql);
|
|
|
if (drugTmps.size() > 0) {
|
|
|
shipmentLog.setPackUnit(drugTmps.get(0).get("pack_unit") == null ? "" : drugTmps.get(0).get("pack_unit").toString());
|
|
|
}
|
|
|
shipmentLog.setEquName(mediicinedevice.getEquName());
|
|
|
shipmentLog.setEquNum(mediicinedevice.getEquNum());
|
|
|
shipmentLog.setDosForm(mediicinedrugs.getDosForm());
|
|
|
shipmentLog.setUseRateCode(mediicineorderdetail.getUseRate());
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(mediicineorderdetail.getUseRate())) {
|
|
|
String sql = " select dict_value from wlyy_hospital_sys_dict where dict_name='drug_use_rate' and dict_code='"+mediicineorderdetail.getUseRate()+"' ";
|
|
|
List<String> useRates = jdbcTemplate.queryForList(sql,String.class);
|
|
|
if (useRates.size()>0){
|
|
|
String sql = " select dict_value from wlyy_hospital_sys_dict where dict_name='drug_use_rate' and dict_code='" + mediicineorderdetail.getUseRate() + "' ";
|
|
|
List<String> useRates = jdbcTemplate.queryForList(sql, String.class);
|
|
|
if (useRates.size() > 0) {
|
|
|
shipmentLog.setUseRate(useRates.get(0));
|
|
|
}
|
|
|
}
|
|
@ -2569,7 +2567,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
}
|
|
|
orderList.add(map);
|
|
|
}
|
|
|
if (orderSetName.size()>0){
|
|
|
if (orderSetName.size() > 0) {
|
|
|
orderDao.save(orderSetName);
|
|
|
}
|
|
|
|
|
@ -2643,10 +2641,10 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
// return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success,mapList);
|
|
|
// }
|
|
|
|
|
|
public MixEnvelop getSumAmount(String belongCommunity, String equNum,String userId,int page, int size) throws Exception {
|
|
|
public MixEnvelop getSumAmount(String belongCommunity, String equNum, String userId, int page, int size) throws Exception {
|
|
|
UserDO user = userDao.findOne(userId);
|
|
|
RoleDO role = roleDao.findOne(user.getRoleId());
|
|
|
if (role==null){
|
|
|
if (role == null) {
|
|
|
throw new Exception("角色为空!");
|
|
|
}
|
|
|
String areaCondition = "";
|
|
@ -2696,35 +2694,35 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
String sql = "select belong_community as \"belongCommunity\"," +
|
|
|
"community as \"community\",id as \"id\",equ_name as \"equName\",equ_num as \"equNum\" from t_mediicine_device where 1=1 ";
|
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(areaCondition)){
|
|
|
sql += " and belong_community in("+areaCondition+") ";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(areaCondition)) {
|
|
|
sql += " and belong_community in(" + areaCondition + ") ";
|
|
|
}
|
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)){
|
|
|
sql += " and belong_community ='"+belongCommunity+"' ";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)) {
|
|
|
sql += " and belong_community ='" + belongCommunity + "' ";
|
|
|
}
|
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
|
|
|
sql += " and equ_num = '%"+equNum+"%' ";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)) {
|
|
|
sql += " and equ_num = '%" + equNum + "%' ";
|
|
|
}
|
|
|
|
|
|
List<Map<String,Object>> mediicinedevices = hibenateUtils.createSQLQuery(sql,page,size);
|
|
|
List<Map<String, Object>> mediicinedevices = hibenateUtils.createSQLQuery(sql, page, size);
|
|
|
|
|
|
for (Map<String,Object> map : mediicinedevices) {
|
|
|
map.put("equName",map.get("equNum").toString()+"/"+map.get("equName").toString());
|
|
|
for (Map<String, Object> map : mediicinedevices) {
|
|
|
map.put("equName", map.get("equNum").toString() + "/" + map.get("equName").toString());
|
|
|
String oneSql = "SELECT SUM(t.amount) AS sumAmount,\n" +
|
|
|
" COUNT(*) AS count,\n" +
|
|
|
" t.shipping_equ AS equNum\n" +
|
|
|
" FROM t_mediicine_order t WHERE t.sell_state = 1 AND t.shipping_equ = '" + map.get("equNum").toString() + "'";
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(oneSql);
|
|
|
for (Map<String,Object> oneMap:list){
|
|
|
String count = oneMap.get("count")==null?"0":oneMap.get("count").toString();
|
|
|
String sumAmount=oneMap.get("sumAmount")==null?"0":oneMap.get("sumAmount").toString();
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(oneSql);
|
|
|
for (Map<String, Object> oneMap : list) {
|
|
|
String count = oneMap.get("count") == null ? "0" : oneMap.get("count").toString();
|
|
|
String sumAmount = oneMap.get("sumAmount") == null ? "0" : oneMap.get("sumAmount").toString();
|
|
|
float price = Float.parseFloat(sumAmount);
|
|
|
BigDecimal b = new BigDecimal(price);
|
|
|
float m_price = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
|
|
|
map.put("ordercount",count);
|
|
|
map.put("sumAmount",m_price);
|
|
|
BigDecimal b = new BigDecimal(price);
|
|
|
float m_price = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
|
|
|
map.put("ordercount", count);
|
|
|
map.put("sumAmount", m_price);
|
|
|
}
|
|
|
}
|
|
|
String countSql = " select " +
|
|
@ -2732,30 +2730,30 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
" from " +
|
|
|
" t_mediicine_device as t " +
|
|
|
" where " +
|
|
|
" 1=1 " ;
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(areaCondition)){
|
|
|
countSql += " and belong_community in("+areaCondition+") ";
|
|
|
" 1=1 ";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(areaCondition)) {
|
|
|
countSql += " and belong_community in(" + areaCondition + ") ";
|
|
|
}
|
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)){
|
|
|
countSql += " and belong_community ='"+belongCommunity+"' ";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)) {
|
|
|
countSql += " and belong_community ='" + belongCommunity + "' ";
|
|
|
}
|
|
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
|
|
|
countSql += " and equ_num = '%"+equNum+"%' ";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)) {
|
|
|
countSql += " and equ_num = '%" + equNum + "%' ";
|
|
|
}
|
|
|
|
|
|
Logger.getAnonymousLogger().info("finalCountSql="+countSql);
|
|
|
int decCount = jdbcTemplate.queryForObject(countSql,Integer.class);
|
|
|
Logger.getAnonymousLogger().info("finalCountSql=" + countSql);
|
|
|
int decCount = jdbcTemplate.queryForObject(countSql, Integer.class);
|
|
|
//总页数
|
|
|
int total=decCount/size+(decCount%size>0?1:0);
|
|
|
MixEnvelop mixEnvelop = MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success,mediicinedevices);
|
|
|
int total = decCount / size + (decCount % size > 0 ? 1 : 0);
|
|
|
MixEnvelop mixEnvelop = MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success, mediicinedevices);
|
|
|
mixEnvelop.setTotalCount(decCount);
|
|
|
mixEnvelop.setTotalPage(total);
|
|
|
return mixEnvelop;
|
|
|
}
|
|
|
|
|
|
public void pushListWrite(OutputStream os, List<Map<String, Object>> list)throws Exception {
|
|
|
public void pushListWrite(OutputStream os, List<Map<String, Object>> list) throws Exception {
|
|
|
WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
|
|
|
try {
|
|
|
WritableSheet sheet;
|
|
@ -2769,10 +2767,10 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
}
|
|
|
int j = 1;
|
|
|
for (Map<String, Object> tmp : list) {
|
|
|
addCell(sheet, j, 0, tmp.get("community")==null ? "" : tmp.get("community").toString());
|
|
|
addCell(sheet, j, 1, tmp.get("equName") == null? "" : tmp.get("equName").toString());
|
|
|
addCell(sheet, j, 0, tmp.get("community") == null ? "" : tmp.get("community").toString());
|
|
|
addCell(sheet, j, 1, tmp.get("equName") == null ? "" : tmp.get("equName").toString());
|
|
|
addCell(sheet, j, 2, tmp.get("ordercount") == null ? "" : tmp.get("ordercount").toString());
|
|
|
addCell(sheet, j, 3, tmp.get("sumAmount") == null ? "" :tmp.get("sumAmount").toString());
|
|
|
addCell(sheet, j, 3, tmp.get("sumAmount") == null ? "" : tmp.get("sumAmount").toString());
|
|
|
j++;
|
|
|
}
|
|
|
wwb.write();
|
|
@ -2783,6 +2781,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
throw e;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
|
|
|
Label label = new Label(column, row, data);
|
|
|
WritableCellFormat cellFormat = new WritableCellFormat();
|
|
@ -2792,8 +2791,8 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
ws.addCell(label);
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getDeviceInfo(String prescribeNum, String startTime, String endTime, String deviceId,int page,int size) {
|
|
|
String sql="SELECT\n" +
|
|
|
public List<Map<String, Object>> getDeviceInfo(String prescribeNum, String startTime, String endTime, String deviceId, int page, int size) {
|
|
|
String sql = "SELECT\n" +
|
|
|
" t.prescribe_time AS 'prescribeTime',\n" +
|
|
|
" t.prescribe_num AS 'prescribeNum',\n" +
|
|
|
" t.amount AS 'amount',\n" +
|
|
@ -2801,22 +2800,22 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
" t.amount AS 'sumAmount'" +
|
|
|
"FROM t_mediicine_order t\n" +
|
|
|
"WHERE " +
|
|
|
"t.shipping_equ='"+deviceId+"'";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(prescribeNum)){
|
|
|
sql += " AND (t.prescribe_num like '%"+prescribeNum+"%' or t.amount like '%"+prescribeNum+"%')";
|
|
|
"t.shipping_equ='" + deviceId + "'";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(prescribeNum)) {
|
|
|
sql += " AND (t.prescribe_num like '%" + prescribeNum + "%' or t.amount like '%" + prescribeNum + "%')";
|
|
|
}
|
|
|
if(org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)){
|
|
|
sql += " AND t.prescribe_time>='"+startTime+"'";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)) {
|
|
|
sql += " AND t.prescribe_time>='" + startTime + "'";
|
|
|
}
|
|
|
if(org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)){
|
|
|
sql += " AND t.prescribe_time<='"+endTime+"'";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)) {
|
|
|
sql += " AND t.prescribe_time<='" + endTime + "'";
|
|
|
}
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,page,size);
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, page, size);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public MixEnvelop getDeviceInfoExcel(String prescribeNum, String startTime, String endTime, String deviceId,int page,int size) {
|
|
|
String sql="SELECT\n" +
|
|
|
public MixEnvelop getDeviceInfoExcel(String prescribeNum, String startTime, String endTime, String deviceId, int page, int size) {
|
|
|
String sql = "SELECT\n" +
|
|
|
" t.prescribe_time AS 'prescribeTime',\n" +
|
|
|
" t.prescribe_num AS 'prescribeNum',\n" +
|
|
|
" t.amount AS 'amount',\n" +
|
|
@ -2824,27 +2823,27 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
" t.amount AS 'sumAmount'" +
|
|
|
"FROM t_mediicine_order t\n" +
|
|
|
"WHERE " +
|
|
|
"t.shipping_equ='"+deviceId+"'";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(prescribeNum)){
|
|
|
sql += " AND (t.prescribe_num like '%"+prescribeNum+"%' or t.amount like '%"+prescribeNum+"%')";
|
|
|
"t.shipping_equ='" + deviceId + "'";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(prescribeNum)) {
|
|
|
sql += " AND (t.prescribe_num like '%" + prescribeNum + "%' or t.amount like '%" + prescribeNum + "%')";
|
|
|
}
|
|
|
if(org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)){
|
|
|
sql += " AND t.prescribe_time>='"+startTime+"'";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)) {
|
|
|
sql += " AND t.prescribe_time>='" + startTime + "'";
|
|
|
}
|
|
|
if(org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)){
|
|
|
sql += " AND t.prescribe_time<='"+endTime+"'";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)) {
|
|
|
sql += " AND t.prescribe_time<='" + endTime + "'";
|
|
|
}
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,page,size);
|
|
|
return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success,list);
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, page, size);
|
|
|
return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success, list);
|
|
|
}
|
|
|
|
|
|
public void deviceInfoExcel(OutputStream os, List<Map<String, Object>> list)throws Exception {
|
|
|
public void deviceInfoExcel(OutputStream os, List<Map<String, Object>> list) throws Exception {
|
|
|
WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
|
|
|
try {
|
|
|
WritableSheet sheet;
|
|
|
sheet = wwb.createSheet("sheet", 1);
|
|
|
|
|
|
String header[] = {"开方时间", "处方号", "交易金额", "社保抵扣","合计"};
|
|
|
String header[] = {"开方时间", "处方号", "交易金额", "社保抵扣", "合计"};
|
|
|
int i = 0;
|
|
|
for (String h : header) {
|
|
|
addCell(sheet, 0, i, h);
|
|
@ -2852,11 +2851,11 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
}
|
|
|
int j = 1;
|
|
|
for (Map<String, Object> tmp : list) {
|
|
|
addCell(sheet, j, 0, tmp.get("prescribeTime")==null ? "" : tmp.get("prescribeTime").toString());
|
|
|
addCell(sheet, j, 1, tmp.get("prescribeNum") == null? "" : tmp.get("prescribeNum").toString());
|
|
|
addCell(sheet, j, 0, tmp.get("prescribeTime") == null ? "" : tmp.get("prescribeTime").toString());
|
|
|
addCell(sheet, j, 1, tmp.get("prescribeNum") == null ? "" : tmp.get("prescribeNum").toString());
|
|
|
addCell(sheet, j, 2, tmp.get("amount") == null ? "0" : tmp.get("amount").toString());
|
|
|
addCell(sheet, j, 3, tmp.get("socialinsurPayment") == null ? "" :tmp.get("socialinsurPayment").toString());
|
|
|
addCell(sheet, j, 4, tmp.get("sumAmount") == null ? "" :tmp.get("sumAmount").toString());
|
|
|
addCell(sheet, j, 3, tmp.get("socialinsurPayment") == null ? "" : tmp.get("socialinsurPayment").toString());
|
|
|
addCell(sheet, j, 4, tmp.get("sumAmount") == null ? "" : tmp.get("sumAmount").toString());
|
|
|
j++;
|
|
|
}
|
|
|
wwb.write();
|
|
@ -2868,30 +2867,30 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getAllAmount() {
|
|
|
String sql="SELECT sum(t.amount) AS 'sumAmount' " +
|
|
|
public List<Map<String, Object>> getAllAmount() {
|
|
|
String sql = "SELECT sum(t.amount) AS 'sumAmount' " +
|
|
|
"from t_mediicine_order t ," +
|
|
|
"t_mediicine_device a " +
|
|
|
"where " +
|
|
|
"a.equ_num=t.shipping_equ " +
|
|
|
"and t.sell_state='1' ";
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
|
|
|
for (Map<String,Object> map:list){
|
|
|
String sumAmount=map.get("sumAmount")==null?"0":map.get("sumAmount").toString();
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
|
|
|
for (Map<String, Object> map : list) {
|
|
|
String sumAmount = map.get("sumAmount") == null ? "0" : map.get("sumAmount").toString();
|
|
|
float price = Float.parseFloat(sumAmount);
|
|
|
BigDecimal b = new BigDecimal(price);
|
|
|
float m_price = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
|
|
|
map.put("sumAmount",m_price);
|
|
|
BigDecimal b = new BigDecimal(price);
|
|
|
float m_price = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
|
|
|
map.put("sumAmount", m_price);
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public JSONObject reviewerOrder(String orderId,String doctor,Integer reviewerState,String reviewerContent) {
|
|
|
public JSONObject reviewerOrder(String orderId, String doctor, Integer reviewerState, String reviewerContent) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
UserDO userDO = userDao.findOne(doctor);
|
|
|
if (null==userDO){
|
|
|
if (null == userDO) {
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg, "无权限操作");
|
|
|
return result;
|
|
@ -2903,7 +2902,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
result.put(ResponseContant.resultMsg, "审方订单不存在");
|
|
|
return result;
|
|
|
}
|
|
|
if (0!= mediicineorder.getReviewerState()) {
|
|
|
if (0 != mediicineorder.getReviewerState()) {
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.fail);
|
|
|
result.put(ResponseContant.resultMsg, "该订单已审核过,无需重复审核");
|
|
|
return result;
|