|
|
|
@ -31,6 +31,7 @@ import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import io.swagger.annotations.ApiParam; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import lombok.extern.log4j.Log4j2; |
|
|
|
|
import org.springblade.common.exception.CustomerException; |
|
|
|
|
import org.springblade.core.boot.ctrl.BladeController; |
|
|
|
|
import org.springblade.core.excel.util.ExcelUtil; |
|
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
@ -50,6 +51,7 @@ import java.math.BigDecimal;
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 物料基础信息 控制器 |
|
|
|
@ -147,10 +149,30 @@ public class BasicMaterialController extends BladeController {
|
|
|
|
|
return R.fail("添加失败,物料信息为空!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
checkBasicMaterialEntity(basicMaterial); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return R.status(basicMaterialService.save(basicMaterial)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void checkBasicMaterialEntity(BasicMaterialEntity basicMaterial) { |
|
|
|
|
|
|
|
|
|
// 判断输入的物料编码是否重复
|
|
|
|
|
List<BasicMaterialEntity> list = basicMaterialService.list(); |
|
|
|
|
|
|
|
|
|
List<BasicMaterialEntity> collect2 = list.stream().filter(item -> item.getName().equals(basicMaterial.getName())).collect(Collectors.toList()); |
|
|
|
|
if(!collect2.isEmpty()){ |
|
|
|
|
throw new CustomerException("物料名称重复,请重新输入"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<BasicMaterialEntity> collect = list.stream().filter(item -> item.getProductCode().equals(basicMaterial.getProductCode())).collect(Collectors.toList()); |
|
|
|
|
if(!collect.isEmpty()){ |
|
|
|
|
throw new CustomerException("物料编码重复,请重新输入"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 物料基础信息 修改 |
|
|
|
|
*/ |
|
|
|
@ -191,12 +213,17 @@ public class BasicMaterialController extends BladeController {
|
|
|
|
|
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
|
|
|
|
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
|
|
|
|
//改为修改隐藏状态
|
|
|
|
|
boolean update = basicMaterialService.update(new UpdateWrapper<BasicMaterialEntity>().lambda() |
|
|
|
|
.in(BasicMaterialEntity::getId, Func.toLongList(ids)) |
|
|
|
|
.set(BasicMaterialEntity::getHide, 2) |
|
|
|
|
); |
|
|
|
|
// basicMaterialService.deleteLogic(Func.toLongList(ids));
|
|
|
|
|
return R.status(update); |
|
|
|
|
// boolean update = basicMaterialService.update(new UpdateWrapper<BasicMaterialEntity>().lambda()
|
|
|
|
|
// .in(BasicMaterialEntity::getId, Func.toLongList(ids))
|
|
|
|
|
// .set(BasicMaterialEntity::getHide, 2)
|
|
|
|
|
// );
|
|
|
|
|
try { |
|
|
|
|
basicMaterialService.deleteLogic(Func.toLongList(ids)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("删除物料失败", e); |
|
|
|
|
throw new CustomerException("服务器异常,请刷新重试"); |
|
|
|
|
} |
|
|
|
|
return R.status(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|