|
@@ -7,21 +7,22 @@ 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.entity.product.ProductEx;
|
|
|
+import com.fjhx.entity.working.WorkingProcedure;
|
|
|
import com.fjhx.entity.working.WorkingRoute;
|
|
|
import com.fjhx.entity.working.WorkingRouteProcedure;
|
|
|
+import com.fjhx.mapper.working.WorkingRouteMapper;
|
|
|
import com.fjhx.params.working.WorkingRouteEx;
|
|
|
import com.fjhx.params.working.WorkingRouteVo;
|
|
|
-import com.fjhx.service.product.ProductExService;
|
|
|
-import com.fjhx.utils.Assert;
|
|
|
-import com.fjhx.utils.WrapperUtil;
|
|
|
-import com.fjhx.mapper.working.WorkingRouteMapper;
|
|
|
+import com.fjhx.service.working.WorkingProcedureService;
|
|
|
import com.fjhx.service.working.WorkingRouteProcedureService;
|
|
|
import com.fjhx.service.working.WorkingRouteService;
|
|
|
+import com.fjhx.utils.Assert;
|
|
|
+import com.fjhx.utils.WrapperUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -41,7 +42,7 @@ public class WorkingRouteServiceImpl extends ServiceImpl<WorkingRouteMapper, Wor
|
|
|
private WorkingRouteProcedureService workingRouteProcedureService;
|
|
|
|
|
|
@Autowired
|
|
|
- private ProductExService productExService;
|
|
|
+ private WorkingProcedureService workingProcedureService;
|
|
|
|
|
|
@Override
|
|
|
public Page<WorkingRouteEx> getPage(Map<String, String> condition) {
|
|
@@ -83,10 +84,10 @@ public class WorkingRouteServiceImpl extends ServiceImpl<WorkingRouteMapper, Wor
|
|
|
}
|
|
|
|
|
|
// 工艺路线适用产品
|
|
|
- List<Long> productIdList = workingRouteVo.getProductIdList();
|
|
|
- if (productIdList.size() > 0) {
|
|
|
- workingRouteProduct(productIdList, id);
|
|
|
- }
|
|
|
+ // List<Long> productIdList = workingRouteVo.getProductIdList();
|
|
|
+ // if (productIdList.size() > 0) {
|
|
|
+ // workingRouteProduct(productIdList, id);
|
|
|
+ // }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -117,15 +118,15 @@ public class WorkingRouteServiceImpl extends ServiceImpl<WorkingRouteMapper, Wor
|
|
|
|
|
|
// 工艺路线适用产品
|
|
|
List<Long> productIdList = workingRouteVo.getProductIdList();
|
|
|
- if (productIdList.size() > 0) {
|
|
|
- workingRouteProduct(productIdList, id);
|
|
|
-
|
|
|
- // 去除这个工艺路线已关联的其他产品
|
|
|
- productExService.update(Wrappers.<ProductEx>lambdaUpdate()
|
|
|
- .eq(ProductEx::getWorkingRouteId, id)
|
|
|
- .notIn(productIdList.size() > 0, ProductEx::getId, productIdList)
|
|
|
- .set(ProductEx::getWorkingRouteId, null));
|
|
|
- }
|
|
|
+ // if (productIdList.size() > 0) {
|
|
|
+ // workingRouteProduct(productIdList, id);
|
|
|
+ //
|
|
|
+ // // 去除这个工艺路线已关联的其他产品
|
|
|
+ // productExService.update(Wrappers.<ProductEx>lambdaUpdate()
|
|
|
+ // .eq(ProductEx::getWorkingRouteId, id)
|
|
|
+ // .notIn(productIdList.size() > 0, ProductEx::getId, productIdList)
|
|
|
+ // .set(ProductEx::getWorkingRouteId, null));
|
|
|
+ // }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -136,10 +137,10 @@ public class WorkingRouteServiceImpl extends ServiceImpl<WorkingRouteMapper, Wor
|
|
|
|
|
|
removeById(id);
|
|
|
|
|
|
- // 去除这个工艺路线已关联的产品
|
|
|
- productExService.update(Wrappers.<ProductEx>lambdaUpdate()
|
|
|
- .eq(ProductEx::getWorkingRouteId, id)
|
|
|
- .set(ProductEx::getWorkingRouteId, null));
|
|
|
+ // // 去除这个工艺路线已关联的产品
|
|
|
+ // productExService.update(Wrappers.<ProductEx>lambdaUpdate()
|
|
|
+ // .eq(ProductEx::getWorkingRouteId, id)
|
|
|
+ // .set(ProductEx::getWorkingRouteId, null));
|
|
|
|
|
|
// 去除工艺路线关联工序
|
|
|
workingRouteProcedureService.remove(WorkingRouteProcedure::getWorkingRouteId, id);
|
|
@@ -153,30 +154,45 @@ public class WorkingRouteServiceImpl extends ServiceImpl<WorkingRouteMapper, Wor
|
|
|
WorkingRouteEx result = BeanUtil.toBean(workingRoute, WorkingRouteEx.class);
|
|
|
|
|
|
List<WorkingRouteProcedure> list = workingRouteProcedureService.lambdaQuery()
|
|
|
- .select(WorkingRouteProcedure::getWorkingProcedureId, WorkingRouteProcedure::getAutomaticCirculation)
|
|
|
.eq(WorkingRouteProcedure::getWorkingRouteId, id)
|
|
|
.orderByAsc(WorkingRouteProcedure::getSort)
|
|
|
.list();
|
|
|
|
|
|
- result.setWorkingRouteProcedureList(list);
|
|
|
+
|
|
|
+ if (list.size() > 0) {
|
|
|
+ List<Long> workingRouteIdList = list.stream().map(WorkingRouteProcedure::getWorkingProcedureId).collect(Collectors.toList());
|
|
|
+ Map<Long, WorkingProcedure> kEntity = workingProcedureService.getKEntity(BaseEntity::getId,
|
|
|
+ q -> q.in(BaseEntity::getId, workingRouteIdList));
|
|
|
+
|
|
|
+ List<WorkingProcedure> workingProcedures = new ArrayList<>();
|
|
|
+
|
|
|
+ for (WorkingRouteProcedure workingRouteProcedure : list) {
|
|
|
+ WorkingProcedure workingProcedure = kEntity.get(workingRouteProcedure.getWorkingProcedureId());
|
|
|
+ if (workingProcedure != null) {
|
|
|
+ workingProcedures.add(workingProcedure);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ result.setWorkingProcedureList(workingProcedures);
|
|
|
+ }
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 产品关联工艺路线
|
|
|
- *
|
|
|
- * @param productIdList 产品id
|
|
|
- * @param workingRouteId 工艺路线id
|
|
|
- */
|
|
|
- private void workingRouteProduct(List<Long> productIdList, Long workingRouteId) {
|
|
|
- List<ProductEx> productExList = productIdList.stream().map(item -> {
|
|
|
- ProductEx productEx = new ProductEx();
|
|
|
- productEx.setId(item);
|
|
|
- productEx.setWorkingRouteId(workingRouteId);
|
|
|
- return productEx;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- productExService.updateBatchById(productExList);
|
|
|
- }
|
|
|
+ // /**
|
|
|
+ // * 产品关联工艺路线
|
|
|
+ // *
|
|
|
+ // * @param productIdList 产品id
|
|
|
+ // * @param workingRouteId 工艺路线id
|
|
|
+ // */
|
|
|
+ // private void workingRouteProduct(List<Long> productIdList, Long workingRouteId) {
|
|
|
+ // List<ProductEx> productExList = productIdList.stream().map(item -> {
|
|
|
+ // ProductEx productEx = new ProductEx();
|
|
|
+ // productEx.setId(item);
|
|
|
+ // productEx.setWorkingRouteId(workingRouteId);
|
|
|
+ // return productEx;
|
|
|
+ // }).collect(Collectors.toList());
|
|
|
+ // productExService.updateBatchById(productExList);
|
|
|
+ // }
|
|
|
|
|
|
}
|