Merge branch 'test' of https://git.will-way.cn/zgty/zt-qms into test
This commit is contained in:
@@ -110,7 +110,9 @@ public class ReportDocumentFileController extends AbstractFileUploadController i
|
||||
version = mainDO.getDocumentVersion();
|
||||
}
|
||||
ReportDocumentFileDO entity = reportDocumentFileService.getByMainIdAndVersion(mainId, version);
|
||||
|
||||
if(entity == null){
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
Long fileId = entity.getFileId();
|
||||
CommonResult<FileRespDTO> fileRet = fileApi.getFile(fileId);
|
||||
FileRespDTO file = fileRet.getData();
|
||||
|
||||
@@ -411,7 +411,10 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
String colKey = parseNumToString(colIndex, 2);
|
||||
t.put(colPrefix + colKey, fieldName);
|
||||
//查询当前字段的检出限
|
||||
JSONObject fieldObj = firstData.getJSONObject(field);
|
||||
JSONObject fieldObj = null;
|
||||
if(firstData != null && !ObjectUtils.isEmpty(field)){
|
||||
fieldObj = firstData.getJSONObject(field);
|
||||
}
|
||||
String rangeVal = "";
|
||||
if (fieldObj != null) {
|
||||
rangeVal = fieldObj.getString(rangeKey);
|
||||
@@ -516,7 +519,9 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
if (FIELD_FIXED.equals(fieldType)) //这里只处理动态列。固定列在 addDataToRowList 处理
|
||||
continue;
|
||||
String field = fieldDO.getField();
|
||||
JSONObject fieldObj = s.getJSONObject(field);
|
||||
JSONObject fieldObj = new JSONObject();
|
||||
if(s != null)
|
||||
fieldObj = s.getJSONObject(field);
|
||||
String fieldValue = "";
|
||||
if (fieldObj != null)
|
||||
fieldValue = fieldObj.getString("fieldValue");
|
||||
|
||||
@@ -59,6 +59,12 @@ public class DeviceMaintainController extends AbstractFileUploadController imple
|
||||
@Resource private DeviceMaintainService deviceMaintainService;
|
||||
@Resource private DeviceInfomationService deviceInfomationService;
|
||||
|
||||
@PostMapping("/saveMaintainVo")
|
||||
@Operation(summary = "创建或获取维护数据")
|
||||
public CommonResult<Boolean> saveMaintainVo(@RequestBody DeviceMaintainVO vo) {
|
||||
return deviceMaintainService.saveMaintainVo(vo);
|
||||
}
|
||||
|
||||
@PostMapping("/createOrGet")
|
||||
@Operation(summary = "创建或获取维护数据")
|
||||
public CommonResult<DeviceMaintainVO> createOrGet(@RequestBody JSONObject jsonObject) {
|
||||
@@ -88,7 +94,7 @@ public class DeviceMaintainController extends AbstractFileUploadController imple
|
||||
}
|
||||
|
||||
@GetMapping("/queryPageListWithCount")
|
||||
@Operation(summary = "维护-分页列表查询")
|
||||
@Operation(summary = "维护-分页列表查询(以设备为主数据)")
|
||||
public CommonResult<PageResult<DeviceMaintainVO>> queryPageListWithCount(@Valid DeviceMaintainPageReqVO pageReqVO) {
|
||||
PageResult<DeviceMaintainVO> pageResult = deviceMaintainService.queryPageListWithCount(pageReqVO);
|
||||
return success(pageResult);
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.zt.plat.module.qms.resource.device.controller.admin;
|
||||
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceUseRecordPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceUseRecordRespVO;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceUseRecordSaveReqVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zt.plat.framework.security.core.LoginUser;
|
||||
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.*;
|
||||
import com.zt.plat.module.qms.resource.device.dal.mapper.DeviceUseRecordMapper;
|
||||
import com.zt.plat.module.qms.resource.device.service.DeviceInfomationService;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -31,6 +35,7 @@ import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_USE_RECORD_NOT_EXISTS;
|
||||
|
||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceUseRecordDO;
|
||||
import com.zt.plat.module.qms.resource.device.service.DeviceUseRecordService;
|
||||
@@ -49,14 +54,43 @@ public class DeviceUseRecordController extends AbstractFileUploadController impl
|
||||
}
|
||||
}
|
||||
|
||||
@Resource
|
||||
private DeviceUseRecordService deviceUseRecordService;
|
||||
@Resource private DeviceUseRecordService deviceUseRecordService;
|
||||
@Resource private DeviceInfomationService deviceInfomationService;
|
||||
@Resource private DeviceUseRecordMapper deviceUseRecordMapper;
|
||||
|
||||
@GetMapping("/queryPageListWithCount")
|
||||
@Operation(summary = "使用记录分页列表查询(以设备为主数据)")
|
||||
public CommonResult<PageResult<DeviceUseRecordVO>> queryPageListWithCount(@Valid DeviceUseRecordPageReqVO pageReqVO) {
|
||||
PageResult<DeviceUseRecordVO> pageResult = deviceUseRecordService.queryPageListWithCount(pageReqVO);
|
||||
return success(pageResult);
|
||||
}
|
||||
|
||||
@GetMapping("/queryLastUsingData")
|
||||
@Operation(summary = "查询设备最近一次使用中的记录")
|
||||
@Parameter(name = "deviceId", description = "设备ID", required = true, example = "1024")
|
||||
public CommonResult<DeviceUseRecordRespVO> queryLastUsingData(@RequestParam("deviceId") Long deviceId) {
|
||||
if(deviceId == null)
|
||||
return CommonResult.error(DEVICE_USE_RECORD_NOT_EXISTS.getCode(), "设备ID不能为空");
|
||||
LambdaQueryWrapper<DeviceUseRecordDO> query = new LambdaQueryWrapper<>();
|
||||
query.eq(DeviceUseRecordDO::getDeviceId, deviceId);
|
||||
query.isNull(DeviceUseRecordDO::getUseTimeEnd);
|
||||
query.orderByDesc(DeviceUseRecordDO::getUseTimeStart);
|
||||
query.last("LIMIT 1");
|
||||
DeviceUseRecordDO recordDO = deviceUseRecordMapper.selectOne( query);
|
||||
return success(BeanUtils.toBean(recordDO, DeviceUseRecordRespVO.class));
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建设备-使用记录")
|
||||
@PreAuthorize("@ss.hasPermission('qms:device-use-record:create')")
|
||||
public CommonResult<DeviceUseRecordRespVO> createDeviceUseRecord(@Valid @RequestBody DeviceUseRecordSaveReqVO createReqVO) {
|
||||
return success(deviceUseRecordService.createDeviceUseRecord(createReqVO));
|
||||
public CommonResult<DeviceUseRecordRespVO> createDeviceUseRecord(@Valid @RequestBody DeviceUseRecordSaveReqVO reqVO) {
|
||||
Long deviceId = reqVO.getDeviceId();
|
||||
if(deviceId == null)
|
||||
return CommonResult.error(DEVICE_USE_RECORD_NOT_EXISTS.getCode(), "设备ID不能为空");
|
||||
//检查设备状态
|
||||
CommonResult<Boolean> checkResult = deviceInfomationService.checkDeviceUsable(deviceId);
|
||||
if(!checkResult.isSuccess())
|
||||
return CommonResult.error(checkResult);
|
||||
return deviceUseRecordService.createDeviceUseRecord(reqVO);
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@@ -96,7 +130,6 @@ public class DeviceUseRecordController extends AbstractFileUploadController impl
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得设备-使用记录分页")
|
||||
@PreAuthorize("@ss.hasPermission('qms:device-use-record:query')")
|
||||
public CommonResult<PageResult<DeviceUseRecordRespVO>> getDeviceUseRecordPage(@Valid DeviceUseRecordPageReqVO pageReqVO) {
|
||||
PageResult<DeviceUseRecordDO> pageResult = deviceUseRecordService.getDeviceUseRecordPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DeviceUseRecordRespVO.class));
|
||||
|
||||
@@ -23,10 +23,10 @@ public class DeviceUseRecordPageReqVO extends PageParam {
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "开始使用时间")
|
||||
private LocalDateTime useTimeStart;
|
||||
private LocalDateTime[] useTimeStart;
|
||||
|
||||
@Schema(description = "结束使用时间")
|
||||
private LocalDateTime useTimeEnd;
|
||||
private LocalDateTime[] useTimeEnd;
|
||||
|
||||
@Schema(description = "使用记录")
|
||||
private String useRemark;
|
||||
@@ -59,4 +59,24 @@ public class DeviceUseRecordPageReqVO extends PageParam {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
//=====================================扩展字段===============================================
|
||||
|
||||
@Schema(description = "产品id")
|
||||
private Long productId;
|
||||
|
||||
@Schema(description = "设备名称")
|
||||
private String deviceName;
|
||||
|
||||
@Schema(description = "管理编号")
|
||||
private String deviceCode;
|
||||
|
||||
@Schema(description = "使用部门")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "产品id查询")
|
||||
private List<Long> productIdList;
|
||||
|
||||
@Schema(description = "设备ID列表")
|
||||
private List<Long> deviceIdList;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.zt.plat.module.qms.resource.device.controller.vo;
|
||||
|
||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainItemDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 设备使用记录VO")
|
||||
@Data
|
||||
public class DeviceUseRecordVO extends DeviceUseRecordRespVO {
|
||||
|
||||
|
||||
//============大类字段============
|
||||
@Schema(description = "产品id")
|
||||
private Long productId;
|
||||
|
||||
@Schema(description = "规格")
|
||||
private String specification;
|
||||
|
||||
@Schema(description = "型号")
|
||||
private String modelNo;
|
||||
|
||||
@Schema(description = "制造商")
|
||||
private String manufacturer;
|
||||
|
||||
//============设备字段============
|
||||
@Schema(description = "设备名称")
|
||||
private String deviceName;
|
||||
|
||||
@Schema(description = "别名")
|
||||
private String alias;
|
||||
|
||||
@Schema(description = "管理编号")
|
||||
private String deviceCode;
|
||||
|
||||
@Schema(description = "资产编号")
|
||||
private String assetCode;
|
||||
|
||||
@Schema(description = "出厂编号")
|
||||
private String factoryCode;
|
||||
|
||||
@Schema(description = "所属部门名称")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "维修状态: 1-维修;0-正常")
|
||||
private Integer repairFlag;
|
||||
|
||||
@Schema(description = "降级状态")
|
||||
private Integer demoteFlag;
|
||||
|
||||
@Schema(description = "报废状态")
|
||||
private Integer scrapFlag;
|
||||
|
||||
@Schema(description = "停用状态")
|
||||
private Integer disableFlag;
|
||||
|
||||
@Schema(description = "外借状态")
|
||||
private Integer lendFlag;
|
||||
|
||||
@Schema(description = "使用中状态")
|
||||
private Integer inUseFlag;
|
||||
|
||||
@Schema(description = "验收状态")
|
||||
private String acceptFlag;
|
||||
|
||||
|
||||
//============其他字段============
|
||||
@Schema(description = "未提交数据量")
|
||||
private Integer runningCount;
|
||||
|
||||
@Schema(description = "已提交数据量")
|
||||
private Integer finishedCount;
|
||||
|
||||
@Schema(description = "截止时间不为空")
|
||||
private String useTimeEndFlag;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.zt.plat.module.qms.resource.device.dal.dataobject;
|
||||
|
||||
import com.zt.plat.module.qms.core.aspect.annotation.Dict;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
public class DeviceInfoWithBizConfigVO extends DeviceInfomationDO{
|
||||
|
||||
@Schema(description = "规则id")
|
||||
private String ruleId;
|
||||
|
||||
@Schema(description = "业务领域:点检|检定校准|期间核查|等")
|
||||
@Dict(dicCode = "device_business_domain")
|
||||
private String businessDomain;
|
||||
|
||||
@Schema(description = "是否需要")
|
||||
private Integer needFlag;
|
||||
|
||||
@Schema(description = "子业务类型")
|
||||
private String subDomainType;
|
||||
|
||||
@Schema(description = "频次类型")
|
||||
private String frequencyType;
|
||||
|
||||
@Schema(description = "频次")
|
||||
private String frequency;
|
||||
|
||||
@Schema(description = "频次说明")
|
||||
private String frequencyRemark;
|
||||
|
||||
@Schema(description = "报表模板")
|
||||
private String reportTemplateKey;
|
||||
|
||||
@Schema(description = "表单组件")
|
||||
private String formComponent;
|
||||
|
||||
@Schema(description = "处理方法")
|
||||
private String processMethod;
|
||||
|
||||
@Schema(description = "处理人")
|
||||
private String processUser;
|
||||
|
||||
@Schema(description = "标准/规范")
|
||||
private String standard;
|
||||
|
||||
@Schema(description = "检定/校准类型")
|
||||
private String calibrationCheckType;
|
||||
|
||||
}
|
||||
@@ -94,12 +94,12 @@ public class DeviceMaintainItemDO extends BusinessBaseDO {
|
||||
/**
|
||||
* 所属周期开始日期
|
||||
*/
|
||||
@TableField("FREQ_ITM_STRT")
|
||||
@TableField("FREQ_TM_STRT")
|
||||
private LocalDateTime frequencyTimeStart;
|
||||
/**
|
||||
* 所属周期截止日期
|
||||
*/
|
||||
@TableField("FREQ_ITM_END")
|
||||
@TableField("FREQ_TM_STRT")
|
||||
private LocalDateTime frequencyTimeEnd;
|
||||
/**
|
||||
* 检查标准
|
||||
|
||||
@@ -41,6 +41,6 @@ public interface DeviceMaintainMapper extends BaseMapperX<DeviceMaintainDO> {
|
||||
}
|
||||
|
||||
IPage<DeviceMaintainVO> queryPageListWithCount(Page<DeviceMaintainVO> page, @Param("param") DeviceMaintainPageReqVO param);
|
||||
DeviceMaintainVO queryMaintainVoById(@Param("id") Long id);
|
||||
DeviceMaintainVO queryVoById(@Param("id") Long id);
|
||||
|
||||
}
|
||||
@@ -1,11 +1,15 @@
|
||||
package com.zt.plat.module.qms.resource.device.dal.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceUseRecordVO;
|
||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceUseRecordDO;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceUseRecordPageReqVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 设备-使用记录 Mapper
|
||||
@@ -20,8 +24,8 @@ public interface DeviceUseRecordMapper extends BaseMapperX<DeviceUseRecordDO> {
|
||||
.eqIfPresent(DeviceUseRecordDO::getDeviceId, reqVO.getDeviceId())
|
||||
.likeIfPresent(DeviceUseRecordDO::getUserName, reqVO.getUserName())
|
||||
.eqIfPresent(DeviceUseRecordDO::getUserId, reqVO.getUserId())
|
||||
.eqIfPresent(DeviceUseRecordDO::getUseTimeStart, reqVO.getUseTimeStart())
|
||||
.eqIfPresent(DeviceUseRecordDO::getUseTimeEnd, reqVO.getUseTimeEnd())
|
||||
.betweenIfPresent(DeviceUseRecordDO::getUseTimeStart, reqVO.getUseTimeStart())
|
||||
.betweenIfPresent(DeviceUseRecordDO::getUseTimeEnd, reqVO.getUseTimeEnd())
|
||||
.eqIfPresent(DeviceUseRecordDO::getUseRemark, reqVO.getUseRemark())
|
||||
.eqIfPresent(DeviceUseRecordDO::getStateBefore, reqVO.getStateBefore())
|
||||
.eqIfPresent(DeviceUseRecordDO::getStateRun, reqVO.getStateRun())
|
||||
@@ -35,4 +39,8 @@ public interface DeviceUseRecordMapper extends BaseMapperX<DeviceUseRecordDO> {
|
||||
.orderByDesc(DeviceUseRecordDO::getId));
|
||||
}
|
||||
|
||||
IPage<DeviceUseRecordVO> queryPageListWithCount(Page<DeviceUseRecordVO> page, @Param("param") DeviceUseRecordPageReqVO param);
|
||||
DeviceUseRecordVO queryVoById(@Param("id") Long id);
|
||||
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceInfomationDO;
|
||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceProductDO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
@@ -55,14 +56,17 @@ public class DeviceConfigBusinessRuleServiceImpl implements DeviceConfigBusiness
|
||||
DeviceInfomationDO deviceDO = deviceInfomationService.getDeviceInfomation(deviceId);
|
||||
DeviceProductDO productDO = deviceProductService.getDeviceProduct(deviceDO.getProductId());
|
||||
String path = productDO.getIdPath();
|
||||
String[] split = path.split("/");
|
||||
List<String> productIdList = new ArrayList<>();
|
||||
for (String s : split) {
|
||||
String id = s.replaceAll("/", "");
|
||||
if(id.equals("0"))
|
||||
continue;
|
||||
productIdList.add(s);
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(path)){
|
||||
String[] split = path.split("/");
|
||||
for (String s : split) {
|
||||
String id = s.replaceAll("/", "");
|
||||
if(id.equals("0"))
|
||||
continue;
|
||||
productIdList.add(s);
|
||||
}
|
||||
}else
|
||||
productIdList.add(productDO.getId().toString());
|
||||
List<DeviceConfigBusinessRuleDO> ruleList = getByProductIdListAndBusinessDomain(productIdList, type);
|
||||
if(ruleList.isEmpty())
|
||||
return CommonResult.error(DEVICE_CONFIG_BUSINESS_RULE_NOT_EXISTS);
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package com.zt.plat.module.qms.resource.device.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceInfomationPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceInfomationRespVO;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceInfomationSaveReqVO;
|
||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceInfoWithBizConfigVO;
|
||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceInfomationDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 设备-设备信息 Service 接口
|
||||
@@ -27,6 +30,29 @@ public interface DeviceInfomationService {
|
||||
|
||||
List<Long> getIdListByProductIdList(List<Long> productIds);
|
||||
|
||||
|
||||
//查询需要“某个业务类型”的设备列表
|
||||
List<DeviceInfoWithBizConfigVO> getListNeedByRule(JSONObject params);
|
||||
|
||||
|
||||
// 更新设备的生命周期状态
|
||||
CommonResult<DeviceInfomationDO> updateLifeStatus(DeviceInfomationDO info, String bizType, Integer flag);
|
||||
|
||||
//更新“使用中”状态
|
||||
void updateDeviceInUseFlag(Long deviceId, Integer inUseFlag);
|
||||
// CommonResult<Boolean> updateDeviceRepairFlag(Long deviceId, Integer repairFlag);
|
||||
// CommonResult<Boolean> updateDeviceDemoteFlag(Long deviceId, Integer demoteFlag);
|
||||
// CommonResult<Boolean> updateDeviceScrapFlag(Long deviceId, Integer scrapFlag);
|
||||
// CommonResult<Boolean> updateDeviceDisableFlag(Long deviceId, Integer disableFlag);
|
||||
// CommonResult<Boolean> updateDeviceAcceptFlag(Long deviceId, String acceptFlag);
|
||||
// CommonResult<Boolean> updateDeviceLendFlag(Long deviceId, Integer lendFlag);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建设备-设备信息
|
||||
*
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.zt.plat.module.qms.resource.device.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
@@ -10,6 +15,7 @@ import com.zt.plat.module.qms.resource.device.controller.vo.DeviceInfomationPage
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceInfomationRespVO;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceInfomationSaveReqVO;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceProductRespVO;
|
||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceInfoWithBizConfigVO;
|
||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceInfomationDO;
|
||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceProductDO;
|
||||
import com.zt.plat.module.qms.resource.device.dal.mapper.DeviceInfomationMapper;
|
||||
@@ -19,7 +25,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||
@@ -80,6 +88,119 @@ public class DeviceInfomationServiceImpl implements DeviceInfomationService {
|
||||
return CommonResult.error( DEVICE_INFOMATION_NOT_EXISTS.getCode(), "设备在维修中");
|
||||
return CommonResult.success( true);
|
||||
}
|
||||
/*todo 查询需要“某个业务类型”的设备列表*/
|
||||
@Override
|
||||
public List<DeviceInfoWithBizConfigVO> getListNeedByRule(JSONObject params) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* 更新设备生命周期状态
|
||||
* 传入设备实体、业务类型(停用、外借、维修、降级等)、状态(1-是,其他-否)
|
||||
* */
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult<DeviceInfomationDO> updateLifeStatus(DeviceInfomationDO info, String bizType, Integer flag) {
|
||||
String stateStack = info.getStateStack();
|
||||
JSONArray arr = new JSONArray();
|
||||
if(!ObjectUtils.isEmpty(stateStack))
|
||||
arr = JSON.parseArray(stateStack);
|
||||
String state = "-1";
|
||||
Map<String, String> stateMap = new HashMap<>();
|
||||
SFunction<DeviceInfomationDO, String> tableField = null;
|
||||
stateMap.put("repair", "维修");
|
||||
stateMap.put("demote", "降级");
|
||||
stateMap.put("scrap", "报废");
|
||||
stateMap.put("disable", "停用");
|
||||
stateMap.put("lend", "外借");
|
||||
if(bizType.equals("repair")){
|
||||
state = info.getRepairFlag();
|
||||
tableField = DeviceInfomationDO::getRepairFlag;
|
||||
}
|
||||
if(bizType.equals("demote")){
|
||||
state = info.getDemoteFlag();
|
||||
tableField = DeviceInfomationDO::getDemoteFlag;
|
||||
}
|
||||
if(bizType.equals("scrap")){
|
||||
state = info.getScrapFlag();
|
||||
tableField = DeviceInfomationDO::getScrapFlag;
|
||||
}
|
||||
if(bizType.equals("disable")){
|
||||
state = info.getDisableFlag();
|
||||
tableField = DeviceInfomationDO::getDisableFlag;
|
||||
}
|
||||
if(bizType.equals("lend")){
|
||||
state = info.getLendFlag();
|
||||
tableField = DeviceInfomationDO::getLendFlag;
|
||||
}
|
||||
if("-1".equals( state))
|
||||
return CommonResult.error(DEVICE_INFOMATION_NOT_EXISTS.getCode(), "请传入正确的业务类型!");
|
||||
//未传入状态,则切换状态
|
||||
if(flag == null){
|
||||
state = "1".equals(state) ? "0" : "1";
|
||||
}else{
|
||||
state = flag.equals(1) ? "1" : "0";
|
||||
}
|
||||
|
||||
JSONObject json = null;
|
||||
int index = -1;
|
||||
boolean itemFindFlag = false;
|
||||
for(int i = 0; i < arr.size(); i++){
|
||||
index = i;
|
||||
JSONObject item = arr.getJSONObject(i);
|
||||
if(item.getString("bizType").equals(bizType)){
|
||||
json = item;
|
||||
itemFindFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//如果栈里不存在记录
|
||||
if(json == null){
|
||||
//状态为正常,不做处理
|
||||
if(!"0".equals(state)){
|
||||
//插入记录
|
||||
json = new JSONObject();
|
||||
json.put("bizType", bizType);
|
||||
json.put("state", state);
|
||||
arr.add(0, json);
|
||||
}
|
||||
}else{
|
||||
//存在记录,移至最前端
|
||||
if(itemFindFlag)
|
||||
arr.remove(index);
|
||||
if("1".equals(state))
|
||||
arr.add(0, json);
|
||||
}
|
||||
info.setStateStack(arr.toJSONString());
|
||||
if(arr.isEmpty()){
|
||||
info.setStateShow("正常");
|
||||
}else{
|
||||
JSONObject first = arr.getJSONObject(0);
|
||||
String firstBiz = first.getString("bizType");
|
||||
info.setStateShow(stateMap.get(firstBiz));
|
||||
}
|
||||
//更新数据
|
||||
LambdaUpdateWrapper<DeviceInfomationDO> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(DeviceInfomationDO::getId, info.getId());
|
||||
updateWrapper.set(tableField, state);
|
||||
updateWrapper.set(DeviceInfomationDO::getStateShow, info.getStateShow());
|
||||
updateWrapper.set(DeviceInfomationDO::getStateStack, info.getStateStack());
|
||||
deviceInfomationMapper.update(updateWrapper);
|
||||
return CommonResult.success(info);
|
||||
}
|
||||
|
||||
/*
|
||||
* 更新“使用中”状态*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDeviceInUseFlag(Long deviceId, Integer inUseFlag) {
|
||||
String state = (1 == inUseFlag) ? "1" : "0";
|
||||
LambdaUpdateWrapper<DeviceInfomationDO> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(DeviceInfomationDO::getId, deviceId);
|
||||
updateWrapper.set(DeviceInfomationDO::getInUseFlag, state);
|
||||
deviceInfomationMapper.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceInfomationDO getByCode(String code) {
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
||||
*/
|
||||
public interface DeviceMaintainItemService {
|
||||
|
||||
void updateBatch(List<DeviceMaintainItemDO> list);
|
||||
|
||||
CommonResult<String> createItems(DeviceMaintainDO maintain, Long ruleId);
|
||||
|
||||
|
||||
@@ -39,6 +39,11 @@ public class DeviceMaintainItemServiceImpl implements DeviceMaintainItemService
|
||||
@Resource private DeviceMaintainItemMapper deviceMaintainItemMapper;
|
||||
@Resource private DeviceConfigBusinessItemService deviceConfigBusinessItemService;;
|
||||
|
||||
@Override
|
||||
public void updateBatch(List<DeviceMaintainItemDO> list) {
|
||||
deviceMaintainItemMapper.updateBatch(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult<String> createItems(DeviceMaintainDO maintain, Long ruleId) {
|
||||
|
||||
@@ -20,6 +20,8 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
||||
*/
|
||||
public interface DeviceMaintainService {
|
||||
|
||||
CommonResult<Boolean> saveMaintainVo(DeviceMaintainVO vo);
|
||||
|
||||
CommonResult<DeviceMaintainVO> createOrGet(Long deviceId, String date, String dataType);
|
||||
|
||||
CommonResult<DeviceMaintainVO> create(Long deviceId, LocalDate lastDate, String dataType);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zt.plat.module.qms.resource.device.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -21,11 +22,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainDO;
|
||||
@@ -53,13 +52,24 @@ public class DeviceMaintainServiceImpl implements DeviceMaintainService {
|
||||
@Resource private DeviceInfomationService deviceInfomationService;
|
||||
@Autowired private DeviceConfigBusinessRuleService deviceConfigBusinessRuleService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult<Boolean> saveMaintainVo(DeviceMaintainVO vo) {
|
||||
DeviceMaintainDO data = new DeviceMaintainDO();
|
||||
BeanUtil.copyProperties(vo, data);
|
||||
deviceMaintainMapper.updateById(data);
|
||||
List<DeviceMaintainItemDO> maintainItemList = vo.getMaintainItemList();
|
||||
deviceMaintainItemService.updateBatch(maintainItemList);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult<DeviceMaintainVO> createOrGet(Long deviceId, String date, String dataType){
|
||||
LocalDateTime curDate = LocalDateTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
if(!ObjectUtils.isEmpty(date))
|
||||
curDate = LocalDateTime.parse( date + " 00:00:00");
|
||||
curDate = LocalDateTime.parse( date + " 00:00:00", formatter);
|
||||
String dateStr = curDate.toLocalDate().toString();
|
||||
//查询上一个点检记录
|
||||
DeviceMaintainDO lastData = getLastData(deviceId, dataType, dateStr).getData();
|
||||
@@ -121,7 +131,7 @@ public class DeviceMaintainServiceImpl implements DeviceMaintainService {
|
||||
|
||||
@Override
|
||||
public CommonResult<DeviceMaintainVO> getMaintainDetail(Long id) {
|
||||
DeviceMaintainVO vo = deviceMaintainMapper.queryMaintainVoById( id);
|
||||
DeviceMaintainVO vo = deviceMaintainMapper.queryVoById( id);
|
||||
if(vo == null)
|
||||
throw exception(DEVICE_MAINTAIN_NOT_EXISTS);
|
||||
List<DeviceMaintainItemDO> itemList = deviceMaintainItemService.getListByParId( id);
|
||||
|
||||
@@ -2,9 +2,8 @@ package com.zt.plat.module.qms.resource.device.service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceUseRecordPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceUseRecordRespVO;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceUseRecordSaveReqVO;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.*;
|
||||
import jakarta.validation.*;
|
||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceUseRecordDO;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
@@ -16,13 +15,16 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
||||
*/
|
||||
public interface DeviceUseRecordService {
|
||||
|
||||
|
||||
PageResult<DeviceUseRecordVO> queryPageListWithCount(DeviceUseRecordPageReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 创建设备-使用记录
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
DeviceUseRecordRespVO createDeviceUseRecord(@Valid DeviceUseRecordSaveReqVO createReqVO);
|
||||
CommonResult<DeviceUseRecordRespVO> createDeviceUseRecord(@Valid DeviceUseRecordSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新设备-使用记录
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package com.zt.plat.module.qms.resource.device.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.security.core.LoginUser;
|
||||
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceUseRecordPageReqVO;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceUseRecordRespVO;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceUseRecordSaveReqVO;
|
||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceUseRecordVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
@@ -17,6 +22,7 @@ import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.qms.resource.device.dal.mapper.DeviceUseRecordMapper;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_USE_RECORD_NOT_EXISTS;
|
||||
|
||||
@@ -29,16 +35,34 @@ import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_USE_RECORD_
|
||||
@Validated
|
||||
public class DeviceUseRecordServiceImpl implements DeviceUseRecordService {
|
||||
|
||||
@Resource
|
||||
private DeviceUseRecordMapper deviceUseRecordMapper;
|
||||
@Resource private DeviceInfomationService deviceInfomationService;
|
||||
@Resource private DeviceUseRecordMapper deviceUseRecordMapper;
|
||||
|
||||
@Override
|
||||
public DeviceUseRecordRespVO createDeviceUseRecord(DeviceUseRecordSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
DeviceUseRecordDO deviceUseRecord = BeanUtils.toBean(createReqVO, DeviceUseRecordDO.class);
|
||||
public PageResult<DeviceUseRecordVO> queryPageListWithCount(DeviceUseRecordPageReqVO reqVO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<DeviceUseRecordRespVO> createDeviceUseRecord(DeviceUseRecordSaveReqVO reqVO) {
|
||||
Long deviceId = reqVO.getDeviceId();
|
||||
if(ObjectUtils.isEmpty(reqVO.getUserName())){
|
||||
//当前登录人
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
//当前登录用户昵称
|
||||
String nickName = SecurityFrameworkUtils.getLoginUserNickname();
|
||||
reqVO.setUserName(nickName);
|
||||
reqVO.setUserId(loginUser.getId());
|
||||
}
|
||||
DeviceUseRecordDO deviceUseRecord = BeanUtils.toBean(reqVO, DeviceUseRecordDO.class);
|
||||
deviceUseRecordMapper.insert(deviceUseRecord);
|
||||
if(reqVO.getUseTimeEnd() == null)
|
||||
deviceInfomationService.updateDeviceInUseFlag(deviceId, 1);
|
||||
else
|
||||
deviceInfomationService.updateDeviceInUseFlag(deviceId, 0);
|
||||
// 返回
|
||||
return BeanUtils.toBean(deviceUseRecord, DeviceUseRecordRespVO.class);
|
||||
DeviceUseRecordRespVO respVO = BeanUtils.toBean(deviceUseRecord, DeviceUseRecordRespVO.class);
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,22 @@
|
||||
|
||||
<resultMap id="DeviceMaintainVO" type="com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainVO">
|
||||
<id property="id" column="ID"/>
|
||||
<result property="deviceName" column="DEV_NAME"/>
|
||||
<result property="dataType" column="DAT_TP"/>
|
||||
<result property="ruleId" column="RUL_ID"/>
|
||||
<result property="deviceId" column="DEV_ID"/>
|
||||
<result property="checkDate" column="CHK_DT"/>
|
||||
<result property="content" column="CNTT"/>
|
||||
<result property="checkUserId" column="CHK_USER_ID"/>
|
||||
<result property="checkUserName" column="CHK_USER_NAME"/>
|
||||
<result property="frequencyType" column="FREQ_TP"/>
|
||||
<result property="frequency" column="FREQ"/>
|
||||
<result property="frequencyRemark" column="FREQ_RMK"/>
|
||||
<result property="frequencyTimeStart" column="FREQ_TM_STRT"/>
|
||||
<result property="frequencyTimeEnd" column="FREQ_TM_END"/>
|
||||
<result property="submitFlag" column="SBM_FLG"/>
|
||||
<result property="systemDepartmentCode" column="SYS_DEPT_CD"/>
|
||||
<result property="remark" column="RMK"/>
|
||||
<!--扩展字段-->
|
||||
<result property="alias" column="ALS"/>
|
||||
<result property="deviceCode" column="DEV_CD"/>
|
||||
<result property="factoryCode" column="FACT_CD"/>
|
||||
@@ -44,7 +59,7 @@
|
||||
p.MDL_NO
|
||||
</sql>
|
||||
|
||||
<select id="queryMaintainVoById" resultMap="DeviceMaintainVO">
|
||||
<select id="queryVoById" resultMap="DeviceMaintainVO">
|
||||
select m.*,
|
||||
<include refid="fieldDAndP"/>
|
||||
from T_DEV_MATN m
|
||||
@@ -59,7 +74,7 @@
|
||||
<select id="queryPageListWithCount" resultMap="DeviceMaintainVO">
|
||||
select
|
||||
<include refid="fieldDAndP"/>
|
||||
(
|
||||
,(
|
||||
select count(*) from T_DEV_MATN m
|
||||
where m.DAT_TP = #{param.dataType}
|
||||
<if test="param.checkDate != null and param.checkDate.length>0">
|
||||
|
||||
@@ -1,12 +1,129 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zt.plat.module.qms.resource.device.dal.mapper.DeviceUseRecordMapper">
|
||||
<resultMap id="DeviceUseRecordVO" type="com.zt.plat.module.qms.resource.device.controller.vo.DeviceUseRecordVO">
|
||||
<id property="id" column="ID"/>
|
||||
<result property="deviceId" column="DEV_ID"/>
|
||||
<result property="userName" column="DAT_TP"/>
|
||||
<result property="userId" column="USER_ID"/>
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
<result property="useTimeStart" column="USE_TM_STRT"/>
|
||||
<result property="useTimeEnd" column="USE_TM_END"/>
|
||||
<result property="useRemark" column="USE_RMK"/>
|
||||
<result property="stateBefore" column="STA_BFR"/>
|
||||
<result property="stateRun" column="STA_RN"/>
|
||||
<result property="stateAfter" column="STA_AFT"/>
|
||||
<result property="temperature" column="TMP"/>
|
||||
<result property="humidity" column="HMD"/>
|
||||
<result property="dataSource" column="DAT_SRC"/>
|
||||
<result property="systemDepartmentCode" column="SYS_DEPT_CD"/>
|
||||
<result property="remark" column="RMK"/>
|
||||
<!--扩展字段-->
|
||||
<result property="alias" column="ALS"/>
|
||||
<result property="deviceCode" column="DEV_CD"/>
|
||||
<result property="factoryCode" column="FACT_CD"/>
|
||||
<result property="deptName" column="DEPT_NAME"/>
|
||||
<result property="repairFlag" column="RPR_FLG"/>
|
||||
<result property="demoteFlag" column="DMOT_FLG"/>
|
||||
<result property="scrapFlag" column="SCR_FLG"/>
|
||||
<result property="disableFlag" column="DSBL_FLG"/>
|
||||
<result property="lendFlag" column="LND_FLG"/>
|
||||
<result property="inUseFlag" column="IN_USE_FLG"/>
|
||||
<result property="acceptFlag" column="ACPT_FLG"/>
|
||||
<result property="productId" column="PRODUCT_ID"/>
|
||||
<result property="manufacturer" column="MFR"/>
|
||||
<result property="specification" column="SPEC"/>
|
||||
<result property="modelNo" column="MDL_NO"/>
|
||||
<result property="finishedCount" column="finished_count"/>
|
||||
<result property="runningCount" column="running_count"/>
|
||||
|
||||
</resultMap>
|
||||
|
||||
<sql id="fieldDAndP">
|
||||
d.DEV_NAME,
|
||||
d.ALS,
|
||||
d.DEV_CD,
|
||||
d.FACT_CD,
|
||||
d.DEPT_NAME,
|
||||
d.RPR_FLG,
|
||||
d.DMOT_FLG,
|
||||
d.SCR_FLG,
|
||||
d.DSBL_FLG,
|
||||
d.LND_FLG,
|
||||
d.IN_USE_FLG,
|
||||
d.ACPT_FLG,
|
||||
p.ID as PRODUCT_ID,
|
||||
p.MFR,
|
||||
p.SPEC,
|
||||
p.MDL_NO
|
||||
</sql>
|
||||
|
||||
<select id="queryVoById" resultMap="DeviceUseRecordVO">
|
||||
select m.*,
|
||||
<include refid="fieldDAndP"/>
|
||||
from T_DEV_USE_RCD m
|
||||
left join T_DEV_INF d on m.DEV_ID = d.id
|
||||
left join T_DEV_PDT p on d.PDT_ID = p.id
|
||||
<where>
|
||||
and m.ID = #{id}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryPageListWithCount" resultMap="DeviceUseRecordVO">
|
||||
select
|
||||
<include refid="fieldDAndP"/>
|
||||
,(
|
||||
select count(*) from T_DEV_USE_RCD m
|
||||
where 1=1
|
||||
<if test="param.useTimeStart != null and param.useTimeStart.length>0">
|
||||
and m.USE_TM_STRT between #{param.useTimeStart[0]} and #{param.useTimeStart[1]}
|
||||
</if>
|
||||
and m.USE_TM_END is not null
|
||||
and m.DELETED = 0
|
||||
) as finished_count,
|
||||
(
|
||||
select count(*) from T_DEV_USE_RCD m
|
||||
where 1=1
|
||||
<if test="param.useTimeStart != null and param.useTimeStart.length>0">
|
||||
and m.USE_TM_STRT between #{param.useTimeStart[0]} and #{param.useTimeStart[1]}
|
||||
</if>
|
||||
and m.USE_TM_END is null
|
||||
and m.DELETED = 0
|
||||
) as running_count
|
||||
from T_DEV_INF d
|
||||
left join T_DEV_PDT p on d.PDT_ID = p.ID
|
||||
<where>
|
||||
<if test="param.deviceId != null and param.deviceId != ''">
|
||||
and d.id = #{param.deviceId}
|
||||
</if>
|
||||
<if test="param.deviceIdList!=null and param.deviceIdList.size>0">
|
||||
and d.id in
|
||||
<foreach collection="param.deviceIdList" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="param.productId != null">
|
||||
and d.PDT_ID = #{param.productId}
|
||||
</if>
|
||||
<if test="param.productIdList!=null and param.productIdList.size>0">
|
||||
and d.PDT_ID in
|
||||
<foreach collection="param.productIdList" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="param.deviceName != null and param.deviceName != ''">
|
||||
and d.DEV_NAME like concat(concat('%', #{param.deviceName}), '%')
|
||||
</if>
|
||||
<if test="param.deviceCode != null and param.deviceCode != ''">
|
||||
and d.DEV_CD like concat(concat('%', #{param.deviceCode}), '%')
|
||||
</if>
|
||||
<if test="param.deptName != null and param.deptName != ''">
|
||||
and d.DEPT_NAME = #{param.deptName}
|
||||
</if>
|
||||
and d.DELETED = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user