|
@@ -16,9 +16,9 @@ import com.fjhx.material.service.MaterialService;
|
|
|
import com.fjhx.material.vo.MaterialVo;
|
|
|
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.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -35,25 +35,29 @@ import java.util.Map;
|
|
|
* @since 2022-06-29
|
|
|
*/
|
|
|
@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> implements MaterialService {
|
|
|
|
|
|
- @Autowired
|
|
|
- private ClassifService classifService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private RedisLockClient redisLockClient;
|
|
|
+ private final ClassifService classifService;
|
|
|
|
|
|
+ private final RedisLockClient redisLockClient;
|
|
|
|
|
|
@Override
|
|
|
public Page<Material> getPage(Map<String, Object> condition) {
|
|
|
|
|
|
QueryWrapper<Material> wrapper = Wrappers.query();
|
|
|
|
|
|
- WrapperUtil.init(condition, wrapper).keyword("code", "name").eqTenantId();
|
|
|
+ WrapperUtil.init(condition, wrapper)
|
|
|
+ .keyword("code", "name")
|
|
|
+ .eqTenantId();
|
|
|
+
|
|
|
+ // 编码正序
|
|
|
+ wrapper.orderByAsc("code");
|
|
|
|
|
|
// 如果传入分类id,查询分类已经分类下级
|
|
|
- if (ObjectUtil.isNotEmpty(condition.get("classifId"))) {
|
|
|
- List<Long> childrenIdList = classifService.getChildrenIdList(Long.valueOf(condition.get("classifId").toString()));
|
|
|
+ Object classifId = condition.get("classifId");
|
|
|
+ if (ObjectUtil.isNotEmpty(classifId)) {
|
|
|
+ List<Long> childrenIdList = classifService.getChildrenIdList(Long.valueOf(classifId.toString()));
|
|
|
wrapper.in("classifId", childrenIdList);
|
|
|
}
|
|
|
|
|
@@ -66,6 +70,8 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
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);
|
|
@@ -79,8 +85,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
materialVo.setQualityTestingRate(BigDecimal.ZERO);
|
|
|
}
|
|
|
|
|
|
- Integer coiled = materialVo.getCoiled();
|
|
|
- Assert.notEmpty(coiled, "是否卷材判断字段不能为空");
|
|
|
if (ObjectUtil.isEmpty(materialVo.getLoss()) || coiled.equals(CommonConstant.No)) {
|
|
|
materialVo.setLoss(BigDecimal.ZERO);
|
|
|
}
|
|
@@ -95,7 +99,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
return true;
|
|
|
});
|
|
|
|
|
|
- Assert.ture(flag, ErrorMsgConstant.SYSTEM_BUSY_ERROR);
|
|
|
+ Assert.eqTrue(flag, ErrorMsgConstant.SYSTEM_BUSY_ERROR);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -108,7 +112,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
updateById(materialVo);
|
|
|
return true;
|
|
|
});
|
|
|
- Assert.ture(flag, ErrorMsgConstant.SYSTEM_BUSY_ERROR);
|
|
|
+ Assert.eqTrue(flag, ErrorMsgConstant.SYSTEM_BUSY_ERROR);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -135,7 +139,11 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
* @param excludeId 排除物料id(编辑时不判断自己)
|
|
|
*/
|
|
|
private void materialCodeOnly(String tenantId, String materialCode, Long excludeId) {
|
|
|
- Integer count = lambdaQuery().eq(BaseEntity::getTenantId, tenantId).eq(Material::getCode, materialCode).ne(ObjectUtil.isNotEmpty(excludeId), BaseEntity::getId, excludeId).count();
|
|
|
+ Integer count = lambdaQuery()
|
|
|
+ .eq(BaseEntity::getTenantId, tenantId)
|
|
|
+ .eq(Material::getCode, materialCode)
|
|
|
+ .ne(ObjectUtil.isNotEmpty(excludeId), BaseEntity::getId, excludeId)
|
|
|
+ .count();
|
|
|
Assert.eqZero(count, "物料编码重复,添加失败");
|
|
|
}
|
|
|
|