| | |
| | | package com.consum.base.controller; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.consum.base.service.FinSysTenantService; |
| | | import com.consum.model.po.FinSysTenant; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.core.type.StatesType; |
| | | import com.consum.base.core.utils.CommonUtil; |
| | | import com.consum.base.pojo.BaseWarehouseParam; |
| | | import com.consum.base.pojo.query.WarehouseQry; |
| | |
| | | import com.consum.base.service.LWhGoodsService; |
| | | import com.consum.model.po.BaseWarehouse; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.consum.model.po.LWhGoods; |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | | import com.walker.infrastructure.utils.StringUtils; |
| | | import com.walker.web.ResponseValue; |
| | | |
| | |
| | | @Api(value = "仓库管理", tags = "仓库管理") |
| | | @RestController |
| | | @RequestMapping("/pc/base/warehouse") |
| | | @Slf4j |
| | | public class BaseWarehouseController extends BaseController { |
| | | |
| | | @Autowired |
| | | private BaseWarehouseService baseWarehouseService; |
| | | |
| | | @Autowired |
| | | private LWhGoodsService lWhGoodsService; |
| | | |
| | | @Autowired |
| | | private FinSysTenantService finSysTenantService; |
| | | |
| | | /** |
| | | * @Description 新增 |
| | |
| | | if (StringUtils.isEmpty(param.getWarehouseName())) { |
| | | return ResponseValue.error("仓库名称为空"); |
| | | } |
| | | // TODO 加权限 省级管理员录入所有仓库信息 |
| | | Long agencyId = param.getAgencyId(); |
| | | BaseWarehouse baseWarehouse = new BaseWarehouse(); |
| | | baseWarehouse.setAgencyId(agencyId); |
| | | List<BaseWarehouse> select = baseWarehouseService.select(baseWarehouse); |
| | | if (!CollectionUtils.isEmpty(select)) { |
| | | return ResponseValue.error("该机构已有仓库不能继续新增!"); |
| | | } |
| | | |
| | | int result = baseWarehouseService.add(param); |
| | | if (result > 0) { |
| | |
| | | } |
| | | return ResponseValue.error("新增失败!"); |
| | | } |
| | | |
| | | // 供产品导数据临时用(可删) |
| | | public String add1(BaseWarehouseParam param) { |
| | | BaseWarehouseParam param2 = new BaseWarehouseParam(); |
| | | CommonUtil.copyProperties(param, param2); |
| | | param = param2; |
| | | |
| | | if (StringUtils.isEmpty(param.getWarehouseName())) { |
| | | return "仓库名称为空"; |
| | | } |
| | | Long agencyId = param.getAgencyId(); |
| | | BaseWarehouse baseWarehouse = new BaseWarehouse(); |
| | | baseWarehouse.setAgencyId(agencyId); |
| | | List<BaseWarehouse> select = baseWarehouseService.select(baseWarehouse); |
| | | if (!CollectionUtils.isEmpty(select)) { |
| | | return "该机构已有仓库不能继续新增!"; |
| | | } |
| | | int result = baseWarehouseService.add(param); |
| | | if (result > 0) { |
| | | return "1"; |
| | | } |
| | | return "新增失败!"; |
| | | } |
| | | |
| | | //供产品导数据临时用(可删) |
| | | //@PostMapping("/addCk") |
| | | public String addCk() { |
| | | int ok = 0; |
| | | int isNull = 0; |
| | | int bnxz = 0; |
| | | int err = 0; |
| | | // 查询所有的机构 |
| | | FinSysTenant finSysTenant = new FinSysTenant(); |
| | | List<FinSysTenant> finSysTenants = finSysTenantService.selectAll(finSysTenant); |
| | | for (FinSysTenant fst : finSysTenants) { |
| | | // 组装仓库数据 |
| | | BaseWarehouseParam baseWarehouseParam = new BaseWarehouseParam(); |
| | | baseWarehouseParam.setWarehouseName(fst.getName() + "仓库"); |
| | | baseWarehouseParam.setAdress(""); |
| | | baseWarehouseParam.setAgencyId(fst.getId()); |
| | | baseWarehouseParam.setClassificationCode("29"); |
| | | baseWarehouseParam.setStates(1); |
| | | // 调用原本的新增接口新增仓库 |
| | | String resSta = add1(baseWarehouseParam); |
| | | if("1".equals(resSta)){ |
| | | ok++; |
| | | }else if("仓库名称为空".equals(resSta)){ |
| | | isNull++; |
| | | }else if("该机构已有仓库不能继续新增!".equals(resSta)){ |
| | | bnxz++; |
| | | }else if("新增失败!".equals(resSta)){ |
| | | err++; |
| | | } |
| | | } |
| | | log.info("ok:"+ok); |
| | | log.info("isNull:"+isNull); |
| | | log.info("bnxz:"+bnxz); |
| | | log.info("err:"+err); |
| | | return "新增仓库..."+"##ok:"+ok+"##isNull:"+isNull+"##bnxz:"+bnxz+"##err:"+err; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description 仓库列表查询 |
| | |
| | | if (baseWarehouse.getId() == null) { |
| | | return ResponseValue.error("仓库id为空"); |
| | | } |
| | | Long id = baseWarehouse.getId(); |
| | | LWhGoods lWhGoods = new LWhGoods(); |
| | | lWhGoods.setWarehouseId(id); |
| | | List<LWhGoods> select = lWhGoodsService.select(lWhGoods); |
| | | if (!CollectionUtils.isEmpty(select)) { |
| | | return ResponseValue.error("该仓库正在使用,不能删除"); |
| | | } |
| | | int num = baseWarehouseService.updateById(baseWarehouse); |
| | | |
| | | return num > 0 ? ResponseValue.success(1) : ResponseValue.error("删除失败!"); |
| | |
| | | if (agencyId == null) { |
| | | return ResponseValue.success(new ArrayList<>()); |
| | | } |
| | | List<BaseWarehouse> list = baseWarehouseService.getBaseWareHouseList(agencyId, null, null); |
| | | List<BaseWarehouse> list = baseWarehouseService.getBaseWareHouseList(agencyId, StatesType.NORMAL.getValue()); |
| | | if (list == null) { |
| | | return ResponseValue.error("查询失败!"); |
| | | } |
| | |
| | | |
| | | @ApiOperation(value = "根据仓库id和型号id 查询库存", notes = "根据仓库id和型号id 查询库存") |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "warehouseQry", value = "仓库id和型号id", required = true, |
| | | dataType = "WarehouseQry", paramType = "query")}) |
| | | dataType = "WarehouseQry", paramType = "query")}) |
| | | @GetMapping("/select/number") |
| | | public ResponseValue selectNumber() { |
| | | WarehouseQry warehouseQry = CommonUtil.getObjFromReq(WarehouseQry.class); |
| | |
| | | Long warehouseId = warehouseQry.getWarehouseId(); |
| | | if (warehouseId == null) { |
| | | Long agencyId = warehouseQry.getAgencyId(); |
| | | BaseWarehouse defaultWarehouseByAgencyId = baseWarehouseService.getDefaultWarehouseByAgencyId(agencyId); |
| | | warehouseId = defaultWarehouseByAgencyId.getId(); |
| | | BaseWarehouse baseWarehouse = baseWarehouseService.getWarehouseByAgencyId(agencyId, null); |
| | | warehouseId = baseWarehouse.getId(); |
| | | } |
| | | Long baseGoodsModelsId = warehouseQry.getBaseGoodsModelsId(); |
| | | Integer warehouseType = warehouseQry.getWarehouseType(); |
| | | Integer states = warehouseQry.getStates(); |
| | | Integer buyType = warehouseQry.getBuyType(); |
| | | |
| | | int num = lWhGoodsService.queryGoodsModelNum(warehouseType, warehouseId, baseGoodsModelsId, 1, buyType); |
| | | // 其他类型的库存查询是否也要查部门类型的库存 |
| | | List<Long> warehouseIds = new ArrayList<>(Arrays.asList(warehouseId)); |
| | | int num = lWhGoodsService.queryGoodsModelNum(warehouseType, warehouseIds, baseGoodsModelsId, 1, buyType); |
| | | return ResponseValue.success(num); |
| | | } |
| | | |
| | | @ApiOperation(value = "根据仓库id和型号id 查询库存", notes = "根据仓库id和型号id 查询库存") |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "warehouseQry", value = "仓库id和型号id", required = true, |
| | | dataType = "WarehouseQry", paramType = "query")}) |
| | | dataType = "WarehouseQry", paramType = "query")}) |
| | | @GetMapping("/select/in/warehouse/num") |
| | | public ResponseValue selectAllNumber() { |
| | | WarehouseQry warehouseQry = CommonUtil.getObjFromReq(WarehouseQry.class); |
| | |
| | | warehouseQry = param2; |
| | | |
| | | Long agencyId = warehouseQry.getAgencyId(); |
| | | List<BaseWarehouse> baseWarehouseList = baseWarehouseService.getBaseWareHouseList(agencyId, null, (short)1); |
| | | List<BaseWarehouse> baseWarehouseList = |
| | | baseWarehouseService.getBaseWareHouseList(agencyId, StatesType.NORMAL.getValue()); |
| | | List<Long> warehouseIdList = baseWarehouseList.stream().map(BaseWarehouse::getId).collect(Collectors.toList()); |
| | | |
| | | Long baseGoodsModelsId = warehouseQry.getBaseGoodsModelsId(); |
| | |
| | | Integer states = warehouseQry.getStates(); |
| | | Integer buyType = warehouseQry.getBuyType(); |
| | | |
| | | // 调拨时只查机构类型的集采仓库库存 |
| | | // 部门分发时不分机构和部门,因为调拨进来的物品也算在库存里只是类型为部门,同样检视所有仓库该型号的数量 |
| | | int num = lWhGoodsService.queryGoodsModelInWareHouseNum(warehouseType, warehouseIdList, baseGoodsModelsId, |
| | | states, buyType); |
| | | states, buyType); |
| | | return ResponseValue.success(num); |
| | | } |
| | | |