|
@@ -9,6 +9,7 @@ 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;
|
|
|
+import com.hssx.cloudmodel.util.ListUtil;
|
|
|
import com.hssx.cloudmodel.util.PageUtil;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -43,9 +44,14 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|
|
ProjectUserMapper projectUserMapper;
|
|
|
@Resource
|
|
|
ProjectApproveMapper projectApproveMapper;
|
|
|
+ @Resource
|
|
|
+ AssetCustomCompanyMapper assetCustomCompanyMapper;
|
|
|
+ @Resource
|
|
|
+ CustomCompanyMapper customCompanyMapper;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg addAndUpdateRole(CompanyVO companyVO, Integer flag) {
|
|
|
+ public HttpRespMsg addAndUpdateRole(CompanyVO companyVO, Integer flag, String companyIds) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
Company company = new Company();
|
|
|
if (flag == 0) {
|
|
@@ -58,32 +64,78 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|
|
} else {
|
|
|
if (companyVO.getCompanyType() == 0) {
|
|
|
//资产方直接添加
|
|
|
- BeanUtils.copyProperties(companyVO,company);
|
|
|
+ BeanUtils.copyProperties(companyVO, company);
|
|
|
companyMapper.insert(company);
|
|
|
- }else if (companyVO.getCompanyType() == 1){
|
|
|
+ if (companyIds != null) {
|
|
|
+ List<Integer> ides = ListUtil.convertIntegerIdsArrayToList(companyIds);
|
|
|
+ for (Integer ide : ides) {
|
|
|
+ if (assetCustomCompanyMapper.selectCount(new QueryWrapper<AssetCustomCompany>().eq("assert_id", company.getId()).eq("custom_id", ide)) == 0) {
|
|
|
+ AssetCustomCompany assetCustomCompany = new AssetCustomCompany();
|
|
|
+ assetCustomCompany.setAssertId(company.getId());
|
|
|
+ assetCustomCompany.setCustomId(ide);
|
|
|
+ assetCustomCompanyMapper.insert(assetCustomCompany);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (companyVO.getCompanyType() == 1) {
|
|
|
//生产方
|
|
|
- BeanUtils.copyProperties(companyVO,company);
|
|
|
+ BeanUtils.copyProperties(companyVO, company);
|
|
|
companyMapper.insert(company);
|
|
|
+ if (companyIds != null) {
|
|
|
+ List<Integer> ides = ListUtil.convertIntegerIdsArrayToList(companyIds);
|
|
|
+ for (Integer ide : ides) {
|
|
|
+ if (assetCustomCompanyMapper.selectCount(new QueryWrapper<AssetCustomCompany>().eq("assert_id", ide).eq("custom_id", company.getId())) == 0) {
|
|
|
+ AssetCustomCompany assetCustomCompany = new AssetCustomCompany();
|
|
|
+ assetCustomCompany.setAssertId(ide);
|
|
|
+ assetCustomCompany.setCustomId(company.getId());
|
|
|
+ assetCustomCompanyMapper.insert(assetCustomCompany);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
LngLatCompany factory = new LngLatCompany();
|
|
|
factory.setxLat(companyVO.getXLat());
|
|
|
factory.setyLng(companyVO.getYLng());
|
|
|
factory.setCompanyId(company.getId());
|
|
|
lngLatCompanyMapper.insert(factory);
|
|
|
}
|
|
|
+ msg.data = company;
|
|
|
}
|
|
|
} else if (flag == 1) {
|
|
|
//更新公司信息
|
|
|
- BeanUtils.copyProperties(companyVO,company);
|
|
|
+ BeanUtils.copyProperties(companyVO, company);
|
|
|
if (companyVO.getCompanyType() == 0) {
|
|
|
//修改资产方
|
|
|
- BeanUtils.copyProperties(companyVO,company);
|
|
|
+ BeanUtils.copyProperties(companyVO, company);
|
|
|
+ List<AssetCustomCompany> list = assetCustomCompanyMapper.selectList(new QueryWrapper<AssetCustomCompany>().eq("assert_id", company.getId()));
|
|
|
+ //判断所关联的生产方是否已被应用到项目
|
|
|
+ List<Integer> idess = new ArrayList<>();
|
|
|
+ idess.add(-1);
|
|
|
+ for (AssetCustomCompany assetCustomCompany : list) {
|
|
|
+ idess.add(assetCustomCompany.getCustomId());
|
|
|
+ }
|
|
|
+ Integer count = customCompanyMapper.selectCount(new QueryWrapper<CustomCompany>().in("company_id", idess));
|
|
|
+ if (count > 0) {
|
|
|
+ msg.setError("当前公司所生产方公司已被用用到项目,不可执行修改操作。");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ if (companyIds != null) {
|
|
|
+ List<Integer> ides = ListUtil.convertIntegerIdsArrayToList(companyIds);
|
|
|
+ for (Integer ide : ides) {
|
|
|
+ if (assetCustomCompanyMapper.selectCount(new QueryWrapper<AssetCustomCompany>().eq("assert_id", company.getId()).eq("custom_id", ide)) == 0) {
|
|
|
+ AssetCustomCompany assetCustomCompany = new AssetCustomCompany();
|
|
|
+ assetCustomCompany.setAssertId(company.getId());
|
|
|
+ assetCustomCompany.setCustomId(ide);
|
|
|
+ assetCustomCompanyMapper.insert(assetCustomCompany);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
companyMapper.updateById(company);
|
|
|
- }else if (companyVO.getCompanyType() == 1){
|
|
|
+ } else if (companyVO.getCompanyType() == 1) {
|
|
|
//生产方
|
|
|
- BeanUtils.copyProperties(companyVO,company);
|
|
|
+ BeanUtils.copyProperties(companyVO, company);
|
|
|
companyMapper.updateById(company);
|
|
|
QueryWrapper<LngLatCompany> qw = new QueryWrapper<>();
|
|
|
- qw.eq("company_id",companyVO.getId());
|
|
|
+ qw.eq("company_id", companyVO.getId());
|
|
|
LngLatCompany lngLatCompany = lngLatCompanyMapper.selectOne(qw);
|
|
|
LngLatCompany factory = new LngLatCompany();
|
|
|
factory.setxLat(companyVO.getXLat());
|
|
@@ -91,24 +143,48 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|
|
factory.setCompanyId(company.getId());
|
|
|
factory.setId(lngLatCompany.getId());
|
|
|
lngLatCompanyMapper.updateById(factory);
|
|
|
+ List<AssetCustomCompany> list = assetCustomCompanyMapper.selectList(new QueryWrapper<AssetCustomCompany>().eq("assert_id", company.getId()));
|
|
|
+ //判断所关联的生产方是否已被应用到项目
|
|
|
+ List<Integer> idess = new ArrayList<>();
|
|
|
+ idess.add(-1);
|
|
|
+ for (AssetCustomCompany assetCustomCompany : list) {
|
|
|
+ idess.add(assetCustomCompany.getCustomId());
|
|
|
+ }
|
|
|
+ Integer count = customCompanyMapper.selectCount(new QueryWrapper<CustomCompany>().eq("company_id", company.getId()));
|
|
|
+ if (count > 0) {
|
|
|
+ msg.setError("当前公司已和所关联的资产方合作相关项目,不可执行修改操作。");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ if (companyIds != null) {
|
|
|
+ List<Integer> ides = ListUtil.convertIntegerIdsArrayToList(companyIds);
|
|
|
+ for (Integer ide : ides) {
|
|
|
+ if (assetCustomCompanyMapper.selectCount(new QueryWrapper<AssetCustomCompany>().eq("assert_id", company.getId()).eq("custom_id", ide)) == 0) {
|
|
|
+ AssetCustomCompany assetCustomCompany = new AssetCustomCompany();
|
|
|
+ assetCustomCompany.setAssertId(company.getId());
|
|
|
+ assetCustomCompany.setCustomId(ide);
|
|
|
+ assetCustomCompanyMapper.insert(assetCustomCompany);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ msg.data = company;
|
|
|
}
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg pageList(PageUtil page, String keyName,Integer companyType) {
|
|
|
+ public HttpRespMsg pageList(PageUtil page, String keyName, Integer companyType) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
List<CompanyVO> list = new ArrayList<>();
|
|
|
System.out.println(page);
|
|
|
Integer start = (page.getPageNum() - 1) * page.getPageSize();
|
|
|
- if(companyType == 0){
|
|
|
- list = companyMapper.getListByKeyName(keyName, start, page.getPageSize(),companyType);
|
|
|
+ if (companyType == 0) {
|
|
|
+ list = companyMapper.getListByKeyName(keyName, start, page.getPageSize(), companyType);
|
|
|
Integer count = list.size();
|
|
|
page.setTotal(count);
|
|
|
page.setPages(page.getTotal());
|
|
|
- }else{
|
|
|
- list = companyMapper.getCustomerListByKeyName(keyName, start, page.getPageSize(),companyType);
|
|
|
+ } else {
|
|
|
+ list = companyMapper.getCustomerListByKeyName(keyName, start, page.getPageSize(), companyType);
|
|
|
Integer count = list.size();
|
|
|
page.setTotal(count);
|
|
|
page.setPages(page.getTotal());
|
|
@@ -192,7 +268,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|
|
set.add(projectUser.getProjectId());
|
|
|
}
|
|
|
}
|
|
|
- List<Mould> moulds = mouldMapper.selectList(new QueryWrapper<Mould>().in("project_id",set));
|
|
|
+ List<Mould> moulds = mouldMapper.selectList(new QueryWrapper<Mould>().in("project_id", set));
|
|
|
for (Mould mould : moulds) {
|
|
|
mouldIds.add(mould.getId());
|
|
|
}
|