|
@ -1483,38 +1483,59 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
}
|
|
|
|
|
|
public MixEnvelop getSumAmount(String belongCommunity, String equNum, String startTime, String endTime) {
|
|
|
List<Map<String,Object>> arrayList=new ArrayList<>();
|
|
|
List<Map<String,Object>> mapList=new ArrayList<>();
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
//查询出所有的设备
|
|
|
Iterable <Mediicinedevice> mediicinedevices = deviceDao.findAll();
|
|
|
List<Mediicinedevice> mediicinedeviceList= IterableUtils.toList(mediicinedevices);
|
|
|
Map<String,Object> map=new HashMap<>();
|
|
|
|
|
|
//将同一个设备的社区/名称/设备编码/历史记录/总金额放到一个Map中
|
|
|
for (Mediicinedevice mediicinedevice:mediicinedeviceList){
|
|
|
String sql = "SELECT SUM(t.amount) AS sumAmount,\n" +
|
|
|
"COUNT(*) AS count,\n" +
|
|
|
"t.shipping_equ AS equNum \n" +
|
|
|
"FROM t_mediicine_order AS t,\n" +
|
|
|
"t_mediicine_device AS a \n" +
|
|
|
"WHERE t.shipping_equ = a.equ_num AND t.sell_state = 1 " +
|
|
|
"AND 1=1";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)){
|
|
|
sql += "AND a.belong_community ='"+belongCommunity+"'";
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
|
|
|
sql += "AND t.shipping_equ = '" + equNum + "'";
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)){
|
|
|
sql += "AND t.shipping_time >= "+ startTime ;
|
|
|
map.put("社区",mediicinedevice.getCommunity());
|
|
|
map.put("设备编号",mediicinedevice.getEquNum()+"/"+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();
|
|
|
map.put("count",count);
|
|
|
map.put("sumAmount",sumAmount);
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)){
|
|
|
sql += "AND t.shipping_time <= "+ endTime ;
|
|
|
}
|
|
|
// sql += "GROUP BY t.shipping_equ";
|
|
|
sql +="AND t.shipping_equ = '" + mediicinedevice.getEquNum()+"'";
|
|
|
Map<String,Object> result=new HashMap<>();
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
|
|
|
result.put("msg",list);
|
|
|
mapList.add(result);
|
|
|
}
|
|
|
String sql = "SELECT SUM(t.amount) AS sumAmount,\n" +
|
|
|
"a.community AS community,\n" +
|
|
|
"a.equ_name AS equName,\n" +
|
|
|
"COUNT(*) AS count,\n" +
|
|
|
"t.shipping_equ AS equNum \n" +
|
|
|
"FROM t_mediicine_order AS t,\n" +
|
|
|
"t_mediicine_device AS a \n" +
|
|
|
"WHERE t.shipping_equ = a.equ_num AND t.sell_state = 1 " +
|
|
|
"AND 1=1";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)){
|
|
|
sql += "AND a.belong_community ='"+belongCommunity+"'";
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
|
|
|
sql += "AND t.shipping_equ = '" + equNum + "'";
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)){
|
|
|
sql += "AND t.shipping_time >= "+ startTime ;
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)){
|
|
|
sql += "AND t.shipping_time <= "+ endTime ;
|
|
|
}
|
|
|
for (Mediicinedevice mediicinedevice:mediicinedeviceList){
|
|
|
}
|
|
|
Map<String,Object> result=new HashMap<>();
|
|
|
List<Map<String,Object>> mapList=new ArrayList<>();
|
|
|
|
|
|
|
|
|
sql += "GROUP BY t.shipping_equ";
|
|
|
sql +="AND t.shipping_equ = '" + equNum+"'";
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
|
|
|
result.put("msg",list);
|
|
|
mapList.add(result);
|
|
|
return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success,mapList);
|
|
|
}
|
|
|
|