|
@@ -1,29 +1,21 @@
|
|
|
package com.fjhx.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.base.BaseEntity;
|
|
|
import com.fjhx.constant.ProductLibraryLockConstant;
|
|
|
import com.fjhx.constants.ErrorMsgConstant;
|
|
|
-import com.fjhx.constants.StatusConstant;
|
|
|
import com.fjhx.entity.Material;
|
|
|
import com.fjhx.mapper.MaterialMapper;
|
|
|
import com.fjhx.params.MaterialVo;
|
|
|
-import com.fjhx.service.ClassifyService;
|
|
|
import com.fjhx.service.MaterialService;
|
|
|
import com.fjhx.utils.Assert;
|
|
|
-import com.fjhx.utils.WrapperUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springblade.core.redis.lock.RedisLockClient;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -37,54 +29,37 @@ import java.util.Map;
|
|
|
@RequiredArgsConstructor
|
|
|
public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> implements MaterialService {
|
|
|
|
|
|
- private final ClassifyService classifyService;
|
|
|
+// private final ClassifyService classifyService;
|
|
|
|
|
|
private final RedisLockClient redisLockClient;
|
|
|
|
|
|
- @Override
|
|
|
- public Page<Material> getPage(Map<String, String> condition) {
|
|
|
-
|
|
|
- QueryWrapper<Material> wrapper = Wrappers.query();
|
|
|
-
|
|
|
- WrapperUtil.init(condition, wrapper)
|
|
|
- .keyword("code", "name")
|
|
|
- .eqTenantId();
|
|
|
-
|
|
|
- // 编码正序
|
|
|
- wrapper.orderByAsc("code");
|
|
|
-
|
|
|
- // 如果传入分类id,查询分类已经分类下级
|
|
|
- String classifyId = condition.get("classifyId");
|
|
|
- if (ObjectUtil.isNotEmpty(classifyId)) {
|
|
|
- List<Long> childrenIdList = classifyService.getChildrenIdList(Long.valueOf(classifyId));
|
|
|
- wrapper.in("classify_id", childrenIdList);
|
|
|
- }
|
|
|
-
|
|
|
- return page(condition, wrapper);
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// public Page<Material> getPage(Map<String, String> condition) {
|
|
|
+//
|
|
|
+// QueryWrapper<Material> wrapper = Wrappers.query();
|
|
|
+//
|
|
|
+// WrapperUtil.init(condition, wrapper)
|
|
|
+// .keyword("code", "name")
|
|
|
+// .eqTenantId();
|
|
|
+//
|
|
|
+// // 编码正序
|
|
|
+// wrapper.orderByAsc("code");
|
|
|
+//
|
|
|
+// // 如果传入分类id,查询分类已经分类下级
|
|
|
+// String classifyId = condition.get("classifyId");
|
|
|
+// if (ObjectUtil.isNotEmpty(classifyId)) {
|
|
|
+// List<Long> childrenIdList = classifyService.getChildrenIdList(Long.valueOf(classifyId));
|
|
|
+// wrapper.in("classify_id", childrenIdList);
|
|
|
+// }
|
|
|
+//
|
|
|
+// return page(condition, wrapper);
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
public void add(MaterialVo materialVo) {
|
|
|
Assert.notEmpty(materialVo.getName(), "物料名称不能为空");
|
|
|
Assert.notEmpty(materialVo.getCode(), "物料编码不能为空");
|
|
|
- Integer coiled = materialVo.getCoiled();
|
|
|
- Assert.notEmpty(coiled, "是否卷材判断字段不能为空");
|
|
|
-
|
|
|
- if (ObjectUtil.isEmpty(materialVo.getSafetyStock())) {
|
|
|
- materialVo.setSafetyStock(BigDecimal.ZERO);
|
|
|
- }
|
|
|
-
|
|
|
- if (ObjectUtil.isEmpty(materialVo.getCycle())) {
|
|
|
- materialVo.setCycle(0);
|
|
|
- }
|
|
|
-
|
|
|
- if (ObjectUtil.isEmpty(materialVo.getQualityTestingRate())) {
|
|
|
- materialVo.setQualityTestingRate(BigDecimal.ZERO);
|
|
|
- }
|
|
|
|
|
|
- if (ObjectUtil.isEmpty(materialVo.getLoss()) || coiled.equals(StatusConstant.No)) {
|
|
|
- materialVo.setLoss(BigDecimal.ZERO);
|
|
|
- }
|
|
|
|
|
|
String tenantId = AuthUtil.getTenantId();
|
|
|
|