Browse Source

Merge branch 'dev' of humingfen/wlyy2.0 into dev

humingfen 3 years ago
parent
commit
78c21004b3

+ 24 - 10
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/NationalDrugDictService.java

@ -9,6 +9,8 @@ import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -23,12 +25,14 @@ import static com.yihu.jw.util.common.BeanUtils.getNullPropertyNames;
public class NationalDrugDictService extends BaseJpaService<BaseNationalDrugDictDO, BaseNationalDrugDictDao> {
    @Autowired
    private BaseNationalDrugDictDao nationalDrugDictDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public BaseNationalDrugDictDO saveNationalDrug(BaseNationalDrugDictDO nationalDrugDictDO) {
        nationalDrugDictDO.setPyName(ConvertToSpellUtils.changeToTonePinYin(nationalDrugDictDO.getName()));
        nationalDrugDictDO.setPyCommonName(ConvertToSpellUtils.changeToTonePinYin(nationalDrugDictDO.getCommonName()));
        //判断新增或编辑
        if (nationalDrugDictDO.getId() == null) {
            nationalDrugDictDO.setPyName(ConvertToSpellUtils.changeToTonePinYin(nationalDrugDictDO.getName()));
            nationalDrugDictDO.setPyCommonName(ConvertToSpellUtils.changeToTonePinYin(nationalDrugDictDO.getCommonName()));
            nationalDrugDictDO.setCreateTime(new Date());
            nationalDrugDictDO.setStatus(1);
            nationalDrugDictDO.setUpdateTime(new Date());
@ -56,21 +60,27 @@ public class NationalDrugDictService extends BaseJpaService<BaseNationalDrugDict
     */
    public MixEnvelop getNationalDrugList(String name, String number, String hospital, Integer status, Integer page, Integer pageSize) throws ParseException {
        MixEnvelop mixEnvelop = new MixEnvelop();
        String filters = "";
        String sql = "SELECT id,number,name,subject_class,subject_class_name,drug_code,drug_name,hospital,hospital_name,relation_code,`status` " +
                "FROM `base_national_drug_dict` WHERE 1=1 ";
        if (StringUtils.isNotBlank(name)) {
            filters += "name?" + name + ";";
            sql += "and name like '%" + name + "%' ";
        }
        if (StringUtils.isNotBlank(number)) {
            filters += "number?" + number + ";";
            sql += "and number like '%" + number + "%' ";
        }
        if (StringUtils.isNotBlank(hospital)) {
            filters += "hospital=" + hospital + ";";
            sql += "and hospital = '" + hospital + "' ";
        } else {
            sql += "and hospital is null ";
        }
        if (status != null) {
            filters += "status=" + status + ";";
            sql += "status = " + status + " ";
        }
        Integer count = jdbcTemplate.queryForList(sql).size();
        if (page != null && pageSize != null) {
            sql += "order by create_time desc limit " + (page - 1) * pageSize + "," + pageSize;
        }
        Integer count = this.search(null, filters, null).size();
        List<BaseNationalDrugDictDO> list = this.search(null, filters, null, page, pageSize);
        List<BaseNationalDrugDictDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(BaseNationalDrugDictDO.class));
        mixEnvelop.setMessage("获取成功!");
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setPageSize(pageSize);
@ -80,6 +90,10 @@ public class NationalDrugDictService extends BaseJpaService<BaseNationalDrugDict
    }
    public void updateNationalDrugStatus(Integer id, Integer status) {
         nationalDrugDictDao.updateStatusById(id, status);
        nationalDrugDictDao.updateStatusById(id, status);
    }
    public BaseNationalDrugDictDO getNationalDrugById(Integer id) {
        return nationalDrugDictDao.findOne(id);
    }
}

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -551,6 +551,7 @@ public class BaseHospitalRequestMapping {
        public static final String saveNationalDrug = "/saveNationalDrug";//保存药品字典
        public static final String getNationalDrugList = "/getNationalDrugList";//获取药品字典
        public static final String updateNationalDrugStatus = "/updateNationalDrugStatus";//更新药品字典状态
        public static final String getNationalDrugById = "/getNationalDrugById";//根据id获取药品信息
    }
    public static class YkyyPrescription extends BaseHospitalRequestMapping.Basic {

+ 7 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/NationalDrugDictEndpoint.java

@ -55,4 +55,11 @@ public class NationalDrugDictEndpoint extends EnvelopRestEndpoint {
        nationalDrugDictService.updateNationalDrugStatus(id,status);
        return success();
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getNationalDrugById)
    @ApiOperation(value = "根据id获取药品字典")
    public ObjEnvelop getNationalDrugById(@ApiParam(name = "id", value = "药品id")
                                          @RequestParam(name = "id", required = true) Integer id) {
        return success(nationalDrugDictService.getNationalDrugById(id));
    }
}