|
|
@@ -1,6 +1,11 @@
|
|
|
package com.github.zuihou.business.productionReadyCenter.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.github.zuihou.authority.entity.auth.Role;
|
|
|
+import com.github.zuihou.authority.entity.auth.User;
|
|
|
+import com.github.zuihou.authority.service.auth.RoleService;
|
|
|
+import com.github.zuihou.authority.service.auth.UserService;
|
|
|
import com.github.zuihou.base.service.SuperServiceImpl;
|
|
|
import com.github.zuihou.business.productionReadyCenter.dao.PlateMapper;
|
|
|
import com.github.zuihou.business.productionReadyCenter.dto.PlateSaveDTO;
|
|
|
@@ -8,16 +13,24 @@ import com.github.zuihou.business.productionReadyCenter.dto.PlateUpdateDTO;
|
|
|
import com.github.zuihou.business.productionReadyCenter.entity.Plate;
|
|
|
import com.github.zuihou.business.productionReadyCenter.service.PlateService;
|
|
|
import com.github.zuihou.business.productionReadyCenter.service.TrayPositionService;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.entity.ZZone;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
|
|
|
import com.github.zuihou.common.constant.CodeRuleModule;
|
|
|
+import com.github.zuihou.common.util.StringUtil;
|
|
|
+import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
|
import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
|
import com.github.zuihou.injection.annonation.InjectionResult;
|
|
|
import com.github.zuihou.tenant.service.CodeRuleService;
|
|
|
import com.github.zuihou.utils.BeanPlusUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.bouncycastle.jcajce.provider.symmetric.AES;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 业务实现类
|
|
|
@@ -35,6 +48,11 @@ public class PlateServiceImpl extends SuperServiceImpl<PlateMapper, Plate> imple
|
|
|
TrayPositionService trayPositionService;
|
|
|
@Autowired
|
|
|
CodeRuleService codeRuleService;
|
|
|
+ @Autowired
|
|
|
+ RoleService roleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ZZoneService zoneService;
|
|
|
|
|
|
@Override
|
|
|
@InjectionResult
|
|
|
@@ -45,12 +63,28 @@ public class PlateServiceImpl extends SuperServiceImpl<PlateMapper, Plate> imple
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Plate save(PlateSaveDTO data) {
|
|
|
+ if(StringUtil.isEmpty(data.getZoneId())){//如果是舱体或框体人员。会根据当前角色获取对应的舱体或框体ID
|
|
|
+ //获取用户ID
|
|
|
+ if(StringUtil.isNotEmpty(data.getUserId())){
|
|
|
+ List<Role> roleList= roleService.findRoleByUserId(Long.parseLong(data.getUserId()));
|
|
|
+ if(CollectionUtil.isNotEmpty(roleList)){
|
|
|
+ String roles = roleList.stream().map(e -> e.getName()).collect(Collectors.joining(","));
|
|
|
+ ZZone zZone = new ZZone();
|
|
|
+ if(roles.indexOf("舱体")>=0){
|
|
|
+ zZone = zoneService.getOne(Wraps.<ZZone>lbQ().like(ZZone::getName, "舱体"));
|
|
|
+ }else{
|
|
|
+ zZone = zoneService.getOne(Wraps.<ZZone>lbQ().like(ZZone::getName, "框体"));
|
|
|
+ }
|
|
|
+ data.setZoneId(zZone.getId().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
Plate module = BeanPlusUtil.toBean(data, Plate.class);
|
|
|
+
|
|
|
//根据编码规则
|
|
|
String no = codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_TRAY);
|
|
|
module.setPlateNo(no);
|
|
|
save(module);
|
|
|
-
|
|
|
return module;
|
|
|
}
|
|
|
|