|
@@ -1,18 +1,32 @@
|
|
|
package com.usky.fire.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.usky.common.core.bean.CommonPage;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
+import com.usky.common.security.utils.SecurityUtils;
|
|
|
import com.usky.fire.domain.BaseCompany;
|
|
|
+import com.usky.fire.domain.BaseCompanyAttach1;
|
|
|
+import com.usky.fire.domain.BaseCompanyPerson;
|
|
|
import com.usky.fire.mapper.BaseCompanyMapper;
|
|
|
+import com.usky.fire.service.BaseCompanyAttach1Service;
|
|
|
+import com.usky.fire.service.BaseCompanyPersonService;
|
|
|
import com.usky.fire.service.BaseCompanyService;
|
|
|
import com.usky.fire.service.BaseUserCompanyService;
|
|
|
+import com.usky.fire.service.vo.CompanyDataVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -28,6 +42,12 @@ public class BaseCompanyServiceImpl extends AbstractCrudService<BaseCompanyMappe
|
|
|
@Autowired
|
|
|
private BaseUserCompanyService baseUserCompanyService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BaseCompanyPersonService baseCompanyPersonService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BaseCompanyAttach1Service baseCompanyAttach1Service;
|
|
|
+
|
|
|
@Override
|
|
|
public List<BaseCompany> userCompanySelect() {
|
|
|
List<String> companyIdList = baseUserCompanyService.companyIdList();
|
|
@@ -44,19 +64,153 @@ public class BaseCompanyServiceImpl extends AbstractCrudService<BaseCompanyMappe
|
|
|
LambdaQueryWrapper<BaseCompany> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.select(BaseCompany::getCompanyId, BaseCompany::getCompanyName)
|
|
|
.in(BaseCompany::getCompanyId, companyIdList)
|
|
|
- .eq(BaseCompany::getEnable, 1)
|
|
|
+ .eq(BaseCompany::getEnable, 0)
|
|
|
.orderByDesc(BaseCompany::getId);
|
|
|
List<BaseCompany> list = this.list(queryWrapper);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<BaseCompany> companyIdList(){
|
|
|
+ public List<BaseCompany> companyIdList() {
|
|
|
LambdaQueryWrapper<BaseCompany> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.select(BaseCompany::getCompanyId)
|
|
|
- .eq(BaseCompany::getEnable, 1);
|
|
|
+ .eq(BaseCompany::getEnable, 0);
|
|
|
List<BaseCompany> list = this.list(queryWrapper);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonPage<Object> companyList(String companyName, String organization, Integer pageNum, Integer pageSize) {
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
+ IPage<BaseCompany> page = new Page<>(pageNum, pageSize);
|
|
|
+ LambdaQueryWrapper<BaseCompany> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.select(BaseCompany::getId, BaseCompany::getCompanyId, BaseCompany::getCompanyName, BaseCompany::getOrganization,
|
|
|
+ BaseCompany::getAddress, BaseCompany::getCompanyType, BaseCompany::getFireHazard, BaseCompany::getLinkPhone,
|
|
|
+ BaseCompany::getFoundTime, BaseCompany::getCompanyNature, BaseCompany::getAdministrativeDivision)
|
|
|
+ .eq(BaseCompany::getEnable, 0)
|
|
|
+ .like(StringUtils.isNotBlank(companyName), BaseCompany::getCompanyName, companyName)
|
|
|
+ .like(StringUtils.isNotBlank(organization), BaseCompany::getOrganization, organization)
|
|
|
+ .orderByDesc(BaseCompany::getId);
|
|
|
+ page = this.page(page, queryWrapper);
|
|
|
+ if (page.getTotal() > 0) {
|
|
|
+ List<String> companyIdList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < page.getRecords().size(); i++) {
|
|
|
+ companyIdList.add(page.getRecords().get(i).getCompanyId());
|
|
|
+ }
|
|
|
+ List<BaseCompanyPerson> list1 = new ArrayList<>();
|
|
|
+ List<BaseCompanyAttach1> list2 = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(companyIdList)) {
|
|
|
+ LambdaQueryWrapper<BaseCompanyPerson> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.select(BaseCompanyPerson::getId, BaseCompanyPerson::getCompanyId, BaseCompanyPerson::getFireDutyName,
|
|
|
+ BaseCompanyPerson::getFireManageName, BaseCompanyPerson::getDelegateName)
|
|
|
+ .in(BaseCompanyPerson::getCompanyId, companyIdList);
|
|
|
+ list1 = baseCompanyPersonService.list(queryWrapper1);
|
|
|
+ LambdaQueryWrapper<BaseCompanyAttach1> queryWrapper2 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper2.select(BaseCompanyAttach1::getId, BaseCompanyAttach1::getCompanyId, BaseCompanyAttach1::getFixedAssets,
|
|
|
+ BaseCompanyAttach1::getCoverArea, BaseCompanyAttach1::getBuildArea, BaseCompanyAttach1::getEmployeeNum,
|
|
|
+ BaseCompanyAttach1::getMainAttribute, BaseCompanyAttach1::getGovernBody)
|
|
|
+ .in(BaseCompanyAttach1::getCompanyId, companyIdList);
|
|
|
+ list2 = baseCompanyAttach1Service.list(queryWrapper2);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < page.getRecords().size(); i++) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("id", page.getRecords().get(i).getId());
|
|
|
+ map.put("companyName", page.getRecords().get(i).getCompanyName());
|
|
|
+ map.put("organization", page.getRecords().get(i).getOrganization());
|
|
|
+ map.put("delegateName", null);
|
|
|
+ map.put("address", page.getRecords().get(i).getAddress());
|
|
|
+ map.put("companyType", page.getRecords().get(i).getCompanyType());
|
|
|
+ map.put("fireHazard", page.getRecords().get(i).getFireHazard());
|
|
|
+ map.put("linkPhone", page.getRecords().get(i).getLinkPhone());
|
|
|
+ map.put("foundTime", page.getRecords().get(i).getFoundTime());
|
|
|
+ map.put("companyNature", page.getRecords().get(i).getCompanyNature());
|
|
|
+ map.put("administrativeDivision", page.getRecords().get(i).getAdministrativeDivision());
|
|
|
+ map.put("fixedAssets", null);
|
|
|
+ map.put("coverArea", null);
|
|
|
+ map.put("buildArea", null);
|
|
|
+ map.put("employeeNum", null);
|
|
|
+ map.put("mainAttribute", null);
|
|
|
+ map.put("governBody", null);
|
|
|
+ map.put("id2", null);
|
|
|
+ map.put("id1", null);
|
|
|
+ map.put("fireDutyName", null);
|
|
|
+ map.put("fireManageName", null);
|
|
|
+ for (int j = 0; j < list1.size(); j++) {
|
|
|
+ if (page.getRecords().get(i).getCompanyId().equals(list1.get(j).getCompanyId())) {
|
|
|
+ map.put("id1", list1.get(j).getId());
|
|
|
+ map.put("fireDutyName", list1.get(j).getFireDutyName());
|
|
|
+ map.put("fireManageName", list1.get(j).getFireManageName());
|
|
|
+ map.put("delegateName", list1.get(j).getDelegateName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (int j = 0; j < list2.size(); j++) {
|
|
|
+ if (page.getRecords().get(i).getCompanyId().equals(list2.get(j).getCompanyId())) {
|
|
|
+ map.put("fixedAssets", list2.get(j).getFixedAssets());
|
|
|
+ map.put("coverArea", list2.get(j).getCoverArea());
|
|
|
+ map.put("buildArea", list2.get(j).getBuildArea());
|
|
|
+ map.put("employeeNum", list2.get(j).getEmployeeNum());
|
|
|
+ map.put("mainAttribute", list2.get(j).getMainAttribute());
|
|
|
+ map.put("governBody", list2.get(j).getGovernBody());
|
|
|
+ map.put("id2", list2.get(j).getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("createTime", page.getRecords().get(i).getCreateTime());
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new CommonPage<>(list, page.getTotal(), pageSize, pageNum);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void updateCompany(CompanyDataVo companyDataVo) {
|
|
|
+ BaseCompany baseCompany = new BaseCompany();
|
|
|
+ baseCompany.setId(companyDataVo.getId());
|
|
|
+ baseCompany.setCompanyName(companyDataVo.getCompanyName());
|
|
|
+ baseCompany.setOrganization(companyDataVo.getOrganization());
|
|
|
+ baseCompany.setAddress(companyDataVo.getAddress());
|
|
|
+ baseCompany.setCompanyType(companyDataVo.getCompanyType());
|
|
|
+ baseCompany.setFireHazard(companyDataVo.getFireHazard());
|
|
|
+ baseCompany.setLinkPerson(companyDataVo.getLinkPhone());
|
|
|
+ baseCompany.setFoundTime(companyDataVo.getFoundTime());
|
|
|
+ baseCompany.setCompanyNature(companyDataVo.getCompanyNature());
|
|
|
+ baseCompany.setAdministrativeDivision(companyDataVo.getAdministrativeDivision());
|
|
|
+ baseCompany.setUpdatePerson(SecurityUtils.getUsername());
|
|
|
+ baseCompany.setUpdateTime(LocalDateTime.now());
|
|
|
+ this.updateById(baseCompany);
|
|
|
+ BaseCompanyPerson baseCompanyPerson = new BaseCompanyPerson();
|
|
|
+ baseCompanyPerson.setId(companyDataVo.getId1());
|
|
|
+ baseCompanyPerson.setCompanyName(companyDataVo.getCompanyName());
|
|
|
+ baseCompanyPerson.setFireDutyName(companyDataVo.getFireDutyName());
|
|
|
+ baseCompanyPerson.setFireManageName(companyDataVo.getFireManageName());
|
|
|
+ baseCompanyPerson.setDelegateName(companyDataVo.getDelegateName());
|
|
|
+ baseCompanyPerson.setUpdatePerson(SecurityUtils.getUsername());
|
|
|
+ baseCompanyPerson.setUpdateTime(LocalDateTime.now());
|
|
|
+ baseCompanyPersonService.updateById(baseCompanyPerson);
|
|
|
+ BaseCompanyAttach1 baseCompanyAttach1 = new BaseCompanyAttach1();
|
|
|
+ baseCompanyAttach1.setId(companyDataVo.getId2());
|
|
|
+ baseCompanyAttach1.setFixedAssets(companyDataVo.getFixedAssets());
|
|
|
+ baseCompanyAttach1.setCoverArea(companyDataVo.getCoverArea());
|
|
|
+ baseCompanyAttach1.setBuildArea(companyDataVo.getBuildArea());
|
|
|
+ baseCompanyAttach1.setEmployeeNum(companyDataVo.getEmployeeNum());
|
|
|
+ baseCompanyAttach1.setMainAttribute(companyDataVo.getMainAttribute());
|
|
|
+ baseCompanyAttach1.setGovernBody(companyDataVo.getGovernBody());
|
|
|
+ baseCompanyAttach1.setUpdatePerson(SecurityUtils.getUsername());
|
|
|
+ baseCompanyAttach1.setUpdateTime(LocalDateTime.now());
|
|
|
+ baseCompanyAttach1Service.updateById(baseCompanyAttach1);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delCompany(Integer id) {
|
|
|
+ BaseCompany baseCompany = new BaseCompany();
|
|
|
+ baseCompany.setId(id);
|
|
|
+ baseCompany.setEnable("1");
|
|
|
+ baseCompany.setUpdateTime(LocalDateTime.now());
|
|
|
+ baseCompany.setUpdatePerson(SecurityUtils.getUsername());
|
|
|
+ this.updateById(baseCompany);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|