|
@@ -1,9 +1,8 @@
|
|
-
|
|
|
|
package com.qunzhixinxi.hnqz.admin.controller;
|
|
package com.qunzhixinxi.hnqz.admin.controller;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
+import cn.hutool.core.text.CharSequenceUtil;
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
@@ -17,6 +16,7 @@ import com.qunzhixinxi.hnqz.admin.service.SysCsmUserRelationService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDictItemService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDictItemService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmDaDrugEntService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmDaDrugEntService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmScorePackageService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmScorePackageService;
|
|
|
|
+import com.qunzhixinxi.hnqz.common.core.constant.CommonConstants;
|
|
import com.qunzhixinxi.hnqz.common.core.util.R;
|
|
import com.qunzhixinxi.hnqz.common.core.util.R;
|
|
import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
|
|
import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmDaDrugEntDrugtable;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmDaDrugEntDrugtable;
|
|
@@ -50,293 +50,284 @@ import java.util.stream.Stream;
|
|
@RequestMapping("/wmdadrugentdrugtable")
|
|
@RequestMapping("/wmdadrugentdrugtable")
|
|
public class WmDaDrugEntDrugtableController {
|
|
public class WmDaDrugEntDrugtableController {
|
|
|
|
|
|
- private final WmDaDrugEntDrugtableService wmDaDrugEntDrugtableService;
|
|
|
|
- private final WmDaDrugEntService wmDaDrugEntService;
|
|
|
|
- private final WmScorePackageService wmScorePackageService;
|
|
|
|
- private final SysDictItemService sysDictItemService;
|
|
|
|
- private final SysCsmUserRelationService sysCsmUserRelationService;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 分页查询
|
|
|
|
- *
|
|
|
|
- * @param page 分页对象
|
|
|
|
- * @param wmDaDrugEntDrugtable 档案-药企药品
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @GetMapping("/page")
|
|
|
|
- @PreAuthorize("@pms.hasPermission('admin_wmdadrugentdrugtable_view')")
|
|
|
|
- public R<IPage<WmDaDrugEntDrugtable>> getWmDaDrugEntDrugtablePage(Page<WmDaDrugEntDrugtable> page, WmDaDrugEntDrugtable wmDaDrugEntDrugtable) {
|
|
|
|
- OrderItem orderItem = new OrderItem();
|
|
|
|
- orderItem.setColumn("create_time");
|
|
|
|
- orderItem.setAsc(false);
|
|
|
|
- page.addOrder(orderItem);
|
|
|
|
- QueryWrapper<WmDaDrugEntDrugtable> queryWrapper = Wrappers.query(wmDaDrugEntDrugtable);
|
|
|
|
- String drugname = wmDaDrugEntDrugtable.getDrugname();
|
|
|
|
- if (StringUtils.isNotEmpty(wmDaDrugEntDrugtable.getDrugname())) {
|
|
|
|
- wmDaDrugEntDrugtable.setDrugname(null);
|
|
|
|
- queryWrapper.like("drugname", drugname);
|
|
|
|
- } else {
|
|
|
|
- wmDaDrugEntDrugtable.setDrugname(null);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- String drugnameTy = wmDaDrugEntDrugtable.getDrugnameTy();
|
|
|
|
- if (StringUtils.isNotEmpty(wmDaDrugEntDrugtable.getDrugnameTy())) {
|
|
|
|
- wmDaDrugEntDrugtable.setDrugnameTy(null);
|
|
|
|
- queryWrapper.like("drugname_ty", drugnameTy);
|
|
|
|
- } else {
|
|
|
|
- wmDaDrugEntDrugtable.setDrugnameTy(null);
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isEmpty(wmDaDrugEntDrugtable.getDrugEntName())) {
|
|
|
|
- wmDaDrugEntDrugtable.setDrugEntName(null);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (SecurityUtils.getRoles().contains(19)) {
|
|
|
|
- // CSM只能查看自己维护的企业下的数据, 以及下属维护的企业下的数据
|
|
|
|
- Integer userId = SecurityUtils.getUser().getId();
|
|
|
|
- // 递归查询下属关联的userId
|
|
|
|
- Set<Integer> allUserIds = sysCsmUserRelationService.recurseCsmLowerUserId(Collections.singleton(userId), new AtomicInteger(10));
|
|
|
|
- queryWrapper.and(wrapper -> {
|
|
|
|
- wrapper.in("create_user", allUserIds)
|
|
|
|
- .or(wrapper2 -> wrapper2.isNull("create_user"));
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- queryWrapper.eq("del_flag", DelEnum.NOT_DEL.getVal());
|
|
|
|
- wmDaDrugEntDrugtableService.page(page, queryWrapper);
|
|
|
|
-
|
|
|
|
- if (CollUtil.isNotEmpty(page.getRecords())) {
|
|
|
|
- // 剂型字典
|
|
|
|
- List<SysDictItem> doseDictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
- .eq(SysDictItem::getType, "dose")
|
|
|
|
- .eq(SysDictItem::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
|
- Map<String, String> doseMap = doseDictItems.stream().collect(Collectors.toMap(SysDictItem::getValue, SysDictItem::getLabel));
|
|
|
|
- // 剂型字典
|
|
|
|
- List<SysDictItem> guigeDictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
- .eq(SysDictItem::getType, "guige")
|
|
|
|
- .eq(SysDictItem::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
|
- Map<String, String> guigeMap = guigeDictItems.stream().collect(Collectors.toMap(SysDictItem::getValue, SysDictItem::getLabel));
|
|
|
|
-
|
|
|
|
- page.getRecords().forEach(record -> {
|
|
|
|
- if (StrUtil.isNotBlank(record.getDoseId()) && StrUtil.isBlank(record.getDoseName())) {
|
|
|
|
- record.setDoseName(doseMap.getOrDefault(record.getDoseId(), record.getDoseId()));
|
|
|
|
- }
|
|
|
|
- if (StrUtil.isNotBlank(record.getGuigeId()) && StrUtil.isBlank(record.getGuigeName())) {
|
|
|
|
- record.setGuigeName(guigeMap.getOrDefault(record.getGuigeId(), record.getGuigeId()));
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok(page);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 通过id查询档案-药企药品
|
|
|
|
- *
|
|
|
|
- * @param id id
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @GetMapping("/{id}")
|
|
|
|
- @PreAuthorize("@pms.hasPermission('admin_wmdadrugentdrugtable_view')")
|
|
|
|
- public R getById(@PathVariable("id") Integer id) {
|
|
|
|
- WmDaDrugEntDrugtable drugEntDrugtable = wmDaDrugEntDrugtableService.getById(id);
|
|
|
|
-
|
|
|
|
- if (drugEntDrugtable != null) {
|
|
|
|
- // 剂型字典
|
|
|
|
- List<SysDictItem> doseDictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
- .eq(SysDictItem::getType, "dose")
|
|
|
|
- .eq(SysDictItem::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
|
- Map<String, String> doseMap = doseDictItems.stream().collect(Collectors.toMap(SysDictItem::getValue, SysDictItem::getLabel));
|
|
|
|
- // 剂型字典
|
|
|
|
- List<SysDictItem> guigeDictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
- .eq(SysDictItem::getType, "guige")
|
|
|
|
- .eq(SysDictItem::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
|
- Map<String, String> guigeMap = guigeDictItems.stream().collect(Collectors.toMap(SysDictItem::getValue, SysDictItem::getLabel));
|
|
|
|
-
|
|
|
|
- if (StrUtil.isNotBlank(drugEntDrugtable.getDoseId()) && StrUtil.isBlank(drugEntDrugtable.getDoseName())) {
|
|
|
|
- drugEntDrugtable.setDoseName(doseMap.getOrDefault(drugEntDrugtable.getDoseId(), drugEntDrugtable.getDoseId()));
|
|
|
|
- }
|
|
|
|
- if (StrUtil.isNotBlank(drugEntDrugtable.getGuigeId()) && StrUtil.isBlank(drugEntDrugtable.getGuigeName())) {
|
|
|
|
- drugEntDrugtable.setGuigeName(guigeMap.getOrDefault(drugEntDrugtable.getGuigeId(), drugEntDrugtable.getGuigeId()));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok(drugEntDrugtable);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 新增档案-药企药品
|
|
|
|
- *
|
|
|
|
- * @param wmDaDrugEntDrugtable 档案-药企药品
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @SysLog("新增档案-药企药品")
|
|
|
|
- @PostMapping
|
|
|
|
- @PreAuthorize("@pms.hasPermission('admin_wmdadrugentdrugtable_add')")
|
|
|
|
- public R save(@RequestBody WmDaDrugEntDrugtable wmDaDrugEntDrugtable) {
|
|
|
|
-
|
|
|
|
- WmDaDrugEntDrugtable query = new WmDaDrugEntDrugtable();
|
|
|
|
- query.setDrugname(wmDaDrugEntDrugtable.getDrugname());
|
|
|
|
- List<WmDaDrugEntDrugtable> list = wmDaDrugEntDrugtableService.list(Wrappers.query(query));
|
|
|
|
- if (list.size() > 0) {
|
|
|
|
- return R.failed("药品名称已存在");
|
|
|
|
- }
|
|
|
|
- WmDaDrugEnt drugEnt = new WmDaDrugEnt();
|
|
|
|
- List<WmDaDrugEnt> daDrugEnts = wmDaDrugEntService.list(Wrappers.query(drugEnt));
|
|
|
|
- if (CollectionUtils.isNotEmpty(daDrugEnts)) {
|
|
|
|
- wmDaDrugEntDrugtable.setDrugEntId(daDrugEnts.get(0).getId().toString());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- wmDaDrugEntDrugtable.setCreateTime(LocalDateTime.now());
|
|
|
|
- wmDaDrugEntDrugtable.setCreateUser(SecurityUtils.getUser().getId());
|
|
|
|
- return R.ok(wmDaDrugEntDrugtableService.save(wmDaDrugEntDrugtable));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 修改档案-药企药品
|
|
|
|
- *
|
|
|
|
- * @param wmDaDrugEntDrugtable 档案-药企药品
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @SysLog("修改档案-药企药品")
|
|
|
|
- @PutMapping
|
|
|
|
- @PreAuthorize("@pms.hasPermission('admin_wmdadrugentdrugtable_edit')")
|
|
|
|
- public R updateById(@RequestBody WmDaDrugEntDrugtable wmDaDrugEntDrugtable) {
|
|
|
|
-
|
|
|
|
- WmDaDrugEntDrugtable oldData = wmDaDrugEntDrugtableService.getById(wmDaDrugEntDrugtable.getId());
|
|
|
|
- if (!oldData.getDrugEntName().equals(wmDaDrugEntDrugtable.getDrugEntName())) {
|
|
|
|
- WmDaDrugEnt drugEnt = new WmDaDrugEnt();
|
|
|
|
- List<WmDaDrugEnt> daDrugEnts = wmDaDrugEntService.list(Wrappers.query(drugEnt));
|
|
|
|
- if (CollectionUtils.isNotEmpty(daDrugEnts)) {
|
|
|
|
- wmDaDrugEntDrugtable.setDrugEntId(daDrugEnts.get(0).getId().toString());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-// if(!oldData.getDrugname().equals(wmDaDrugEntDrugtable.getDrugname())){
|
|
|
|
-// WmDaDrugEntDrugtable query = new WmDaDrugEntDrugtable();
|
|
|
|
-// query.setDrugname(wmDaDrugEntDrugtable.getDrugname());
|
|
|
|
-// List<WmDaDrugEntDrugtable> list = wmDaDrugEntDrugtableService.list(Wrappers.query(query));
|
|
|
|
-// if (list.size() > 0) {
|
|
|
|
-// return R.failed("药品名称已存在");
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
- wmDaDrugEntDrugtable.setUpdateTime(LocalDateTime.now());
|
|
|
|
- wmDaDrugEntDrugtable.setUpdateUser(SecurityUtils.getUser().getId());
|
|
|
|
-
|
|
|
|
- return R.ok(wmDaDrugEntDrugtableService.updateById(wmDaDrugEntDrugtable));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 通过id删除档案-药企药品
|
|
|
|
- *
|
|
|
|
- * @param id id
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @SysLog("通过id删除档案-药企药品")
|
|
|
|
- @DeleteMapping("/{id}")
|
|
|
|
- @PreAuthorize("@pms.hasPermission('admin_wmdadrugentdrugtable_del')")
|
|
|
|
- public R removeById(@PathVariable Integer id) {
|
|
|
|
- return R.ok(wmDaDrugEntDrugtableService.removeById(id));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @GetMapping("/list")
|
|
|
|
- public R listWmDaDrugEntDrugtable() {
|
|
|
|
- WmDaDrugEntDrugtable wmDaDrugEnt = new WmDaDrugEntDrugtable();
|
|
|
|
- wmDaDrugEnt.setDelFlag("0");
|
|
|
|
- wmDaDrugEnt.setEnableFlag("0");
|
|
|
|
-
|
|
|
|
- List<WmDaDrugEntDrugtable> list = wmDaDrugEntDrugtableService.list(Wrappers.query(wmDaDrugEnt));
|
|
|
|
-
|
|
|
|
- if (CollUtil.isNotEmpty(list)) {
|
|
|
|
- // 剂型字典
|
|
|
|
- List<SysDictItem> doseDictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
- .eq(SysDictItem::getType, "dose")
|
|
|
|
- .eq(SysDictItem::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
|
- Map<String, String> doseMap = doseDictItems.stream().collect(Collectors.toMap(SysDictItem::getValue, SysDictItem::getLabel));
|
|
|
|
- // 剂型字典
|
|
|
|
- List<SysDictItem> guigeDictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
- .eq(SysDictItem::getType, "guige")
|
|
|
|
- .eq(SysDictItem::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
|
- Map<String, String> guigeMap = guigeDictItems.stream().collect(Collectors.toMap(SysDictItem::getValue, SysDictItem::getLabel));
|
|
|
|
-
|
|
|
|
- list.forEach(drugEntDrugtable -> {
|
|
|
|
- if (StrUtil.isNotBlank(drugEntDrugtable.getDoseId()) && StrUtil.isBlank(drugEntDrugtable.getDoseName())) {
|
|
|
|
- drugEntDrugtable.setDoseName(doseMap.getOrDefault(drugEntDrugtable.getDoseId(), drugEntDrugtable.getDoseId()));
|
|
|
|
- }
|
|
|
|
- if (StrUtil.isNotBlank(drugEntDrugtable.getGuigeId()) && StrUtil.isBlank(drugEntDrugtable.getGuigeName())) {
|
|
|
|
- drugEntDrugtable.setGuigeName(guigeMap.getOrDefault(drugEntDrugtable.getGuigeId(), drugEntDrugtable.getGuigeId()));
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok(list);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @SysLog("药企药品-分配")
|
|
|
|
- @PostMapping("/distribute")
|
|
|
|
- public R distribute(@RequestBody WmDaDrugEntDrugtable wmDaDrugEntDrugtable) {
|
|
|
|
- return wmDaDrugEntDrugtableService.distribute(wmDaDrugEntDrugtable);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @SysLog("获取药品关联部门列表")
|
|
|
|
- @GetMapping("/listReDept")
|
|
|
|
- public R listReDept(WmDaDrugEntDrugtable wmDaDrugEntDrugtable) {
|
|
|
|
- return wmDaDrugEntDrugtableService.listReDept(wmDaDrugEntDrugtable);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取药品生产企业名称列表(已废弃,改为接口/list-drug-table直接获取药品, 兼容历史数据需要用到)
|
|
|
|
- *
|
|
|
|
- * @param deptId 部门id
|
|
|
|
- * @return 名称列表
|
|
|
|
- */
|
|
|
|
- @GetMapping(value = "/list-drug-producer")
|
|
|
|
- public R listDrugProducerByDeptId(@RequestParam(value = "deptId", required = false) Integer deptId) {
|
|
|
|
- return R.ok(wmDaDrugEntDrugtableService.listDrugProducerByDeptId(deptId));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取药品列表
|
|
|
|
- *
|
|
|
|
- * @param drugEntName 部门id
|
|
|
|
- * @param packageId 积分包id
|
|
|
|
- * @return 名称列表
|
|
|
|
- */
|
|
|
|
- @GetMapping(value = "/list-drug-table")
|
|
|
|
- public R listDrugByDrugEntName(@RequestParam(value = "drugEntName", required = false) String drugEntName,
|
|
|
|
- @RequestParam(value = "packageId") String packageId) {
|
|
|
|
-
|
|
|
|
- WmScorePackage scorePackage = wmScorePackageService.getById(packageId);
|
|
|
|
-
|
|
|
|
- // 兼容历史数据(通过推广药品企业查询药品)
|
|
|
|
- if (ArrayUtil.isNotEmpty(scorePackage.getDrugProducerList())) {
|
|
|
|
- return R.ok(wmDaDrugEntDrugtableService.list(Wrappers.<WmDaDrugEntDrugtable>lambdaQuery()
|
|
|
|
- .in(WmDaDrugEntDrugtable::getDrugEntName, Stream.of(scorePackage.getDrugProducerList()).collect(Collectors.toList())))
|
|
|
|
- .stream().map(WmDaDrugEntDrugtable::getDrugname).collect(Collectors.toList()));
|
|
|
|
- } else if (ArrayUtil.isNotEmpty(scorePackage.getDrugtable())) {
|
|
|
|
- // 查询积分包的推广药品id
|
|
|
|
- List<WmDaDrugEntDrugtable> drugEntDrugtables =
|
|
|
|
- wmDaDrugEntDrugtableService.listByIds(Arrays.stream(scorePackage.getDrugtable()).collect(Collectors.toSet()));
|
|
|
|
- return R.ok(drugEntDrugtables.stream().map(WmDaDrugEntDrugtable::getDrugname).collect(Collectors.toList()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok(Collections.emptyList());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取分配给当前企业的药品列表
|
|
|
|
- *
|
|
|
|
- * @return {@link R}<{@link ?}> 药品列表
|
|
|
|
- */
|
|
|
|
- @GetMapping("/list-drug")
|
|
|
|
- public R<?> listDrugByDeptId() {
|
|
|
|
- Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
- return R.ok(wmDaDrugEntDrugtableService.listDrugByDeptId(Collections.singleton(deptId)));
|
|
|
|
- }
|
|
|
|
|
|
+ private final WmDaDrugEntDrugtableService wmDaDrugEntDrugtableService;
|
|
|
|
+ private final WmDaDrugEntService wmDaDrugEntService;
|
|
|
|
+ private final WmScorePackageService wmScorePackageService;
|
|
|
|
+ private final SysDictItemService sysDictItemService;
|
|
|
|
+ private final SysCsmUserRelationService sysCsmUserRelationService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页查询
|
|
|
|
+ *
|
|
|
|
+ * @param page 分页对象
|
|
|
|
+ * @param wmDaDrugEntDrugtable 档案-药企药品
|
|
|
|
+ * @return 分页
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/page")
|
|
|
|
+ @PreAuthorize("@pms.hasPermission('admin_wmdadrugentdrugtable_view')")
|
|
|
|
+ public R<IPage<WmDaDrugEntDrugtable>> getWmDaDrugEntDrugtablePage(Page<WmDaDrugEntDrugtable> page, WmDaDrugEntDrugtable wmDaDrugEntDrugtable) {
|
|
|
|
+ OrderItem orderItem = new OrderItem();
|
|
|
|
+ orderItem.setColumn("create_time");
|
|
|
|
+ orderItem.setAsc(false);
|
|
|
|
+ page.addOrder(orderItem);
|
|
|
|
+ QueryWrapper<WmDaDrugEntDrugtable> queryWrapper = Wrappers.query(wmDaDrugEntDrugtable);
|
|
|
|
+ String drugname = wmDaDrugEntDrugtable.getDrugname();
|
|
|
|
+ if (StringUtils.isNotEmpty(wmDaDrugEntDrugtable.getDrugname())) {
|
|
|
|
+ wmDaDrugEntDrugtable.setDrugname(null);
|
|
|
|
+ queryWrapper.like("drugname", drugname);
|
|
|
|
+ } else {
|
|
|
|
+ wmDaDrugEntDrugtable.setDrugname(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String drugnameTy = wmDaDrugEntDrugtable.getDrugnameTy();
|
|
|
|
+ if (StringUtils.isNotEmpty(wmDaDrugEntDrugtable.getDrugnameTy())) {
|
|
|
|
+ wmDaDrugEntDrugtable.setDrugnameTy(null);
|
|
|
|
+ queryWrapper.like("drugname_ty", drugnameTy);
|
|
|
|
+ } else {
|
|
|
|
+ wmDaDrugEntDrugtable.setDrugnameTy(null);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(wmDaDrugEntDrugtable.getDrugEntName())) {
|
|
|
|
+ wmDaDrugEntDrugtable.setDrugEntName(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (SecurityUtils.getRoles().contains(19)) {
|
|
|
|
+ // CSM只能查看自己维护的企业下的数据, 以及下属维护的企业下的数据
|
|
|
|
+ Integer userId = SecurityUtils.getUser().getId();
|
|
|
|
+ // 递归查询下属关联的userId
|
|
|
|
+ Set<Integer> allUserIds = sysCsmUserRelationService.recurseCsmLowerUserId(Collections.singleton(userId), new AtomicInteger(10));
|
|
|
|
+ queryWrapper.and(wrapper -> {
|
|
|
|
+ wrapper.in("create_user", allUserIds)
|
|
|
|
+ .or(wrapper2 -> wrapper2.isNull("create_user"));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ queryWrapper.eq("del_flag", DelEnum.NOT_DEL.getVal());
|
|
|
|
+ wmDaDrugEntDrugtableService.page(page, queryWrapper);
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(page.getRecords())) {
|
|
|
|
+ // 剂型字典
|
|
|
|
+ List<SysDictItem> doseDictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
+ .eq(SysDictItem::getType, "dose")
|
|
|
|
+ .eq(SysDictItem::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
|
+ Map<String, String> doseMap = doseDictItems.stream().collect(Collectors.toMap(SysDictItem::getValue, SysDictItem::getLabel));
|
|
|
|
+ // 剂型字典
|
|
|
|
+ List<SysDictItem> guigeDictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
+ .eq(SysDictItem::getType, "guige")
|
|
|
|
+ .eq(SysDictItem::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
|
+ Map<String, String> guigeMap = guigeDictItems.stream().collect(Collectors.toMap(SysDictItem::getValue, SysDictItem::getLabel));
|
|
|
|
+
|
|
|
|
+ page.getRecords().forEach(record -> {
|
|
|
|
+ if (CharSequenceUtil.isNotBlank(record.getDoseId()) && CharSequenceUtil.isBlank(record.getDoseName())) {
|
|
|
|
+ record.setDoseName(doseMap.getOrDefault(record.getDoseId(), record.getDoseId()));
|
|
|
|
+ }
|
|
|
|
+ if (CharSequenceUtil.isNotBlank(record.getGuigeId()) && CharSequenceUtil.isBlank(record.getGuigeName())) {
|
|
|
|
+ record.setGuigeName(guigeMap.getOrDefault(record.getGuigeId(), record.getGuigeId()));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.ok(page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 通过id查询档案-药企药品
|
|
|
|
+ *
|
|
|
|
+ * @param id id
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/{id}")
|
|
|
|
+ @PreAuthorize("@pms.hasPermission('admin_wmdadrugentdrugtable_view')")
|
|
|
|
+ public R<WmDaDrugEntDrugtable> getById(@PathVariable("id") Integer id) {
|
|
|
|
+ WmDaDrugEntDrugtable drugEntDrugtable = wmDaDrugEntDrugtableService.getById(id);
|
|
|
|
+
|
|
|
|
+ if (drugEntDrugtable != null) {
|
|
|
|
+ // 剂型字典
|
|
|
|
+ List<SysDictItem> doseDictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
+ .eq(SysDictItem::getType, "dose")
|
|
|
|
+ .eq(SysDictItem::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
|
+ Map<String, String> doseMap = doseDictItems.stream().collect(Collectors.toMap(SysDictItem::getValue, SysDictItem::getLabel));
|
|
|
|
+ // 剂型字典
|
|
|
|
+ List<SysDictItem> guigeDictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
+ .eq(SysDictItem::getType, "guige")
|
|
|
|
+ .eq(SysDictItem::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
|
+ Map<String, String> guigeMap = guigeDictItems.stream().collect(Collectors.toMap(SysDictItem::getValue, SysDictItem::getLabel));
|
|
|
|
+
|
|
|
|
+ if (CharSequenceUtil.isNotBlank(drugEntDrugtable.getDoseId()) && CharSequenceUtil.isBlank(drugEntDrugtable.getDoseName())) {
|
|
|
|
+ drugEntDrugtable.setDoseName(doseMap.getOrDefault(drugEntDrugtable.getDoseId(), drugEntDrugtable.getDoseId()));
|
|
|
|
+ }
|
|
|
|
+ if (CharSequenceUtil.isNotBlank(drugEntDrugtable.getGuigeId()) && CharSequenceUtil.isBlank(drugEntDrugtable.getGuigeName())) {
|
|
|
|
+ drugEntDrugtable.setGuigeName(guigeMap.getOrDefault(drugEntDrugtable.getGuigeId(), drugEntDrugtable.getGuigeId()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.ok(drugEntDrugtable);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增档案-药企药品
|
|
|
|
+ *
|
|
|
|
+ * @param wmDaDrugEntDrugtable 档案-药企药品
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @SysLog("新增档案-药企药品")
|
|
|
|
+ @PostMapping
|
|
|
|
+ @PreAuthorize("@pms.hasPermission('admin_wmdadrugentdrugtable_add')")
|
|
|
|
+ public R<Boolean> save(@RequestBody WmDaDrugEntDrugtable wmDaDrugEntDrugtable) {
|
|
|
|
+
|
|
|
|
+ WmDaDrugEntDrugtable query = new WmDaDrugEntDrugtable();
|
|
|
|
+ query.setDrugname(wmDaDrugEntDrugtable.getDrugname());
|
|
|
|
+ int count = wmDaDrugEntDrugtableService.count(Wrappers.query(query));
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ return R.failed("药品名称已存在");
|
|
|
|
+ }
|
|
|
|
+ WmDaDrugEnt drugEnt = new WmDaDrugEnt();
|
|
|
|
+ List<WmDaDrugEnt> daDrugEnts = wmDaDrugEntService.list(Wrappers.query(drugEnt));
|
|
|
|
+ if (CollectionUtils.isNotEmpty(daDrugEnts)) {
|
|
|
|
+ wmDaDrugEntDrugtable.setDrugEntId(daDrugEnts.get(0).getId().toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ wmDaDrugEntDrugtable.setCreateTime(LocalDateTime.now());
|
|
|
|
+ wmDaDrugEntDrugtable.setCreateUser(SecurityUtils.getUser().getId());
|
|
|
|
+ return R.ok(wmDaDrugEntDrugtableService.save(wmDaDrugEntDrugtable));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改档案-药企药品
|
|
|
|
+ *
|
|
|
|
+ * @param wmDaDrugEntDrugtable 档案-药企药品
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @SysLog("修改档案-药企药品")
|
|
|
|
+ @PutMapping
|
|
|
|
+ @PreAuthorize("@pms.hasPermission('admin_wmdadrugentdrugtable_edit')")
|
|
|
|
+ public R<Boolean> updateById(@RequestBody WmDaDrugEntDrugtable wmDaDrugEntDrugtable) {
|
|
|
|
+
|
|
|
|
+ WmDaDrugEntDrugtable oldData = wmDaDrugEntDrugtableService.getById(wmDaDrugEntDrugtable.getId());
|
|
|
|
+ if (!oldData.getDrugEntName().equals(wmDaDrugEntDrugtable.getDrugEntName())) {
|
|
|
|
+ WmDaDrugEnt drugEnt = new WmDaDrugEnt();
|
|
|
|
+ List<WmDaDrugEnt> daDrugEnts = wmDaDrugEntService.list(Wrappers.query(drugEnt));
|
|
|
|
+ if (CollectionUtils.isNotEmpty(daDrugEnts)) {
|
|
|
|
+ wmDaDrugEntDrugtable.setDrugEntId(daDrugEnts.get(0).getId().toString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wmDaDrugEntDrugtable.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ wmDaDrugEntDrugtable.setUpdateUser(SecurityUtils.getUser().getId());
|
|
|
|
+
|
|
|
|
+ return R.ok(wmDaDrugEntDrugtableService.updateById(wmDaDrugEntDrugtable));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 通过id删除档案-药企药品
|
|
|
|
+ *
|
|
|
|
+ * @param id id
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @SysLog("通过id删除档案-药企药品")
|
|
|
|
+ @DeleteMapping("/{id}")
|
|
|
|
+ @PreAuthorize("@pms.hasPermission('admin_wmdadrugentdrugtable_del')")
|
|
|
|
+ public R<Boolean> removeById(@PathVariable Integer id) {
|
|
|
|
+ return R.ok(wmDaDrugEntDrugtableService.removeById(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping("/list")
|
|
|
|
+ public R<List<WmDaDrugEntDrugtable>> listWmDaDrugEntDrugtable() {
|
|
|
|
+ WmDaDrugEntDrugtable wmDaDrugEnt = new WmDaDrugEntDrugtable();
|
|
|
|
+ wmDaDrugEnt.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
|
+ wmDaDrugEnt.setEnableFlag(CommonConstants.STATUS_NORMAL);
|
|
|
|
+
|
|
|
|
+ List<WmDaDrugEntDrugtable> list = wmDaDrugEntDrugtableService.list(Wrappers.query(wmDaDrugEnt));
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(list)) {
|
|
|
|
+ // 剂型字典
|
|
|
|
+ List<SysDictItem> doseDictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
+ .eq(SysDictItem::getType, "dose")
|
|
|
|
+ .eq(SysDictItem::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
|
+ Map<String, String> doseMap = doseDictItems.stream().collect(Collectors.toMap(SysDictItem::getValue, SysDictItem::getLabel));
|
|
|
|
+ // 剂型字典
|
|
|
|
+ List<SysDictItem> guigeDictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
+ .eq(SysDictItem::getType, "guige")
|
|
|
|
+ .eq(SysDictItem::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
|
+ Map<String, String> guigeMap = guigeDictItems.stream().collect(Collectors.toMap(SysDictItem::getValue, SysDictItem::getLabel));
|
|
|
|
+
|
|
|
|
+ list.forEach(drugEntDrugtable -> {
|
|
|
|
+ if (CharSequenceUtil.isNotBlank(drugEntDrugtable.getDoseId()) && CharSequenceUtil.isBlank(drugEntDrugtable.getDoseName())) {
|
|
|
|
+ drugEntDrugtable.setDoseName(doseMap.getOrDefault(drugEntDrugtable.getDoseId(), drugEntDrugtable.getDoseId()));
|
|
|
|
+ }
|
|
|
|
+ if (CharSequenceUtil.isNotBlank(drugEntDrugtable.getGuigeId()) && CharSequenceUtil.isBlank(drugEntDrugtable.getGuigeName())) {
|
|
|
|
+ drugEntDrugtable.setGuigeName(guigeMap.getOrDefault(drugEntDrugtable.getGuigeId(), drugEntDrugtable.getGuigeId()));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.ok(list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @SysLog("药企药品-分配")
|
|
|
|
+ @PostMapping("/distribute")
|
|
|
|
+ public R<Boolean> distribute(@RequestBody WmDaDrugEntDrugtable wmDaDrugEntDrugtable) {
|
|
|
|
+ return wmDaDrugEntDrugtableService.distribute(wmDaDrugEntDrugtable);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @SysLog("获取药品关联部门列表")
|
|
|
|
+ @GetMapping("/listReDept")
|
|
|
|
+ public R<List<String>> listReDept(WmDaDrugEntDrugtable wmDaDrugEntDrugtable) {
|
|
|
|
+ return wmDaDrugEntDrugtableService.listReDept(wmDaDrugEntDrugtable);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取药品生产企业名称列表(已废弃,改为接口/list-drug-table直接获取药品, 兼容历史数据需要用到)
|
|
|
|
+ *
|
|
|
|
+ * @param deptId 部门id
|
|
|
|
+ * @return 名称列表
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/list-drug-producer")
|
|
|
|
+ public R<Set<String>> listDrugProducerByDeptId(@RequestParam(value = "deptId", required = false) Integer deptId) {
|
|
|
|
+ return R.ok(wmDaDrugEntDrugtableService.listDrugProducerByDeptId(deptId));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取药品列表
|
|
|
|
+ *
|
|
|
|
+ * @param drugEntName 部门id
|
|
|
|
+ * @param packageId 积分包id
|
|
|
|
+ * @return 名称列表
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/list-drug-table")
|
|
|
|
+ public R<List<String>> listDrugByDrugEntName(@RequestParam(value = "drugEntName", required = false) String drugEntName,
|
|
|
|
+ @RequestParam(value = "packageId") String packageId) {
|
|
|
|
+
|
|
|
|
+ WmScorePackage scorePackage = wmScorePackageService.getById(packageId);
|
|
|
|
+
|
|
|
|
+ // 兼容历史数据(通过推广药品企业查询药品)
|
|
|
|
+ if (ArrayUtil.isNotEmpty(scorePackage.getDrugProducerList())) {
|
|
|
|
+ return R.ok(wmDaDrugEntDrugtableService.list(Wrappers.<WmDaDrugEntDrugtable>lambdaQuery()
|
|
|
|
+ .in(WmDaDrugEntDrugtable::getDrugEntName, Stream.of(scorePackage.getDrugProducerList()).collect(Collectors.toList())))
|
|
|
|
+ .stream().map(WmDaDrugEntDrugtable::getDrugname).collect(Collectors.toList()));
|
|
|
|
+ } else if (ArrayUtil.isNotEmpty(scorePackage.getDrugtable())) {
|
|
|
|
+ // 查询积分包的推广药品id
|
|
|
|
+ List<WmDaDrugEntDrugtable> drugEntDrugtables =
|
|
|
|
+ wmDaDrugEntDrugtableService.listByIds(Arrays.stream(scorePackage.getDrugtable()).collect(Collectors.toSet()));
|
|
|
|
+ return R.ok(drugEntDrugtables.stream().map(WmDaDrugEntDrugtable::getDrugname).collect(Collectors.toList()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.ok(Collections.emptyList());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取分配给当前企业的药品列表
|
|
|
|
+ *
|
|
|
|
+ * @return {@link R}<{@link ?}> 药品列表
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/list-drug")
|
|
|
|
+ public R<List<Map<String, String>>> listDrugByDeptId() {
|
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
+ return R.ok(wmDaDrugEntDrugtableService.listDrugByDeptId(Collections.singleton(deptId)));
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|