| | |
| | | package com.consum.base.controller; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | 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.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.core.utils.CommonUtil; |
| | | 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.base.service.BaseWarehouseServiceImpl; |
| | | import com.consum.base.service.BaseGoodsTemplateService; |
| | | import com.consum.base.service.BaseWarehouseService; |
| | | import com.consum.base.service.LWhGoodsService; |
| | | import com.consum.model.po.*; |
| | | import com.consum.model.po.BaseGoodsModels; |
| | | import com.consum.model.po.BaseGoodsTemplate; |
| | | import com.consum.model.po.BaseWarehouse; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.consum.model.po.SDictData; |
| | | import com.consum.model.vo.BaseGoodsTemplateVo; |
| | | 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 物品模板 |
| | |
| | | public class BaseGoodsTemplateController extends BaseController { |
| | | |
| | | @Autowired |
| | | private BaseGoodsTemplateServiceImpl baseGoodsTemplateService; |
| | | private BaseGoodsTemplateService baseGoodsTemplateService; |
| | | |
| | | @Autowired |
| | | private LWhGoodsService lWhGoodsService; |
| | | |
| | | @Autowired |
| | | private BaseWarehouseServiceImpl baseWarehouseService; |
| | | private BaseWarehouseService baseWarehouseService; |
| | | |
| | | /** |
| | | * @Description 新增物品模板 |
| | |
| | | * @Date 2023/10/24 |
| | | */ |
| | | @PostMapping("/add") |
| | | public ResponseValue add(@RequestBody BaseGoodsTemplateParam param) { |
| | | public ResponseValue add() { |
| | | BaseGoodsTemplateParam param = CommonUtil.getObjFromReqBody(BaseGoodsTemplateParam.class); |
| | | BaseGoodsTemplateParam param2 = new BaseGoodsTemplateParam(); |
| | | CommonUtil.copyProperties(param, param2); |
| | | param = param2; |
| | | |
| | | FinSysTenantUser sysInfo = this.getSysInfo(); |
| | | if (param.getCategoryId() == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | |
| | | if (StringUtils.isEmpty(param.getGoodsName())) { |
| | | return ResponseValue.error("物品名称为空"); |
| | | } |
| | | //判断同一分类下的物品名称是否重复 |
| | | BaseGoodsTemplate goodsTemplate = this.baseGoodsTemplateService.getByGoodsNameAndCategoryId(param.getGoodsName(), param.getCategoryId()); |
| | | // 判断同一分类下的物品名称是否重复 |
| | | BaseGoodsTemplate goodsTemplate = |
| | | this.baseGoodsTemplateService.getByGoodsNameAndCategoryId(param.getGoodsName(), param.getCategoryId()); |
| | | if (goodsTemplate != null) { |
| | | return ResponseValue.error("物品名称已存在"); |
| | | } |
| | |
| | | * @Date 2023/10/24 |
| | | */ |
| | | @GetMapping("/list") |
| | | public ResponseValue queryList(BaseGoodsTemplateParam param) { |
| | | public ResponseValue queryList() { |
| | | BaseGoodsTemplateParam param = CommonUtil.getObjFromReq(BaseGoodsTemplateParam.class); |
| | | BaseGoodsTemplateParam param2 = new BaseGoodsTemplateParam(); |
| | | CommonUtil.copyProperties(param, param2); |
| | | param = param2; |
| | | |
| | | FinSysTenantUser sysInfo = this.getSysInfo(); |
| | | if (sysInfo == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | |
| | | * @Date 2023/10/24 |
| | | */ |
| | | @PostMapping("/edit") |
| | | public ResponseValue edit(@RequestBody BaseGoodsTemplateParam param) { |
| | | public ResponseValue edit() { |
| | | BaseGoodsTemplateParam param = CommonUtil.getObjFromReqBody(BaseGoodsTemplateParam.class); |
| | | BaseGoodsTemplateParam param2 = new BaseGoodsTemplateParam(); |
| | | CommonUtil.copyProperties(param, param2); |
| | | param = param2; |
| | | |
| | | if (StringUtils.isEmpty(param.getGoodsName())) { |
| | | return ResponseValue.error("物品名称为空"); |
| | | } |
| | |
| | | * @author 卢庆阳 |
| | | * @date 2023/10/25 |
| | | */ |
| | | //TODO 物品的禁用或删除,不影响已经采购入过库的物品信息。 |
| | | // TODO 物品的禁用或删除,不影响已经采购入过库的物品信息。 |
| | | @PostMapping("/updStatus") |
| | | public ResponseValue updateStatus(@RequestBody BaseGoodsTemplate goodsTemplate) { |
| | | public ResponseValue updateStatus() { |
| | | BaseGoodsTemplate goodsTemplate = CommonUtil.getObjFromReqBody(BaseGoodsTemplate.class); |
| | | BaseGoodsTemplate param2 = new BaseGoodsTemplate(); |
| | | CommonUtil.copyProperties(goodsTemplate, param2); |
| | | goodsTemplate = param2; |
| | | |
| | | if (goodsTemplate == null || goodsTemplate.getId() == null || goodsTemplate.getStates() == null) { |
| | | return ResponseValue.error("参数错误"); |
| | | } |
| | |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/25 |
| | | */ |
| | | //TODO 物品的禁用或删除,不影响已经采购入过库的物品信息。 |
| | | // TODO 物品的禁用或删除,不影响已经采购入过库的物品信息。 |
| | | @DeleteMapping("/del") |
| | | public ResponseValue updateById(@RequestBody BaseGoodsTemplate goodsTemplate) { |
| | | public ResponseValue updateById() { |
| | | BaseGoodsTemplate goodsTemplate = CommonUtil.getObjFromReqBody(BaseGoodsTemplate.class); |
| | | BaseGoodsTemplate param2 = new BaseGoodsTemplate(); |
| | | CommonUtil.copyProperties(goodsTemplate, param2); |
| | | goodsTemplate = param2; |
| | | |
| | | if (goodsTemplate.getId() == null) { |
| | | return ResponseValue.error("物品id为空"); |
| | | } |
| | |
| | | |
| | | @GetMapping("/query/goodsTemplate") |
| | | public ResponseValue queryGoodsTemplateByCategoryId(Long agencyId, Long categoryId) { |
| | | List<BaseGoodsTemplate> list = this.baseGoodsTemplateService.queryGoodsTemplateByCategoryId(agencyId, categoryId,null,null); |
| | | // TODO 不限制机构 |
| | | List<BaseGoodsTemplate> list = |
| | | this.baseGoodsTemplateService.queryGoodsTemplateByCategoryId(null, 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") |
| | | }) |
| | | @ApiImplicitParam(name = "agencyId", value = "父级机构id", required = true, dataType = "java.lang.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) { |
| | | |
| | | // TODO 调拨查询仓库物品 |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("categoryId", categoryId); |
| | | |
| | | List<BaseWarehouse> baseWarehouseList = baseWarehouseService.getByAgencyId(agencyId, (short) 1, (short) 1); |
| | | 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"; |
| | | String sql = |
| | | "SELECT DISTINCT bgt.id,bgt.GOODS_NAME, CLASSIFICATION type 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 " |
| | | // TODO 临时解决 |
| | | /*+ "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()); |
| | |
| | | return ResponseValue.success("查询成功!", resultList); |
| | | } |
| | | |
| | | |
| | | } |
| | | |