Browse Source

设备管理-20240902 优化

thing_master
xiezw 2 years ago
parent
commit
2bd307fd97
  1. 4
      modules/equipment/src/main/java/com/thing/eq/eqbxwx/controller/EqWxPlanController.java
  2. 5
      modules/equipment/src/main/java/com/thing/eq/eqbxwx/service/impl/EqBxServiceImpl.java
  3. 2
      modules/equipment/src/main/java/com/thing/eq/eqbxwx/service/impl/EqWxPlanServiceImpl.java
  4. 4
      modules/equipment/src/main/java/com/thing/eq/eqby/dto/EqByDTO.java
  5. 4
      modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByDetailEntity.java
  6. 33
      modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByServiceImpl.java
  7. 5
      modules/equipment/src/main/java/com/thing/eq/eqcheck/dto/EqPatrolCheckRecordDTO.java
  8. 1
      modules/equipment/src/main/java/com/thing/eq/eqcheck/mapper/EqSpotCheckRecordMapper.java
  9. 3
      modules/equipment/src/main/java/com/thing/eq/eqcheck/service/impl/EqPatrolCheckPlanServiceImpl.java
  10. 10
      modules/equipment/src/main/java/com/thing/eq/eqcheck/service/impl/EqPatrolCheckRecordServiceImpl.java
  11. 19
      modules/equipment/src/main/java/com/thing/eq/eqcheck/service/impl/EqSpotCheckRecordServiceImpl.java
  12. 4
      modules/equipment/src/main/java/com/thing/eq/eqpartrecord/entity/EqPartRecordEntity.java
  13. 12
      modules/equipment/src/main/java/com/thing/eq/equsergroup/controller/EqUserGroupController.java
  14. 25
      modules/equipment/src/main/java/com/thing/eq/equsergroup/dto/UserInfoDTO.java
  15. 3
      modules/equipment/src/main/java/com/thing/eq/equsergroup/service/EqUserGroupService.java
  16. 26
      modules/equipment/src/main/java/com/thing/eq/equsergroup/service/impl/EqUserGroupServiceImpl.java
  17. 38
      modules/equipment/src/main/resources/mapper/eqcheck/EqSpotCheckRecordMapper.xml

4
modules/equipment/src/main/java/com/thing/eq/eqbxwx/controller/EqWxPlanController.java

@ -187,8 +187,8 @@ public class EqWxPlanController {
throw new SysException("维修计划不存在");
}
//
// EqWxInfoRes eqWxInfoRes = new EqWxInfoRes();
// BeanUtils.copyProperties(data, eqWxInfoRes);
EqWxInfoRes eqWxInfoRes = new EqWxInfoRes();
BeanUtils.copyProperties(data, eqWxInfoRes);
// 查询设备信息
ThingDTO thingDTO = new ThingDTO();
ThingDTO thingInfo = iotThingBaseInfoService.getThingInfo(thingDTO, data.getThingId(), null, "1", String.valueOf(relationTypeId));

5
modules/equipment/src/main/java/com/thing/eq/eqbxwx/service/impl/EqBxServiceImpl.java

@ -6,6 +6,7 @@ import com.mybatisflex.core.query.QueryWrapper;
import com.thing.common.core.constants.Constant;
import com.thing.common.core.web.response.PageData;
import com.thing.common.orm.service.impl.BaseServiceImpl;
import com.thing.common.orm.utils.IdGenerator;
import com.thing.eq.eqbxwx.dto.EqBxDTO;
import com.thing.eq.eqbxwx.dto.EqWxPlanAddDTO;
import com.thing.eq.eqbxwx.entity.EqBxEntity;
@ -257,8 +258,8 @@ public class EqBxServiceImpl extends BaseServiceImpl<EqBxMapper, EqBxEntity> imp
dto.setBxNo(lastNo);
dto.setTenantCode(UserContext.getRealTenantCode());
// Long eqBxId = IdWorker.getId();
// dto.setId(eqBxId);
Long eqBxId = IdGenerator.nextId();
dto.setId(eqBxId);
if ("1".equals(dto.getInWx())) {
dto.setWxStatus("1");

2
modules/equipment/src/main/java/com/thing/eq/eqbxwx/service/impl/EqWxPlanServiceImpl.java

@ -297,7 +297,7 @@ public class EqWxPlanServiceImpl extends BaseServiceImpl<EqWxPlanMapper, EqWxPla
replacementDTO.setWxPlanId(dto.getId());
});
}
eqWxReplacementService.saveDto(ConvertUtils.sourceToTarget(replacementDTOS, EqWxReplacementEntity.class));
eqWxReplacementService.saveBatch(ConvertUtils.sourceToTarget(replacementDTOS, EqWxReplacementEntity.class));
}
// 重新赋值备件的各个使用总数

