|  | @ -1,23 +1,48 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.base.endpoint.a4endpoint;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.fasterxml.jackson.databind.ObjectMapper;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.service.a3service.MedicineDrugsService;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.service.a3service.MedicineOrderService;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.util.ConstantUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.a1entity.Mediicinedrugs;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.voluntary.VoluntaryRecruitmentCompanyDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.base.doctor.BaseDoctorVO;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.Envelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.PageEnvelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
 | 
	
		
			
				|  |  | import com.yihu.jw.rm.base.BaseRequestMapping;
 | 
	
		
			
				|  |  | 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.poi.hssf.usermodel.HSSFRow;
 | 
	
		
			
				|  |  | import org.apache.poi.hssf.usermodel.HSSFSheet;
 | 
	
		
			
				|  |  | import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.web.bind.annotation.GetMapping;
 | 
	
		
			
				|  |  | import org.springframework.web.bind.annotation.RequestMapping;
 | 
	
		
			
				|  |  | import org.springframework.web.bind.annotation.RestController;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Value;
 | 
	
		
			
				|  |  | import org.springframework.web.bind.annotation.*;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.servlet.http.HttpServletRequest;
 | 
	
		
			
				|  |  | import javax.servlet.http.HttpServletResponse;
 | 
	
		
			
				|  |  | import java.io.FileInputStream;
 | 
	
		
			
				|  |  | import java.io.OutputStream;
 | 
	
		
			
				|  |  | import java.util.List;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | @Api(description = "药品信息")
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | @RestController
 | 
	
		
			
				|  |  | @RequestMapping("/MedicineDrugsEndpoint")
 | 
	
		
			
				|  |  | public class MedicineDrugsEndpoint {
 | 
	
		
			
				|  |  | @RequestMapping(value = BaseRequestMapping.BaseDrug.PREFIX)
 | 
	
		
			
				|  |  | @Api(value = "药品信息管理", description = "药品信息管理服务接口", tags = {"wlyy基础服务 - 药品信息管理服务接口"})
 | 
	
		
			
				|  |  | public class MedicineDrugsEndpoint extends EnvelopRestEndpoint {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     MedicineDrugsService drugsService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
	
		
			
				|  | @ -25,6 +50,152 @@ public class MedicineDrugsEndpoint {
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private ObjectMapper objectMapper;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Value("${wechat.id}")
 | 
	
		
			
				|  |  |     private String wechatId;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping(value = BaseRequestMapping.BaseDrug.CREATE)
 | 
	
		
			
				|  |  |     @ApiOperation(value = "新增药品信息")
 | 
	
		
			
				|  |  |     public Envelop create(
 | 
	
		
			
				|  |  |             @ApiParam(name = "jsonData", value = "Json数据", required = true)
 | 
	
		
			
				|  |  |             @RequestParam String jsonData) throws Exception {
 | 
	
		
			
				|  |  |         JSONObject jsonObject = null;
 | 
	
		
			
				|  |  |         String str = drugsService.createDrug(jsonData);
 | 
	
		
			
				|  |  |         jsonObject = JSONObject.parseObject(str);
 | 
	
		
			
				|  |  |         if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
 | 
	
		
			
				|  |  |             return failed(jsonObject.getString("msg"));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return success(jsonObject.getString("msg"));
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping(value = BaseRequestMapping.BaseDrug.DELETE)
 | 
	
		
			
				|  |  |     @ApiOperation(value = "删除")
 | 
	
		
			
				|  |  |     public Envelop delete(
 | 
	
		
			
				|  |  |             @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
 | 
	
		
			
				|  |  |             @RequestParam(value = "ids") String ids) {
 | 
	
		
			
				|  |  |         drugsService.delete(ids.split(","));
 | 
	
		
			
				|  |  |         return success("删除成功");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @PostMapping(value = BaseRequestMapping.BaseDrug.UPDATE)
 | 
	
		
			
				|  |  |     @ApiOperation(value = "更新药品信息")
 | 
	
		
			
				|  |  |     public Envelop update(
 | 
	
		
			
				|  |  |             @ApiParam(name = "jsonData", value = "Json数据", required = true)
 | 
	
		
			
				|  |  |             @RequestParam String jsonData) throws Exception {
 | 
	
		
			
				|  |  |         String str = drugsService.updateDrug(jsonData);
 | 
	
		
			
				|  |  |         JSONObject jsonObject = JSONObject.parseObject(str);
 | 
	
		
			
				|  |  |         if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
 | 
	
		
			
				|  |  |             return failed(jsonObject.getString("msg"));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return success(jsonObject.getString("response"));
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = BaseRequestMapping.BaseDrug.docFullInfo)
 | 
	
		
			
				|  |  |     @ApiOperation(value = "获取药品信息基础信息列表")
 | 
	
		
			
				|  |  |     public PageEnvelop getDrugFullInfolist(
 | 
	
		
			
				|  |  |             @ApiParam(name = "state", value = "药品状态")
 | 
	
		
			
				|  |  |             @RequestParam(value = "state", required = false) String state,
 | 
	
		
			
				|  |  |             @ApiParam(name = "content", value = "查询内容")
 | 
	
		
			
				|  |  |             @RequestParam(value = "content", required = false) String content,
 | 
	
		
			
				|  |  |             @ApiParam(name = "drugClass", value = "药品分类")
 | 
	
		
			
				|  |  |             @RequestParam(value = "drugClass", required = false) String drugClass,
 | 
	
		
			
				|  |  |             @ApiParam(name = "drugType", value = "药品类型")
 | 
	
		
			
				|  |  |             @RequestParam(value = "drugType", required = false) String drugType,
 | 
	
		
			
				|  |  |             @ApiParam(name = "lowVolume", value = "销量下限")
 | 
	
		
			
				|  |  |             @RequestParam(value = "lowVolume", required = false) String lowVolume,
 | 
	
		
			
				|  |  |             @ApiParam(name = "heightVolume", value = "销量上限")
 | 
	
		
			
				|  |  |             @RequestParam(value = "heightVolume", required = false) String heightVolume,
 | 
	
		
			
				|  |  |             @ApiParam(name = "lowPrice", value = "价格下限")
 | 
	
		
			
				|  |  |             @RequestParam(value = "lowPrice", required = false) String lowPrice,
 | 
	
		
			
				|  |  |             @ApiParam(name = "heightPrice", value = "价格上限")
 | 
	
		
			
				|  |  |             @RequestParam(value = "heightPrice", required = false) String heightPrice,
 | 
	
		
			
				|  |  |             @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
 | 
	
		
			
				|  |  |             @RequestParam(value = "page") int page,
 | 
	
		
			
				|  |  |             @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
 | 
	
		
			
				|  |  |             @RequestParam(value = "size") int size) throws Exception {
 | 
	
		
			
				|  |  |         JSONObject result = drugsService.queryDrugListFullInfo(state, content, drugClass, drugType, lowVolume, heightVolume, lowPrice, heightPrice,page,size,wechatId);
 | 
	
		
			
				|  |  |         return success(result.getJSONArray("msg"),result.getInteger("count"),page,size);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = "/excelControl/exportExcel")
 | 
	
		
			
				|  |  |     @ApiOperation("导出列表")
 | 
	
		
			
				|  |  |     @ResponseBody
 | 
	
		
			
				|  |  |     public void searchList(
 | 
	
		
			
				|  |  |             @ApiParam(name = "state", value = "药品状态")
 | 
	
		
			
				|  |  |             @RequestParam(value = "state", required = false) String state,
 | 
	
		
			
				|  |  |             @ApiParam(name = "content", value = "查询内容")
 | 
	
		
			
				|  |  |             @RequestParam(value = "content", required = false) String content,
 | 
	
		
			
				|  |  |             @ApiParam(name = "drugClass", value = "药品分类")
 | 
	
		
			
				|  |  |             @RequestParam(value = "drugClass", required = false) String drugClass,
 | 
	
		
			
				|  |  |             @ApiParam(name = "drugType", value = "药品类型")
 | 
	
		
			
				|  |  |             @RequestParam(value = "drugType", required = false) String drugType,
 | 
	
		
			
				|  |  |             @ApiParam(name = "lowVolume", value = "销量下限")
 | 
	
		
			
				|  |  |             @RequestParam(value = "lowVolume", required = false) String lowVolume,
 | 
	
		
			
				|  |  |             @ApiParam(name = "heightVolume", value = "销量上限")
 | 
	
		
			
				|  |  |             @RequestParam(value = "heightVolume", required = false) String heightVolume,
 | 
	
		
			
				|  |  |             @ApiParam(name = "lowPrice", value = "价格下限")
 | 
	
		
			
				|  |  |             @RequestParam(value = "lowPrice", required = false) String lowPrice,
 | 
	
		
			
				|  |  |             @ApiParam(name = "heightPrice", value = "价格上限")
 | 
	
		
			
				|  |  |             @RequestParam(value = "heightPrice", required = false) String heightPrice,
 | 
	
		
			
				|  |  |             HttpServletResponse response) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             JSONObject result = drugsService.queryDrugListFullInfo(state, content, drugClass, drugType, lowVolume, heightVolume, lowPrice, heightPrice,1,10000,wechatId);
 | 
	
		
			
				|  |  |             List<Mediicinedrugs> list = JSONObject.parseArray(result.getJSONArray("msg").toJSONString(), Mediicinedrugs.class);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             response.setContentType("octets/stream");
 | 
	
		
			
				|  |  |             response.setHeader("Content-Disposition", "attachment; filename=" + new String("volunteerInfo.xls"));
 | 
	
		
			
				|  |  |             OutputStream os = response.getOutputStream();
 | 
	
		
			
				|  |  |             this.write(os, list);
 | 
	
		
			
				|  |  |         } catch (Exception ex) {
 | 
	
		
			
				|  |  |             Envelop.getError("导出失败");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private void write(OutputStream os, List<Mediicinedrugs> 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 (Mediicinedrugs tmp : list) {
 | 
	
		
			
				|  |  |                 addCell(sheet, j, 0, ii + "img");
 | 
	
		
			
				|  |  |                 addCell(sheet, j, 1, tmp.getDrugNameAlies() +"/" + tmp.getDrugBarCode());
 | 
	
		
			
				|  |  |                 addCell(sheet, j, 2, tmp.getDrugTypeCode());
 | 
	
		
			
				|  |  |                 addCell(sheet, j, 3, tmp.getDosForm() + "");
 | 
	
		
			
				|  |  |                 addCell(sheet, j, 4, tmp.getDrugTypeCode()+"");
 | 
	
		
			
				|  |  |                 addCell(sheet, j, 5, tmp.getUnit() + "");
 | 
	
		
			
				|  |  |                 addCell(sheet, j, 6, tmp.getPrice() + "");
 | 
	
		
			
				|  |  |                 addCell(sheet, j, 7, tmp.getInventory() + "");
 | 
	
		
			
				|  |  |                 addCell(sheet, j, 8, tmp.getSaleVolume() + "");
 | 
	
		
			
				|  |  |                 addCell(sheet, j, 9, tmp.getSelfCode() + "");
 | 
	
		
			
				|  |  |                 addCell(sheet, j, 10, tmp.getSpecif() + "");
 | 
	
		
			
				|  |  |                 addCell(sheet, j, 11, tmp.getManufactor() + "");
 | 
	
		
			
				|  |  |                 addCell(sheet, j, 12, tmp.getApprovalNum() + "");
 | 
	
		
			
				|  |  |                 addCell(sheet, j, 13, tmp.getBrand() + "");
 | 
	
		
			
				|  |  |                 addCell(sheet, j, 14, tmp.getState() + "");
 | 
	
		
			
				|  |  |                 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);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @ApiOperation(value = "提交药品列表", notes="参数未添加通过数据区域查询获取")
 | 
	
		
			
				|  |  |     @GetMapping("/list")
 | 
	
		
			
				|  |  |     public List<Mediicinedrugs> list(){
 |