|
@ -13,15 +13,22 @@ 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.hospital.HospitalDao;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import jxl.format.VerticalAlignment;
|
|
|
import jxl.write.*;
|
|
|
import org.apache.commons.collections4.IterableUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.lang.Boolean;
|
|
|
import java.util.*;
|
|
|
import java.util.logging.Logger;
|
|
|
import java.util.stream.Collectors;
|
|
@ -1474,4 +1481,78 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
result.put("msg", jsonObject);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
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<>();
|
|
|
Iterable <Mediicinedevice> mediicinedevices = deviceDao.findAll();
|
|
|
List<Mediicinedevice> mediicinedeviceList= IterableUtils.toList(mediicinedevices);
|
|
|
for (Mediicinedevice mediicinedevice:mediicinedeviceList){
|
|
|
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 ;
|
|
|
}
|
|
|
// 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);
|
|
|
}
|
|
|
return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success,mapList);
|
|
|
}
|
|
|
|
|
|
public void pushListWrite(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("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, 2, tmp.get("count") == null ? "" : tmp.get("count").toString());
|
|
|
addCell(sheet, j, 3, 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;
|
|
|
}
|
|
|
}
|
|
|
public void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
|
|
|
Label label = new Label(column, row, data);
|
|
|
WritableCellFormat cellFormat = new WritableCellFormat();
|
|
|
cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
|
|
|
cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
|
|
|
label.setCellFormat(cellFormat);
|
|
|
ws.addCell(label);
|
|
|
}
|
|
|
}
|