|
@ -1,26 +1,42 @@
|
|
|
package com.yihu.jw.base.endpoint.a4endpoint;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.jw.base.dao.a2dao.MedicineorderDao;
|
|
|
import com.yihu.jw.base.service.a3service.MedicineOrderService;
|
|
|
import com.yihu.jw.base.service.a3service.MedicinedeviceService;
|
|
|
import com.yihu.jw.base.util.ConstantUtils;
|
|
|
import com.yihu.jw.entity.a1entity.Mediicineorder;
|
|
|
import com.yihu.jw.entity.a1entity.Mediicineorderdetail;
|
|
|
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentArrangeDO;
|
|
|
import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentPeopleDO;
|
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.ListEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
|
|
|
import com.yihu.jw.rm.base.BaseRequestMapping;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import jxl.Workbook;
|
|
|
import jxl.write.Label;
|
|
|
import jxl.write.WritableSheet;
|
|
|
import jxl.write.WritableWorkbook;
|
|
|
import jxl.write.WriteException;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.OutputStream;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@RestController
|
|
@ -34,6 +50,8 @@ public class MedicineOrderEndpoint extends EnvelopRestEndpoint {
|
|
|
private MedicineOrderService orderservice;
|
|
|
@Autowired
|
|
|
private ObjectMapper objectMapper;
|
|
|
@Autowired
|
|
|
private MedicineorderDao medicineorderDao;
|
|
|
|
|
|
|
|
|
@Value("${wechat.id}")
|
|
@ -253,6 +271,93 @@ public class MedicineOrderEndpoint extends EnvelopRestEndpoint {
|
|
|
return success(result.getString("msg"));
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = BaseRequestMapping.BaseOrder.export)
|
|
|
@ApiOperation(value = "处方订单列表导出" , notes="处方订单列表导出")
|
|
|
@ResponseBody
|
|
|
public void export(
|
|
|
@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
|
|
|
@RequestParam(value = "fields", required = false) String fields,
|
|
|
@ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
|
|
|
@RequestParam(value = "filters", required = false) String filters,
|
|
|
@ApiParam(name = "sorts", value = "排序,规则参见说明文档")
|
|
|
@RequestParam(value = "sorts", required = false) String sorts,
|
|
|
HttpServletResponse response) {
|
|
|
try {
|
|
|
List<Mediicineorder> result = orderservice.search(fields, filters, sorts);
|
|
|
response.setContentType("octets/stream");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + new String("medicineOrder.xls"));
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
this.write(os, result);
|
|
|
} catch (Exception ex) {
|
|
|
Envelop.getError("导出失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void write(OutputStream os, List<Mediicineorder> list) throws Exception {
|
|
|
WritableWorkbook wwb = Workbook.createWorkbook(os);
|
|
|
try {
|
|
|
WritableSheet sheet = wwb.createSheet("sheet", 1);
|
|
|
String header[] = {"序号", "患者", "处方号", "交易金额", " 出货状态", "社区", "设备信息", "开方时间", "付款时间", "订单类型", "订单来源", "存取信息"};
|
|
|
int i = 0;
|
|
|
for (String h : header) {
|
|
|
addCell(sheet, 0, i, h);
|
|
|
i++;
|
|
|
}
|
|
|
int j = 1;
|
|
|
int ii=1;
|
|
|
for (Mediicineorder tmp : list) {
|
|
|
Mediicineorder mediicineorder= medicineorderDao.findById(tmp.getId());
|
|
|
if (null == mediicineorder){
|
|
|
continue;
|
|
|
}
|
|
|
String sellStateName = "";
|
|
|
if (StringUtils.isNotBlank(mediicineorder.getSellState())) {
|
|
|
String sellState = mediicineorder.getSellState();
|
|
|
switch (sellState) {
|
|
|
case "0":
|
|
|
sellStateName = "未取药";
|
|
|
break;
|
|
|
case "1":
|
|
|
sellStateName = "已取药";
|
|
|
break;
|
|
|
case "-1":
|
|
|
sellStateName = "药房已取药";
|
|
|
break;
|
|
|
case "-2":
|
|
|
sellStateName = "药房已作废";
|
|
|
break;
|
|
|
case "-5":
|
|
|
sellStateName = "出药异常";
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
addCell(sheet, j, 0, ii + "");
|
|
|
addCell(sheet, j, 1, tmp.getName());
|
|
|
addCell(sheet, j, 2, tmp.getPrescribeNum());
|
|
|
addCell(sheet, j, 3, tmp.getAmount());
|
|
|
addCell(sheet, j, 4, sellStateName);
|
|
|
addCell(sheet, j, 5, tmp.getCommunity());
|
|
|
addCell(sheet, j, 6, tmp.getShippingEqu());
|
|
|
addCell(sheet, j, 7, DateUtil.dateToStrLong(tmp.getPrescribeTime()));
|
|
|
addCell(sheet, j, 8, DateUtil.dateToStrLong(tmp.getPayTime()));
|
|
|
addCell(sheet, j, 9, tmp.getOrderType());
|
|
|
addCell(sheet, j, 10, tmp.getInfoAccess());
|
|
|
j++;
|
|
|
ii++;
|
|
|
}
|
|
|
wwb.write();
|
|
|
wwb.close();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
if (wwb != null) wwb.close();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
|
|
|
Label label = new Label(column, row, data);
|
|
|
ws.addCell(label);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|