wangzhinan il y a 3 ans
Parent
commit
83e78f93b7

+ 13 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicinedrugs.java

@ -15,6 +15,12 @@ import java.io.Serializable;
public class Mediicinedrugs extends UuidIdentityEntityWithOperator implements Serializable {
    /**
     * 状态
     */
    private String state;
    /**
     * 名称
     */
@ -128,6 +134,13 @@ public class Mediicinedrugs extends UuidIdentityEntityWithOperator implements Se
    public Mediicinedrugs() {
    }
    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
    public String getDrugName() {
        return drugName;

+ 25 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -9,6 +9,31 @@ public class BaseRequestMapping {
    @Deprecated
    public static final String api_base_common = "/svr-bases";
    /**
     * 药品信息  BaseSensitive
     */
    public static class BaseDrug extends Basic {
        public static final String PREFIX  = "/baseDrug";
        public static final String DOCINFO  = "/docInfo";
        public static final String CREATE  = "/create";
        public static final String getOrgListByTown  = "/getOrgListByTown";
        public static final String enableOrDis  = "/enableOrDis";
        public static final String docFullInfo  = "/docFullInfo";
        public static final String docOrgDutyTreeInfo  = "/docOrgDutyTreeInfo";
        public static final String docOrgDeptTreeInfo  = "/docOrgDeptTreeInfo";
        public static final String getDoctorListByDept  = "/getDoctorListByDept";
        public static final String DOCTOR_INFO_IMPORT  = "/baseDoctorInfoImport";
        public static final String findIncentive  = "/findIncentive";
        public static final String findIncentiveById  = "/findIncentiveById";
        public static final String deleteIncentiveById  = "/deleteIncentiveById";
        public static final String saveIncentiveById  = "/saveIncentiveById";
        public static final String saveDoctorIncentive  = "/saveDoctorIncentive";
        public static final String findDoctorIncentive  = "/findDoctorIncentive";
        public static final String findDoctorOtherIncentive  = "/findDoctorOtherIncentive";
        public static final String removeIncentive  = "/removeIncentive";
        public static final String resetDoctorPwd  = "/resetDoctorPwd";
    }
    /**
     * 基础请求地址
     */

+ 177 - 6
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineDrugsEndpoint.java

@ -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(){

+ 202 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineDrugsService.java

@ -1,27 +1,48 @@
package com.yihu.jw.base.service.a3service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.base.dao.a2dao.MediicinedrugsDao;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.base.util.JavaBeanUtils;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.a1entity.Mediicinedrugs;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.team.BaseTeamMemberDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.util.List;
import java.util.*;
import java.util.logging.Logger;
/**
 * Created by Bing on 2021/9/23.
 */
@Service
public class MedicineDrugsService  {
public class MedicineDrugsService extends BaseJpaService<Mediicinedrugs, MediicinedrugsDao> {
    @Autowired
    private MediicinedrugsDao drugsDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private HibenateUtils hibenateUtils;
    //获取药品信息列表
    public List<Mediicinedrugs> getMediicinedrugs() {
@ -67,4 +88,183 @@ public class MedicineDrugsService  {
//        result.put(ResponseContant.resultMsg,"success");
        return result;
    }
    /**
     * 新增药品信息
     * @param jsonData
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public String createDrug(String jsonData) {
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(jsonData)){
            result.put("msg","jsonData is null");
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        JSONObject drug = JSONObject.parseObject(jsonData);
        if(null == drug){
            result.put("msg","parameter drug of jsonData is null");
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        String orgCode="";
        //判断药品id是否存在
        if(StringUtils.isEmpty(drug.getString("id"))){
            result.put("msg","parameter id for drug is null when update drug");
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        Mediicinedrugs mediicinedrugs = null;
        try {
            mediicinedrugs = objectMapper.readValue(drug.toJSONString(), Mediicinedrugs.class);
        } catch (IOException e) {
            result.put("msg", "convert drug jsonObject to BaseDoctorDO failed," + e.getCause());
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        } catch (Exception e) {
            result.put("msg", "convert drug birth failed," + e.getCause());
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        this.save(mediicinedrugs);
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg",mediicinedrugs);
        return result.toJSONString();
    }
    /**
     * 修改药品信息
     * @param jsonData
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public String updateDrug(String jsonData){
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(jsonData)){
            result.put("msg","jsonData is null");
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        JSONObject drug = JSONObject.parseObject(jsonData);
        if(null == drug){
            result.put("msg","parameter drug of jsonData is null");
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        String orgCode="";
        //判断医生id是否存在
        if(StringUtils.isEmpty(drug.getString("id"))){
            result.put("msg","parameter id for drug is null when update drug");
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        Mediicinedrugs mediicinedrugs = null;
        try {
            mediicinedrugs = objectMapper.readValue(drug.toJSONString(), Mediicinedrugs.class);
        } catch (IOException e) {
            result.put("msg", "convert drug jsonObject to BaseDoctorDO failed," + e.getCause());
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        } catch (Exception e) {
            result.put("msg", "convert drug birth failed," + e.getCause());
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        this.save(mediicinedrugs);
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg",mediicinedrugs);
        return result.toJSONString();
    }
    public JSONObject queryDrugListFullInfo(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" +
                "FROM\n" +
                "    t_mediicine_drugs AS t where 1=1\n";
        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> map:list){
        }
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
        return result;
    }
}