|
@ -13,6 +13,7 @@ import com.yihu.jw.entity.base.role.RoleDO;
|
|
import com.yihu.jw.entity.base.user.UserDO;
|
|
import com.yihu.jw.entity.base.user.UserDO;
|
|
import com.yihu.jw.entity.hospital.DmHospitalDO;
|
|
import com.yihu.jw.entity.hospital.DmHospitalDO;
|
|
import com.yihu.jw.hospital.HospitalDao;
|
|
import com.yihu.jw.hospital.HospitalDao;
|
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
|
|
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
@ -26,6 +27,7 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
import java.awt.print.Pageable;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
import java.io.OutputStream;
|
|
import java.lang.Boolean;
|
|
import java.lang.Boolean;
|
|
@ -1488,20 +1490,36 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
public MixEnvelop getSumAmount(String belongCommunity, String equNum, String startTime, String endTime) {
|
|
|
|
|
|
public MixEnvelop getSumAmountExcel(String belongCommunity, String equNum, String startTime, String endTime,int page,int size) {
|
|
|
|
page = (page - 1) * size;
|
|
//查询出所有的设备
|
|
//查询出所有的设备
|
|
Iterable <Mediicinedevice> mediicinedevices = deviceDao.findAll();
|
|
|
|
|
|
Iterable <Mediicinedevice> mediicinedevices = deviceDao.findDeviceAll(page,size);
|
|
List<Mediicinedevice> mediicinedeviceList= IterableUtils.toList(mediicinedevices);
|
|
List<Mediicinedevice> mediicinedeviceList= IterableUtils.toList(mediicinedevices);
|
|
Map<String,Object> map=new HashMap<>();
|
|
|
|
|
|
|
|
//将同一个设备的社区/名称/设备编码/历史记录/总金额放到一个Map中
|
|
|
|
|
|
//将同一个设备的社区/名称/设备编码/历史记录/总金额放到一个Map中,并将这些Map放到同一个list中返回
|
|
|
|
List<Map<String,Object>> mapList=new ArrayList<>();
|
|
for (Mediicinedevice mediicinedevice:mediicinedeviceList){
|
|
for (Mediicinedevice mediicinedevice:mediicinedeviceList){
|
|
map.put("社区",mediicinedevice.getCommunity());
|
|
|
|
map.put("设备编号",mediicinedevice.getEquNum()+"/"+mediicinedevice.getEquName());
|
|
|
|
|
|
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" +
|
|
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 AND t.shipping_equ = '" + mediicinedevice.getEquNum()+"'";
|
|
" FROM t_mediicine_order t WHERE t.sell_state = 1 AND t.shipping_equ = '" + mediicinedevice.getEquNum()+"'";
|
|
|
|
String conditionSql="";
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)){
|
|
|
|
conditionSql += "AND t.belong_community ='"+belongCommunity+"'";
|
|
|
|
}
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
|
|
|
|
conditionSql += "AND t.shipping_equ = '" + equNum + "'";
|
|
|
|
}
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)){
|
|
|
|
conditionSql += "AND t.shipping_time >= "+ startTime ;
|
|
|
|
}
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)){
|
|
|
|
conditionSql += "AND t.shipping_time <= "+ endTime ;
|
|
|
|
}
|
|
|
|
oneSql=oneSql+conditionSql;
|
|
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();
|
|
@ -1509,40 +1527,60 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
map.put("count",count);
|
|
map.put("count",count);
|
|
map.put("sumAmount",sumAmount);
|
|
map.put("sumAmount",sumAmount);
|
|
}
|
|
}
|
|
|
|
mapList.add(map);
|
|
}
|
|
}
|
|
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 ;
|
|
|
|
}
|
|
|
|
|
|
return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success,mapList);
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Map<String,Object>> getSumAmount(String belongCommunity, String equNum, String startTime, String endTime,int page,int size) {
|
|
|
|
List<Map<String,Object>> mapList=new ArrayList<>();
|
|
|
|
page = (page - 1) * size;
|
|
|
|
//查询出所有的设备
|
|
|
|
Iterable <Mediicinedevice> mediicinedevices = deviceDao.findDeviceAll(page,size);
|
|
|
|
List<Mediicinedevice> mediicinedeviceList= IterableUtils.toList(mediicinedevices);
|
|
|
|
String countSql = " select " +
|
|
|
|
" COUNT(DISTINCT (t.id)) as count " +
|
|
|
|
" from " +
|
|
|
|
" t_mediicine_device " +
|
|
|
|
" where " +
|
|
|
|
" 1=1 " ;
|
|
|
|
Logger.getAnonymousLogger().info("finalCountSql="+countSql);
|
|
|
|
int decCount = jdbcTemplate.queryForObject(countSql,Integer.class);
|
|
|
|
Map<String,Object> countMap = new HashMap<>();
|
|
|
|
countMap.put("count",decCount);
|
|
|
|
mapList.add(countMap);
|
|
|
|
|
|
|
|
//将同一个设备的社区/名称/设备编码/历史记录/总金额放到一个Map中,并将这些Map放到同一个list中返回
|
|
for (Mediicinedevice mediicinedevice:mediicinedeviceList){
|
|
for (Mediicinedevice mediicinedevice:mediicinedeviceList){
|
|
|
|
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()+"'";
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(belongCommunity)){
|
|
|
|
oneSql += "AND t.belong_community ='"+belongCommunity+"'";
|
|
|
|
}
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(equNum)){
|
|
|
|
oneSql += "AND t.shipping_equ = '" + equNum + "'";
|
|
|
|
}
|
|
|
|
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 ;
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
mapList.add(map);
|
|
}
|
|
}
|
|
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);
|
|
|
|
|
|
return mapList;
|
|
}
|
|
}
|
|
|
|
|
|
public void pushListWrite(OutputStream os, List<Map<String, Object>> list)throws Exception {
|
|
public void pushListWrite(OutputStream os, List<Map<String, Object>> list)throws Exception {
|
|
@ -1551,7 +1589,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
WritableSheet sheet;
|
|
WritableSheet sheet;
|
|
sheet = wwb.createSheet("sheet", 1);
|
|
sheet = wwb.createSheet("sheet", 1);
|
|
|
|
|
|
String header[] = {"社区", "设备名/设备编号", "历史订单", "总销售额"};
|
|
|
|
|
|
String header[] = {"社区", "设备编号/设备名", "历史订单", "总销售额"};
|
|
int i = 0;
|
|
int i = 0;
|
|
for (String h : header) {
|
|
for (String h : header) {
|
|
addCell(sheet, 0, i, h);
|
|
addCell(sheet, 0, i, h);
|
|
@ -1560,7 +1598,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
int j = 1;
|
|
int j = 1;
|
|
for (Map<String, Object> tmp : list) {
|
|
for (Map<String, Object> tmp : list) {
|
|
addCell(sheet, j, 0, tmp.get("community")==null ? "" : tmp.get("community").toString());
|
|
addCell(sheet, j, 0, tmp.get("community")==null ? "" : tmp.get("community").toString());
|
|
addCell(sheet, j, 1, tmp.get("equName") == null? "" : tmp.get("drugTypeCode").toString()+(tmp.get("equNum")==null?"":tmp.get("equNum")));
|
|
|
|
|
|
addCell(sheet, j, 1, tmp.get("equName") == null? "" : tmp.get("equName").toString());
|
|
addCell(sheet, j, 2, tmp.get("count") == null ? "" : tmp.get("count").toString());
|
|
addCell(sheet, j, 2, tmp.get("count") == null ? "" : tmp.get("count").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++;
|
|
j++;
|
|
@ -1581,4 +1619,86 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
label.setCellFormat(cellFormat);
|
|
label.setCellFormat(cellFormat);
|
|
ws.addCell(label);
|
|
ws.addCell(label);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public List<Map<String,Object>> getDeviceInfo(String prescribeNum, String amount, 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" +
|
|
|
|
" t.socialinsur_payment AS 'socialinsurPayment',\n" +
|
|
|
|
" 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='"+prescribeNum+"'";
|
|
|
|
}
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(amount)){
|
|
|
|
sql += " AND t.amount='"+amount+"'";
|
|
|
|
}
|
|
|
|
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+"'";
|
|
|
|
}
|
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,page,size);
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
public MixEnvelop getDeviceInfoExcel(String prescribeNum, String amount, 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" +
|
|
|
|
" t.socialinsur_payment AS 'socialinsurPayment',\n" +
|
|
|
|
" 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='"+prescribeNum+"'";
|
|
|
|
}
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(amount)){
|
|
|
|
sql += " AND t.amount='"+amount+"'";
|
|
|
|
}
|
|
|
|
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+"'";
|
|
|
|
}
|
|
|
|
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 {
|
|
|
|
WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
|
|
|
|
try {
|
|
|
|
WritableSheet sheet;
|
|
|
|
sheet = wwb.createSheet("sheet", 1);
|
|
|
|
|
|
|
|
String header[] = {"开方时间", "处方号", "交易金额", "社保抵扣","合计"};
|
|
|
|
int i = 0;
|
|
|
|
for (String h : header) {
|
|
|
|
addCell(sheet, 0, i, h);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
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, 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());
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
wwb.write();
|
|
|
|
wwb.close();
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
if (wwb != null) wwb.close();
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|