|
@ -29,6 +29,7 @@ import com.yihu.jw.util.http.HttpClientUtil;
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
import com.yihu.jw.wlyy.dao.OauthWlyyConfigDao;
|
|
import com.yihu.jw.wlyy.dao.OauthWlyyConfigDao;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
|
import com.ylzinfo.onepay.sdk.utils.StringUtil;
|
|
import jxl.format.VerticalAlignment;
|
|
import jxl.format.VerticalAlignment;
|
|
import jxl.write.*;
|
|
import jxl.write.*;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
@ -353,7 +354,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
if (!StringUtils.isEmpty(dispensingWindow)) {
|
|
if (!StringUtils.isEmpty(dispensingWindow)) {
|
|
conditionSql += " and t.dispensing_window = '" + 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);
|
|
orderList = hibenateUtils.createSQLQuery(sencodSql, page, size);
|
|
|
|
|
|
@ -1802,96 +1803,22 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
public MixEnvelop getSumAmount(String belongCommunity, String equNum, int page, int size) {
|
|
public MixEnvelop getSumAmount(String belongCommunity, String equNum, int page, int size) {
|
|
List<Map<String,Object>> mapList=new ArrayList<>();
|
|
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" +
|
|
" COUNT(*) AS count,\n" +
|
|
" t.shipping_equ AS equNum\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);
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(oneSql);
|
|
for (Map<String,Object> oneMap:list){
|
|
for (Map<String,Object> oneMap:list){
|
|
String count = oneMap.get("count")==null?"0":oneMap.get("count").toString();
|
|
String count = oneMap.get("count")==null?"0":oneMap.get("count").toString();
|
|
@ -1903,9 +1830,20 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
map.put("sumAmount",m_price);
|
|
map.put("sumAmount",m_price);
|
|
}
|
|
}
|
|
mapList.add(map);
|
|
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 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;
|
|
return mixEnvelop;
|
|
}
|
|
}
|
|
|
|
|