|
@ -3,6 +3,7 @@ package com.yihu.jw.base.service.a3service;
|
|
|
|
|
|
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.role.RoleDao;
|
|
|
import com.yihu.jw.base.dao.user.UserDao;
|
|
@ -12,17 +13,31 @@ import com.yihu.jw.entity.a1entity.*;
|
|
|
import com.yihu.jw.entity.base.role.RoleDO;
|
|
|
import com.yihu.jw.entity.base.user.UserDO;
|
|
|
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.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
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;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@ -37,12 +52,16 @@ import java.util.*;
|
|
|
import java.util.logging.Logger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static jxl.biff.BaseCellFeatures.logger;
|
|
|
|
|
|
/**
|
|
|
* Created by Bing on 2021/9/23.
|
|
|
*/
|
|
|
@Service
|
|
|
public class MedicineOrderService extends BaseJpaService<Mediicineorder, MediicineorderDao> {
|
|
|
|
|
|
private final org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
@Autowired
|
|
|
private MediicineorderDao orderDao;
|
|
|
@Autowired
|
|
@ -79,6 +98,19 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
@Autowired
|
|
|
private HibenateUtils hibenateUtils;
|
|
|
|
|
|
@Autowired
|
|
|
private OauthWlyyConfigDao oauthWlyyConfigDao;
|
|
|
|
|
|
@Autowired
|
|
|
private HttpClientUtil httpClientUtil;
|
|
|
|
|
|
@Autowired
|
|
|
private WlyyHttpLogDao httpLogDao;
|
|
|
|
|
|
@Autowired
|
|
|
private MedicineDevicePrintMessageDao printMessageDao;
|
|
|
@Autowired
|
|
|
private WlyyHospitalSysDictDao hospitalSysDictDao;
|
|
|
|
|
|
/**
|
|
|
* 新增药品信息
|
|
@ -187,6 +219,9 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
UserDO user = userDao.findOne(userId);
|
|
|
RoleDO role = roleDao.findOne(user.getRoleId());
|
|
|
if (role==null){
|
|
|
throw new Exception("角色为空!");
|
|
|
}
|
|
|
//订单列表
|
|
|
List<Map<String, Object>> orderList = null;
|
|
|
String conditionSql = "";
|
|
@ -287,7 +322,8 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
" t.allergy_info AS allergyInfo,\n" +
|
|
|
" t.info AS info,\n" +
|
|
|
" t.social_security_card_num AS socialSecurityCardNum,\n" +
|
|
|
" t.belong_community AS belongCommunity\n" +
|
|
|
" t.belong_community AS belongCommunity, \n" +
|
|
|
" t.community AS community\n" +
|
|
|
"FROM\n" +
|
|
|
" t_mediicine_order AS t left join t_mediicine_device tmd on t.shipping_equ = tmd.equ_num where 1=1 \n";
|
|
|
|
|
@ -323,7 +359,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
if (!StringUtils.isEmpty(dispensingWindow)) {
|
|
|
conditionSql += " and t.dispensing_window = '" + dispensingWindow + "'";
|
|
|
}
|
|
|
sencodSql = sencodSql + conditionSql;
|
|
|
sencodSql = sencodSql + conditionSql + " order by t.prescribe_time desc,t.sell_state asc ";
|
|
|
|
|
|
orderList = hibenateUtils.createSQLQuery(sencodSql, page, size);
|
|
|
|
|
@ -780,6 +816,8 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
if (Integer.compare(totalShipmentLog, shipped + 1) == 0) {
|
|
|
Mediicineorder order = orderDao.findOne(medicineShipmentLog.getOrderId());
|
|
|
order.setSellState("1");
|
|
|
Boolean flag = scanQrdispensaryCode(order.getPickUpNum());
|
|
|
logger.info("flag"+flag);
|
|
|
orderDao.save(order);
|
|
|
}
|
|
|
if (Integer.compare(totalShipmentLog, shipped + 1) < 0) {
|
|
@ -892,6 +930,177 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
result.put("msg", "订单未完成,请联系管理员!");
|
|
|
return result;
|
|
|
}
|
|
|
//=================================调用i健康接口=================================//
|
|
|
|
|
|
public String getEhcCardInfo(String ehealthCode) throws Exception {
|
|
|
OauthWlyyConfigDO 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");
|
|
|
String token = null;
|
|
|
JSONObject rsjson = JSONObject.parseObject(res);
|
|
|
|
|
|
logger.info("checkWlyyDoctor token :"+rsjson.toString());
|
|
|
|
|
|
Integer status = rsjson.getInteger("status");
|
|
|
if(status==10000){
|
|
|
|
|
|
//设置入参
|
|
|
List<NameValuePair> p = new ArrayList<>();
|
|
|
p.add(new BasicNameValuePair("ehealthCode", ehealthCode));
|
|
|
|
|
|
//设置头部
|
|
|
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("EHCVerify");
|
|
|
wlyyHttpLogDO.setRequest(p.toString());
|
|
|
wlyyHttpLogDO.setResponse(rs);
|
|
|
wlyyHttpLogDO.setName("电子健康卡扫码读取");
|
|
|
wlyyHttpLogDO.setStatus("1");
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
httpLogDao.save(wlyyHttpLogDO);
|
|
|
logger.info("checkWlyyDoctor EHCVerify :"+rs);
|
|
|
if (rs!=null&&rs!=""){
|
|
|
JSONObject ehc = JSONObject.parseObject(rs);
|
|
|
if (ehc.getString("ret_code").equalsIgnoreCase("0000")){
|
|
|
JSONObject biz = ehc.getJSONObject("biz_content");
|
|
|
String cardNo = biz.getString("card_no");
|
|
|
if (cardNo!=null&&cardNo!=""){
|
|
|
return cardNo;
|
|
|
}else {
|
|
|
return null;
|
|
|
}
|
|
|
}else {
|
|
|
return null;
|
|
|
}
|
|
|
}else {
|
|
|
return null;
|
|
|
}
|
|
|
}else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public boolean scanQrdispensaryCode(String code){
|
|
|
OauthWlyyConfigDO 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");
|
|
|
String token = null;
|
|
|
JSONObject rsjson = JSONObject.parseObject(res);
|
|
|
|
|
|
logger.info("checkWlyyDoctor token :"+rsjson.toString());
|
|
|
|
|
|
Integer status = rsjson.getInteger("status");
|
|
|
if(status==10000){
|
|
|
|
|
|
//设置入参
|
|
|
List<NameValuePair> p = new ArrayList<>();
|
|
|
p.add(new BasicNameValuePair("code", code));
|
|
|
|
|
|
//设置头部
|
|
|
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("scanQrdispensaryCode");
|
|
|
wlyyHttpLogDO.setRequest(p.toString());
|
|
|
wlyyHttpLogDO.setResponse(rs);
|
|
|
wlyyHttpLogDO.setName("更新取药码状态");
|
|
|
wlyyHttpLogDO.setStatus("1");
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
httpLogDao.save(wlyyHttpLogDO);
|
|
|
logger.info("scanQrdispensaryCode:"+rs);
|
|
|
if (rs!=null&&rs!=""){
|
|
|
JSONObject ehc = JSONObject.parseObject(rs);
|
|
|
if (ehc.getString("status").equalsIgnoreCase("200")){
|
|
|
return true;
|
|
|
}
|
|
|
}else {
|
|
|
return false;
|
|
|
}
|
|
|
}else {
|
|
|
return false;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @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){
|
|
|
OauthWlyyConfigDO 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");
|
|
|
String token = null;
|
|
|
JSONObject rsjson = JSONObject.parseObject(res);
|
|
|
|
|
|
logger.info("checkWlyyDoctor token :"+rsjson.toString());
|
|
|
|
|
|
Integer status = rsjson.getInteger("status");
|
|
|
if(status==10000){
|
|
|
|
|
|
//设置入参
|
|
|
List<NameValuePair> p = new ArrayList<>();
|
|
|
p.add(new BasicNameValuePair("idcard", idcard));
|
|
|
p.add(new BasicNameValuePair("type", "9"));
|
|
|
p.add(new BasicNameValuePair("jumpUrl", jumpUrl));
|
|
|
p.add(new BasicNameValuePair("first", first));
|
|
|
p.add(new BasicNameValuePair("remark", remark));
|
|
|
p.add(new BasicNameValuePair("keywords", keywords));
|
|
|
|
|
|
//设置头部
|
|
|
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("sendDoctorTemplates");
|
|
|
wlyyHttpLogDO.setRequest(p.toString());
|
|
|
wlyyHttpLogDO.setResponse(rs);
|
|
|
wlyyHttpLogDO.setName("发送医生智能助手模板消息");
|
|
|
wlyyHttpLogDO.setStatus("1");
|
|
|
wlyyHttpLogDO.setCreateTime(new Date());
|
|
|
httpLogDao.save(wlyyHttpLogDO);
|
|
|
logger.info("sendDoctorTemplates:"+rs);
|
|
|
if (rs!=null&&rs!=""){
|
|
|
JSONObject ehc = JSONObject.parseObject(rs);
|
|
|
if (ehc.getString("status").equalsIgnoreCase("200")){
|
|
|
return true;
|
|
|
}
|
|
|
}else {
|
|
|
return false;
|
|
|
}
|
|
|
}else {
|
|
|
return false;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//=================================调用i健康接口=================================//
|
|
|
|
|
|
|
|
|
/**
|
|
@ -1020,12 +1229,32 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
"\tt.order_id = '" + mediicineorder.getId() + "'";
|
|
|
List<Map<String, Object>> tempList = hibenateUtils.createSQLQuery(tempSql);
|
|
|
jsonObject.put("community", dmHospitalDO == null ? "" : dmHospitalDO.getName());
|
|
|
jsonObject.put("phone", "123456");
|
|
|
MedicineDevicePrintMessage devicePrintMessage = printMessageDao.findDeviceId(deviceId);
|
|
|
if (devicePrintMessage==null){
|
|
|
WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("printSys");
|
|
|
if (hospitalSysDictDO!=null){
|
|
|
JSONObject object = JSONObject.parseObject(hospitalSysDictDO.getDictValue());
|
|
|
jsonObject.put("phone", object.getString("phone"));
|
|
|
jsonObject.put("remark",object.getString("remark"));
|
|
|
jsonObject.put("qrCodeContent", object.getString("qrCodeContent"));
|
|
|
jsonObject.put("info", object.getString("info"));
|
|
|
}else {
|
|
|
jsonObject.put("phone", "123456");
|
|
|
jsonObject.put("remark", "若未取到货物,请您扫描小票二维码申请退款。\n谢谢慢走,祝您生活愉快!");
|
|
|
jsonObject.put("qrCodeContent", "谢谢慢走,祝您生活愉快!");
|
|
|
jsonObject.put("info","community,phone,equNum,shipTime");
|
|
|
}
|
|
|
}else {
|
|
|
jsonObject.put("phone",devicePrintMessage.getPhone());
|
|
|
jsonObject.put("remark",devicePrintMessage.getRemark());
|
|
|
jsonObject.put("qrCodeContent", devicePrintMessage.getPicture());
|
|
|
jsonObject.put("info",devicePrintMessage.getInfo());
|
|
|
}
|
|
|
|
|
|
jsonObject.put("num", mediicineorder.getPrescribeNum());
|
|
|
jsonObject.put("date", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
|
|
|
jsonObject.put("time", DateUtil.dateToStr(new Date(), "HH:mm:ss"));
|
|
|
jsonObject.put("remark", "若未取到货物,请您扫描小票二维码申请退款。\n谢谢慢走,祝您生活愉快!");
|
|
|
jsonObject.put("qrCodeContent", "谢谢慢走,祝您生活愉快!");
|
|
|
|
|
|
jsonObject.put("list", tempList);
|
|
|
jsonObject.put("status", 1);
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
@ -1364,15 +1593,35 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
return result;
|
|
|
}
|
|
|
MedicineDevicePrintMessage devicePrintMessage = printMessageDao.findDeviceId(deviceId);
|
|
|
if (devicePrintMessage==null){
|
|
|
WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("printSys");
|
|
|
if (hospitalSysDictDO!=null){
|
|
|
JSONObject object = JSONObject.parseObject(hospitalSysDictDO.getDictValue());
|
|
|
map.put("phone", object.getString("phone"));
|
|
|
map.put("remark",object.getString("remark"));
|
|
|
map.put("qrCodeContent", object.getString("qrCodeContent"));
|
|
|
map.put("info", object.getString("info"));
|
|
|
}else {
|
|
|
map.put("phone", "123456");
|
|
|
map.put("remark", "若未取到货物,请您扫描小票二维码申请退款。\n谢谢慢走,祝您生活愉快!");
|
|
|
map.put("qrCodeContent", "谢谢慢走,祝您生活愉快!");
|
|
|
map.put("info","community,phone,equNum,shipTime");
|
|
|
}
|
|
|
}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("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("phone", "123456");
|
|
|
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("remark", "若未取到货物,请您扫描小票二维码申请退款。\n谢谢慢走,祝您生活愉快!");
|
|
|
map.put("qrCodeContent", "谢谢慢走,祝您生活愉快!");
|
|
|
if ("1".equals(order.getSellState())) {
|
|
|
map.put("status", 1);
|
|
|
map.put("statusName", "已取药");
|
|
@ -1679,96 +1928,22 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
public MixEnvelop getSumAmount(String belongCommunity, String equNum, int page, int size) {
|
|
|
List<Map<String,Object>> mapList=new ArrayList<>();
|
|
|
//查询出所有的设备
|
|
|
if (!org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)&&!org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)) {
|
|
|
page=(page-1)*size;
|
|
|
Iterable<Mediicinedevice> mediicinedevices = deviceDao.findDeviceAll(page, size);
|
|
|
for (Mediicinedevice mediicinedevice : mediicinedevices) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("community", mediicinedevice.getCommunity());
|
|
|
map.put("equName", mediicinedevice.getEquNum() + (mediicinedevice.getEquName() == null ? "" : "/" + mediicinedevice.getEquName()));
|
|
|
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 = '" + mediicinedevice.getEquNum() + "'";
|
|
|
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);
|
|
|
}
|
|
|
mapList.add(map);
|
|
|
}
|
|
|
String countSql = " select " +
|
|
|
" COUNT(DISTINCT (t.id)) as count " +
|
|
|
" from " +
|
|
|
" t_mediicine_device as t " +
|
|
|
" where " +
|
|
|
" 1=1 " ;
|
|
|
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,mapList);
|
|
|
mixEnvelop.setTotalCount(decCount);
|
|
|
mixEnvelop.setTotalPage(total);
|
|
|
return mixEnvelop;
|
|
|
}
|
|
|
//将同一个设备的社区/名称/设备编码/历史记录/总金额放到一个Map中,并将这些Map放到同一个list中返回
|
|
|
Map<String,Object> map=new HashMap<>();
|
|
|
String oneSql="SELECT SUM(t.amount) AS sumAmount,\n" +
|
|
|
page=(page-1)*size;
|
|
|
List<Mediicinedevice> mediicinedevices = new ArrayList<>();
|
|
|
if(org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)&& !org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
|
|
|
mediicinedevices= deviceDao.findDeviceByCommunity(page, size,belongCommunity);
|
|
|
}else if(org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)&& org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
|
|
|
mediicinedevices= deviceDao.findDeviceByEquNum(page, size,equNum);
|
|
|
}
|
|
|
|
|
|
for (Mediicinedevice mediicinedevice : mediicinedevices) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("community", mediicinedevice.getCommunity());
|
|
|
map.put("equName", mediicinedevice.getEquNum() + (mediicinedevice.getEquName() == null ? "" : "/" + mediicinedevice.getEquName()));
|
|
|
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 ";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)){
|
|
|
oneSql += "AND t.belong_community = '"+belongCommunity+"' ";
|
|
|
if (!org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
|
|
|
Mediicinedevice device=deviceDao.findByBelongCommunity(belongCommunity);
|
|
|
if (device==null){
|
|
|
return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success,new ArrayList());
|
|
|
}
|
|
|
map.put("community",device.getCommunity());
|
|
|
map.put("equName",device.getEquNum()+(device.getEquName()==null?"":"/"+device.getEquName()));
|
|
|
}else {
|
|
|
oneSql += "AND t.shipping_equ = '" + equNum + "'";
|
|
|
Mediicinedevice device=deviceDao.findByBelongCommunityAndEquNum(belongCommunity,equNum);
|
|
|
if (device==null){
|
|
|
return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success,new ArrayList());
|
|
|
}
|
|
|
map.put("community",device.getCommunity());
|
|
|
map.put("equName",device.getEquNum()+(device.getEquName()==null?"":"/"+device.getEquName()));
|
|
|
}
|
|
|
}else {
|
|
|
if (!org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
|
|
|
// Mediicinedevice device=deviceDao.findByBelongCommunity(belongCommunity);
|
|
|
// map.put("community",device.getCommunity());
|
|
|
}else {
|
|
|
oneSql += "AND t.shipping_equ = '" + equNum + "'";
|
|
|
Mediicinedevice device=deviceDao.findMediicinedeviceByEquNum(equNum);
|
|
|
if (device==null){
|
|
|
return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success,new ArrayList());
|
|
|
}
|
|
|
map.put("community",device.getCommunity());
|
|
|
map.put("equName",device.getEquNum()+(device.getEquName()==null?"":"/"+device.getEquName()));
|
|
|
}
|
|
|
}
|
|
|
// if (org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
|
|
|
// oneSql += "AND t.shipping_equ = '" + equNum + "'";
|
|
|
// Mediicinedevice daoByEquNum=deviceDao.findMediicinedeviceByEquNum(equNum);
|
|
|
// map.put("equName",daoByEquNum.getEquNum()+(daoByEquNum.getEquName()==null?"":"/"+daoByEquNum.getEquName()));
|
|
|
// }else {
|
|
|
// map.put("equName",mediicinedevice.getEquNum()+(mediicinedevice.getEquName()==null?"":"/"+mediicinedevice.getEquName()));
|
|
|
// }
|
|
|
// if (org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)){
|
|
|
// oneSql += "AND t.shipping_time >= "+ startTime ;
|
|
|
// }
|
|
|
// if (org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)){
|
|
|
// oneSql += "AND t.shipping_time <= "+ endTime ;
|
|
|
// }
|
|
|
" FROM t_mediicine_order t WHERE t.sell_state = 1 AND t.shipping_equ = '" + mediicinedevice.getEquNum() + "'";
|
|
|
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();
|
|
@ -1780,9 +1955,20 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
map.put("sumAmount",m_price);
|
|
|
}
|
|
|
mapList.add(map);
|
|
|
}
|
|
|
String countSql = " select " +
|
|
|
" COUNT(DISTINCT (t.id)) as count " +
|
|
|
" from " +
|
|
|
" t_mediicine_device as t " +
|
|
|
" where " +
|
|
|
" 1=1 " ;
|
|
|
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,mapList);
|
|
|
mixEnvelop.setTotalPage(mapList.size()/size+(mapList.size()%size==0?0:1));
|
|
|
mixEnvelop.setTotalCount(mapList.size());
|
|
|
mixEnvelop.setTotalCount(decCount);
|
|
|
mixEnvelop.setTotalPage(total);
|
|
|
return mixEnvelop;
|
|
|
}
|
|
|
|