|
@@ -5,10 +5,7 @@ import com.hssx.cloudmodel.constant.Constant;
|
|
|
import com.hssx.cloudmodel.entity.*;
|
|
|
import com.hssx.cloudmodel.entity.vo.CompanyVO;
|
|
|
import com.hssx.cloudmodel.entity.vo.UserVO;
|
|
|
-import com.hssx.cloudmodel.mapper.CompanyMapper;
|
|
|
-import com.hssx.cloudmodel.mapper.LngLatCompanyMapper;
|
|
|
-import com.hssx.cloudmodel.mapper.ProjectMapper;
|
|
|
-import com.hssx.cloudmodel.mapper.UserMapper;
|
|
|
+import com.hssx.cloudmodel.mapper.*;
|
|
|
import com.hssx.cloudmodel.service.CompanyService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.hssx.cloudmodel.util.HttpRespMsg;
|
|
@@ -20,6 +17,7 @@ import org.springframework.stereotype.Service;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -39,6 +37,10 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|
|
LngLatCompanyMapper lngLatCompanyMapper;
|
|
|
@Resource
|
|
|
ProjectMapper projectMapper;
|
|
|
+ @Resource
|
|
|
+ MouldMapper mouldMapper;
|
|
|
+ @Resource
|
|
|
+ ProjectUserMapper projectUserMapper;
|
|
|
|
|
|
@Override
|
|
|
public HttpRespMsg addAndUpdateRole(CompanyVO companyVO, Integer flag) {
|
|
@@ -142,8 +144,54 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|
|
|
|
|
@Override
|
|
|
public HttpRespMsg getCoutomCompanyAndMouldsByUser(UserVO userVO) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ List<CompanyVO> companyVOS = new ArrayList<>();
|
|
|
User currentUser = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", userVO.getToken()));
|
|
|
- return null;
|
|
|
+ if (Constant.SYS_ID == currentUser.getParentId()) {
|
|
|
+ //此时是admin,可看到自己公司下的模具和交于生产的公司
|
|
|
+ QueryWrapper<Mould> qw = new QueryWrapper<>();
|
|
|
+ List<Mould> moulds = mouldMapper.selectList(qw.eq("company_id", currentUser.getCompanyId()));
|
|
|
+ List<Integer> mouldIds = new ArrayList<>();
|
|
|
+ for (Mould mould : moulds) {
|
|
|
+ mouldIds.add(mould.getId());
|
|
|
+ }
|
|
|
+ companyVOS = companyMapper.getListMould(mouldIds);
|
|
|
+ } else if (Constant.SYS_PARENT_ID == currentUser.getParentId()) {
|
|
|
+ //系统管理员创建admin,返回资产方公司
|
|
|
+ List<Mould> moulds = mouldMapper.selectList(new QueryWrapper<Mould>());
|
|
|
+ List<Integer> mouldIds = new ArrayList<>();
|
|
|
+ for (Mould mould : moulds) {
|
|
|
+ mouldIds.add(mould.getId());
|
|
|
+ }
|
|
|
+ companyVOS = companyMapper.getListMould(mouldIds);
|
|
|
+ } else {
|
|
|
+ //此时是项目经理创建其他用户
|
|
|
+ QueryWrapper<Project> qw = new QueryWrapper<>();
|
|
|
+ qw.eq("manager_id", currentUser.getId());
|
|
|
+ List<Integer> set = new ArrayList<>();
|
|
|
+ set.add(-1);
|
|
|
+ List<Project> projects = projectMapper.selectList(qw);
|
|
|
+ if (projects.size() > 0) {
|
|
|
+ for (Project project : projects) {
|
|
|
+ set.add(project.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+// //充当普通人员参与的项目
|
|
|
+ List<ProjectUser> projectUsers = projectUserMapper.selectList(new QueryWrapper<ProjectUser>().eq("user_id", currentUser.getId()));
|
|
|
+ if (projectUsers.size() > 0) {
|
|
|
+ for (ProjectUser projectUser : projectUsers) {
|
|
|
+ set.add(projectUser.getProjectId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Mould> moulds = mouldMapper.selectList(new QueryWrapper<Mould>().in("project_id",set));
|
|
|
+ List<Integer> mouldIds = new ArrayList<>();
|
|
|
+ for (Mould mould : moulds) {
|
|
|
+ mouldIds.add(mould.getId());
|
|
|
+ }
|
|
|
+ companyVOS = companyMapper.getListMould(mouldIds);
|
|
|
+ }
|
|
|
+ msg.data = companyVOS;
|
|
|
+ return msg;
|
|
|
}
|
|
|
|
|
|
@Override
|