|
@@ -6,12 +6,12 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.usky.common.core.exception.BusinessException;
|
|
|
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.PatrolInspectionArea;
|
|
|
import com.usky.fire.mapper.PatrolInspectionAreaMapper;
|
|
|
import com.usky.fire.service.BaseCompanyService;
|
|
|
import com.usky.fire.service.PatrolInspectionAreaService;
|
|
|
import com.usky.fire.service.vo.PatrolInspectionAreaVo;
|
|
|
+import com.usky.system.RemoteDeptService;
|
|
|
import com.usky.system.model.LoginUser;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -35,6 +36,9 @@ public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolI
|
|
|
@Autowired
|
|
|
private BaseCompanyService baseCompanyService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RemoteDeptService remoteDeptService;
|
|
|
+
|
|
|
/**
|
|
|
* 巡查自检-巡检区域-新增
|
|
|
*
|
|
@@ -45,6 +49,7 @@ public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolI
|
|
|
public void addPatrolInspectionArea(PatrolInspectionAreaVo patrolInspectionAreaVo) {
|
|
|
LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(PatrolInspectionArea::getEnable, 1)
|
|
|
+ .eq(PatrolInspectionArea::getDeptId, patrolInspectionAreaVo.getDeptId())
|
|
|
.eq(PatrolInspectionArea::getAreaName, patrolInspectionAreaVo.getAreaName());
|
|
|
List<PatrolInspectionArea> list = this.list(queryWrapper);
|
|
|
if (list.size() > 0) {
|
|
@@ -53,7 +58,7 @@ public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolI
|
|
|
PatrolInspectionArea patrolInspectionArea = new PatrolInspectionArea();
|
|
|
patrolInspectionArea.setAreaName(patrolInspectionAreaVo.getAreaName());
|
|
|
patrolInspectionArea.setAreaFid(0);
|
|
|
- patrolInspectionArea.setCompanyId(patrolInspectionAreaVo.getCompanyId());
|
|
|
+ patrolInspectionArea.setDeptId(patrolInspectionAreaVo.getDeptId());
|
|
|
patrolInspectionArea.setCreator(SecurityUtils.getUsername());
|
|
|
patrolInspectionArea.setCreateTime(LocalDateTime.now());
|
|
|
patrolInspectionArea.setEnable(1);
|
|
@@ -72,7 +77,7 @@ public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolI
|
|
|
PatrolInspectionArea patrolInspectionAreaZ = new PatrolInspectionArea();
|
|
|
patrolInspectionAreaZ.setAreaName(patrolInspectionAreaVo.getAreaNameArray()[i]);
|
|
|
patrolInspectionAreaZ.setAreaFid(areaFid);
|
|
|
- patrolInspectionAreaZ.setCompanyId(patrolInspectionAreaVo.getCompanyId());
|
|
|
+ patrolInspectionAreaZ.setDeptId(patrolInspectionAreaVo.getDeptId());
|
|
|
patrolInspectionAreaZ.setCreator(SecurityUtils.getUsername());
|
|
|
patrolInspectionAreaZ.setCreateTime(LocalDateTime.now());
|
|
|
patrolInspectionAreaZ.setEnable(1);
|
|
@@ -98,7 +103,7 @@ public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolI
|
|
|
if (list2.size() > 0) {
|
|
|
throw new BusinessException("区域名称不可重复");
|
|
|
}
|
|
|
- patrolInspectionArea.setCompanyId(list.get(0).getCompanyId());
|
|
|
+ patrolInspectionArea.setDeptId(list.get(0).getDeptId());
|
|
|
patrolInspectionArea.setCreator(SecurityUtils.getUsername());
|
|
|
patrolInspectionArea.setCreateTime(LocalDateTime.now());
|
|
|
patrolInspectionArea.setEnable(1);
|
|
@@ -123,7 +128,8 @@ public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolI
|
|
|
queryWrapperTwo.select(PatrolInspectionArea::getAreaFid)
|
|
|
.eq(PatrolInspectionArea::getAreaFid, patrolInspectionAreaMap.getAreaFid())
|
|
|
.eq(PatrolInspectionArea::getAreaName, patrolInspectionArea.getAreaName())
|
|
|
- .eq(PatrolInspectionArea::getEnable, 1);
|
|
|
+ .eq(PatrolInspectionArea::getEnable, 1)
|
|
|
+ .ne(PatrolInspectionArea::getId,patrolInspectionArea.getId());
|
|
|
List<PatrolInspectionArea> list1 = this.list(queryWrapperTwo);
|
|
|
if (list1.size() > 0) {
|
|
|
throw new BusinessException(patrolInspectionArea.getAreaName() + "重复,区域不可以重复");
|
|
@@ -136,7 +142,7 @@ public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolI
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
PatrolInspectionArea patrolInspectionAreaSon = new PatrolInspectionArea();
|
|
|
patrolInspectionAreaSon.setId(list.get(i).getId());
|
|
|
- patrolInspectionAreaSon.setCompanyId(patrolInspectionArea.getCompanyId());
|
|
|
+ patrolInspectionAreaSon.setDeptId(patrolInspectionArea.getDeptId());
|
|
|
this.updateById(patrolInspectionAreaSon);
|
|
|
}
|
|
|
}
|
|
@@ -195,11 +201,11 @@ public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolI
|
|
|
queryWrapper.orderByDesc(PatrolInspectionArea::getId);
|
|
|
List<PatrolInspectionArea> list = this.list(queryWrapper);
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
- List<BaseCompany> companyList = baseCompanyService.userCompanySelect();
|
|
|
+ List<Map<String, Object>> deptList = remoteDeptService.getDeptList(SecurityUtils.getTenantId());
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
- for (int j = 0; j < companyList.size(); j++) {
|
|
|
- if (list.get(i).getCompanyId().equals(companyList.get(j).getCompanyId())) {
|
|
|
- list.get(i).setCompanyName(companyList.get(j).getCompanyName());
|
|
|
+ for (int j = 0; j < deptList.size(); j++) {
|
|
|
+ if (list.get(i).getDeptId().equals(deptList.get(j).get("dept_id"))) {
|
|
|
+ list.get(i).setCompanyName(deptList.get(j).get("dept_name").toString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -232,9 +238,9 @@ public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolI
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Integer> areaIdList(String companyId){
|
|
|
+ public List<Integer> areaIdList(Integer deptId){
|
|
|
LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.eq(PatrolInspectionArea::getCompanyId, companyId)
|
|
|
+ queryWrapper.eq(PatrolInspectionArea::getDeptId, deptId)
|
|
|
.eq(PatrolInspectionArea::getEnable, 1);
|
|
|
List<PatrolInspectionArea> list = this.list(queryWrapper);
|
|
|
List<Integer> areaIdList = new ArrayList<>();
|