|
@@ -1,10 +1,21 @@
|
|
|
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.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.PatrolInspectionArea;
|
|
|
import com.usky.fire.mapper.PatrolInspectionAreaMapper;
|
|
|
import com.usky.fire.service.PatrolInspectionAreaService;
|
|
|
+import com.usky.fire.service.vo.PatrolInspectionAreaVo;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -17,4 +28,111 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolInspectionAreaMapper, PatrolInspectionArea> implements PatrolInspectionAreaService {
|
|
|
|
|
|
+ /**
|
|
|
+ * 巡查自检-巡检区域-新增
|
|
|
+ *
|
|
|
+ * @param patrolInspectionAreaVo
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void addPatrolInspectionArea(PatrolInspectionAreaVo patrolInspectionAreaVo) {
|
|
|
+ PatrolInspectionArea patrolInspectionArea = new PatrolInspectionArea();
|
|
|
+ patrolInspectionArea.setAreaName(patrolInspectionAreaVo.getAreaName());
|
|
|
+ patrolInspectionArea.setAreaFid(0);
|
|
|
+ patrolInspectionArea.setCompanyId(patrolInspectionAreaVo.getCompanyId());
|
|
|
+ patrolInspectionArea.setCreator(SecurityUtils.getUsername());
|
|
|
+ patrolInspectionArea.setCreateTime(LocalDateTime.now());
|
|
|
+ patrolInspectionArea.setEnable(1);
|
|
|
+ patrolInspectionArea.setTenantId(SecurityUtils.getTenantId());
|
|
|
+ this.save(patrolInspectionArea);
|
|
|
+ Integer areaFid = patrolInspectionArea.getId();
|
|
|
+ for (int i = 0; i < patrolInspectionAreaVo.getAreaNameArray().length; i++) {
|
|
|
+ PatrolInspectionArea patrolInspectionAreaZ = new PatrolInspectionArea();
|
|
|
+ patrolInspectionAreaZ.setAreaName(patrolInspectionAreaVo.getAreaNameArray()[i]);
|
|
|
+ patrolInspectionAreaZ.setAreaFid(areaFid);
|
|
|
+ patrolInspectionAreaZ.setCompanyId(patrolInspectionAreaVo.getCompanyId());
|
|
|
+ patrolInspectionAreaZ.setCreator(SecurityUtils.getUsername());
|
|
|
+ patrolInspectionAreaZ.setCreateTime(LocalDateTime.now());
|
|
|
+ patrolInspectionAreaZ.setEnable(1);
|
|
|
+ patrolInspectionAreaZ.setTenantId(SecurityUtils.getTenantId());
|
|
|
+ this.save(patrolInspectionAreaZ);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 巡查自检-巡检区域-编辑
|
|
|
+ *
|
|
|
+ * @param patrolInspectionArea
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void updatePatrolInspectionArea(PatrolInspectionArea patrolInspectionArea) {
|
|
|
+ this.updateById(patrolInspectionArea);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 巡查自检-巡检区域-删除
|
|
|
+ *
|
|
|
+ * @param id 区域ID
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void delPatrolInspectionArea(Integer id) {
|
|
|
+ LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(PatrolInspectionArea::getEnable, 1).eq(PatrolInspectionArea::getAreaFid,id);
|
|
|
+ List<PatrolInspectionArea> patrolInspectionArealist = this.list(queryWrapper);
|
|
|
+ if (null!=patrolInspectionArealist&&!patrolInspectionArealist.isEmpty()){
|
|
|
+ for (int i=0;i<patrolInspectionArealist.size();i++){
|
|
|
+ PatrolInspectionArea patrolInspectionAreaz = new PatrolInspectionArea();
|
|
|
+ patrolInspectionAreaz.setId(patrolInspectionArealist.get(i).getId());
|
|
|
+ patrolInspectionAreaz.setEnable(0);
|
|
|
+ this.updateById(patrolInspectionAreaz);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PatrolInspectionArea patrolInspectionArea = new PatrolInspectionArea();
|
|
|
+ patrolInspectionArea.setId(id);
|
|
|
+ patrolInspectionArea.setEnable(0);
|
|
|
+ this.updateById(patrolInspectionArea);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 巡查自检-巡检区域-列表查詢
|
|
|
+ * @param id 区域ID
|
|
|
+ * @param areaName 区域名称
|
|
|
+ * @param pageNum 当前页
|
|
|
+ * @param pageSize 每页条数
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public CommonPage<PatrolInspectionArea> patrolInspectionAreaList(Integer id, String areaName, Integer pageNum, Integer pageSize) {
|
|
|
+ IPage<PatrolInspectionArea> page = new Page<PatrolInspectionArea>(pageNum, pageSize);
|
|
|
+ LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(PatrolInspectionArea::getTenantId, SecurityUtils.getTenantId())
|
|
|
+ .eq(PatrolInspectionArea::getEnable, 1);
|
|
|
+ if (id != null && id != 0) {
|
|
|
+ queryWrapper.eq(PatrolInspectionArea::getId, id);
|
|
|
+ }
|
|
|
+ if (!"".equals(areaName) && areaName != null) {
|
|
|
+ queryWrapper.eq(PatrolInspectionArea::getAreaName, areaName);
|
|
|
+ }
|
|
|
+ queryWrapper.orderByDesc(PatrolInspectionArea::getId);
|
|
|
+ Integer total = this.list(queryWrapper).size();
|
|
|
+ page = this.page(page, queryWrapper);
|
|
|
+ this.ToCommonPage(page);
|
|
|
+ return new CommonPage<>(page.getRecords(), total, page.getSize(), page.getCurrent());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 巡查自检-巡检区域-一级区域下拉框
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<PatrolInspectionArea> patrolInspectionAreaSelect(){
|
|
|
+ LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(PatrolInspectionArea::getTenantId, SecurityUtils.getTenantId())
|
|
|
+ .eq(PatrolInspectionArea::getEnable, 1).eq(PatrolInspectionArea::getAreaFid,0)
|
|
|
+ .orderByDesc(PatrolInspectionArea::getId);
|
|
|
+ return this.list(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|