4
modules/equipment/src/main/java/com/thing/eq/eqby/dto/EqByDTO.java

@ -80,4 +80,8 @@ public class EqByDTO extends BaseDTO implements Serializable {
@JsonFormat(pattern = DateTimeUtils.DATE_TIME_PATTERN_STR)
private Date updateDate;
private Long deptId;
private Long tenantCode;
}

4
modules/equipment/src/main/java/com/thing/eq/eqby/entity/EqByDetailEntity.java

@ -1,7 +1,9 @@
package com.thing.eq.eqby.entity;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -19,7 +21,7 @@ import java.util.Date;
public class EqByDetailEntity {
private static final long serialVersionUID = 1L;
@Id
@Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId)
private Long id;
/**
* 保养id

33
modules/equipment/src/main/java/com/thing/eq/eqby/service/impl/EqByServiceImpl.java

@ -37,6 +37,7 @@ import com.thing.sys.biz.service.SysDictDataService;
import com.thing.sys.biz.service.SysDictTypeService;
import com.thing.sys.biz.service.SysUserService;
import com.thing.sys.security.context.TenantContext;
import com.thing.sys.security.context.UserContext;
import com.thing.sys.security.domain.SecurityUser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@ -239,19 +240,11 @@ public class EqByServiceImpl extends BaseServiceImpl<EqByMapper, EqByEntity> imp
// Long id = IdWorker.getId();
// dto.setId(id);
dto.setCreator(null);
dto.setCreateDate(null);
dto.setCreateDate(new Date());
dto.setUpdater(null);
dto.setUpdateDate(null);
//部位保养明细记录
if (CollectionUtil.isNotEmpty(dto.getEqByDetailDTOList())) {
for (EqByDetailDTO eqByDetailDTO : dto.getEqByDetailDTOList()) {
EqByTemplateDetailDTO detailDTO = eqByTemplateDetailService.getByIdAs(eqByDetailDTO.getByTemplateDetailId(),EqByTemplateDetailDTO.class);
BeanUtils.copyProperties(detailDTO, eqByDetailDTO);
//调整
// eqByDetailDTO.setId(IdWorker.getId());
// eqByDetailDTO.setById(id);
}
}
dto.setUpdateDate(new Date());
dto.setTenantCode(TenantContext.getTenantCode(SecurityUser.getUser()));
//当前时间作为保养执行时间
Long currentTime = System.currentTimeMillis();
if (dto.getByStartTime().getTime() >= eqByPlanDTO.getPlanEndTime().getTime()){
@ -316,13 +309,21 @@ public class EqByServiceImpl extends BaseServiceImpl<EqByMapper, EqByEntity> imp
dto.setByNo(lastNo);
//保存保养记录
saveDto(dto);
//部位保养明细记录
if (CollectionUtil.isNotEmpty(dto.getEqByDetailDTOList())) {
for (EqByDetailDTO eqByDetailDTO : dto.getEqByDetailDTOList()) {
EqByTemplateDetailDTO detailDTO = eqByTemplateDetailService.getByIdAs(eqByDetailDTO.getByTemplateDetailId(),EqByTemplateDetailDTO.class);
eqByDetailDTO.setById(dto.getId());
BeanUtils.copyProperties(detailDTO, eqByDetailDTO);
}
}
//保存保养明细记录
eqByDetailService.saveDto(ConvertUtils.sourceToTarget(dto.getEqByDetailDTOList(), EqByDetailEntity.class));
List<EqByDetailEntity> eqByDetailEntities = ConvertUtils.sourceToTarget(dto.getEqByDetailDTOList(), EqByDetailEntity.class);
eqByDetailService.saveBatch(eqByDetailEntities);
//更新库存 调整
// updateStock(id, dto);
updateStock(dto.getId(), dto);
//更新部件更换记录
eqPartRecordService.saveDto(ConvertUtils.sourceToTarget(dto.getThingParts(), EqPartRecordEntity.class));
eqPartRecordService.saveBatch(ConvertUtils.sourceToTarget(dto.getThingParts(), EqPartRecordEntity.class));
}

5
modules/equipment/src/main/java/com/thing/eq/eqcheck/dto/EqPatrolCheckRecordDTO.java

@ -71,4 +71,9 @@ public class EqPatrolCheckRecordDTO extends BaseDTO implements Serializable {
@Schema(description = "设备id")
private Long thingId;
@Schema(description = "创建时间")
private Date createDate;
@Schema(description = "更新时间")
private Date updateDate;
}

1
modules/equipment/src/main/java/com/thing/eq/eqcheck/mapper/EqSpotCheckRecordMapper.java

@ -23,4 +23,5 @@ public interface EqSpotCheckRecordMapper extends PowerBaseMapper<EqSpotCheckReco
List<EqSpotCheckRecordDTO> searchRecord(@Param("params") Map<String, Object> params);
List<EqSpotCheckRecordDTO> searchRecordList(@Param("params")Map<String, Object> params);
}

3
modules/equipment/src/main/java/com/thing/eq/eqcheck/service/impl/EqPatrolCheckPlanServiceImpl.java

@ -535,6 +535,9 @@ public class EqPatrolCheckPlanServiceImpl extends BaseServiceImpl<EqPatrolCheckP
recordDTO.setTip(dto.getRemark());
recordDTO.setCheckTime(actCheckTime);
recordDTO.setPatrolCheckPlanId(checkPlanDTO.getId());
recordDTO.setTenantCode(TenantContext.getTenantCode(SecurityUser.getUser()));
recordDTO.setCreateDate(new Date());
recordDTO.setUpdateDate(new Date());
if (StringUtils.equals("0",checkPlanDTO.getType())){
recordDTO.setCheckPlanTime(DateTimeUtils.format(checkPlanDTO.getPlanStartTime(), DateTimeUtils.DATE_TIME_PATTERN_STR + " 至 " + DateTimeUtils.format(checkPlanDTO.getCheckEndTime(), DateTimeUtils.DATE_TIME_PATTERN_STR)));
}else{

10
modules/equipment/src/main/java/com/thing/eq/eqcheck/service/impl/EqPatrolCheckRecordServiceImpl.java

@ -8,6 +8,7 @@ import com.thing.common.core.utils.ConvertUtils;
import com.thing.common.orm.service.impl.BaseServiceImpl;
import com.thing.eq.checkresult.dto.CheckResultDTO;
import com.thing.eq.checkresult.service.CheckResultService;
import com.thing.eq.eqby.entity.EqByDetailEntity;
import com.thing.eq.eqcheck.dto.EqCheckSettingDTO;
import com.thing.eq.eqcheck.dto.EqPatrolCheckRecordDTO;
import com.thing.eq.eqcheck.dto.EqPatrolCheckRecordResDTO;
@ -97,7 +98,8 @@ public class EqPatrolCheckRecordServiceImpl extends BaseServiceImpl<EqPatrolChec
}
String lastNo = SerialNumberUnit.generateChildNumber(checkPlanEntity.getPatrolCheckPlanNo(), recordEntity.getPatrolCheckRecordNo());
eqPatrolCheckRecordDTO.setPatrolCheckRecordNo(lastNo);
saveDto(eqPatrolCheckRecordDTO);
EqPatrolCheckRecordEntity eqPatrolCheckRecordEntity = ConvertUtils.sourceToTarget(eqPatrolCheckRecordDTO, EqPatrolCheckRecordEntity.class);
save(eqPatrolCheckRecordEntity);
if (Objects.isNull(eqPatrolCheckRecordDTO)) {
throw new SysException("巡检结果保存失败");
@ -105,7 +107,7 @@ public class EqPatrolCheckRecordServiceImpl extends BaseServiceImpl<EqPatrolChec
if (eqPatrolCheckRecordDTO.getThingId() !=null){
eqScrapService.checkThingStatus(eqPatrolCheckRecordDTO.getThingId());
CheckResultDTO checkResult = new CheckResultDTO();
checkResult.setCheckRecordId(eqPatrolCheckRecordDTO.getId());
checkResult.setCheckRecordId(eqPatrolCheckRecordEntity.getId());
checkResult.setType("1");
checkResult.setThingId(eqPatrolCheckRecordDTO.getThingId());
checkResult.setCheckPlanId(eqPatrolCheckRecordDTO.getPatrolCheckPlanId());
@ -119,7 +121,7 @@ public class EqPatrolCheckRecordServiceImpl extends BaseServiceImpl<EqPatrolChec
eqScrapService.checkThingStatus(thingId);
CheckResultDTO checkResult = new CheckResultDTO();
checkResult.setCheckRecordId(eqPatrolCheckRecordDTO.getId());
checkResult.setCheckRecordId(eqPatrolCheckRecordEntity.getId());
checkResult.setType("1");
checkResult.setThingId(thingId);
checkResult.setCheckPlanId(eqPatrolCheckRecordDTO.getPatrolCheckPlanId());
@ -128,7 +130,7 @@ public class EqPatrolCheckRecordServiceImpl extends BaseServiceImpl<EqPatrolChec
}
}
return eqPatrolCheckRecordDTO.getId();
return eqPatrolCheckRecordEntity.getId();
}
@Override

19
modules/equipment/src/main/java/com/thing/eq/eqcheck/service/impl/EqSpotCheckRecordServiceImpl.java

@ -4,6 +4,7 @@ import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.thing.common.core.exception.SysException;
import com.thing.common.core.utils.DateTimeUtils;
import com.thing.common.core.utils.PageUtils;
import com.thing.common.orm.service.impl.BaseServiceImpl;
import com.thing.eq.eqcheck.dto.EqSpotCheckRecordDTO;
import com.thing.eq.eqcheck.entity.EqSpotCheckPlanEntity;
@ -15,6 +16,7 @@ import com.thing.eq.eqmanager.service.EqScrapService;
import com.thing.eq.utils.SerialNumberUnit;
import com.thing.sys.security.context.TenantContext;
import com.thing.sys.security.domain.SecurityUser;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -60,9 +62,14 @@ public class EqSpotCheckRecordServiceImpl extends BaseServiceImpl<EqSpotCheckRec
int limit = Integer.parseInt(String.valueOf(params.get("limit")));
getParam(params);
Page<EqSpotCheckRecordDTO> eqSpotCheckPlanList = eqSpotCheckRecordDao.searchRecord(new Page<>(page, limit), params);
Page<EqSpotCheckRecordDTO> eqSpotCheckPlanList = new Page<>();
// Page<EqSpotCheckRecordDTO> eqSpotCheckPlanList = eqSpotCheckRecordDao.searchRecord(new Page<>(page, limit), params);
List<EqSpotCheckRecordDTO> eqSpotCheckPlanList1 = eqSpotCheckRecordDao.searchRecordList(params);
List<EqSpotCheckRecordDTO> eqSpotCheckRecordDTOS = PageUtils.startPage(eqSpotCheckPlanList1, page, limit);
eqSpotCheckPlanList.setRecords(eqSpotCheckRecordDTOS);
eqSpotCheckPlanList.setPageNumber(page);
eqSpotCheckPlanList.setPageSize(limit);
eqSpotCheckPlanList.setTotalRow(CollectionUtils.size(eqSpotCheckPlanList1));
return eqSpotCheckPlanList;
}
@ -145,10 +152,12 @@ public class EqSpotCheckRecordServiceImpl extends BaseServiceImpl<EqSpotCheckRec
String lastNo = SerialNumberUnit.generateChildNumber(checkPlanEntity.getSpotCheckNo(), spotCheckRecordEntity.getSpotCheckRecordNo());
dto.setSpotCheckRecordNo(lastNo);
dto.setCreateDate(new Date());
dto.setUpdateDate(new Date());
dto.setTenantCode(TenantContext.getTenantCode(SecurityUser.getUser()));
saveDto(dto);
checkPlanEntity.setLastCheckTime(dto.getCheckTime());
// checkPlanEntity.setLastCheckTime(dto.getCheckTime());
eqSpotCheckPlanService.updateById(checkPlanEntity);
}
}

4
modules/equipment/src/main/java/com/thing/eq/eqpartrecord/entity/EqPartRecordEntity.java

@ -1,7 +1,9 @@
package com.thing.eq.eqpartrecord.entity;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -22,7 +24,7 @@ public class EqPartRecordEntity {
/**
* id
*/
@Id
@Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId)
private Long id;
/**
* 更换数量

12
modules/equipment/src/main/java/com/thing/eq/equsergroup/controller/EqUserGroupController.java

@ -18,6 +18,7 @@ import com.thing.eq.eqby.service.EqByPlanService;
import com.thing.eq.eqcheck.dto.EqPatrolCheckPlanDTO;
import com.thing.eq.eqcheck.service.EqPatrolCheckPlanService;
import com.thing.eq.equsergroup.dto.EqUserGroupDTO;
import com.thing.eq.equsergroup.dto.UserInfoDTO;
import com.thing.eq.equsergroup.excel.EqUserGroupExcel;
import com.thing.eq.equsergroup.service.EqUserGroupService;
import com.thing.sys.security.context.TenantContext;
@ -90,6 +91,17 @@ public class EqUserGroupController {
return new Result<List<EqUserGroupDTO>>().ok(data);
}
@GetMapping("groupList")
@Operation(summary="用户组用户列表")
@Parameters({
@Parameter(name = "groupId", description = "组id")
})
// @RequiresPermissions("equsergroup:equsergroup:info")
public Result<List<UserInfoDTO>> groupList(@Parameter(hidden = true) @RequestParam Map<String, Object> params){
List<UserInfoDTO> data = eqUserGroupService.groupList(params);
return new Result<List<UserInfoDTO>>().ok(data);
}
@PostMapping
@Operation(summary="保存")
@LogOperation("保存")

25
modules/equipment/src/main/java/com/thing/eq/equsergroup/dto/UserInfoDTO.java

@ -0,0 +1,25 @@
package com.thing.eq.equsergroup.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* 用户组
*
* @author xiezw 806671840@qq.com
* @since 3.0 2022-06-24
*/
@Data
@Schema(description = "组用户信息")
public class UserInfoDTO implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "用户id")
private Long userId;
@Schema(description = "名称")
private String userName;
}

