chenjiasheng 3 年之前
父节点
当前提交
3922546934

+ 30 - 25
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineDrugsEndpoint.java

@ -11,6 +11,7 @@ import com.yihu.jw.entity.a1entity.Mediicinedrugs;
import com.yihu.jw.entity.a1entity.Mediicinestockoutdetail;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
@ -18,18 +19,18 @@ 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 jxl.format.Alignment;
import jxl.write.*;
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.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
@RestController
@ -146,9 +147,8 @@ public class MedicineDrugsEndpoint extends EnvelopRestEndpoint {
            @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);
            MixEnvelop result = drugsService.queryDrugListFullInfo2(state, content, drugClass, drugType, lowVolume, heightVolume, lowPrice, heightPrice,1,10000,wechatId);
            List<Map<String,Object>> list=result.getDetailModelList();
            response.setContentType("application/octet-stream");
            response.setHeader("Content-Disposition", "attachment; filename=" + new String("volunteerInfo.xls"));
            OutputStream os = response.getOutputStream();
@ -158,8 +158,8 @@ public class MedicineDrugsEndpoint extends EnvelopRestEndpoint {
        }
    }
    private void write(OutputStream os, List<Mediicinedrugs> list) throws Exception {
        WritableWorkbook wwb = Workbook.createWorkbook(os);
    private void write(OutputStream os, List<Map<String,Object>> list) throws Exception {
        WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
        try {
            WritableSheet sheet = wwb.createSheet("sheet", 1);
            String header[] = {"图片", "药品名称/药品条码", "分类", "剂型", "类型", "单位", "售价", "库存", "销量", "自编码", "规格", "厂家", "批准文号", "品牌", "状态"};
@ -170,35 +170,40 @@ public class MedicineDrugsEndpoint extends EnvelopRestEndpoint {
            }
            int j = 1;
            int ii=1;
            for (Mediicinedrugs tmp : list) {
            for (Map<String,Object> 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() + "");
                addCell(sheet, j, 1, tmp.get("drugNameAlies") +"/" + tmp.get("drugBarCode"));
                addCell(sheet, j, 2, tmp.get("drugTypeCode").toString());
                addCell(sheet, j, 3, tmp.get("dosForm") + "");
                addCell(sheet, j, 4, tmp.get("drugTypeCode")+"");
                addCell(sheet, j, 5, tmp.get("unit") + "");
                addCell(sheet, j, 6, tmp.get("price") + "");
                addCell(sheet, j, 7, tmp.get("inventory") + "");
                addCell(sheet, j, 8, tmp.get("saleVolume") + "");
                addCell(sheet, j, 9, tmp.get("selfCode") + "");
                addCell(sheet, j, 10, tmp.get("specif") + "");
                addCell(sheet, j, 11, tmp.get("manufactor") + "");
                addCell(sheet, j, 12, tmp.get("approvalNum") + "");
                addCell(sheet, j, 13, tmp.get("brand") + "");
                addCell(sheet, j, 14, tmp.get("state") + "");
                j++;
                ii++;
            }
            wwb.write();
            wwb.close();
        } catch (Exception e) {
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    private 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(Alignment.CENTRE);
        cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
        label.setCellFormat(cellFormat);
        ws.addCell(label);
    }

+ 120 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineDrugsService.java

@ -15,6 +15,8 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.team.BaseTeamDO;
import com.yihu.jw.entity.base.team.BaseTeamMemberDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
@ -309,6 +311,124 @@ public class MedicineDrugsService extends BaseJpaService<Mediicinedrugs, Mediici
    }
    public MixEnvelop queryDrugListFullInfo2(String state, String content, String drugClass,
                                            String drugType, String lowVolume, String heightVolume,
                                            String lowPrice, String heightPrice, int page, int size, String wechatId) throws Exception {
        JSONObject result = new JSONObject();
        /*String orgCodeVale = null == orgCode ? "" : orgCode;
        String del = null == docStatus ? "" : docStatus;
        String nameOrIdcardValue = null == nameOrIdcard ? "" : "%" + nameOrIdcard + "%";
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;*/
        String sql = "SELECT\n" +
                "    t.id as id,\n" +
                "    t.approval_num as approvalNum,\n" +
                "    t.barcode as barcode,\n" +
                "    t.brand as brand,\n" +
                "    t.dos_form as dosForm,\n" +
                "    t.state as state,\n" +
                "    t.drug_bar_code as drugBarCode,\n" +
                "    t.drug_class as drugClass,\n" +
                "    t.drug_class_code as drugClassCode,\n" +
                "    t.drug_code as drugCode,\n" +
                "    t.drug_name as drugName,\n" +
                "    t.drug_name_alies as drugNameAlies,\n" +
                "    t.drug_short_code as drugShortCode,\n" +
                "    t.drug_type_code as drugTypeCode,\n" +
                "    t.earlywarningcate as earlywarningcate,\n" +
                "    t.inventory as inventory,\n" +
                "    t.manufactor as manufactor,\n" +
                "    t.med_cabinet as medCabinet,\n" +
                "    t.pic as pic,\n" +
                "    t.price as price,\n" +
                "    t.sale_volume as saleVolume,\n" +
                "    t.self_code as selfCode,\n" +
                "    t.specif as specif,\n" +
                "    t.unit as unit,\n" +
                "    t.create_time as createTime,\n" +
                "    t.create_user as createUser,\n" +
                "    t.create_user_name as createUserName,\n" +
                "    t.update_time as updateTime,\n" +
                "    t.update_user as updateUser,\n" +
                "    t.update_user_name as updateUserName,\n" +
                "    t.drug_sku as drugSku,\n" +
                "    t.drug_num as drugNum,\n" +
                "    t.use_num as useNum,\n" +
                "    t.use_way as useWay,\n" +
                "    t.use_rate as useRate,\n" +
                "    t.use_dose as useDose,\n" +
                "    t.use_way_add as useWayAdd,\n" +
                "    t.org_code as orgCode,\n" +
                "    t.org_name as orgName,\n" +
                "    t.quantity_unit as quantityUnit,\n" +
                "    t.pack_unit as packUnit\n" +
                "FROM\n" +
                "    t_mediicine_drugs AS t where 1=1";
        String conditionSql = "";
        if (!StringUtils.isEmpty(state)){
            conditionSql += " and t.state = '" + state + "'";
        }
        if (!StringUtils.isEmpty(content)){
            conditionSql += " and CONCAT(t.drug_code, t.drug_bar_code, drug_name, t.drug_short_code) like '%"+content+"%'";
        }
        if (!StringUtils.isEmpty(drugClass)){
            conditionSql += " and t.drug_class_code = '" + drugClass + "'";
        }
        if (!StringUtils.isEmpty(drugType)){
            conditionSql += " and t.drug_type_code = '" + drugType + "'";
        }
        if (!StringUtils.isEmpty(lowVolume)){
            conditionSql += " and t.sale_volume >= " + lowVolume;
        }
        if (!StringUtils.isEmpty(heightVolume)) {
            conditionSql += " and t.sale_volume <= " + heightVolume;
        }
        if (!StringUtils.isEmpty(lowPrice)){
            conditionSql += " and t.price >= " + lowPrice;
        }
        if (!StringUtils.isEmpty(heightPrice)) {
            conditionSql += " and t.price <= " + heightPrice;
        }
        sql = sql + conditionSql;
        List<Map<String,Object>> list=null;
        list = hibenateUtils.createSQLQuery(sql,page,size);
        String countSql = " select " +
                "     COUNT(DISTINCT (t.id)) as count " +
                "   from " +
                "     t_mediicine_drugs t " +
                "  where " +
                "  1=1   " +
                conditionSql;
        Logger.getAnonymousLogger().info("finalCountSql="+countSql);
        int count = jdbcTemplate.queryForObject(countSql,Integer.class);
        for (Map<String,Object> stringObjectMap:list){
            if (stringObjectMap.get("state") != null) {
                if (!StringUtils.isEmpty(stringObjectMap.get("state").toString())) {
                    if ("1".equals(stringObjectMap.get("state").toString())) {
                        stringObjectMap.put("stateName", "已上架");
                    }
                    if ("2".equals(stringObjectMap.get("state").toString())) {
                        stringObjectMap.put("stateName", "已下架");
                    }
                    if ("3".equals(stringObjectMap.get("state").toString())) {
                        stringObjectMap.put("stateName", "处方");
                    }
                    if ("4".equals(stringObjectMap.get("state").toString())) {
                        stringObjectMap.put("stateName", "非处方");
                    }
                }
            }
        }
        Map<String,Object> map=new HashMap<>();
        map.put("count",count);
        list.add(map);
//        result.put("count", count);
//        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
        return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success,list);
    }
    public void getOrgPhysicDict(String jsonData) {
    }