|
@ -15,14 +15,20 @@ 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.entity.hospital.prescription.WlyyPrescriptionInfoDO;
|
|
|
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 jxl.format.VerticalAlignment;
|
|
|
import jxl.write.*;
|
|
|
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.util.*;
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
@ -288,6 +294,181 @@ public class MedicineDrugsService extends BaseJpaService<Mediicinedrugs, Mediici
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
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) {
|
|
|
String sql ="";
|
|
|
|
|
|
{
|
|
|
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", "非处方");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return MixEnvelop.getSuccessListWithPage2(BaseHospitalRequestMapping.Prescription.api_success, list);
|
|
|
}
|
|
|
|
|
|
public void pushListWrite(OutputStream os, List<Map<String, Object>> ls) 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;
|
|
|
int ii=1;
|
|
|
for (Map<String, Object> tmp : ls) {
|
|
|
addCell(sheet, j, 0, ii + "img");
|
|
|
addCell(sheet, j, 1, tmp.get("drugNameAlies") +"/" + tmp.get("drugBarCode"));
|
|
|
addCell(sheet, j, 2, tmp.get("drugTypeCode") + "");
|
|
|
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 (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);
|
|
|
}
|
|
|
|
|
|
//添加单元格内容
|
|
|
public void addCell(WritableSheet ws, int row, int column, String data, String memo) throws WriteException {
|
|
|
Label label = new Label(column, row, data);
|
|
|
if (!org.springframework.util.StringUtils.isEmpty(memo)) {
|
|
|
WritableCellFeatures cellFeatures = new WritableCellFeatures();
|
|
|
cellFeatures.setComment(memo);
|
|
|
label.setCellFeatures(cellFeatures);
|
|
|
}
|
|
|
ws.addCell(label);
|
|
|
}
|
|
|
|
|
|
public JSONObject getOneDrugInfo(String drugId) throws Exception{
|
|
|
JSONObject result = new JSONObject();
|
|
|
if(StringUtils.isEmpty(drugId)){
|