3
modules/equipment/src/main/java/com/thing/eq/equsergroup/service/EqUserGroupService.java

@ -6,6 +6,7 @@ package com.thing.eq.equsergroup.service;
import com.thing.common.core.web.response.PageData;
import com.thing.common.orm.service.IBaseService;
import com.thing.eq.equsergroup.dto.EqUserGroupDTO;
import com.thing.eq.equsergroup.dto.UserInfoDTO;
import com.thing.eq.equsergroup.entity.EqUserGroupEntity;
import java.util.List;
@ -30,4 +31,6 @@ public interface EqUserGroupService extends IBaseService<EqUserGroupEntity> {
EqUserGroupDTO getByNameNoCurrenId(String name, Long tenantCode, Long id);
PageData<EqUserGroupDTO> page(Map<String, Object> params);
List<UserInfoDTO> groupList(Map<String, Object> params);
}

26
modules/equipment/src/main/java/com/thing/eq/equsergroup/service/impl/EqUserGroupServiceImpl.java

@ -1,5 +1,6 @@
package com.thing.eq.equsergroup.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
@ -7,6 +8,7 @@ import com.thing.common.core.utils.ConvertUtils;
import com.thing.common.core.web.response.PageData;
import com.thing.common.orm.service.impl.BaseServiceImpl;
import com.thing.eq.equsergroup.dto.EqUserGroupDTO;
import com.thing.eq.equsergroup.dto.UserInfoDTO;
import com.thing.eq.equsergroup.entity.EqUserGroupEntity;
import com.thing.eq.equsergroup.mapper.EqUserGroupMapper;
import com.thing.eq.equsergroup.service.EqUserGroupService;
@ -61,6 +63,30 @@ public class EqUserGroupServiceImpl extends BaseServiceImpl<EqUserGroupMapper, E
return new PageData<>(pageList.getRecords(), pageList.getTotalRow());
}
@Override
public List<UserInfoDTO> groupList(Map<String, Object> params) {
List<UserInfoDTO> result = new ArrayList<>();
params.put("tenantCode", TenantContext.getTenantCode(SecurityUser.getUser()));
Long groupId = Long.parseLong(params.get("groupId").toString());
EqUserGroupDTO eqUserGroupDTO = mapper.selectByid(groupId);
//调整
String userId = eqUserGroupDTO.getUserId();
String[] split = userId.split(",");
List<Long> longs = new ArrayList<>();
for (String s : split) {
longs.add(Long.parseLong(s));
UserInfoDTO userInfoDTO = new UserInfoDTO();
List<String> planUserName = sysUserService.getUserNameLists(longs);
if (CollectionUtil.isEmpty(planUserName)){
continue;
}
userInfoDTO.setUserId(Long.parseLong(s));
userInfoDTO.setUserName(planUserName.get(0));
result.add(userInfoDTO);
}
return result;
}
@Override
public void save(EqUserGroupDTO dto) {
EqUserGroupEntity eqUserGroupEntity = ConvertUtils.sourceToTarget(dto, EqUserGroupEntity.class);

38
modules/equipment/src/main/resources/mapper/eqcheck/EqSpotCheckRecordMapper.xml

@ -60,5 +60,43 @@
</where>
order by record.create_date desc
</select>
<select id="searchRecordList" resultType="com.thing.eq.eqcheck.dto.EqSpotCheckRecordDTO">
select
record.*,
thing.code as thingCode,
thing.name as thingName,
base.standard as thingStandard,
base.eq_code as eqCode
from
eq_spot_check_record record
left join iot_thing_entity thing on thing.id = record.thing_id
left join iot_thing_base_info base on base.thing_id = thing.id
<where>
<if test="params.spotPlanId!=null">
record.spot_check_id = #{params.spotPlanId}
</if>
<if test="params.code!=null and params.code.trim() !=''">
and thing.code like concat('%',#{params.code}::varchar,'%')
</if>
<if test="params.name!=null and params.name.trim() !=''">
and thing.name like concat('%',#{params.name}::varchar,'%')
</if>
<if test="params.startTime!=null and params.endTime !=null">
and record.check_time is not null
and record.check_time <![CDATA[ >= ]]> #{params.startTime}
and record.check_time <![CDATA[ < ]]> #{params.endTime}
</if>
<if test="params.useId!=null">
and record.user_Id = #{params.useId}
</if>
<if test="params.spotCheckRecordNo!=null and params.spotCheckRecordNo.trim() !=''">
and record.spot_check_record_no like concat('%',#{params.spotCheckRecordNo}::varchar,'%')
</if>
<if test="params.tenantCode != null">
and record.tenant_code = #{params.tenantCode}
</if>
</where>
order by record.create_date desc
</select>
</mapper>
Loading…
Cancel
Save