Compare commits
2 Commits
c6425c93af
...
6a0633bc14
Author | SHA1 | Date |
---|---|---|
chenlong | 6a0633bc14 | 3 months ago |
chenlong | d5dcfee1f7 | 3 months ago |
8 changed files with 202 additions and 0 deletions
@ -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; |
||||
} |
@ -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); |
||||
} |
@ -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); |
||||
} |
||||
|
||||
} |
@ -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; |
||||
} |
@ -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); |
||||
} |
||||
} |
@ -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> { |
||||
} |
@ -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); |
||||
} |
@ -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…
Reference in new issue