|
|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.thing.eq.eqby.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.map.MapUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.mybatisflex.core.paginate.Page; |
|
|
|
@ -23,7 +24,6 @@ import com.thing.eq.utils.SerialNumberUnit; |
|
|
|
import com.thing.sys.biz.dto.SysDictTypeListDTO; |
|
|
|
import com.thing.sys.biz.entity.SysDeptEntity; |
|
|
|
import com.thing.sys.biz.entity.SysDictDataEntity; |
|
|
|
import com.thing.sys.biz.entity.SysDictTypeEntity; |
|
|
|
import com.thing.sys.biz.entity.SysUserEntity; |
|
|
|
import com.thing.sys.biz.service.SysDeptService; |
|
|
|
import com.thing.sys.biz.service.SysDictDataService; |
|
|
|
@ -86,24 +86,36 @@ public class EqByPlanServiceImpl extends BaseServiceImpl<EqByPlanMapper, EqByPla |
|
|
|
@Override |
|
|
|
public QueryWrapper getWrapper(Map<String, Object> params) { |
|
|
|
QueryWrapper wrapper = new QueryWrapper(); |
|
|
|
wrapper.eq(EqByPlanEntity::getTenantCode,UserContext.getRealTenantCode()); |
|
|
|
String byStatus = MapUtil.getStr(params, "byStatus"); |
|
|
|
wrapper.eq(EqByPlanEntity::getByStatus, byStatus,StringUtils::isNotBlank); |
|
|
|
String by_user = MapUtil.getStr(params, "checkUserId"); |
|
|
|
wrapper.like(EqByPlanEntity::getByUser, by_user,StringUtils::isNotBlank); |
|
|
|
String byNo = MapUtil.getStr(params, "byNo"); |
|
|
|
wrapper.like(EqByPlanEntity::getByNo, byNo,StringUtils::isNotBlank); |
|
|
|
|
|
|
|
if (params.get("eqIds") != null) { |
|
|
|
String eqIds = params.get("eqIds").toString(); |
|
|
|
List<Long> eqthingIds = Arrays.stream(eqIds.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList()); |
|
|
|
wrapper.in(EqByPlanEntity::getThingsId, eqthingIds,CollectionUtil.isNotEmpty(eqthingIds)); |
|
|
|
} |
|
|
|
|
|
|
|
Long startTime = MapUtil.getLong(params, "startTime"); |
|
|
|
Long endTime = MapUtil.getLong(params, "endTime"); |
|
|
|
String relationTypeId = MapUtil.getStr(params, "relationTypeId"); |
|
|
|
|
|
|
|
|
|
|
|
return wrapper; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<EqByPlanDTO> page(Map<String, Object> params) { |
|
|
|
Page<EqByPlanEntity> page = getPage(params); |
|
|
|
int pageNumber = MapUtil.getInt(params, "page",1); |
|
|
|
int pageSize = MapUtil.getInt(params, "limit",10); |
|
|
|
|
|
|
|
// IPage<EqByPlanEntity> thingsEntityPage = baseDao.selectPage(page, getWrapper(params)); |
|
|
|
String eqIds; |
|
|
|
List<Long> eqthingIds = new ArrayList<>(); |
|
|
|
if (params.get("eqIds") != null) { |
|
|
|
eqIds = params.get("eqIds").toString(); |
|
|
|
eqthingIds = Arrays.stream(eqIds.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList()); |
|
|
|
params.put("eqIdList", eqthingIds); |
|
|
|
} |
|
|
|
params.put("tenantCode", TenantContext.getTenantCode(SecurityUser.getUser())); |
|
|
|
Page<EqByPlanDTO> paginate = mapper.paginateAs(new Page<>(pageNumber, pageSize), getWrapper(params),EqByPlanDTO.class); |
|
|
|
List<EqByPlanDTO> eqByPlansDTOS = paginate.getRecords(); |
|
|
|
String relationTypeId = params.get("relationTypeId").toString(); |
|
|
|
List<EqByPlanDTO> eqByPlansDTOS = eqByPlanDao.getListData(params); |
|
|
|
for (EqByPlanDTO eqByPlansDTO : eqByPlansDTOS) { |
|
|
|
EqInfo thingsInfo = iotThingsService.getThingInfo(eqByPlansDTO.getThingsId(),relationTypeId); |
|
|
|
if (thingsInfo != null) { |
|
|
|
@ -160,9 +172,13 @@ public class EqByPlanServiceImpl extends BaseServiceImpl<EqByPlanMapper, EqByPla |
|
|
|
for (EqByPlanPartDTO eqpart : dto.getThingParts()) { |
|
|
|
//调整 |
|
|
|
// eqpart.setEqByPlanId(id); |
|
|
|
eqpart.setCreateDate(new Date()); |
|
|
|
eqpart.setUpdateDate(new Date()); |
|
|
|
eqpart.setCreator(SecurityUser.getUserId()); |
|
|
|
eqByParts.add(eqpart); |
|
|
|
} |
|
|
|
eqByPlanPartService.saveDto(ConvertUtils.sourceToTarget(eqByParts, EqByPlanPartEntity.class)); |
|
|
|
List<EqByPlanPartEntity> eqByPlanPartEntities = ConvertUtils.sourceToTarget(eqByParts, EqByPlanPartEntity.class); |
|
|
|
eqByPlanPartService.saveBatch(eqByPlanPartEntities); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -197,13 +213,14 @@ public class EqByPlanServiceImpl extends BaseServiceImpl<EqByPlanMapper, EqByPla |
|
|
|
//先删除保养计划更换部件 |
|
|
|
eqByPlanPartService.deleteByEqByPlanId(dto.getId()); |
|
|
|
//保存保养计划部件 |
|
|
|
List<EqByPlanPartDTO> eqByParts = new ArrayList<>(); |
|
|
|
List<EqByPlanPartEntity> eqByParts = new ArrayList<>(); |
|
|
|
if (CollectionUtil.isNotEmpty(dto.getThingParts())) { |
|
|
|
for (EqByPlanPartDTO eqpart : dto.getThingParts()) { |
|
|
|
eqpart.setEqByPlanId(dto.getId()); |
|
|
|
eqByParts.add(eqpart); |
|
|
|
EqByPlanPartEntity eqByPlanPartEntity = ConvertUtils.sourceToTarget(eqpart, EqByPlanPartEntity.class); |
|
|
|
eqByPlanPartEntity.setEqByPlanId(dto.getId()); |
|
|
|
eqByParts.add(eqByPlanPartEntity); |
|
|
|
} |
|
|
|
eqByPlanPartService.saveDto(ConvertUtils.sourceToTarget(eqByParts, EqByPlanPartEntity.class)); |
|
|
|
eqByPlanPartService.saveBatch(ConvertUtils.sourceToTarget(eqByParts, EqByPlanPartEntity.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|