ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/WxLoginController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/dto/TErpGoodsAddDto.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/dto/TErpGoodsUpdateStatusDto.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpGoodsMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsQuery.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/service/TErpGoodsService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpGoodsVO.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java
@@ -1,8 +1,27 @@ package com.ruoyi.web.controller.api; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.dto.TErpGoodsAddDto; import com.ruoyi.system.dto.TErpGoodsUpdateStatus; import com.ruoyi.system.dto.TErpGoodsUpdateStatusDto; import com.ruoyi.system.model.TErpGoods; import com.ruoyi.system.query.TErpGoodsQuery; import com.ruoyi.system.query.TErpIssueReportingQuery; import com.ruoyi.system.service.TCrmClinicService; import com.ruoyi.system.service.TCrmSupplierService; import com.ruoyi.system.service.TErpGoodsService; import com.ruoyi.system.service.TErpIssueReportingService; import com.ruoyi.system.vo.TErpGoodsVO; import com.ruoyi.system.vo.TErpIssueReportingVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; /** * <p> @@ -14,7 +33,73 @@ */ @RestController @RequestMapping("/t-erp-goods") @Api(tags = "供应商商品管理") public class TErpGoodsController { private final TErpGoodsService erpGoodsService; private final TokenService tokenService; @Autowired public TErpGoodsController(TErpGoodsService erpGoodsService, TokenService tokenService) { this.erpGoodsService = erpGoodsService; this.tokenService = tokenService; } /** * 获取erp问题上报管理列表 */ @ApiOperation(value = "供应商获取商品分页列表") @PostMapping(value = "/pageList") public R<PageInfo<TErpGoodsVO>> pageList(@RequestBody TErpGoodsQuery query) { SysUser user = tokenService.getLoginUser().getUser(); return R.ok(erpGoodsService.pageList(query,user)); } @ApiOperation(value = "供应商添加商品") @PostMapping(value = "/add") public R<Boolean> add(@Validated @RequestBody TErpGoodsAddDto dto) { if (erpGoodsService.isExit(dto.getGoodsIdCode())) { return R.fail("erp商品已存在"); } TErpGoods goods = new TErpGoods(); goods.setSupplierId(user.getClinicId()); goods.setGoodsIdCode(dto.getGoodsIdCode()); goods.setQuasiNumber(dto.getQuasiNumber()); goods.setManufacturer(dto.getManufacturer()); goods.setFormulationSpec(dto.getFormulationSpec()); goods.setPackingSpec(dto.getPackingSpec()); goods.setGoodsName(dto.getGoodsName()); return R.ok(erpGoodsService.save(goods)); } @ApiOperation(value = "供应商删除商品") @DeleteMapping(value = "/delete/{id}") public R<Boolean> delete(@PathVariable String id) { return R.ok(erpGoodsService.removeById(id)); } /** * 启用 停用 */ @ApiOperation(value = "供应商启用 停用商品") @PostMapping(value = "/updateStatus") public R<Boolean> updateStatus(@RequestBody TErpGoodsUpdateStatusDto dto) { TErpGoods goods = erpGoodsService.getById(dto.getId()); if(dto.getState()==1 && goods.getTypeId()==null){ return R.fail("操作失败,请先完善商品信息"); } if(dto.getState()==1 && goods.getClinicPurchasePrice()==null){ return R.fail("操作失败,请设置供应商分佣比例后再启用"); } goods.setState(dto.getState()); boolean b = erpGoodsService.updateById(goods); return R.ok(b); } } ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/WxLoginController.java
@@ -27,7 +27,6 @@ import com.ruoyi.system.utils.wx.tools.WxUtils; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; ruoyi-system/src/main/java/com/ruoyi/system/dto/TErpGoodsAddDto.java
New file @@ -0,0 +1,38 @@ package com.ruoyi.system.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; @Data @ApiModel(value = "erp商品添加DTO") public class TErpGoodsAddDto { @ApiModelProperty(value = "商品名称") @NotBlank(message = "商品名称不能为空") private String goodsName; @ApiModelProperty(value = "商品标识码") @NotBlank(message = "商品标识码不能为空") private String goodsIdCode; @ApiModelProperty(value = "国药准字号") @NotBlank(message = "国药准字号不能为空") private String quasiNumber; @ApiModelProperty(value = "生产厂家") @NotBlank(message = "生产厂家不能为空") private String manufacturer; @ApiModelProperty(value = "制剂规格") @NotBlank(message = "制剂规格不能为空") private String formulationSpec; @ApiModelProperty(value = "包装规格") @NotBlank(message = "包装规格不能为空") private String packingSpec; } ruoyi-system/src/main/java/com/ruoyi/system/dto/TErpGoodsUpdateStatusDto.java
New file @@ -0,0 +1,19 @@ package com.ruoyi.system.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; @Data @ApiModel(value = "商品修改状态DTO") public class TErpGoodsUpdateStatusDto { @ApiModelProperty(value = "商品id") @NotBlank(message = "商品id不能为空") private String id; @ApiModelProperty(value = "1启用 2禁用") @NotNull(message = "状态不能为空") private Integer state; } ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpGoodsMapper.java
@@ -1,7 +1,14 @@ package com.ruoyi.system.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.system.model.TErpGoods; import com.ruoyi.system.query.TErpGoodsQuery; import com.ruoyi.system.vo.TErpGoodsVO; import org.apache.ibatis.annotations.Param; import java.util.List; /** * <p> @@ -13,4 +20,6 @@ */ public interface TErpGoodsMapper extends BaseMapper<TErpGoods> { List<TErpGoodsVO> pageList(@Param("query") TErpGoodsQuery query, @Param("pageInfo") PageInfo<TErpGoodsVO> pageInfo, @Param("user") SysUser user); } ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsQuery.java
New file @@ -0,0 +1,28 @@ package com.ruoyi.system.query; import com.ruoyi.common.core.domain.BasePage; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "erp商品信息查询参数query") public class TErpGoodsQuery extends BasePage { @ApiModelProperty(value = "商品名称") private String goodsName; @ApiModelProperty(value = "商品标识码") private String goodsIdCode; @ApiModelProperty(value = "商品类型id") private String typeId; @ApiModelProperty(value = "国药准字号") private String quasiNumber; @ApiModelProperty(value = "1启用 2禁用") private Integer state; } ruoyi-system/src/main/java/com/ruoyi/system/service/TErpGoodsService.java
@@ -1,7 +1,13 @@ package com.ruoyi.system.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.system.model.TErpGoods; import com.ruoyi.system.query.TErpGoodsQuery; import com.ruoyi.system.vo.TErpGoodsVO; import javax.validation.constraints.NotBlank; /** * <p> @@ -13,4 +19,14 @@ */ public interface TErpGoodsService extends IService<TErpGoods> { /** * 分页查询 * @param query * @return */ PageInfo<TErpGoodsVO> pageList(TErpGoodsQuery query, SysUser user); boolean isExit(String goodsIdCode); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java
@@ -1,10 +1,22 @@ package com.ruoyi.system.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.system.mapper.TErpGoodsMapper; import com.ruoyi.system.mapper.TErpGoodsTypeMapper; import com.ruoyi.system.model.TErpGoods; import com.ruoyi.system.model.TErpGoodsType; import com.ruoyi.system.model.TSysBanner; import com.ruoyi.system.query.TErpGoodsQuery; import com.ruoyi.system.service.TErpGoodsService; import com.ruoyi.system.vo.TErpGoodsVO; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; import java.util.stream.Collectors; /** * <p> @@ -17,4 +29,35 @@ @Service public class TErpGoodsServiceImpl extends ServiceImpl<TErpGoodsMapper, TErpGoods> implements TErpGoodsService { @Resource private TErpGoodsTypeMapper erpGoodsTypeMapper; @Override public PageInfo<TErpGoodsVO> pageList(TErpGoodsQuery query, SysUser user) { PageInfo<TErpGoodsVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); List<TErpGoodsVO> list = this.baseMapper.pageList(query,pageInfo,user); if(list.isEmpty()){ return pageInfo; } List<String> typeIds = list.stream().map(TErpGoods::getTypeId).collect(Collectors.toList()); if(!typeIds.isEmpty()){ List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds); for (TErpGoodsVO tErpGoodsVO : list) { typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName())); tErpGoodsVO.setTypeName(tErpGoodsVO.getTypeName()); } } pageInfo.setRecords(list); return pageInfo; } @Override public boolean isExit(String goodsIdCode) { Long size = this.baseMapper.selectCount(new LambdaQueryWrapper<>(TErpGoods.class).eq(TErpGoods::getGoodsIdCode, goodsIdCode)); if(size>0){ return true; } return false; } } ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpGoodsVO.java
New file @@ -0,0 +1,13 @@ package com.ruoyi.system.vo; import com.ruoyi.system.model.TErpGoods; import com.ruoyi.system.model.TErpIssueReporting; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "供应商erp商品VO") public class TErpGoodsVO extends TErpGoods { }