|
@@ -14,20 +14,14 @@ import com.usky.fire.domain.*;
|
|
|
import com.usky.fire.mapper.BaseCompanyMapper;
|
|
|
import com.usky.fire.service.*;
|
|
|
import com.usky.fire.service.util.OnlineMethod;
|
|
|
-import com.usky.fire.service.vo.BaseCompanyExportVO;
|
|
|
-import com.usky.fire.service.vo.CompanyDataVo;
|
|
|
-import com.usky.fire.service.vo.CompanyExportVO;
|
|
|
-import com.usky.fire.service.vo.LocateInfo;
|
|
|
+import com.usky.fire.service.vo.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -58,6 +52,12 @@ public class BaseCompanyServiceImpl extends AbstractCrudService<BaseCompanyMappe
|
|
|
@Autowired
|
|
|
private DemEnforceReportComplaintService demEnforceReportComplaintService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BaseCompanyChangeService baseCompanyChangeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BaseBuildService baseBuildService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<BaseCompany> userCompanySelect() {
|
|
|
List<String> companyIdList = baseUserCompanyService.companyIdList();
|
|
@@ -803,6 +803,170 @@ public class BaseCompanyServiceImpl extends AbstractCrudService<BaseCompanyMappe
|
|
|
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void addBaseCompany(CompanyAddVO companyAddVO) {
|
|
|
+ BaseCompany baseCompany = companyAddVO.getBaseCompany();
|
|
|
+ BaseCompanyAttach1 baseCompanyAttach1 = companyAddVO.getBaseCompanyAttach1();
|
|
|
+ BaseCompanyPerson baseCompanyPerson = companyAddVO.getBaseCompanyPerson();
|
|
|
+ List<BaseBuild> list;
|
|
|
+ list = companyAddVO.getBaseBuildList();
|
|
|
+ if (StringUtils.isNotBlank(baseCompany.getCompanyId())) {
|
|
|
+ LambdaQueryWrapper<BaseCompany> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.select(BaseCompany::getCompanyId,BaseCompany::getOrganization,BaseCompany::getCompanyName,
|
|
|
+ BaseCompany::getAddress,BaseCompany::getFoundTime)
|
|
|
+ .eq(BaseCompany::getCompanyId, baseCompany.getCompanyId())
|
|
|
+ .eq(BaseCompany::getEnable, 0)
|
|
|
+ .orderByDesc(BaseCompany::getId);
|
|
|
+ List<BaseCompany> list1 = this.list(queryWrapper);
|
|
|
+ if (CollectionUtils.isNotEmpty(list1)) {
|
|
|
+ List<String> companyIdList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < list1.size(); i++) {
|
|
|
+ companyIdList.add(list1.get(i).getCompanyId());
|
|
|
+ }
|
|
|
+ List<BaseCompanyAttach1> list2 = new ArrayList<>();
|
|
|
+ List<BaseCompanyPerson> list3 = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(companyIdList)) {
|
|
|
+ LambdaQueryWrapper<BaseCompanyAttach1> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.select(BaseCompanyAttach1::getId, BaseCompanyAttach1::getEmployeeNum,
|
|
|
+ BaseCompanyAttach1::getBuildArea, BaseCompanyAttach1::getCoverArea, BaseCompanyAttach1::getFixedAssets,
|
|
|
+ BaseCompanyAttach1::getCompanyId)
|
|
|
+ .in(BaseCompanyAttach1::getCompanyId, companyIdList);
|
|
|
+ list2 = baseCompanyAttach1Service.list(queryWrapper1);
|
|
|
+ LambdaQueryWrapper<BaseCompanyPerson> queryWrapper2 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper2.select(BaseCompanyPerson::getId, BaseCompanyPerson::getDelegateName, BaseCompanyPerson::getFireDutyName,
|
|
|
+ BaseCompanyPerson::getFireManageName,BaseCompanyPerson::getFireManagePhone,
|
|
|
+ BaseCompanyPerson::getCompanyId)
|
|
|
+ .in(BaseCompanyPerson::getCompanyId, companyIdList);
|
|
|
+ list3 = baseCompanyPersonService.list(queryWrapper2);
|
|
|
+ }
|
|
|
+ for (int i = 0; i < list1.size(); i++) {
|
|
|
+ BaseCompanyChange baseCompanyChange = new BaseCompanyChange();
|
|
|
+ baseCompanyChange.setCompanyId(list1.get(i).getCompanyId());
|
|
|
+ baseCompanyChange.setCompanyName(list1.get(i).getCompanyName());
|
|
|
+ baseCompanyChange.setOrganization(list1.get(i).getOrganization());
|
|
|
+ baseCompanyChange.setAddress(list1.get(i).getAddress());
|
|
|
+ baseCompanyChange.setFoundTime(list1.get(i).getFoundTime());
|
|
|
+ for (int j = 0; j < list2.size(); j++) {
|
|
|
+ if (list1.get(i).getCompanyId().equals(list2.get(j).getCompanyId())) {
|
|
|
+ baseCompanyChange.setEmployeeNum(list2.get(j).getEmployeeNum());
|
|
|
+ baseCompanyChange.setCoverArea(list2.get(j).getCoverArea());
|
|
|
+ baseCompanyChange.setBuildArea(list2.get(j).getBuildArea());
|
|
|
+ baseCompanyChange.setFixedAssets(list2.get(j).getFixedAssets());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (int j = 0; j < list3.size(); j++) {
|
|
|
+ if (list1.get(i).getCompanyId().equals(list3.get(j).getCompanyId())) {
|
|
|
+ baseCompanyChange.setDelegateName(list3.get(j).getDelegateName());
|
|
|
+ baseCompanyChange.setFireDutyName(list3.get(j).getFireDutyName());
|
|
|
+ baseCompanyChange.setFireManageName(list3.get(j).getFireManageName());
|
|
|
+ baseCompanyChange.setFireManagePhone(list3.get(j).getFireManagePhone());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ baseCompanyChangeService.baseCompanyChangeAdd(baseCompanyChange);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.updateById(baseCompany);
|
|
|
+ baseCompanyAttach1Service.updateById(baseCompanyAttach1);
|
|
|
+ baseCompanyPersonService.updateById(baseCompanyPerson);
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ for (int j = 0; j < list.size(); j++) {
|
|
|
+ BaseBuild baseBuild;
|
|
|
+ baseBuild = list.get(j);
|
|
|
+ baseBuild.setCreateTime(LocalDateTime.now());
|
|
|
+ baseBuild.setCreator("123");
|
|
|
+ baseBuild.setCompanyId(baseCompany.getCompanyId());
|
|
|
+ baseBuild.setDeleteFlag("0");
|
|
|
+ baseBuildService.save(baseBuild);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ UUID uuid = UUID.randomUUID();
|
|
|
+ String uuidStr = uuid.toString();
|
|
|
+ baseCompany.setCompanyId(uuidStr.replaceAll("-",""));
|
|
|
+ baseCompany.setEnable("0");
|
|
|
+ this.save(baseCompany);
|
|
|
+ baseCompanyAttach1.setCompanyId(uuidStr.replaceAll("-",""));
|
|
|
+ baseCompanyAttach1Service.save(baseCompanyAttach1);
|
|
|
+ baseCompanyPerson.setCompanyId(uuidStr.replaceAll("-",""));
|
|
|
+ baseCompanyPersonService.save(baseCompanyPerson);
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ for (int j = 0; j < list.size(); j++) {
|
|
|
+ BaseBuild baseBuild;
|
|
|
+ baseBuild = list.get(j);
|
|
|
+ baseBuild.setCreateTime(LocalDateTime.now());
|
|
|
+ baseBuild.setCreator("123");
|
|
|
+ baseBuild.setCompanyId(uuidStr.replaceAll("-",""));
|
|
|
+ baseBuild.setDeleteFlag("0");
|
|
|
+ baseBuildService.save(baseBuild);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<CompanyDataVo> companyByNameSelect(String companyName) {
|
|
|
+ List<CompanyDataVo> list = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<BaseCompany> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.select(BaseCompany::getCompanyId,BaseCompany::getOrganization,BaseCompany::getCompanyName,
|
|
|
+ BaseCompany::getAddress,BaseCompany::getFoundTime)
|
|
|
+ .like(StringUtils.isNotBlank(companyName),BaseCompany::getCompanyName, companyName)
|
|
|
+ .eq(BaseCompany::getEnable, 0)
|
|
|
+ .orderByDesc(BaseCompany::getId);
|
|
|
+ List<BaseCompany> list1 = this.list(queryWrapper);
|
|
|
+ if (CollectionUtils.isNotEmpty(list1)) {
|
|
|
+ List<String> companyIdList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < list1.size(); i++) {
|
|
|
+ companyIdList.add(list1.get(i).getCompanyId());
|
|
|
+ }
|
|
|
+ List<BaseCompanyAttach1> list2 = new ArrayList<>();
|
|
|
+ List<BaseCompanyPerson> list3 = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(companyIdList)) {
|
|
|
+ LambdaQueryWrapper<BaseCompanyAttach1> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.select(BaseCompanyAttach1::getId, BaseCompanyAttach1::getEmployeeNum,
|
|
|
+ BaseCompanyAttach1::getBuildArea, BaseCompanyAttach1::getCoverArea, BaseCompanyAttach1::getFixedAssets,
|
|
|
+ BaseCompanyAttach1::getCompanyId)
|
|
|
+ .in(BaseCompanyAttach1::getCompanyId, companyIdList);
|
|
|
+ list2 = baseCompanyAttach1Service.list(queryWrapper1);
|
|
|
+ LambdaQueryWrapper<BaseCompanyPerson> queryWrapper2 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper2.select(BaseCompanyPerson::getId, BaseCompanyPerson::getDelegateName, BaseCompanyPerson::getFireDutyName,
|
|
|
+ BaseCompanyPerson::getFireManageName,BaseCompanyPerson::getFireManagePhone,
|
|
|
+ BaseCompanyPerson::getCompanyId)
|
|
|
+ .in(BaseCompanyPerson::getCompanyId, companyIdList);
|
|
|
+ list3 = baseCompanyPersonService.list(queryWrapper2);
|
|
|
+ }
|
|
|
+ for (int i = 0; i < list1.size(); i++) {
|
|
|
+ CompanyDataVo companyDataVo = new CompanyDataVo();
|
|
|
+ companyDataVo.setId(list1.get(i).getId());
|
|
|
+ companyDataVo.setCompanyId(list1.get(i).getCompanyId());
|
|
|
+ companyDataVo.setCompanyName(list1.get(i).getCompanyName());
|
|
|
+ companyDataVo.setOrganization(list1.get(i).getOrganization());
|
|
|
+ companyDataVo.setAddress(list1.get(i).getAddress());
|
|
|
+ companyDataVo.setFoundTime(list1.get(i).getFoundTime());
|
|
|
+ for (int j = 0; j < list2.size(); j++) {
|
|
|
+ if (list1.get(i).getCompanyId().equals(list2.get(j).getCompanyId())) {
|
|
|
+ companyDataVo.setId1(list2.get(j).getId());
|
|
|
+ companyDataVo.setEmployeeNum(list2.get(j).getEmployeeNum());
|
|
|
+ companyDataVo.setCoverArea(list2.get(j).getCoverArea());
|
|
|
+ companyDataVo.setBuildArea(list2.get(j).getBuildArea());
|
|
|
+ companyDataVo.setFixedAssets(list2.get(j).getFixedAssets());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (int j = 0; j < list3.size(); j++) {
|
|
|
+ if (list1.get(i).getCompanyId().equals(list3.get(j).getCompanyId())) {
|
|
|
+ companyDataVo.setId2(list3.get(j).getId());
|
|
|
+ companyDataVo.setDelegateName(list3.get(j).getDelegateName());
|
|
|
+ companyDataVo.setFireDutyName(list3.get(j).getFireDutyName());
|
|
|
+ companyDataVo.setFireManageName(list3.get(j).getFireManageName());
|
|
|
+ companyDataVo.setFireManagePhone(list3.get(j).getFireManagePhone());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list.add(companyDataVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|