diff --git a/java/local/src/main/java/cn/toesbieya/jxc/controller/sys/LocationController.java b/java/local/src/main/java/cn/toesbieya/jxc/controller/sys/LocationController.java index d4a46a4..972ccdb 100644 --- a/java/local/src/main/java/cn/toesbieya/jxc/controller/sys/LocationController.java +++ b/java/local/src/main/java/cn/toesbieya/jxc/controller/sys/LocationController.java @@ -15,6 +15,11 @@ public class LocationController { @Resource private SysLocationService service; + @GetMapping("get") + public R get() { + return R.success(service.get()); + } + @PostMapping("search") public R search(@RequestBody LocationSearch vo) { return R.success(service.search(vo)); diff --git a/java/local/src/main/java/cn/toesbieya/jxc/controller/sys/ReagentInfoController.java b/java/local/src/main/java/cn/toesbieya/jxc/controller/sys/ReagentInfoController.java new file mode 100644 index 0000000..974afc6 --- /dev/null +++ b/java/local/src/main/java/cn/toesbieya/jxc/controller/sys/ReagentInfoController.java @@ -0,0 +1,62 @@ +package cn.toesbieya.jxc.controller.sys; + +import cn.toesbieya.jxc.model.entity.ReagentInfo; +import cn.toesbieya.jxc.model.vo.R; +import cn.toesbieya.jxc.model.vo.UserVo; +import cn.toesbieya.jxc.model.vo.search.ReagentSearch; +import cn.toesbieya.jxc.service.sys.SysReagentInfoService; +import cn.toesbieya.jxc.util.SessionUtil; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RestController +@RequestMapping("system/reagent") +public class ReagentInfoController { + @Resource + private SysReagentInfoService service; + + @PostMapping("search") + public R search(@RequestBody ReagentSearch vo) { + return R.success(service.search(vo)); + } + + @PostMapping("add") + public R add(@RequestBody ReagentInfo reagent) { + String errMsg = validateCreateParam(reagent); + if (errMsg != null) return R.fail("添加失败," + errMsg); + UserVo user = SessionUtil.get(); + reagent.setId(null); + reagent.setCreateTime(System.currentTimeMillis()); + reagent.setCreatorId(user.getId()); + reagent.setCreator(user.getNickName()); + return service.add(reagent); + } + + @PostMapping("update") + public R update(@RequestBody ReagentInfo reagent) { + String errMsg = validateUpdateParam(reagent); + return errMsg == null ? service.update(reagent) : R.fail("修改失败," + errMsg); + } + + @PostMapping("del") + public R del(@RequestBody ReagentInfo reagent) { + if (reagent.getId() == null) return R.fail("删除失败,参数错误"); + return service.del(reagent); + } + + private String validateCreateParam(ReagentInfo reagent) { + if (StringUtils.isEmpty(reagent.getName())) return "货位名称不能为空"; + return null; + } + + private String validateUpdateParam(ReagentInfo reagent) { + if (reagent.getId() == null) return "参数错误"; + return validateCreateParam(reagent); + } +} + diff --git a/java/local/src/main/java/cn/toesbieya/jxc/controller/sys/SupplierController.java b/java/local/src/main/java/cn/toesbieya/jxc/controller/sys/SupplierController.java index edecc06..1b1f7d9 100644 --- a/java/local/src/main/java/cn/toesbieya/jxc/controller/sys/SupplierController.java +++ b/java/local/src/main/java/cn/toesbieya/jxc/controller/sys/SupplierController.java @@ -15,6 +15,11 @@ public class SupplierController { @Resource private SysSupplierService service; + @GetMapping("get") + public R get() { + return R.success(service.get()); + } + @GetMapping("getLimitRegion") public R getLimitRegion() { return R.success(service.getLimitRegion()); diff --git a/java/local/src/main/java/cn/toesbieya/jxc/model/entity/ReagentInfo.java b/java/local/src/main/java/cn/toesbieya/jxc/model/entity/ReagentInfo.java index 86490a2..d53628b 100644 --- a/java/local/src/main/java/cn/toesbieya/jxc/model/entity/ReagentInfo.java +++ b/java/local/src/main/java/cn/toesbieya/jxc/model/entity/ReagentInfo.java @@ -48,7 +48,12 @@ public class ReagentInfo implements Serializable { /** * 货位 */ - private String location; + private String locationName; + + /** + * 货位id + */ + private Integer locationId; /** * 仓库 @@ -68,13 +73,17 @@ public class ReagentInfo implements Serializable { /** * 状态,0停用,1启用 */ - private Boolean enable = false; + private boolean enable = false; /** * 创建人id */ private Integer creatorId; + /** + * 创建人姓名 + */ + private String creator; /** * 创建时间 */ @@ -99,7 +108,12 @@ public class ReagentInfo implements Serializable { * 试剂厂商 */ @Column - private String manufacture; + private String supplierName; + /** + * 试剂厂商id + */ + @Column + private Integer supplierId; /** * 试剂类型 */ diff --git a/java/local/src/main/java/cn/toesbieya/jxc/model/vo/ReagentVo.java b/java/local/src/main/java/cn/toesbieya/jxc/model/vo/ReagentVo.java new file mode 100644 index 0000000..6556d4f --- /dev/null +++ b/java/local/src/main/java/cn/toesbieya/jxc/model/vo/ReagentVo.java @@ -0,0 +1,20 @@ +package cn.toesbieya.jxc.model.vo; + +import cn.toesbieya.jxc.model.entity.ReagentInfo; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.ToString; +import org.springframework.beans.BeanUtils; + +@Data +@NoArgsConstructor +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class ReagentVo extends ReagentInfo { + + public ReagentVo(ReagentInfo parent) { + super(); + BeanUtils.copyProperties(parent, this); + } +} diff --git a/java/local/src/main/java/cn/toesbieya/jxc/model/vo/search/ReagentSearch.java b/java/local/src/main/java/cn/toesbieya/jxc/model/vo/search/ReagentSearch.java index 2e16956..1df583a 100644 --- a/java/local/src/main/java/cn/toesbieya/jxc/model/vo/search/ReagentSearch.java +++ b/java/local/src/main/java/cn/toesbieya/jxc/model/vo/search/ReagentSearch.java @@ -4,14 +4,23 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; + @Data @ToString(callSuper = true) @EqualsAndHashCode(callSuper = true) public class ReagentSearch extends BaseSearch{ + private Integer id; private String name; - private String manufacture; - private String type; + private String supplierName; private String risk; + private String batch; + + private String locationName; + private String storehouse; + private Boolean enable = false; + + private String creator; + } diff --git a/java/local/src/main/java/cn/toesbieya/jxc/service/ReagentService.java b/java/local/src/main/java/cn/toesbieya/jxc/service/ReagentService.java index 8f55535..31c2990 100644 --- a/java/local/src/main/java/cn/toesbieya/jxc/service/ReagentService.java +++ b/java/local/src/main/java/cn/toesbieya/jxc/service/ReagentService.java @@ -61,14 +61,12 @@ public class ReagentService { private Wrapper getSearchCondition(ReagentSearch vo) { String name = vo.getName(); - String manufacture = vo.getManufacture(); - String type = vo.getType(); + String supplierName = vo.getSupplierName(); String risk = vo.getRisk(); return Wrappers.lambdaQuery(ReagentInfo.class) .inSql(!StringUtils.isEmpty(name), ReagentInfo::getId, name) - .inSql(!StringUtils.isEmpty(manufacture), ReagentInfo::getManufacture, manufacture) - .inSql(!StringUtils.isEmpty(type), ReagentInfo::getType, type) + .inSql(!StringUtils.isEmpty(supplierName), ReagentInfo::getSupplierName, supplierName) .inSql(!StringUtils.isEmpty(risk), ReagentInfo::getRisk, risk); diff --git a/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysLocationService.java b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysLocationService.java index 499404d..96fd82d 100644 --- a/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysLocationService.java +++ b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysLocationService.java @@ -2,6 +2,7 @@ package cn.toesbieya.jxc.service.sys; import cn.toesbieya.jxc.annoation.UserAction; import cn.toesbieya.jxc.mapper.SysLocationMapper; import cn.toesbieya.jxc.model.entity.SysLocation; +import cn.toesbieya.jxc.model.entity.SysStorehouse; import cn.toesbieya.jxc.model.vo.LocationVo; import cn.toesbieya.jxc.model.vo.R; import cn.toesbieya.jxc.model.vo.result.PageResult; @@ -20,6 +21,13 @@ public class SysLocationService { @Resource private SysLocationMapper LocationMapper; + public List get() { + return LocationMapper.selectList( + Wrappers.lambdaQuery(SysLocation.class) + .eq(SysLocation::isEnable, true) + ); + } + public PageResult search(LocationSearch vo){ Integer id = vo.getId(); String name = vo.getName(); diff --git a/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysReagentInfoService.java b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysReagentInfoService.java new file mode 100644 index 0000000..642464d --- /dev/null +++ b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysReagentInfoService.java @@ -0,0 +1,112 @@ +package cn.toesbieya.jxc.service.sys; + +import cn.toesbieya.jxc.annoation.UserAction; +import cn.toesbieya.jxc.mapper.ReagentMapper; +import cn.toesbieya.jxc.model.entity.ReagentInfo; +import cn.toesbieya.jxc.model.vo.ReagentVo; +import cn.toesbieya.jxc.model.vo.search.ReagentSearch; +import cn.toesbieya.jxc.model.vo.R; +import cn.toesbieya.jxc.model.vo.result.PageResult; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.pagehelper.PageHelper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +@Service +public class SysReagentInfoService { + @Resource + private ReagentMapper ReagentMapper; + + public PageResult search(ReagentSearch vo){ + Integer id = vo.getId(); + String name = vo.getName(); + String supplier = vo.getSupplierName(); + String risk = vo.getRisk(); + String batch = vo.getBatch(); + String location = vo.getLocationName(); + String storehouse = vo.getStorehouse(); + String creator = vo.getCreator(); + Boolean enable = vo.getEnable(); + + Wrapper wrapper = + Wrappers.lambdaQuery(ReagentInfo.class) + .eq(id != null,ReagentInfo::getId,id) + .like(!StringUtils.isEmpty(name),ReagentInfo::getName,name) + .like(!StringUtils.isEmpty(supplier),ReagentInfo::getSupplierId,supplier) + .like(!StringUtils.isEmpty(risk),ReagentInfo::getRisk,risk) + .like(!StringUtils.isEmpty(batch),ReagentInfo::getBatch,batch) + .like(!StringUtils.isEmpty(location),ReagentInfo::getLocationId,location) + .like(!StringUtils.isEmpty(storehouse),ReagentInfo::getStorehouse,storehouse) + .like(!StringUtils.isEmpty(creator),ReagentInfo::getCreator,creator) + .eq(enable != null,ReagentInfo::isEnable,enable) + .orderByDesc(ReagentInfo::getCreateTime); + + PageHelper.startPage(vo.getPage(), vo.getPageSize()); + + List Reagents = ReagentMapper.selectList(wrapper); + + PageResult pageResult = new PageResult<>(Reagents); + + int ReagentNum = Reagents.size(); + + List list = new ArrayList<>(ReagentNum); + + Reagents.forEach(ReagentInfo -> { + list.add(new ReagentVo(ReagentInfo)); + }); + + return new PageResult<>(pageResult.getTotal(),list); + } + + @UserAction("'添加试剂:'+ #Reagent.name") + public R add(ReagentInfo Reagent){ + if (isNameExist(Reagent.getName(), null)) { + return R.fail(String.format("添加失败,试剂【%s】已存在", Reagent.getName())); + } + int rows = ReagentMapper.insert(Reagent); + return rows > 0 ? R.success("添加成功") : R.fail("添加失败"); + } + + @UserAction("'修改试剂' + #Reagent.name") + public R update(ReagentInfo Reagent){ + Integer id = Reagent.getId(); + String name = Reagent.getName(); + + if(isNameExist(name,id)) { + return R.fail(String.format("修改失败,试剂【%s】已存在", name)); + } + ReagentMapper.update( + null, + Wrappers.lambdaUpdate(ReagentInfo.class) + .set(ReagentInfo::getName, name) + .set(ReagentInfo::isEnable, Reagent.isEnable()) + .eq(ReagentInfo::getId, id) + ); + return R.success("修改成功"); + } + + @UserAction("'删除试剂:'+ #Reagent.name") + public R del(ReagentInfo Reagent) { + int rows = ReagentMapper.delete( + Wrappers.lambdaQuery(ReagentInfo.class) + .eq(ReagentInfo::getId, Reagent.getId()) + .eq(ReagentInfo::isEnable, false) + ); + return rows > 0 ? R.success("删除成功") : R.fail("删除失败,请刷新重试"); + } + + private boolean isNameExist(String name, Integer id) { + Integer num = ReagentMapper.selectCount( + Wrappers.lambdaQuery(ReagentInfo.class) + .eq(ReagentInfo::getName, name) + .ne(id != null, ReagentInfo::getId, id) + ); + + return num != null && num > 0; + } +} diff --git a/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysSupplierService.java b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysSupplierService.java index 9bf3bd5..bd5c59c 100644 --- a/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysSupplierService.java +++ b/java/local/src/main/java/cn/toesbieya/jxc/service/sys/SysSupplierService.java @@ -4,6 +4,7 @@ import cn.toesbieya.jxc.annoation.UserAction; import cn.toesbieya.jxc.mapper.SysRegionMapper; import cn.toesbieya.jxc.mapper.SysSupplierMapper; import cn.toesbieya.jxc.model.entity.SysRegion; +import cn.toesbieya.jxc.model.entity.SysStorehouse; import cn.toesbieya.jxc.model.entity.SysSupplier; import cn.toesbieya.jxc.model.vo.R; import cn.toesbieya.jxc.model.vo.SupplierVo; @@ -27,6 +28,14 @@ public class SysSupplierService { @Resource private SysRegionMapper regionMapper; + public List get() { + + return supplierMapper.selectList( + Wrappers.lambdaQuery(SysSupplier.class) + .eq(SysSupplier::isEnable, true) + ); + } + public List getLimitRegion() { return supplierMapper.getLimitRegion(); } diff --git a/vue/full/src/api/system/location.js b/vue/full/src/api/system/location.js index 0af224e..f63f66b 100644 --- a/vue/full/src/api/system/location.js +++ b/vue/full/src/api/system/location.js @@ -1,4 +1,4 @@ -import {PostApi} from "@/api/request" +import {GetApi, PostApi} from "@/api/request" export const search = new PostApi(`/system/location/search`) @@ -6,4 +6,6 @@ export const add = new PostApi(`/system/location/add`) export const update = new PostApi(`/system/location/update`) -export const del = new PostApi(`/system/location/del`) \ No newline at end of file +export const del = new PostApi(`/system/location/del`) + +export const get = new GetApi(`/system/location/get`) \ No newline at end of file diff --git a/vue/full/src/api/system/reagent.js b/vue/full/src/api/system/reagent.js new file mode 100644 index 0000000..16cf023 --- /dev/null +++ b/vue/full/src/api/system/reagent.js @@ -0,0 +1,9 @@ +import {PostApi} from "@/api/request" + +export const search = new PostApi(`/system/reagent/search`) + +export const add = new PostApi(`/system/reagent/add`) + +export const update = new PostApi(`/system/reagent/update`) + +export const del = new PostApi(`/system/reagent/del`) diff --git a/vue/full/src/api/system/supplier.js b/vue/full/src/api/system/supplier.js index fca8561..8b53b53 100644 --- a/vue/full/src/api/system/supplier.js +++ b/vue/full/src/api/system/supplier.js @@ -9,3 +9,5 @@ export const add = new PostApi(`/system/supplier/add`) export const update = new PostApi(`/system/supplier/update`) export const del = new PostApi(`/system/supplier/del`) + +export const get = new GetApi(`/system/supplier/get`) diff --git a/vue/full/src/view/admin/system/reagent/EditDialog.vue b/vue/full/src/view/admin/system/reagent/EditDialog.vue new file mode 100644 index 0000000..850f338 --- /dev/null +++ b/vue/full/src/view/admin/system/reagent/EditDialog.vue @@ -0,0 +1,207 @@ + + + + diff --git a/vue/full/src/view/admin/system/reagent/component/LocationSelector.vue b/vue/full/src/view/admin/system/reagent/component/LocationSelector.vue new file mode 100644 index 0000000..e38259e --- /dev/null +++ b/vue/full/src/view/admin/system/reagent/component/LocationSelector.vue @@ -0,0 +1,43 @@ + + + diff --git a/vue/full/src/view/admin/system/reagent/component/SupplierSelector.vue b/vue/full/src/view/admin/system/reagent/component/SupplierSelector.vue new file mode 100644 index 0000000..f21c6de --- /dev/null +++ b/vue/full/src/view/admin/system/reagent/component/SupplierSelector.vue @@ -0,0 +1,43 @@ + + + diff --git a/vue/full/src/view/admin/system/reagent/indexPage.vue b/vue/full/src/view/admin/system/reagent/indexPage.vue new file mode 100644 index 0000000..c1e566b --- /dev/null +++ b/vue/full/src/view/admin/system/reagent/indexPage.vue @@ -0,0 +1,219 @@ + + + diff --git a/vue/full/src/view/admin/system/supplier/indexPage.vue b/vue/full/src/view/admin/system/supplier/indexPage.vue index ce9f954..924c83d 100644 --- a/vue/full/src/view/admin/system/supplier/indexPage.vue +++ b/vue/full/src/view/admin/system/supplier/indexPage.vue @@ -41,7 +41,7 @@