Browse Source

最新巡查时间

master
yinzuomei 3 years ago
parent
commit
32e319716c
  1. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcEnterpriseController.java
  2. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcEnterpriseService.java
  3. 31
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcEnterpriseServiceImpl.java
  4. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPlaceOrgServiceImpl.java
  5. 2
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcEnterpriseDao.xml

4
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcEnterpriseController.java

@ -159,8 +159,8 @@ public class IcEnterpriseController implements ResultDataResolver {
* @return
*/
@PostMapping("delete/{enterpriseId}")
public Result delete(@PathVariable("enterpriseId") String enterpriseId) {
icEnterpriseService.delete(enterpriseId);
public Result delete(@LoginUser TokenDto tokenDto,@PathVariable("enterpriseId") String enterpriseId) {
icEnterpriseService.delete(enterpriseId,tokenDto.getCustomerId(),tokenDto.getUserId());
return new Result();
}

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcEnterpriseService.java

@ -58,7 +58,7 @@ public interface IcEnterpriseService extends BaseService<IcEnterpriseEntity> {
* @param enterpriseId
* @return
*/
void delete(String enterpriseId);
void delete(String enterpriseId,String customerId,String userId);
/**
* 企事业单位列表

31
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcEnterpriseServiceImpl.java

@ -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);
}
/**

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPlaceOrgServiceImpl.java

@ -93,7 +93,7 @@ public class IcPlaceOrgServiceImpl extends BaseServiceImpl<IcPlaceOrgDao, IcPlac
if (!staffInfo.getAgencyId().equals(entity.getAgencyId())) {
AgencyInfoCache agencyInfoCache = CustomerOrgRedis.getAgencyInfo(entity.getAgencyId());
String agencyName = null != agencyInfoCache ? agencyInfoCache.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));
}
entity = ConvertUtils.sourceToTarget(formDTO, IcPlaceOrgEntity.class);
entity.setId(formDTO.getPlaceOrgId());

2
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcEnterpriseDao.xml

@ -31,7 +31,7 @@
update ic_enterprise
set LATEST_RESULT = #{result},
UPDATED_BY = #{userId},
UPDATED_TIME=NOW(),
UPDATED_TIME = NOW(),
LATEST_PATROL_TIME = #{updatedTime}
WHERE ID = #{enterpriseId}
</update>

Loading…
Cancel
Save