|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.Constant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
@ -116,7 +117,7 @@ public class IcEnterpriseServiceImpl extends BaseServiceImpl<IcEnterpriseDao, Ic |
|
|
|
if (!staffInfo.getAgencyId().equals(origin.getAgencyId())) { |
|
|
|
AgencyInfoCache orginAgencyInfo = CustomerOrgRedis.getAgencyInfo(origin.getAgencyId()); |
|
|
|
String agencyName = null != orginAgencyInfo ? orginAgencyInfo.getOrganizationName() : StrConstant.EPMETY_STR; |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "", String.format("当前场所属于%s,您无权编辑", agencyName)); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "", String.format("修改失败,当前场所属于%s", agencyName)); |
|
|
|
} |
|
|
|
enterpriseEntity.setId(formDTO.getEnterpriseId()); |
|
|
|
baseDao.updateById(enterpriseEntity); |
|
|
@ -134,8 +135,6 @@ public class IcEnterpriseServiceImpl extends BaseServiceImpl<IcEnterpriseDao, Ic |
|
|
|
@Override |
|
|
|
public String addOrUpdatePatrol(EnterprisePatrolFormDTO formDTO) { |
|
|
|
IcEnterprisePatrolRecordEntity patrolRecordEntity=ConvertUtils.sourceToTarget(formDTO,IcEnterprisePatrolRecordEntity.class); |
|
|
|
//校验名称唯一
|
|
|
|
// todo
|
|
|
|
if(StringUtils.isBlank(formDTO.getPatrolId())){ |
|
|
|
enterprisePatrolRecordDao.insert(patrolRecordEntity); |
|
|
|
}else{ |
|
|
@ -157,7 +156,7 @@ public class IcEnterpriseServiceImpl extends BaseServiceImpl<IcEnterpriseDao, Ic |
|
|
|
sort++; |
|
|
|
} |
|
|
|
// 更新主表的最新结果和最新检查时间
|
|
|
|
baseDao.updateLatestPatrol(formDTO.getEnterpriseId(),patrolRecordEntity.getUpdatedTime(),patrolRecordEntity.getResult(),formDTO.getUserId()); |
|
|
|
baseDao.updateLatestPatrol(formDTO.getEnterpriseId(),patrolRecordEntity.getPatrolTime(),patrolRecordEntity.getResult(),formDTO.getUserId()); |
|
|
|
return patrolRecordEntity.getId(); |
|
|
|
} |
|
|
|
|
|
|
@ -169,10 +168,20 @@ public class IcEnterpriseServiceImpl extends BaseServiceImpl<IcEnterpriseDao, Ic |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public void delPatrol(String patrolId,String currentUserId) { |
|
|
|
IcEnterprisePatrolRecordEntity origin=enterprisePatrolRecordDao.selectById(patrolId); |
|
|
|
if(null==origin){ |
|
|
|
return; |
|
|
|
} |
|
|
|
//1、删除巡查记录
|
|
|
|
enterprisePatrolRecordDao.deleteById(patrolId); |
|
|
|
//2、删除之前的图片
|
|
|
|
enterprisePatrolAttachmentDao.deleteByPatrolId(patrolId,currentUserId); |
|
|
|
//3、如果是记录清空,那主表的最近一次巡查时间和最新结果也置空
|
|
|
|
LambdaQueryWrapper<IcEnterprisePatrolRecordEntity> queryWrapper=new LambdaQueryWrapper<>(); |
|
|
|
queryWrapper.eq(IcEnterprisePatrolRecordEntity::getEnterpriseId,origin.getEnterpriseId()); |
|
|
|
if (NumConstant.ZERO == enterprisePatrolRecordDao.selectCount(queryWrapper)) { |
|
|
|
baseDao.updateLatestPatrol(origin.getEnterpriseId(),null,StrConstant.EPMETY_STR,currentUserId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -234,10 +243,16 @@ public class IcEnterpriseServiceImpl extends BaseServiceImpl<IcEnterpriseDao, Ic |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public void delete(String enterpriseId) { |
|
|
|
//要删除的记录的agencyId要与当前登录用户的agencyId一致
|
|
|
|
//ToDo
|
|
|
|
baseDao.deleteById(enterpriseId); |
|
|
|
public void delete(String enterpriseId, String customerId, String userId) { |
|
|
|
//如果是编辑判断下权限要删除的记录的agencyId要与当前登录用户的agencyId一致
|
|
|
|
IcEnterpriseEntity origin = baseDao.selectById(enterpriseId); |
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, userId); |
|
|
|
if (!staffInfo.getAgencyId().equals(origin.getAgencyId())) { |
|
|
|
AgencyInfoCache orginAgencyInfo = CustomerOrgRedis.getAgencyInfo(origin.getAgencyId()); |
|
|
|
String agencyName = null != orginAgencyInfo ? orginAgencyInfo.getOrganizationName() : StrConstant.EPMETY_STR; |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "", String.format("删除失败,当前场所属于%s", agencyName)); |
|
|
|
} |
|
|
|
baseDao.deleteById(enterpriseId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|