|
@@ -3,13 +3,24 @@ package com.abi.qms.platform.service.impl;
|
|
|
import com.abi.qms.platform.dao.entity.BaseActive;
|
|
|
import com.abi.qms.platform.dao.entity.BaseMaterial;
|
|
|
import com.abi.qms.platform.dao.entity.BaseSapMaterial;
|
|
|
-import com.abi.qms.platform.dao.enums.*;
|
|
|
+import com.abi.qms.platform.dao.enums.MaterialTypeEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.TrueFalseEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.ValidEnum;
|
|
|
import com.abi.qms.platform.dao.mapper.BaseActiveMapper;
|
|
|
import com.abi.qms.platform.dao.mapper.BaseMaterialMapper;
|
|
|
import com.abi.qms.platform.dao.mapper.BaseSapMaterialMapper;
|
|
|
import com.abi.qms.platform.dao.vo.result.MaterialVO;
|
|
|
-import com.abi.qms.platform.dto.req.*;
|
|
|
-import com.abi.qms.platform.dto.res.*;
|
|
|
+import com.abi.qms.platform.dto.req.AddMaterialReq;
|
|
|
+import com.abi.qms.platform.dto.req.DisableMaterialReq;
|
|
|
+import com.abi.qms.platform.dto.req.EnableMaterialReq;
|
|
|
+import com.abi.qms.platform.dto.req.GetMaterialReq;
|
|
|
+import com.abi.qms.platform.dto.req.ListMaterialForSelectReq;
|
|
|
+import com.abi.qms.platform.dto.req.ListMaterialReq;
|
|
|
+import com.abi.qms.platform.dto.req.UpdateMaterialReq;
|
|
|
+import com.abi.qms.platform.dto.res.ExcelImportRes;
|
|
|
+import com.abi.qms.platform.dto.res.GetMaterialRes;
|
|
|
+import com.abi.qms.platform.dto.res.ListMaterialForSelectRes;
|
|
|
+import com.abi.qms.platform.dto.res.ListMaterialRes;
|
|
|
import com.abi.qms.platform.infrastructure.util.AssertUtil;
|
|
|
import com.abi.qms.platform.infrastructure.util.PageUtil;
|
|
|
import com.abi.qms.platform.service.MaterialService;
|
|
@@ -25,7 +36,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -50,22 +64,22 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
* 新增物料
|
|
|
*/
|
|
|
@Override
|
|
|
- public void addMaterial(AddMaterialReq req){
|
|
|
+ public void addMaterial(AddMaterialReq req) {
|
|
|
//校验入参
|
|
|
//查询是否存在物料号
|
|
|
QueryWrapper<BaseMaterial> materialQw = new QueryWrapper<>();
|
|
|
- materialQw.eq("material_code",req.getMaterialCode());
|
|
|
+ materialQw.eq("material_code", req.getMaterialCode());
|
|
|
materialQw.eq("is_delete", 0);
|
|
|
List<BaseMaterial> materialList = baseMaterialMapper.selectList(materialQw);
|
|
|
- if(CollectionUtils.isNotEmpty(materialList)){
|
|
|
- throw new BusinessException("物料号"+req.getMaterialCode()+"已存在,请勿重复创建");
|
|
|
+ if (CollectionUtils.isNotEmpty(materialList)) {
|
|
|
+ throw new BusinessException("物料号" + req.getMaterialCode() + "已存在,请勿重复创建");
|
|
|
}
|
|
|
//查询SAP物料,因为新增QMS物料需要选择SAP物料来匹配
|
|
|
QueryWrapper<BaseSapMaterial> baseSapMaterialQw = new QueryWrapper<>();
|
|
|
- baseSapMaterialQw.eq("sap_material_id",req.getMaterialCode());
|
|
|
- baseSapMaterialQw.eq("is_delete",0);
|
|
|
+ baseSapMaterialQw.eq("sap_material_id", req.getMaterialCode());
|
|
|
+ baseSapMaterialQw.eq("is_delete", 0);
|
|
|
BaseSapMaterial baseSapMaterial = baseSapMaterialMapper.selectOne(baseSapMaterialQw);
|
|
|
- AssertUtil.isNull(baseSapMaterial,"SAP物料不存在!");
|
|
|
+ AssertUtil.isNull(baseSapMaterial, "SAP物料不存在!");
|
|
|
|
|
|
//1-新增
|
|
|
BaseMaterial material = new BaseMaterial();
|
|
@@ -83,11 +97,11 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
* 编辑物料
|
|
|
*/
|
|
|
@Override
|
|
|
- public void updateMaterial(UpdateMaterialReq req){
|
|
|
+ public void updateMaterial(UpdateMaterialReq req) {
|
|
|
|
|
|
//1-查询物料
|
|
|
BaseMaterial material = baseMaterialMapper.selectById(req.getId());
|
|
|
- AssertUtil.isNull(material,"物料不存在");
|
|
|
+ AssertUtil.isNull(material, "物料不存在");
|
|
|
|
|
|
//2-修改物料
|
|
|
material.setMaterialType(req.getMaterialType());
|
|
@@ -103,7 +117,7 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
* 分页查询物料
|
|
|
*/
|
|
|
@Override
|
|
|
- public ListMaterialRes listMaterial(ListMaterialReq req){
|
|
|
+ public ListMaterialRes listMaterial(ListMaterialReq req) {
|
|
|
|
|
|
//1-分页查询
|
|
|
IPage<MaterialVO> iPage = baseMaterialMapper.listMaterial(PageUtil.createPage(req), req);
|
|
@@ -125,7 +139,7 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
* 查询物料明细
|
|
|
*/
|
|
|
@Override
|
|
|
- public GetMaterialRes getMaterial(GetMaterialReq req){
|
|
|
+ public GetMaterialRes getMaterial(GetMaterialReq req) {
|
|
|
|
|
|
//1-查询物料对象
|
|
|
BaseMaterial material = baseMaterialMapper.selectById(req.getId());
|
|
@@ -142,7 +156,7 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void enableMaterial(EnableMaterialReq req){
|
|
|
+ public void enableMaterial(EnableMaterialReq req) {
|
|
|
List<Long> ids = req.getIds();
|
|
|
|
|
|
//循环启用
|
|
@@ -166,7 +180,7 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void disableMaterial(DisableMaterialReq req){
|
|
|
+ public void disableMaterial(DisableMaterialReq req) {
|
|
|
List<Long> ids = req.getIds();
|
|
|
|
|
|
//循环禁用
|
|
@@ -192,9 +206,9 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
public ListMaterialForSelectRes listMaterialForSelect(ListMaterialForSelectReq req) {
|
|
|
//1-查询所有有效的物料
|
|
|
QueryWrapper<BaseMaterial> materialQw = new QueryWrapper<>();
|
|
|
- materialQw.eq("has_qr",1);
|
|
|
- materialQw.eq("valid",1);
|
|
|
- materialQw.eq("is_delete",0);
|
|
|
+ materialQw.eq("has_qr", 1);
|
|
|
+ materialQw.eq("valid", 1);
|
|
|
+ materialQw.eq("is_delete", 0);
|
|
|
List<BaseMaterial> baseMaterialList = baseMaterialMapper.selectList(materialQw);
|
|
|
|
|
|
//构造出参
|
|
@@ -207,6 +221,7 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
|
|
|
/**
|
|
|
* 批量导入物料
|
|
|
+ *
|
|
|
* @param materialPropertyList
|
|
|
* @return
|
|
|
* @throws Exception
|
|
@@ -228,14 +243,14 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
|
|
|
//2-查询活动
|
|
|
Long activeId = null;
|
|
|
- if(StringUtils.isNotBlank(materialProperty.getActiveName())){
|
|
|
+ if (StringUtils.isNotBlank(materialProperty.getActiveName())) {
|
|
|
QueryWrapper<BaseActive> activeQw = new QueryWrapper<>();
|
|
|
- activeQw.eq("active_name",materialProperty.getActiveName());
|
|
|
- activeQw.eq("is_delete",0);
|
|
|
- activeQw.eq("valid",1);
|
|
|
- activeQw.eq("audit_status",2);
|
|
|
+ activeQw.eq("active_name", materialProperty.getActiveName());
|
|
|
+ activeQw.eq("is_delete", 0);
|
|
|
+ activeQw.eq("valid", 1);
|
|
|
+ activeQw.eq("audit_status", 2);
|
|
|
BaseActive baseActive = baseActiveMapper.selectOne(activeQw);
|
|
|
- AssertUtil.isNull(baseActive,"活动不存在或活动未启用");
|
|
|
+ AssertUtil.isNull(baseActive, "活动不存在或活动未启用");
|
|
|
activeId = baseActive.getId();
|
|
|
}
|
|
|
|
|
@@ -263,8 +278,8 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- private Map<String,Object> checkMaterialProperty(MaterialProperty materialProperty) {
|
|
|
- Map<String,Object> returnMap = new HashMap<>();
|
|
|
+ private Map<String, Object> checkMaterialProperty(MaterialProperty materialProperty) {
|
|
|
+ Map<String, Object> returnMap = new HashMap<>();
|
|
|
StringBuffer errorMessage = new StringBuffer();
|
|
|
//逐个字段校验
|
|
|
if (StringUtils.isBlank(materialProperty.getMaterialCode())) {
|
|
@@ -277,20 +292,21 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
&& MaterialTypeEnum.getCode(materialProperty.getMaterialType()) == null) {
|
|
|
errorMessage.append("物料类型").append("枚举值不正确,");
|
|
|
}
|
|
|
- if(StringUtils.isBlank(materialProperty.getHasQr())){
|
|
|
+ if (StringUtils.isBlank(materialProperty.getHasQr())) {
|
|
|
errorMessage.append("二维码").append("为空,");
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(materialProperty.getHasQr())
|
|
|
- && TrueFalseEnum.getCode(materialProperty.getHasQr())==null){
|
|
|
+ if (StringUtils.isNotBlank(materialProperty.getHasQr())
|
|
|
+ && TrueFalseEnum.getCode(materialProperty.getHasQr()) == null) {
|
|
|
errorMessage.append("二维码").append("枚举值不正确,");
|
|
|
}
|
|
|
|
|
|
- returnMap.put("errorMessage",errorMessage.toString());
|
|
|
+ returnMap.put("errorMessage", errorMessage.toString());
|
|
|
return returnMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* code查询物料
|
|
|
+ *
|
|
|
* @param materialCode
|
|
|
* @return
|
|
|
*/
|
|
@@ -298,8 +314,8 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
public BaseMaterial getMaterialByCode(String materialCode) {
|
|
|
|
|
|
QueryWrapper<BaseMaterial> materialQw = new QueryWrapper<>();
|
|
|
- materialQw.eq("material_code",materialCode);
|
|
|
- materialQw.eq("is_delete",0);
|
|
|
+ materialQw.eq("material_code", materialCode);
|
|
|
+ materialQw.eq("is_delete", 0);
|
|
|
BaseMaterial material = baseMaterialMapper.selectOne(materialQw);
|
|
|
|
|
|
return material;
|