Compare commits

...

2 Commits

Author SHA1 Message Date
chenlong 6a0633bc14 还原配置 3 months ago
chenlong d5dcfee1f7 新增仓库扩展 , 3 months ago
  1. 25
      blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseSettingEntity.java
  2. 19
      blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/feign/IWarehouseSettingClient.java
  3. 26
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/controller/WarehouseSettingController.java
  4. 19
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/WarehouseSettingDTO.java
  5. 24
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/feign/WarehouseSettingClient.java
  6. 7
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseSettingMapper.java
  7. 13
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseSettingService.java
  8. 69
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseSettingImpl.java

25
blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseSettingEntity.java

@ -0,0 +1,25 @@
package com.logpm.warehouse.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
@TableName("logpm_warehouse_setting")
@ApiModel(value = "WarehouseSetting对象", description = "仓库设置")
@EqualsAndHashCode(callSuper = true)
@Data
public class WarehouseSettingEntity extends TenantEntity {
private static final long serialVersionUID = 1L;
/**
* 仓库id
*/
private Long warehouseId;
/**
* 强制装车0=不限制1=强制
*/
private Integer mandatoryLoading;
}

19
blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/feign/IWarehouseSettingClient.java

@ -0,0 +1,19 @@
package com.logpm.warehouse.feign;
import org.springblade.common.constant.ModuleNameConstant;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
/**
* 仓库设置 Feign接口
*/
@FeignClient(
value = ModuleNameConstant.APPLICATION_WAREHOUSE_NAME
)
public interface IWarehouseSettingClient {
String API_PREFIX = "warehouse-setting/client";
@GetMapping(API_PREFIX + "/is-mandatory-loading")
Boolean isMandatoryLoading(Long warehouseId);
}

26
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/controller/WarehouseSettingController.java

@ -0,0 +1,26 @@
package com.logpm.warehouse.controller;
import com.logpm.warehouse.dto.WarehouseSettingDTO;
import com.logpm.warehouse.service.IWarehouseSettingService;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@AllArgsConstructor
@RequestMapping("/warehouse-setting")
@Api(value = "仓库设置", tags = "仓库设置")
public class WarehouseSettingController extends BladeController {
private final IWarehouseSettingService warehouseSettingService;
@PostMapping("/save")
public R<String> save(WarehouseSettingDTO warehouseSettingDTO) {
return warehouseSettingService.saveSetting(warehouseSettingDTO);
}
}

19
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/WarehouseSettingDTO.java

@ -0,0 +1,19 @@
package com.logpm.warehouse.dto;
import com.logpm.warehouse.entity.WarehouseSettingEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
@EqualsAndHashCode(callSuper = true)
@Data
public class WarehouseSettingDTO extends WarehouseSettingEntity {
private static final long serialVersionUID = 1L;
/**
* 仓库id集合
*/
List<Long> warehouseListIds;
}

24
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/feign/WarehouseSettingClient.java

@ -0,0 +1,24 @@
package com.logpm.warehouse.feign;
import com.logpm.warehouse.service.IWarehouseSettingService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
@ApiIgnore()
@RestController
@AllArgsConstructor
public class WarehouseSettingClient implements IWarehouseSettingClient{
private final IWarehouseSettingService warehouseSettingService;
/**
* 是否强制装车
* @param warehouseId
* @return
*/
@Override
public Boolean isMandatoryLoading(Long warehouseId) {
return warehouseSettingService.isMandatoryLoading(warehouseId);
}
}

7
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseSettingMapper.java

@ -0,0 +1,7 @@
package com.logpm.warehouse.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.warehouse.entity.WarehouseSettingEntity;
public interface WarehouseSettingMapper extends BaseMapper<WarehouseSettingEntity> {
}

13
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseSettingService.java

@ -0,0 +1,13 @@
package com.logpm.warehouse.service;
import com.logpm.warehouse.dto.WarehouseSettingDTO;
import com.logpm.warehouse.entity.WarehouseSettingEntity;
import org.springblade.core.mp.base.BaseService;
import org.springblade.core.tool.api.R;
public interface IWarehouseSettingService extends BaseService<WarehouseSettingEntity> {
boolean isMandatoryLoading(Long WarehouseId);
R<String> saveSetting(WarehouseSettingDTO warehouseSettingDTO);
}

69
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseSettingImpl.java

@ -0,0 +1,69 @@
package com.logpm.warehouse.service.impl;
import com.baomidou.mybatisplus.core.toolkit.SerializationUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.warehouse.dto.WarehouseSettingDTO;
import com.logpm.warehouse.entity.WarehouseSettingEntity;
import com.logpm.warehouse.mapper.WarehouseSettingMapper;
import com.logpm.warehouse.service.IWarehouseSettingService;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
@Service
@AllArgsConstructor
public class WarehouseSettingImpl extends BaseServiceImpl<WarehouseSettingMapper, WarehouseSettingEntity> implements IWarehouseSettingService {
public boolean isMandatoryLoading(Long WarehouseId){
WarehouseSettingEntity setting = getSetting(WarehouseId);
int noLimit = 0;
int forcibly = 1;
int res = noLimit;
if (setting != null && forcibly == setting.getMandatoryLoading() ) {
res = forcibly;
}
return res == forcibly;
}
@Transactional
@Override
public R<String> saveSetting(WarehouseSettingDTO warehouseSettingDTO) {
if (warehouseSettingDTO == null) {
return R.fail("参数错误");
}
if (warehouseSettingDTO.getWarehouseListIds().isEmpty()) {
if (warehouseSettingDTO.getWarehouseId() == null) {
return R.fail("参数错误");
}
save(warehouseSettingDTO);
return R.success("保存成功");
}
List<WarehouseSettingEntity> list = new ArrayList<>();
for (int i = 0; i < warehouseSettingDTO.getWarehouseListIds().size(); i++) {
WarehouseSettingEntity setting = SerializationUtils.clone(warehouseSettingDTO);
setting.setWarehouseId(warehouseSettingDTO.getWarehouseListIds().get(i));
list.add(setting);
}
return saveBatch(list) ? R.success("保存成功") : R.fail("保存失败");
}
private WarehouseSettingEntity getSetting(Long WarehouseId){
return baseMapper.selectOne(Wrappers.<WarehouseSettingEntity>lambdaQuery()
.eq(WarehouseSettingEntity::getWarehouseId, WarehouseId)
);
}
}
Loading…
Cancel
Save