| | |
| | | package com.consum.base.controller; |
| | | |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.core.utils.MapUtils; |
| | | import com.consum.base.core.utils.MapperUtil; |
| | | import com.consum.base.pojo.BaseGoodsTemplateParam; |
| | | import com.consum.base.pojo.response.GoodsTemplateVO; |
| | | import com.consum.base.service.BaseGoodsTemplateServiceImpl; |
| | | import com.consum.model.po.BaseGoodsTemplate; |
| | | import com.consum.base.service.BaseWarehouseServiceImpl; |
| | | import com.consum.base.service.LWhGoodsService; |
| | | import com.consum.model.po.*; |
| | | import com.consum.model.vo.BaseGoodsTemplateVo; |
| | | import com.iplatform.model.po.S_user_core; |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.infrastructure.utils.StringUtils; |
| | | import com.walker.web.ResponseValue; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description 物品模板 |
| | |
| | | @Autowired |
| | | private BaseGoodsTemplateServiceImpl baseGoodsTemplateService; |
| | | |
| | | @Autowired |
| | | private LWhGoodsService lWhGoodsService; |
| | | |
| | | @Autowired |
| | | private BaseWarehouseServiceImpl baseWarehouseService; |
| | | |
| | | /** |
| | | * @Description 新增物品模板 |
| | | * @Author 卢庆阳 |
| | |
| | | */ |
| | | @PostMapping("/add") |
| | | public ResponseValue add(@RequestBody BaseGoodsTemplateParam param) { |
| | | FinSysTenantUser sysInfo = this.getSysInfo(); |
| | | if (param.getCategoryId() == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | if (param.getCategoryId() == null) { |
| | | return ResponseValue.error("分类为空"); |
| | | } |
| | |
| | | return ResponseValue.error("物品名称已存在"); |
| | | } |
| | | |
| | | int result = this.baseGoodsTemplateService.add(param, this.getCurrentUser()); |
| | | if (result > 0) return ResponseValue.success(1); |
| | | int result = this.baseGoodsTemplateService.add(param, sysInfo); |
| | | if (result > 0) { |
| | | return ResponseValue.success(1); |
| | | } |
| | | return ResponseValue.error("新增失败!"); |
| | | } |
| | | |
| | |
| | | */ |
| | | @GetMapping("/list") |
| | | public ResponseValue queryList(BaseGoodsTemplateParam param) { |
| | | S_user_core currentUser = this.getCurrentUser(); |
| | | if (currentUser == null) { |
| | | FinSysTenantUser sysInfo = this.getSysInfo(); |
| | | if (sysInfo == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | param.setAgencyId(Long.valueOf(sysInfo.getTenantId())); |
| | | GenericPager<BaseGoodsTemplate> pager = this.baseGoodsTemplateService.queryList(param); |
| | | return ResponseValue.success(pager); |
| | | } |
| | | |
| | | /** |
| | | * 根据物品id查询物品详情 |
| | | * |
| | | * @author 卢庆阳 |
| | | * @date 2023/9/26 |
| | | */ |
| | |
| | | return ResponseValue.error("物品id为空"); |
| | | } |
| | | BaseGoodsTemplateVo vo = this.baseGoodsTemplateService.getById(id); |
| | | if (vo == null) return ResponseValue.error("查询失败!"); |
| | | if (vo == null) { |
| | | return ResponseValue.error("查询失败!"); |
| | | } |
| | | return ResponseValue.success("查询成功!", vo); |
| | | } |
| | | |
| | |
| | | if (StringUtils.isEmpty(param.getGoodsName())) { |
| | | return ResponseValue.error("物品名称为空"); |
| | | } |
| | | List<BaseGoodsModels> models = param.getModels(); |
| | | if (CollectionUtils.isEmpty(models)) { |
| | | return ResponseValue.error("物品型号为空"); |
| | | } |
| | | |
| | | int num = this.baseGoodsTemplateService.updateBaseGoodsTemplate(param); |
| | | return num > 0 ? ResponseValue.success(1) : ResponseValue.error("编辑失败!"); |
| | |
| | | |
| | | /** |
| | | * 修改状态 |
| | | * |
| | | * @author 卢庆阳 |
| | | * @date 2023/10/25 |
| | | */ |
| | |
| | | if (goodsTemplate.getId() == null) { |
| | | return ResponseValue.error("物品id为空"); |
| | | } |
| | | int num = this.baseGoodsTemplateService.updateById(goodsTemplate,this.getCurrentUser()); |
| | | int num = this.baseGoodsTemplateService.updateById(goodsTemplate, this.getCurrentUser()); |
| | | |
| | | return num > 0 ? ResponseValue.success(1) : ResponseValue.error("删除失败!"); |
| | | } |
| | | |
| | | /** |
| | | * @Description 查询仓库类型(数据字典) |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/30 |
| | | */ |
| | | @GetMapping("/select/classificationCode") |
| | | public ResponseValue queryClassificationCode() { |
| | | List<SDictData> list = this.baseGoodsTemplateService.queryClassificationCode(); |
| | | return ResponseValue.success(list); |
| | | } |
| | | |
| | | /** |
| | | * @Description 根据分类id查询物品模板 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/30 |
| | | */ |
| | | @GetMapping("/selectByCategoryId") |
| | | public ResponseValue queryByCategoryId(Long categoryId) { |
| | | List<BaseGoodsTemplate> list = this.baseGoodsTemplateService.queryByCategoryId(categoryId); |
| | | return ResponseValue.success(list); |
| | | } |
| | | |
| | | @GetMapping("/query/goodsTemplate") |
| | | public ResponseValue queryGoodsTemplateByCategoryId(Long agencyId, Long categoryId) { |
| | | List<BaseGoodsTemplate> list = this.baseGoodsTemplateService.queryGoodsTemplateByCategoryId(agencyId, categoryId,null,null); |
| | | if (list == null) { |
| | | return ResponseValue.error("查询失败!"); |
| | | } |
| | | return ResponseValue.success("查询成功!", list); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "查询机构下默认仓库下的分类模板信息", notes = "查询机构下默认仓库下的分类模板信息") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "agencyId", value = "父级机构id", required = true, dataType = "Long", paramType = "query"), |
| | | @ApiImplicitParam(name = "categoryId", value = "分类id", required = true, dataType = "Long", paramType = "query") |
| | | }) |
| | | @GetMapping("/query/warehouse/goods") |
| | | public ResponseValue queryWarehouseGoods(Long agencyId, Long categoryId) { |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("categoryId", categoryId); |
| | | |
| | | List<BaseWarehouse> baseWarehouseList = baseWarehouseService.getByAgencyId(agencyId, (short) 1, (short) 1); |
| | | if (CollectionUtils.isEmpty(baseWarehouseList)) { |
| | | return ResponseValue.error("机构无默认仓库!"); |
| | | |
| | | } |
| | | map.put("warehouseId", baseWarehouseList.get(0).getId()); |
| | | |
| | | String sql = "SELECT DISTINCT bgt.id,bgt.GOODS_NAME FROM l_wh_goods g LEFT JOIN base_goods_template bgt ON g.BASE_GOODS_TEMPLATE_ID = bgt.id " |
| | | + "WHERE WAREHOUSE_TYPE = 0 " |
| | | + "AND WAREHOUSE_ID = :warehouseId " |
| | | + "AND CATEGORY_ID = :categoryId " |
| | | // 1:集采,2:自退货 |
| | | + "AND BUY_TYPE =1"; |
| | | |
| | | List<GoodsTemplateVO> resultList = Lists.newArrayList(); |
| | | List<Map<String, Object>> goodsTemplateList = lWhGoodsService.select(sql, map, new MapperUtil()); |
| | | goodsTemplateList.forEach(item -> { |
| | | GoodsTemplateVO goodsTemplateVO = MapUtils.convertMapToObj(item, GoodsTemplateVO.class); |
| | | resultList.add(goodsTemplateVO); |
| | | }); |
| | | return ResponseValue.success("查询成功!", resultList); |
| | | } |
| | | |
| | | |
| | | } |
| | | |