feat:设备接口开发:业务配置、维护等
This commit is contained in:
@@ -105,7 +105,7 @@ public class RedisSessionComponent {
|
|||||||
context.setDeviceType(deviceType);
|
context.setDeviceType(deviceType);
|
||||||
context.setDeviceCode(deviceCode);
|
context.setDeviceCode(deviceCode);
|
||||||
if(deviceInfo != null){
|
if(deviceInfo != null){
|
||||||
context.setDeviceName(deviceInfo.getProductName());
|
context.setDeviceName(deviceInfo.getDeviceName());
|
||||||
context.setTenantId(deviceInfo.getTenantId().toString());
|
context.setTenantId(deviceInfo.getTenantId().toString());
|
||||||
deviceInfo.setIsConnect("1");
|
deviceInfo.setIsConnect("1");
|
||||||
deviceInfo.setLastConnectTime(LocalDateTime.now());
|
deviceInfo.setLastConnectTime(LocalDateTime.now());
|
||||||
|
|||||||
@@ -0,0 +1,140 @@
|
|||||||
|
package com.zt.plat.module.qms.resource.device.common;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
|
import java.time.DayOfWeek;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.time.temporal.TemporalAdjusters;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DeviceUtil {
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 根据频率类型,获取当前频率周期的开始时间和结束时间
|
||||||
|
* @param date 上次执行日期
|
||||||
|
* @param frequencyType 频率类型
|
||||||
|
* @param frequency 频率
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static LocalDateTime[] getDateRangeByFrequency(LocalDate date, boolean nextFlag, String frequencyType, String frequency) {
|
||||||
|
LocalDate referenceDate = (date != null) ? date : LocalDate.now();
|
||||||
|
LocalDate startDate = null;
|
||||||
|
LocalDate endDate = null;
|
||||||
|
int frequencyInt = Integer.parseInt(frequency);
|
||||||
|
if(!nextFlag)
|
||||||
|
frequencyInt --;
|
||||||
|
switch (frequencyType.toLowerCase()) {
|
||||||
|
case "day":
|
||||||
|
startDate = referenceDate.plusDays(frequencyInt);
|
||||||
|
endDate = startDate.plusDays(frequencyInt + 1);
|
||||||
|
break;
|
||||||
|
// case "day_before_use": //每天第一次使用前,与按天相同。 截止2025-4-19,未启用此项
|
||||||
|
// startDate = referenceDate.plusDays(frequencyInt);
|
||||||
|
// endDate = startDate.plusDays(frequencyInt + 1);
|
||||||
|
// break;
|
||||||
|
case "week":
|
||||||
|
startDate = referenceDate.plusWeeks(frequencyInt);
|
||||||
|
startDate = startDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
||||||
|
endDate = startDate.plusWeeks(1).minusDays(1);
|
||||||
|
break;
|
||||||
|
case "month":
|
||||||
|
startDate = referenceDate.plusMonths(frequencyInt).withDayOfMonth(1);
|
||||||
|
endDate = startDate.plusMonths(1).minusDays(1);
|
||||||
|
break;
|
||||||
|
case "year":
|
||||||
|
startDate = referenceDate.plusYears(frequencyInt);
|
||||||
|
endDate = startDate.plusYears(1).minusDays(1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new LocalDateTime[]{
|
||||||
|
LocalDateTime.of(startDate, LocalTime.of(0, 0, 0)),
|
||||||
|
LocalDateTime.of(endDate, LocalTime.of(23, 59, 59))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String assembleCommentJson(JSONArray flow){
|
||||||
|
if(flow == null)
|
||||||
|
return "";
|
||||||
|
JSONArray entity = new JSONArray();
|
||||||
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
for(int i = flow.size() - 1; i >= 0; i--){
|
||||||
|
JSONObject flowItem = flow.getJSONObject(i);
|
||||||
|
String historyActivityId = flowItem.getString("historyActivityId");
|
||||||
|
String historyActivityName = flowItem.getString("historyActivityName");
|
||||||
|
if(checkContains(entity, historyActivityId))
|
||||||
|
continue;
|
||||||
|
String assigneeName = flowItem.getString("assigneeName");
|
||||||
|
String assignee = flowItem.getString("assignee");
|
||||||
|
String endTime = flowItem.getString("endTime");
|
||||||
|
JSONArray comments = flowItem.getJSONArray("comments");
|
||||||
|
String comment = "";
|
||||||
|
if(comments != null && comments.size() > 0){
|
||||||
|
comment = comments.getJSONObject(0).getString("message");
|
||||||
|
}
|
||||||
|
if(!historyActivityId.toLowerCase().startsWith("activity_"))
|
||||||
|
continue;
|
||||||
|
if(!ObjectUtils.isEmpty(endTime)){
|
||||||
|
JSONObject commentObj = new JSONObject();
|
||||||
|
commentObj.put("nodeId", historyActivityId);
|
||||||
|
commentObj.put("nodeName", historyActivityName);
|
||||||
|
commentObj.put("comment", comment);
|
||||||
|
commentObj.put("userName", assigneeName);
|
||||||
|
commentObj.put("userId", assignee);
|
||||||
|
commentObj.put("time", endTime);
|
||||||
|
entity.add(commentObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entity.toJSONString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void transCommentToValue(JSONObject voJson, String commentJsonStr){
|
||||||
|
List<String> hasActivityList = new ArrayList<>();
|
||||||
|
if(!ObjectUtils.isEmpty(commentJsonStr)){
|
||||||
|
JSONArray arr = JSONArray.parseArray(commentJsonStr);
|
||||||
|
for(int i=0;i<arr.size();i++){
|
||||||
|
JSONObject obj = arr.getJSONObject(i);
|
||||||
|
String nodeId = obj.getString("nodeId");
|
||||||
|
String time = obj.getString("time");
|
||||||
|
String comment = obj.getString("comment");
|
||||||
|
String userName = obj.getString("userName");
|
||||||
|
if(hasActivityList.contains(nodeId))
|
||||||
|
continue;
|
||||||
|
voJson.put(nodeId + "-Comment",comment);
|
||||||
|
voJson.put(nodeId + "-Time",time);
|
||||||
|
voJson.put(nodeId + "-UserName",userName);
|
||||||
|
hasActivityList.add(nodeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkContains(JSONArray entity, String nodeId){
|
||||||
|
for(int i = 0; i < entity.size(); i++){
|
||||||
|
JSONObject item2 = entity.getJSONObject(i);
|
||||||
|
if(item2.getString("nodeId").equals(nodeId)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
LocalDate lastDate = LocalDate.of(2025, 3 , 25);
|
||||||
|
String frequencyType = "month";
|
||||||
|
String frequency = "3";
|
||||||
|
|
||||||
|
LocalDateTime[] result = getDateRangeByFrequency(lastDate, false, frequencyType, frequency);
|
||||||
|
System.out.println("Start Date: " + result[0]);
|
||||||
|
System.out.println("End Date: " + result[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.device.service.DeviceAffiliationRelativit
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 附属设备关系")
|
@Tag(name = "管理后台 - 附属设备关系")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/device-affiliation-relativity")
|
@RequestMapping("/qms/resource/device-affiliation-relativity")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.deviceaffiliationrelativity")
|
@FileUploadController(source = "qms.deviceaffiliationrelativity")
|
||||||
public class DeviceAffiliationRelativityController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class DeviceAffiliationRelativityController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.device.service.DeviceApplyService;
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 设备通用流程,验收、降级、停用、报废、还原、启用")
|
@Tag(name = "管理后台 - 设备通用流程,验收、降级、停用、报废、还原、启用")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/device-apply")
|
@RequestMapping("/qms/resource/device-apply")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.deviceapply")
|
@FileUploadController(source = "qms.deviceapply")
|
||||||
public class DeviceApplyController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class DeviceApplyController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.device.service.DeviceApplyDetailService;
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 设备通用流程明细")
|
@Tag(name = "管理后台 - 设备通用流程明细")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/device-apply-detail")
|
@RequestMapping("/qms/resource/device-apply-detail")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.deviceapplydetail")
|
@FileUploadController(source = "qms.deviceapplydetail")
|
||||||
public class DeviceApplyDetailController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class DeviceApplyDetailController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.device.service.DeviceCalibrationService;
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 设备-检定校准")
|
@Tag(name = "管理后台 - 设备-检定校准")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/device-calibration")
|
@RequestMapping("/qms/resource/device-calibration")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.devicecalibration")
|
@FileUploadController(source = "qms.devicecalibration")
|
||||||
public class DeviceCalibrationController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class DeviceCalibrationController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.device.service.DeviceCalibrationPlanServi
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 设备-检定校准计划")
|
@Tag(name = "管理后台 - 设备-检定校准计划")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/device-calibration-plan")
|
@RequestMapping("/qms/resource/device-calibration-plan")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.devicecalibrationplan")
|
@FileUploadController(source = "qms.devicecalibrationplan")
|
||||||
public class DeviceCalibrationPlanController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class DeviceCalibrationPlanController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.device.service.DeviceConfigBusinessItemSe
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 设备-检查项目配置")
|
@Tag(name = "管理后台 - 设备-检查项目配置")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/device-config-business-item")
|
@RequestMapping("/qms/resource/device-config-business-item")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.deviceconfigbusinessitem")
|
@FileUploadController(source = "qms.deviceconfigbusinessitem")
|
||||||
public class DeviceConfigBusinessItemController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class DeviceConfigBusinessItemController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.zt.plat.module.qms.resource.device.controller.admin;
|
package com.zt.plat.module.qms.resource.device.controller.admin;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRulePageReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRulePageReqVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRuleRespVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRuleRespVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRuleSaveReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRuleSaveReqVO;
|
||||||
|
import com.zt.plat.module.qms.resource.device.dal.mapper.DeviceConfigBusinessRuleMapper;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -37,7 +39,7 @@ import com.zt.plat.module.qms.resource.device.service.DeviceConfigBusinessRuleSe
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 设备-业务配置")
|
@Tag(name = "管理后台 - 设备-业务配置")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/device-config-business-rule")
|
@RequestMapping("/qms/resource/device-config-business-rule")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.deviceconfigbusinessrule")
|
@FileUploadController(source = "qms.deviceconfigbusinessrule")
|
||||||
public class DeviceConfigBusinessRuleController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class DeviceConfigBusinessRuleController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
@@ -49,8 +51,8 @@ public class DeviceConfigBusinessRuleController extends AbstractFileUploadContro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Resource
|
@Resource private DeviceConfigBusinessRuleService deviceConfigBusinessRuleService;
|
||||||
private DeviceConfigBusinessRuleService deviceConfigBusinessRuleService;
|
@Resource private DeviceConfigBusinessRuleMapper deviceConfigBusinessRuleMapper;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建设备-业务配置")
|
@Operation(summary = "创建设备-业务配置")
|
||||||
@@ -59,6 +61,17 @@ public class DeviceConfigBusinessRuleController extends AbstractFileUploadContro
|
|||||||
return success(deviceConfigBusinessRuleService.createDeviceConfigBusinessRule(createReqVO));
|
return success(deviceConfigBusinessRuleService.createDeviceConfigBusinessRule(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/getByProductId")
|
||||||
|
@Operation(summary = "获得设备-业务配置")
|
||||||
|
@Parameter(name = "productId", description = "设备大类id", required = true, example = "1024")
|
||||||
|
public CommonResult<DeviceConfigBusinessRuleRespVO> getByProductId(@RequestParam("productId") Long productId) {
|
||||||
|
DeviceConfigBusinessRuleDO entity = deviceConfigBusinessRuleService.getByProductId(productId);
|
||||||
|
if(entity == null)
|
||||||
|
return success(null);
|
||||||
|
return success(BeanUtils.toBean(entity, DeviceConfigBusinessRuleRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新设备-业务配置")
|
@Operation(summary = "更新设备-业务配置")
|
||||||
@PreAuthorize("@ss.hasPermission('qms:device-config-business-rule:update')")
|
@PreAuthorize("@ss.hasPermission('qms:device-config-business-rule:update')")
|
||||||
|
|||||||
@@ -51,6 +51,13 @@ public class DeviceInfomationController extends AbstractFileUploadController imp
|
|||||||
@Resource private DeviceInfomationService deviceInfomationService;
|
@Resource private DeviceInfomationService deviceInfomationService;
|
||||||
@Resource private DeviceProductService deviceProductService;
|
@Resource private DeviceProductService deviceProductService;
|
||||||
|
|
||||||
|
@PostMapping("/saveDevice")
|
||||||
|
@Operation(summary = "创建设备-设备信息")
|
||||||
|
// @PreAuthorize("@ss.hasPermission('resource:device-infomation:create')")
|
||||||
|
public CommonResult<DeviceInfomationRespVO> saveDevice(@Valid @RequestBody DeviceInfomationSaveReqVO reqVO) {
|
||||||
|
return deviceInfomationService.saveDevice(reqVO);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建设备-设备信息")
|
@Operation(summary = "创建设备-设备信息")
|
||||||
@PreAuthorize("@ss.hasPermission('resource:device-infomation:create')")
|
@PreAuthorize("@ss.hasPermission('resource:device-infomation:create')")
|
||||||
@@ -99,10 +106,11 @@ public class DeviceInfomationController extends AbstractFileUploadController imp
|
|||||||
public CommonResult<PageResult<DeviceInfomationRespVO>> getDeviceInfomationPage(@Valid DeviceInfomationPageReqVO pageReqVO) {
|
public CommonResult<PageResult<DeviceInfomationRespVO>> getDeviceInfomationPage(@Valid DeviceInfomationPageReqVO pageReqVO) {
|
||||||
Long productId = pageReqVO.getProductId();
|
Long productId = pageReqVO.getProductId();
|
||||||
if(productId != null){
|
if(productId != null){
|
||||||
List<DeviceProductDO> productDOList = deviceProductService.listByIdPath(productId, DataTypeConstant.DATA_TYPE_DATA);
|
List<Long> productIds = deviceProductService.getIdListByIdPath(productId);
|
||||||
List<Long> productIds = productDOList.stream().map(DeviceProductDO::getId).toList();
|
if(!productIds.isEmpty()){
|
||||||
pageReqVO.setProductIds(productIds);
|
pageReqVO.setProductIds(productIds);
|
||||||
pageReqVO.setProductId(null);
|
pageReqVO.setProductId(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
PageResult<DeviceInfomationDO> pageResult = deviceInfomationService.getDeviceInfomationPage(pageReqVO);
|
PageResult<DeviceInfomationDO> pageResult = deviceInfomationService.getDeviceInfomationPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, DeviceInfomationRespVO.class));
|
return success(BeanUtils.toBean(pageResult, DeviceInfomationRespVO.class));
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package com.zt.plat.module.qms.resource.device.controller.admin;
|
package com.zt.plat.module.qms.resource.device.controller.admin;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainPageReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainPageReqVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainRespVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainRespVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainSaveReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainSaveReqVO;
|
||||||
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainVO;
|
||||||
|
import com.zt.plat.module.qms.resource.device.service.DeviceInfomationService;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -17,6 +21,8 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
|
|
||||||
import jakarta.validation.*;
|
import jakarta.validation.*;
|
||||||
import jakarta.servlet.http.*;
|
import jakarta.servlet.http.*;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@@ -31,13 +37,14 @@ import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
|||||||
|
|
||||||
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
|
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
|
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_MAINTAIN_NOT_EXISTS;
|
||||||
|
|
||||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainDO;
|
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainDO;
|
||||||
import com.zt.plat.module.qms.resource.device.service.DeviceMaintainService;
|
import com.zt.plat.module.qms.resource.device.service.DeviceMaintainService;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 设备-点检、保养记录")
|
@Tag(name = "管理后台 - 设备-点检、保养记录")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/device-maintain")
|
@RequestMapping("/qms/resource/device-maintain")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.devicemaintain")
|
@FileUploadController(source = "qms.devicemaintain")
|
||||||
public class DeviceMaintainController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class DeviceMaintainController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
@@ -49,8 +56,43 @@ public class DeviceMaintainController extends AbstractFileUploadController imple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Resource
|
@Resource private DeviceMaintainService deviceMaintainService;
|
||||||
private DeviceMaintainService deviceMaintainService;
|
@Resource private DeviceInfomationService deviceInfomationService;
|
||||||
|
|
||||||
|
@PostMapping("/createOrGet")
|
||||||
|
@Operation(summary = "创建或获取维护数据")
|
||||||
|
public CommonResult<DeviceMaintainVO> createOrGet(@RequestBody JSONObject jsonObject) {
|
||||||
|
Long deviceId = jsonObject.getLong("deviceId");
|
||||||
|
String dataType = jsonObject.getString("dataType");
|
||||||
|
String dateStr = jsonObject.getString("date");
|
||||||
|
if (deviceId == null || dataType == null) {
|
||||||
|
return CommonResult.error(DEVICE_MAINTAIN_NOT_EXISTS.getCode(), "参数错误");
|
||||||
|
}
|
||||||
|
//检查设备状态
|
||||||
|
CommonResult<Boolean> checkResult = deviceInfomationService.checkDeviceUsable(deviceId);
|
||||||
|
if(!checkResult.isSuccess()){
|
||||||
|
return checkResult.error(checkResult.getCode(), checkResult.getMsg());
|
||||||
|
}
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
if(ObjectUtils.isEmpty(dateStr))
|
||||||
|
dateStr = sdf.format(new Date());
|
||||||
|
return deviceMaintainService.createOrGet(deviceId, dateStr, dataType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/getMaintainDetail")
|
||||||
|
@Operation(summary = "查询维护记录详情")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
public CommonResult<DeviceMaintainVO> getMaintainDetail(@RequestParam("id") Long id) {
|
||||||
|
return deviceMaintainService.getMaintainDetail(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/queryPageListWithCount")
|
||||||
|
@Operation(summary = "维护-分页列表查询")
|
||||||
|
public CommonResult<PageResult<DeviceMaintainVO>> queryPageListWithCount(@Valid DeviceMaintainPageReqVO pageReqVO) {
|
||||||
|
PageResult<DeviceMaintainVO> pageResult = deviceMaintainService.queryPageListWithCount(pageReqVO);
|
||||||
|
return success(pageResult);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建设备-点检、保养记录")
|
@Operation(summary = "创建设备-点检、保养记录")
|
||||||
@@ -88,7 +130,6 @@ public class DeviceMaintainController extends AbstractFileUploadController imple
|
|||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "获得设备-点检、保养记录")
|
@Operation(summary = "获得设备-点检、保养记录")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('qms:device-maintain:query')")
|
|
||||||
public CommonResult<DeviceMaintainRespVO> getDeviceMaintain(@RequestParam("id") Long id) {
|
public CommonResult<DeviceMaintainRespVO> getDeviceMaintain(@RequestParam("id") Long id) {
|
||||||
DeviceMaintainDO deviceMaintain = deviceMaintainService.getDeviceMaintain(id);
|
DeviceMaintainDO deviceMaintain = deviceMaintainService.getDeviceMaintain(id);
|
||||||
return success(BeanUtils.toBean(deviceMaintain, DeviceMaintainRespVO.class));
|
return success(BeanUtils.toBean(deviceMaintain, DeviceMaintainRespVO.class));
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.device.service.DeviceMaintainItemService;
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 设备-保养分项")
|
@Tag(name = "管理后台 - 设备-保养分项")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/device-maintain-item")
|
@RequestMapping("/qms/resource/device-maintain-item")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.devicemaintainitem")
|
@FileUploadController(source = "qms.devicemaintainitem")
|
||||||
public class DeviceMaintainItemController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class DeviceMaintainItemController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.device.service.DevicePeriodCheckService;
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 设备-期间核查")
|
@Tag(name = "管理后台 - 设备-期间核查")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/device-period-check")
|
@RequestMapping("/qms/resource/device-period-check")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.deviceperiodcheck")
|
@FileUploadController(source = "qms.deviceperiodcheck")
|
||||||
public class DevicePeriodCheckController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class DevicePeriodCheckController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.device.service.DevicePeriodCheckPlanServi
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 设备-期间核查计划")
|
@Tag(name = "管理后台 - 设备-期间核查计划")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/device-period-check-plan")
|
@RequestMapping("/qms/resource/device-period-check-plan")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.deviceperiodcheckplan")
|
@FileUploadController(source = "qms.deviceperiodcheckplan")
|
||||||
public class DevicePeriodCheckPlanController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class DevicePeriodCheckPlanController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.device.service.DeviceRepairApplyService;
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 维修申请")
|
@Tag(name = "管理后台 - 维修申请")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/device-repair-apply")
|
@RequestMapping("/qms/resource/device-repair-apply")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.devicerepairapply")
|
@FileUploadController(source = "qms.devicerepairapply")
|
||||||
public class DeviceRepairApplyController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class DeviceRepairApplyController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.device.service.DeviceRepairDetailService;
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 设备维修明细")
|
@Tag(name = "管理后台 - 设备维修明细")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/device-repair-detail")
|
@RequestMapping("/qms/resource/device-repair-detail")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.devicerepairdetail")
|
@FileUploadController(source = "qms.devicerepairdetail")
|
||||||
public class DeviceRepairDetailController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class DeviceRepairDetailController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.device.service.DeviceRepairResultDetailSe
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 故障处理明细")
|
@Tag(name = "管理后台 - 故障处理明细")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/device-repair-result-detail")
|
@RequestMapping("/qms/resource/device-repair-result-detail")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.devicerepairresultdetail")
|
@FileUploadController(source = "qms.devicerepairresultdetail")
|
||||||
public class DeviceRepairResultDetailController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class DeviceRepairResultDetailController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.device.service.DeviceUseRecordService;
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 设备-使用记录")
|
@Tag(name = "管理后台 - 设备-使用记录")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/device-use-record")
|
@RequestMapping("/qms/resource/device-use-record")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.deviceuserecord")
|
@FileUploadController(source = "qms.deviceuserecord")
|
||||||
public class DeviceUseRecordController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class DeviceUseRecordController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class DeviceInfomationPageReqVO extends PageParam {
|
|||||||
private Long productId;
|
private Long productId;
|
||||||
|
|
||||||
@Schema(description = "设备名称", example = "张三")
|
@Schema(description = "设备名称", example = "张三")
|
||||||
private String productName;
|
private String deviceName;
|
||||||
|
|
||||||
@Schema(description = "别名")
|
@Schema(description = "别名")
|
||||||
private String alias;
|
private String alias;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class DeviceInfomationRespVO {
|
|||||||
|
|
||||||
@Schema(description = "设备名称", example = "张三")
|
@Schema(description = "设备名称", example = "张三")
|
||||||
@ExcelProperty("设备名称")
|
@ExcelProperty("设备名称")
|
||||||
private String productName;
|
private String deviceName;
|
||||||
|
|
||||||
@Schema(description = "别名")
|
@Schema(description = "别名")
|
||||||
@ExcelProperty("别名")
|
@ExcelProperty("别名")
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package com.zt.plat.module.qms.resource.device.controller.vo;
|
package com.zt.plat.module.qms.resource.device.controller.vo;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 设备-设备信息新增/修改 Request VO")
|
@Schema(description = "管理后台 - 设备-设备信息新增/修改 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@@ -15,10 +16,11 @@ public class DeviceInfomationSaveReqVO {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "设备大类id", example = "32101")
|
@Schema(description = "设备大类id", example = "32101")
|
||||||
|
@NotNull(message = "请选择设备大类!")
|
||||||
private Long productId;
|
private Long productId;
|
||||||
|
|
||||||
@Schema(description = "设备名称", example = "张三")
|
@Schema(description = "设备名称", example = "张三")
|
||||||
private String productName;
|
private String deviceName;
|
||||||
|
|
||||||
@Schema(description = "别名")
|
@Schema(description = "别名")
|
||||||
private String alias;
|
private String alias;
|
||||||
@@ -54,6 +56,7 @@ public class DeviceInfomationSaveReqVO {
|
|||||||
private String deviceNumber;
|
private String deviceNumber;
|
||||||
|
|
||||||
@Schema(description = "管理编号")
|
@Schema(description = "管理编号")
|
||||||
|
@NotEmpty (message = "管理编号不能为空!")
|
||||||
private String deviceCode;
|
private String deviceCode;
|
||||||
|
|
||||||
@Schema(description = "资产编号")
|
@Schema(description = "资产编号")
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.zt.plat.module.qms.resource.device.controller.vo;
|
package com.zt.plat.module.qms.resource.device.controller.vo;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import java.util.*;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import com.zt.plat.framework.common.pojo.PageParam;
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
@@ -51,10 +50,10 @@ public class DeviceMaintainItemPageReqVO extends PageParam {
|
|||||||
private String frequency;
|
private String frequency;
|
||||||
|
|
||||||
@Schema(description = "所属周期开始日期")
|
@Schema(description = "所属周期开始日期")
|
||||||
private LocalDateTime frequencyItemStart;
|
private LocalDateTime frequencyTimeStart;
|
||||||
|
|
||||||
@Schema(description = "所属周期截止日期")
|
@Schema(description = "所属周期截止日期")
|
||||||
private LocalDateTime frequencyItemEnd;
|
private LocalDateTime frequencyTimeEnd;
|
||||||
|
|
||||||
@Schema(description = "检查标准")
|
@Schema(description = "检查标准")
|
||||||
private String standard;
|
private String standard;
|
||||||
@@ -69,7 +68,7 @@ public class DeviceMaintainItemPageReqVO extends PageParam {
|
|||||||
private String dutyRemark;
|
private String dutyRemark;
|
||||||
|
|
||||||
@Schema(description = "排序号")
|
@Schema(description = "排序号")
|
||||||
private Integer periodNo;
|
private Integer sortNo;
|
||||||
|
|
||||||
@Schema(description = "所属部门")
|
@Schema(description = "所属部门")
|
||||||
private String systemDepartmentCode;
|
private String systemDepartmentCode;
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ package com.zt.plat.module.qms.resource.device.controller.vo;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import java.util.*;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import com.alibaba.excel.annotation.*;
|
import com.alibaba.excel.annotation.*;
|
||||||
|
|
||||||
@@ -66,11 +65,11 @@ public class DeviceMaintainItemRespVO {
|
|||||||
|
|
||||||
@Schema(description = "所属周期开始日期")
|
@Schema(description = "所属周期开始日期")
|
||||||
@ExcelProperty("所属周期开始日期")
|
@ExcelProperty("所属周期开始日期")
|
||||||
private LocalDateTime frequencyItemStart;
|
private LocalDateTime frequencyTimeStart;
|
||||||
|
|
||||||
@Schema(description = "所属周期截止日期")
|
@Schema(description = "所属周期截止日期")
|
||||||
@ExcelProperty("所属周期截止日期")
|
@ExcelProperty("所属周期截止日期")
|
||||||
private LocalDateTime frequencyItemEnd;
|
private LocalDateTime frequencyTimeEnd;
|
||||||
|
|
||||||
@Schema(description = "检查标准")
|
@Schema(description = "检查标准")
|
||||||
@ExcelProperty("检查标准")
|
@ExcelProperty("检查标准")
|
||||||
@@ -90,7 +89,7 @@ public class DeviceMaintainItemRespVO {
|
|||||||
|
|
||||||
@Schema(description = "排序号")
|
@Schema(description = "排序号")
|
||||||
@ExcelProperty("排序号")
|
@ExcelProperty("排序号")
|
||||||
private Integer periodNo;
|
private Integer sortNo;
|
||||||
|
|
||||||
@Schema(description = "所属部门")
|
@Schema(description = "所属部门")
|
||||||
@ExcelProperty("所属部门")
|
@ExcelProperty("所属部门")
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ package com.zt.plat.module.qms.resource.device.controller.vo;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import java.util.*;
|
|
||||||
import jakarta.validation.constraints.*;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 设备-保养分项新增/修改 Request VO")
|
@Schema(description = "管理后台 - 设备-保养分项新增/修改 Request VO")
|
||||||
@@ -51,10 +49,10 @@ public class DeviceMaintainItemSaveReqVO {
|
|||||||
private String frequency;
|
private String frequency;
|
||||||
|
|
||||||
@Schema(description = "所属周期开始日期")
|
@Schema(description = "所属周期开始日期")
|
||||||
private LocalDateTime frequencyItemStart;
|
private LocalDateTime frequencyTimeStart;
|
||||||
|
|
||||||
@Schema(description = "所属周期截止日期")
|
@Schema(description = "所属周期截止日期")
|
||||||
private LocalDateTime frequencyItemEnd;
|
private LocalDateTime frequencyTimeEnd;
|
||||||
|
|
||||||
@Schema(description = "检查标准")
|
@Schema(description = "检查标准")
|
||||||
private String standard;
|
private String standard;
|
||||||
@@ -69,7 +67,7 @@ public class DeviceMaintainItemSaveReqVO {
|
|||||||
private String dutyRemark;
|
private String dutyRemark;
|
||||||
|
|
||||||
@Schema(description = "排序号")
|
@Schema(description = "排序号")
|
||||||
private Integer periodNo;
|
private Integer sortNo;
|
||||||
|
|
||||||
@Schema(description = "所属部门")
|
@Schema(description = "所属部门")
|
||||||
private String systemDepartmentCode;
|
private String systemDepartmentCode;
|
||||||
|
|||||||
@@ -63,4 +63,23 @@ public class DeviceMaintainPageReqVO extends PageParam {
|
|||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
private LocalDateTime[] createTime;
|
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;
|
||||||
}
|
}
|
||||||
@@ -80,4 +80,9 @@ public class DeviceMaintainRespVO {
|
|||||||
@ExcelProperty("创建时间")
|
@ExcelProperty("创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================扩展字段===============================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package com.zt.plat.module.qms.resource.device.controller.vo;
|
||||||
|
|
||||||
|
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainDO;
|
||||||
|
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 DeviceMaintainVO extends DeviceMaintainRespVO {
|
||||||
|
|
||||||
|
|
||||||
|
//============大类字段============
|
||||||
|
@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 = "维护项目列表")
|
||||||
|
List<DeviceMaintainItemDO> maintainItemList;
|
||||||
|
|
||||||
|
@Schema(description = "未提交数据量")
|
||||||
|
private Integer runningCount;
|
||||||
|
|
||||||
|
@Schema(description = "已提交数据量")
|
||||||
|
private Integer finishedCount;
|
||||||
|
|
||||||
|
//导出报表时使用
|
||||||
|
@Schema(description = "维护保养内")
|
||||||
|
private String maintainContent;
|
||||||
|
|
||||||
|
//============其他字段============
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,7 +6,6 @@ import lombok.*;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备-设备信息 DO
|
* 设备-设备信息 DO
|
||||||
@@ -41,8 +40,8 @@ public class DeviceInfomationDO extends BusinessBaseDO {
|
|||||||
/**
|
/**
|
||||||
* 设备名称
|
* 设备名称
|
||||||
*/
|
*/
|
||||||
@TableField("PDT_NAME")
|
@TableField("DEV_NAME")
|
||||||
private String productName;
|
private String deviceName;
|
||||||
/**
|
/**
|
||||||
* 别名
|
* 别名
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -95,12 +95,12 @@ public class DeviceMaintainItemDO extends BusinessBaseDO {
|
|||||||
* 所属周期开始日期
|
* 所属周期开始日期
|
||||||
*/
|
*/
|
||||||
@TableField("FREQ_ITM_STRT")
|
@TableField("FREQ_ITM_STRT")
|
||||||
private LocalDateTime frequencyItemStart;
|
private LocalDateTime frequencyTimeStart;
|
||||||
/**
|
/**
|
||||||
* 所属周期截止日期
|
* 所属周期截止日期
|
||||||
*/
|
*/
|
||||||
@TableField("FREQ_ITM_END")
|
@TableField("FREQ_ITM_END")
|
||||||
private LocalDateTime frequencyItemEnd;
|
private LocalDateTime frequencyTimeEnd;
|
||||||
/**
|
/**
|
||||||
* 检查标准
|
* 检查标准
|
||||||
*/
|
*/
|
||||||
@@ -124,8 +124,8 @@ public class DeviceMaintainItemDO extends BusinessBaseDO {
|
|||||||
/**
|
/**
|
||||||
* 排序号
|
* 排序号
|
||||||
*/
|
*/
|
||||||
@TableField("PRD_NO")
|
@TableField("SRT_NO")
|
||||||
private Integer periodNo;
|
private Integer sortNo;
|
||||||
/**
|
/**
|
||||||
* 所属部门
|
* 所属部门
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public interface DeviceInfomationMapper extends BaseMapperX<DeviceInfomationDO>
|
|||||||
return selectPage(reqVO, new LambdaQueryWrapperX<DeviceInfomationDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<DeviceInfomationDO>()
|
||||||
.eqIfPresent(DeviceInfomationDO::getProductId, reqVO.getProductId())
|
.eqIfPresent(DeviceInfomationDO::getProductId, reqVO.getProductId())
|
||||||
.inIfPresent(DeviceInfomationDO::getProductId, reqVO.getProductIds())
|
.inIfPresent(DeviceInfomationDO::getProductId, reqVO.getProductIds())
|
||||||
.likeIfPresent(DeviceInfomationDO::getProductName, reqVO.getProductName())
|
.likeIfPresent(DeviceInfomationDO::getDeviceName, reqVO.getDeviceName())
|
||||||
.eqIfPresent(DeviceInfomationDO::getAlias, reqVO.getAlias())
|
.eqIfPresent(DeviceInfomationDO::getAlias, reqVO.getAlias())
|
||||||
.eqIfPresent(DeviceInfomationDO::getDeviceStatus, reqVO.getDeviceStatus())
|
.eqIfPresent(DeviceInfomationDO::getDeviceStatus, reqVO.getDeviceStatus())
|
||||||
.eqIfPresent(DeviceInfomationDO::getRepairFlag, reqVO.getRepairFlag())
|
.eqIfPresent(DeviceInfomationDO::getRepairFlag, reqVO.getRepairFlag())
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ public interface DeviceMaintainItemMapper extends BaseMapperX<DeviceMaintainItem
|
|||||||
.likeIfPresent(DeviceMaintainItemDO::getItemName, reqVO.getItemName())
|
.likeIfPresent(DeviceMaintainItemDO::getItemName, reqVO.getItemName())
|
||||||
.eqIfPresent(DeviceMaintainItemDO::getFrequencyType, reqVO.getFrequencyType())
|
.eqIfPresent(DeviceMaintainItemDO::getFrequencyType, reqVO.getFrequencyType())
|
||||||
.eqIfPresent(DeviceMaintainItemDO::getFrequency, reqVO.getFrequency())
|
.eqIfPresent(DeviceMaintainItemDO::getFrequency, reqVO.getFrequency())
|
||||||
.eqIfPresent(DeviceMaintainItemDO::getFrequencyItemStart, reqVO.getFrequencyItemStart())
|
.eqIfPresent(DeviceMaintainItemDO::getFrequencyTimeStart, reqVO.getFrequencyTimeStart())
|
||||||
.eqIfPresent(DeviceMaintainItemDO::getFrequencyItemEnd, reqVO.getFrequencyItemEnd())
|
.eqIfPresent(DeviceMaintainItemDO::getFrequencyTimeEnd, reqVO.getFrequencyTimeEnd())
|
||||||
.eqIfPresent(DeviceMaintainItemDO::getStandard, reqVO.getStandard())
|
.eqIfPresent(DeviceMaintainItemDO::getStandard, reqVO.getStandard())
|
||||||
.eqIfPresent(DeviceMaintainItemDO::getItemMethod, reqVO.getItemMethod())
|
.eqIfPresent(DeviceMaintainItemDO::getItemMethod, reqVO.getItemMethod())
|
||||||
.eqIfPresent(DeviceMaintainItemDO::getFrequencyRemark, reqVO.getFrequencyRemark())
|
.eqIfPresent(DeviceMaintainItemDO::getFrequencyRemark, reqVO.getFrequencyRemark())
|
||||||
.eqIfPresent(DeviceMaintainItemDO::getDutyRemark, reqVO.getDutyRemark())
|
.eqIfPresent(DeviceMaintainItemDO::getDutyRemark, reqVO.getDutyRemark())
|
||||||
.eqIfPresent(DeviceMaintainItemDO::getPeriodNo, reqVO.getPeriodNo())
|
.eqIfPresent(DeviceMaintainItemDO::getSortNo, reqVO.getSortNo())
|
||||||
.eqIfPresent(DeviceMaintainItemDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
|
.eqIfPresent(DeviceMaintainItemDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
|
||||||
.eqIfPresent(DeviceMaintainItemDO::getRemark, reqVO.getRemark())
|
.eqIfPresent(DeviceMaintainItemDO::getRemark, reqVO.getRemark())
|
||||||
.betweenIfPresent(DeviceMaintainItemDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(DeviceMaintainItemDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
package com.zt.plat.module.qms.resource.device.dal.mapper;
|
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.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainVO;
|
||||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainDO;
|
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainDO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainPageReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainPageReqVO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备-点检、保养记录 Mapper
|
* 设备-点检、保养记录 Mapper
|
||||||
@@ -36,4 +40,7 @@ public interface DeviceMaintainMapper extends BaseMapperX<DeviceMaintainDO> {
|
|||||||
.orderByDesc(DeviceMaintainDO::getId));
|
.orderByDesc(DeviceMaintainDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IPage<DeviceMaintainVO> queryPageListWithCount(Page<DeviceMaintainVO> page, @Param("param") DeviceMaintainPageReqVO param);
|
||||||
|
DeviceMaintainVO queryMaintainVoById(@Param("id") Long id);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,9 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
|||||||
*/
|
*/
|
||||||
public interface DeviceConfigBusinessItemService {
|
public interface DeviceConfigBusinessItemService {
|
||||||
|
|
||||||
|
List<DeviceConfigBusinessItemDO> listByRuleId(Long ruleId);
|
||||||
|
List<DeviceConfigBusinessItemDO> getByIdList(List<Long> ruleId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建设备-检查项目配置
|
* 创建设备-检查项目配置
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.zt.plat.module.qms.resource.device.service;
|
package com.zt.plat.module.qms.resource.device.service;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessItemPageReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessItemPageReqVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessItemRespVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessItemRespVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessItemSaveReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessItemSaveReqVO;
|
||||||
@@ -32,6 +33,18 @@ public class DeviceConfigBusinessItemServiceImpl implements DeviceConfigBusiness
|
|||||||
@Resource
|
@Resource
|
||||||
private DeviceConfigBusinessItemMapper deviceConfigBusinessItemMapper;
|
private DeviceConfigBusinessItemMapper deviceConfigBusinessItemMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceConfigBusinessItemDO> listByRuleId(Long ruleId) {
|
||||||
|
LambdaQueryWrapper<DeviceConfigBusinessItemDO> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(DeviceConfigBusinessItemDO::getRuleId, ruleId);
|
||||||
|
return deviceConfigBusinessItemMapper.selectList(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceConfigBusinessItemDO> getByIdList(List<Long> ruleId) {
|
||||||
|
return deviceConfigBusinessItemMapper.selectByIds(ruleId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeviceConfigBusinessItemRespVO createDeviceConfigBusinessItem(DeviceConfigBusinessItemSaveReqVO createReqVO) {
|
public DeviceConfigBusinessItemRespVO createDeviceConfigBusinessItem(DeviceConfigBusinessItemSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.zt.plat.module.qms.resource.device.service;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRulePageReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRulePageReqVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRuleRespVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRuleRespVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRuleSaveReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRuleSaveReqVO;
|
||||||
@@ -16,6 +17,12 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
|||||||
*/
|
*/
|
||||||
public interface DeviceConfigBusinessRuleService {
|
public interface DeviceConfigBusinessRuleService {
|
||||||
|
|
||||||
|
DeviceConfigBusinessRuleDO getByProductId(Long productId);
|
||||||
|
|
||||||
|
CommonResult<DeviceConfigBusinessRuleDO> getRuleByDeviceIdAndType(Long deviceId, String type);
|
||||||
|
|
||||||
|
List<DeviceConfigBusinessRuleDO> getByProductIdListAndBusinessDomain(List<String> productIdList, String businessDomain);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建设备-业务配置
|
* 创建设备-业务配置
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package com.zt.plat.module.qms.resource.device.service;
|
package com.zt.plat.module.qms.resource.device.service;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRulePageReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRulePageReqVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRuleRespVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRuleRespVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRuleSaveReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigBusinessRuleSaveReqVO;
|
||||||
|
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 org.springframework.stereotype.Service;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -17,6 +21,7 @@ import com.zt.plat.framework.common.util.object.BeanUtils;
|
|||||||
import com.zt.plat.module.qms.resource.device.dal.mapper.DeviceConfigBusinessRuleMapper;
|
import com.zt.plat.module.qms.resource.device.dal.mapper.DeviceConfigBusinessRuleMapper;
|
||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_CONFIG_BUSINESS_RULE_NOT_EXISTS;
|
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_CONFIG_BUSINESS_RULE_NOT_EXISTS;
|
||||||
|
|
||||||
@@ -29,8 +34,58 @@ import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_CONFIG_BUSI
|
|||||||
@Validated
|
@Validated
|
||||||
public class DeviceConfigBusinessRuleServiceImpl implements DeviceConfigBusinessRuleService {
|
public class DeviceConfigBusinessRuleServiceImpl implements DeviceConfigBusinessRuleService {
|
||||||
|
|
||||||
@Resource
|
@Resource private DeviceConfigBusinessRuleMapper deviceConfigBusinessRuleMapper;
|
||||||
private DeviceConfigBusinessRuleMapper deviceConfigBusinessRuleMapper;
|
@Resource private DeviceInfomationService deviceInfomationService;
|
||||||
|
@Resource private DeviceProductService deviceProductService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeviceConfigBusinessRuleDO getByProductId(Long productId) {
|
||||||
|
LambdaQueryWrapper<DeviceConfigBusinessRuleDO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(DeviceConfigBusinessRuleDO::getProductId, productId);
|
||||||
|
List<DeviceConfigBusinessRuleDO> list = deviceConfigBusinessRuleMapper.selectList(queryWrapper);
|
||||||
|
if(list.size() > 1)
|
||||||
|
throw exception0(DEVICE_CONFIG_BUSINESS_RULE_NOT_EXISTS.getCode(), "业务配置数据有" + list.size() + "行, 请联系管理员处理!");
|
||||||
|
if(list.isEmpty())
|
||||||
|
return null;
|
||||||
|
return list.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<DeviceConfigBusinessRuleDO> getRuleByDeviceIdAndType(Long deviceId, String type) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
List<DeviceConfigBusinessRuleDO> ruleList = getByProductIdListAndBusinessDomain(productIdList, type);
|
||||||
|
if(ruleList.isEmpty())
|
||||||
|
return CommonResult.error(DEVICE_CONFIG_BUSINESS_RULE_NOT_EXISTS);
|
||||||
|
if(ruleList.size() == 1)
|
||||||
|
return CommonResult.success(ruleList.get(0));
|
||||||
|
//取最底层的配置
|
||||||
|
for(int i = productIdList.size() - 1; i > 0; i--){
|
||||||
|
String id = productIdList.get(i);
|
||||||
|
for(DeviceConfigBusinessRuleDO rule : ruleList){
|
||||||
|
if(Objects.equals(rule.getProductId(), Long.valueOf(id)))
|
||||||
|
return CommonResult.success(rule);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CommonResult.error(DEVICE_CONFIG_BUSINESS_RULE_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceConfigBusinessRuleDO> getByProductIdListAndBusinessDomain(List<String> productIdList, String businessDomain) {
|
||||||
|
LambdaQueryWrapper<DeviceConfigBusinessRuleDO> query = new LambdaQueryWrapper<>();
|
||||||
|
query.in(DeviceConfigBusinessRuleDO::getProductId, productIdList);
|
||||||
|
query.eq(DeviceConfigBusinessRuleDO::getBusinessDomain, businessDomain);
|
||||||
|
return deviceConfigBusinessRuleMapper.selectList( query);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeviceConfigBusinessRuleRespVO createDeviceConfigBusinessRule(DeviceConfigBusinessRuleSaveReqVO createReqVO) {
|
public DeviceConfigBusinessRuleRespVO createDeviceConfigBusinessRule(DeviceConfigBusinessRuleSaveReqVO createReqVO) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.zt.plat.module.qms.resource.device.service;
|
package com.zt.plat.module.qms.resource.device.service;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
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.DeviceInfomationPageReqVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceInfomationRespVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceInfomationRespVO;
|
||||||
@@ -16,6 +17,16 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface DeviceInfomationService {
|
public interface DeviceInfomationService {
|
||||||
|
|
||||||
|
CommonResult<DeviceInfomationRespVO> saveDevice(@Valid DeviceInfomationSaveReqVO reqVO);
|
||||||
|
|
||||||
|
CommonResult<Boolean> checkDeviceUsable(Long id );
|
||||||
|
|
||||||
|
DeviceInfomationDO getByCode(String code);
|
||||||
|
|
||||||
|
List<DeviceInfomationDO> getListByProductIdList(List<Long> productIds);
|
||||||
|
|
||||||
|
List<Long> getIdListByProductIdList(List<Long> productIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建设备-设备信息
|
* 创建设备-设备信息
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,21 +1,30 @@
|
|||||||
package com.zt.plat.module.qms.resource.device.service;
|
package com.zt.plat.module.qms.resource.device.service;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
import com.zt.plat.module.qms.core.constant.DataTypeConstant;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceInfomationPageReqVO;
|
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.DeviceInfomationRespVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceInfomationSaveReqVO;
|
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.DeviceInfomationDO;
|
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;
|
import com.zt.plat.module.qms.resource.device.dal.mapper.DeviceInfomationMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_INFOMATION_NOT_EXISTS;
|
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_INFOMATION_NOT_EXISTS;
|
||||||
|
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_PRODUCT_NOT_EXISTS;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,8 +36,70 @@ import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_INFOMATION_
|
|||||||
@Validated
|
@Validated
|
||||||
public class DeviceInfomationServiceImpl implements DeviceInfomationService {
|
public class DeviceInfomationServiceImpl implements DeviceInfomationService {
|
||||||
|
|
||||||
@Resource
|
@Resource private DeviceInfomationMapper deviceInfomationMapper;
|
||||||
private DeviceInfomationMapper deviceInfomationMapper;
|
@Resource private DeviceProductService deviceProductService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public CommonResult<DeviceInfomationRespVO> saveDevice(DeviceInfomationSaveReqVO reqVO) {
|
||||||
|
Long productId = reqVO.getProductId();
|
||||||
|
String deviceCode = reqVO.getDeviceCode();
|
||||||
|
if(productId == null)
|
||||||
|
throw exception0(DEVICE_INFOMATION_NOT_EXISTS.getCode(), "请选择所属设备大类!");
|
||||||
|
DeviceProductDO productDO = deviceProductService.getDeviceProduct(productId);
|
||||||
|
if(productDO == null)
|
||||||
|
throw exception(DEVICE_PRODUCT_NOT_EXISTS);
|
||||||
|
if(!DataTypeConstant.DATA_TYPE_DATA.equals(productDO.getNodeType()))
|
||||||
|
throw exception0(DEVICE_INFOMATION_NOT_EXISTS.getCode(), "您选择的是“分类”,请选择“产品”!");
|
||||||
|
DeviceInfomationDO checkData = getByCode(deviceCode);
|
||||||
|
if(reqVO.getId() == null){
|
||||||
|
if(checkData != null && !checkData.getId().equals(reqVO.getId()))
|
||||||
|
throw exception0(DEVICE_INFOMATION_NOT_EXISTS.getCode(), "管理编号已存在,请重新填写!");
|
||||||
|
DeviceInfomationRespVO respVO = this.createDeviceInfomation(reqVO);
|
||||||
|
return CommonResult.success(respVO);
|
||||||
|
}
|
||||||
|
if(checkData != null)
|
||||||
|
throw exception0(DEVICE_INFOMATION_NOT_EXISTS.getCode(), "管理编号已存在,请重新填写!");
|
||||||
|
reqVO.setDeviceParameter(productDO.getParameter());
|
||||||
|
this.updateDeviceInfomation(reqVO);
|
||||||
|
return CommonResult.success(BeanUtils.toBean(reqVO, DeviceInfomationRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<Boolean> checkDeviceUsable(Long id) {
|
||||||
|
DeviceInfomationDO deviceDO = this.getDeviceInfomation(id);
|
||||||
|
if(ObjectUtils.isEmpty(deviceDO))
|
||||||
|
return CommonResult.error(DEVICE_INFOMATION_NOT_EXISTS.getCode(), "设备不存在,请刷新后重试!");
|
||||||
|
if("1".equals(deviceDO.getDisableFlag()))
|
||||||
|
return CommonResult.error(DEVICE_INFOMATION_NOT_EXISTS.getCode(), "设备已停用!");
|
||||||
|
if("1".equals(deviceDO.getScrapFlag()))
|
||||||
|
return CommonResult.error(DEVICE_INFOMATION_NOT_EXISTS.getCode(), "设备已报废!");
|
||||||
|
if("1".equals(deviceDO.getLendFlag()))
|
||||||
|
return CommonResult.error(DEVICE_INFOMATION_NOT_EXISTS.getCode(), "设备已外借!");
|
||||||
|
if("1".equals(deviceDO.getRepairFlag()))
|
||||||
|
return CommonResult.error( DEVICE_INFOMATION_NOT_EXISTS.getCode(), "设备在维修中");
|
||||||
|
return CommonResult.success( true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeviceInfomationDO getByCode(String code) {
|
||||||
|
LambdaQueryWrapper<DeviceInfomationDO> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(DeviceInfomationDO::getDeviceCode, code);
|
||||||
|
return deviceInfomationMapper.selectOne(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceInfomationDO> getListByProductIdList(List<Long> productIds) {
|
||||||
|
LambdaQueryWrapper<DeviceInfomationDO> query = new LambdaQueryWrapper<>();
|
||||||
|
query.in(DeviceInfomationDO::getProductId, productIds);
|
||||||
|
return deviceInfomationMapper.selectList(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Long> getIdListByProductIdList(List<Long> productIds) {
|
||||||
|
List<DeviceInfomationDO> list = getListByProductIdList(productIds);
|
||||||
|
return list.stream().map(DeviceInfomationDO::getId).toList();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeviceInfomationRespVO createDeviceInfomation(DeviceInfomationSaveReqVO createReqVO) {
|
public DeviceInfomationRespVO createDeviceInfomation(DeviceInfomationSaveReqVO createReqVO) {
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package com.zt.plat.module.qms.resource.device.service;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainItemPageReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainItemPageReqVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainItemRespVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainItemRespVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainItemSaveReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainItemSaveReqVO;
|
||||||
|
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainDO;
|
||||||
import jakarta.validation.*;
|
import jakarta.validation.*;
|
||||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainItemDO;
|
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainItemDO;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
@@ -16,6 +18,11 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
|||||||
*/
|
*/
|
||||||
public interface DeviceMaintainItemService {
|
public interface DeviceMaintainItemService {
|
||||||
|
|
||||||
|
|
||||||
|
CommonResult<String> createItems(DeviceMaintainDO maintain, Long ruleId);
|
||||||
|
|
||||||
|
List<DeviceMaintainItemDO> getListByParId(Long maintainId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建设备-保养分项
|
* 创建设备-保养分项
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,14 +1,20 @@
|
|||||||
package com.zt.plat.module.qms.resource.device.service;
|
package com.zt.plat.module.qms.resource.device.service;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainItemPageReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainItemPageReqVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainItemRespVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainItemRespVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainItemSaveReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainItemSaveReqVO;
|
||||||
|
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceConfigBusinessItemDO;
|
||||||
|
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainDO;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainItemDO;
|
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainItemDO;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
@@ -18,6 +24,7 @@ import com.zt.plat.module.qms.resource.device.dal.mapper.DeviceMaintainItemMappe
|
|||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
|
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_CONFIG_BUSINESS_ITEM_NOT_EXISTS;
|
||||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_MAINTAIN_ITEM_NOT_EXISTS;
|
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_MAINTAIN_ITEM_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,8 +36,51 @@ import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_MAINTAIN_IT
|
|||||||
@Validated
|
@Validated
|
||||||
public class DeviceMaintainItemServiceImpl implements DeviceMaintainItemService {
|
public class DeviceMaintainItemServiceImpl implements DeviceMaintainItemService {
|
||||||
|
|
||||||
@Resource
|
@Resource private DeviceMaintainItemMapper deviceMaintainItemMapper;
|
||||||
private DeviceMaintainItemMapper deviceMaintainItemMapper;
|
@Resource private DeviceConfigBusinessItemService deviceConfigBusinessItemService;;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public CommonResult<String> createItems(DeviceMaintainDO maintain, Long ruleId) {
|
||||||
|
List<DeviceConfigBusinessItemDO> itemList = deviceConfigBusinessItemService.listByRuleId(ruleId); //配置的所有明细项
|
||||||
|
List<Long> itemIdList = itemList.stream().map(DeviceConfigBusinessItemDO::getId).toList();
|
||||||
|
if(itemIdList.isEmpty())
|
||||||
|
return CommonResult.error(DEVICE_CONFIG_BUSINESS_ITEM_NOT_EXISTS.getCode(), "没有配置检查项,请联系管理员处理!");
|
||||||
|
//查询各明细项的最新数据
|
||||||
|
// List<DeviceBusMaintainItem> lastDataList = queryLastestData(itemIdList, maintain.getDeviceId());
|
||||||
|
|
||||||
|
//循环检查当前维护
|
||||||
|
List<DeviceMaintainItemDO> insertList = new ArrayList<>();
|
||||||
|
for(DeviceConfigBusinessItemDO library : itemList){
|
||||||
|
// if(!checkItemNeeded(maintain, library, lastDataList))
|
||||||
|
// continue;
|
||||||
|
DeviceMaintainItemDO item = new DeviceMaintainItemDO();
|
||||||
|
item.setParentId(maintain.getId());
|
||||||
|
item.setFrequencyTimeStart(maintain.getFrequencyTimeStart());
|
||||||
|
item.setFrequencyTimeEnd(maintain.getFrequencyTimeEnd());
|
||||||
|
item.setCheckItemId(library.getId());
|
||||||
|
item.setItemKey(library.getItemKey());
|
||||||
|
item.setItemName(library.getItemName());
|
||||||
|
item.setFrequencyType(library.getFrequencyType());
|
||||||
|
item.setFrequency(library.getFrequency());
|
||||||
|
item.setStandard(library.getStandard());
|
||||||
|
item.setItemMethod(library.getItemMethod());
|
||||||
|
item.setFrequencyRemark(library.getFrequencyRemark());
|
||||||
|
item.setSortNo(library.getOrderNo());
|
||||||
|
insertList.add(item);
|
||||||
|
}
|
||||||
|
if(!insertList.isEmpty())
|
||||||
|
deviceMaintainItemMapper.insertBatch(insertList);
|
||||||
|
return CommonResult.success("");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceMaintainItemDO> getListByParId(Long maintainId) {
|
||||||
|
LambdaQueryWrapper<DeviceMaintainItemDO> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(DeviceMaintainItemDO::getParentId, maintainId);
|
||||||
|
query.orderByAsc(DeviceMaintainItemDO::getSortNo);
|
||||||
|
return deviceMaintainItemMapper.selectList(query);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeviceMaintainItemRespVO createDeviceMaintainItem(DeviceMaintainItemSaveReqVO createReqVO) {
|
public DeviceMaintainItemRespVO createDeviceMaintainItem(DeviceMaintainItemSaveReqVO createReqVO) {
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package com.zt.plat.module.qms.resource.device.service;
|
package com.zt.plat.module.qms.resource.device.service;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainPageReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainPageReqVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainRespVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainRespVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainSaveReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainSaveReqVO;
|
||||||
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainVO;
|
||||||
import jakarta.validation.*;
|
import jakarta.validation.*;
|
||||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainDO;
|
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainDO;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
@@ -16,6 +20,17 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
|||||||
*/
|
*/
|
||||||
public interface DeviceMaintainService {
|
public interface DeviceMaintainService {
|
||||||
|
|
||||||
|
CommonResult<DeviceMaintainVO> createOrGet(Long deviceId, String date, String dataType);
|
||||||
|
|
||||||
|
CommonResult<DeviceMaintainVO> create(Long deviceId, LocalDate lastDate, String dataType);
|
||||||
|
|
||||||
|
PageResult<DeviceMaintainVO> queryPageListWithCount(DeviceMaintainPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
CommonResult<DeviceMaintainVO> getMaintainDetail(Long id);
|
||||||
|
|
||||||
|
CommonResult<DeviceMaintainDO> getLastData(Long deviceId, String dataType, String date);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建设备-点检、保养记录
|
* 创建设备-点检、保养记录
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,13 +1,31 @@
|
|||||||
package com.zt.plat.module.qms.resource.device.service;
|
package com.zt.plat.module.qms.resource.device.service;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
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.common.DeviceUtil;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainPageReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainPageReqVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainRespVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainRespVO;
|
||||||
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainSaveReqVO;
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainSaveReqVO;
|
||||||
|
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainVO;
|
||||||
|
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceConfigBusinessRuleDO;
|
||||||
|
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainItemDO;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
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.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainDO;
|
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainDO;
|
||||||
@@ -29,8 +47,119 @@ import static com.zt.plat.module.qms.enums.ErrorCodeConstants.DEVICE_MAINTAIN_NO
|
|||||||
@Validated
|
@Validated
|
||||||
public class DeviceMaintainServiceImpl implements DeviceMaintainService {
|
public class DeviceMaintainServiceImpl implements DeviceMaintainService {
|
||||||
|
|
||||||
@Resource
|
@Resource private DeviceMaintainMapper deviceMaintainMapper;
|
||||||
private DeviceMaintainMapper deviceMaintainMapper;
|
@Resource private DeviceMaintainItemService deviceMaintainItemService;
|
||||||
|
@Resource private DeviceProductService deviceProductService;
|
||||||
|
@Resource private DeviceInfomationService deviceInfomationService;
|
||||||
|
@Autowired private DeviceConfigBusinessRuleService deviceConfigBusinessRuleService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public CommonResult<DeviceMaintainVO> createOrGet(Long deviceId, String date, String dataType){
|
||||||
|
LocalDateTime curDate = LocalDateTime.now();
|
||||||
|
if(!ObjectUtils.isEmpty(date))
|
||||||
|
curDate = LocalDateTime.parse( date + " 00:00:00");
|
||||||
|
String dateStr = curDate.toLocalDate().toString();
|
||||||
|
//查询上一个点检记录
|
||||||
|
DeviceMaintainDO lastData = getLastData(deviceId, dataType, dateStr).getData();
|
||||||
|
if(lastData != null && (lastData.getFrequencyTimeStart() == null || lastData.getFrequencyTimeEnd() == null))
|
||||||
|
return getMaintainDetail(lastData.getId());
|
||||||
|
if(lastData != null && curDate.compareTo(lastData.getFrequencyTimeStart()) >=0 && curDate.compareTo(lastData.getFrequencyTimeEnd()) <=0 ){
|
||||||
|
return getMaintainDetail(lastData.getId());
|
||||||
|
}
|
||||||
|
LocalDate lastDate = null;
|
||||||
|
if(lastData != null)
|
||||||
|
lastDate = lastData.getFrequencyTimeEnd().toLocalDate();
|
||||||
|
|
||||||
|
//比较lastDate与curDate
|
||||||
|
if(lastDate != null ){
|
||||||
|
if(lastDate.isBefore(curDate.toLocalDate()))
|
||||||
|
lastDate = curDate.toLocalDate();
|
||||||
|
}
|
||||||
|
return create(deviceId, lastDate, dataType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public CommonResult<DeviceMaintainVO> create(Long deviceId, LocalDate lastDate, String dataType) {
|
||||||
|
//当前登录人
|
||||||
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
|
//当前登录用户昵称
|
||||||
|
String nickName = SecurityFrameworkUtils.getLoginUserNickname();
|
||||||
|
//获取配置
|
||||||
|
CommonResult<DeviceConfigBusinessRuleDO> ruleRet = deviceConfigBusinessRuleService.getRuleByDeviceIdAndType(deviceId, dataType);
|
||||||
|
if(!ruleRet.isSuccess())
|
||||||
|
return CommonResult.error(ruleRet.getCode(), ruleRet.getMsg());
|
||||||
|
DeviceConfigBusinessRuleDO rule = ruleRet.getData();
|
||||||
|
//根据周期判断当前日期是否存在数据
|
||||||
|
LocalDateTime[] dateRange = null;
|
||||||
|
if(lastDate != null){
|
||||||
|
dateRange = DeviceUtil.getDateRangeByFrequency(lastDate, false, rule.getFrequencyType(), rule.getFrequency());
|
||||||
|
}
|
||||||
|
DeviceMaintainDO data = new DeviceMaintainDO();
|
||||||
|
data.setDeviceId(deviceId);
|
||||||
|
data.setDataType(dataType);
|
||||||
|
data.setCheckDate(LocalDateTime.now());
|
||||||
|
data.setRuleId(rule.getId());
|
||||||
|
data.setCheckUserId(loginUser.getId());
|
||||||
|
data.setCheckUserName(nickName);
|
||||||
|
data.setFrequencyType(rule.getFrequencyType());
|
||||||
|
data.setFrequency(rule.getFrequency());
|
||||||
|
data.setFrequencyRemark(rule.getFrequencyRemark());
|
||||||
|
if(dateRange != null){
|
||||||
|
data.setFrequencyTimeStart(dateRange[0]);
|
||||||
|
data.setFrequencyTimeEnd(dateRange[1]);
|
||||||
|
}
|
||||||
|
deviceMaintainMapper.insert(data);
|
||||||
|
|
||||||
|
//创建明细项
|
||||||
|
deviceMaintainItemService.createItems(data, rule.getId());
|
||||||
|
|
||||||
|
return getMaintainDetail(data.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<DeviceMaintainVO> getMaintainDetail(Long id) {
|
||||||
|
DeviceMaintainVO vo = deviceMaintainMapper.queryMaintainVoById( id);
|
||||||
|
if(vo == null)
|
||||||
|
throw exception(DEVICE_MAINTAIN_NOT_EXISTS);
|
||||||
|
List<DeviceMaintainItemDO> itemList = deviceMaintainItemService.getListByParId( id);
|
||||||
|
vo.setMaintainItemList(itemList);
|
||||||
|
return CommonResult.success( vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<DeviceMaintainDO> getLastData(Long deviceId, String dataType, String date) {
|
||||||
|
LambdaQueryWrapper<DeviceMaintainDO> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(DeviceMaintainDO::getDeviceId, deviceId);
|
||||||
|
query.eq(DeviceMaintainDO::getDataType, dataType);
|
||||||
|
if(!ObjectUtils.isEmpty(date)){
|
||||||
|
query.ge(DeviceMaintainDO::getCheckDate, date);
|
||||||
|
query.le(DeviceMaintainDO::getCheckDate, date + " 23:59:59");
|
||||||
|
}
|
||||||
|
query.orderByDesc(DeviceMaintainDO::getCheckDate);
|
||||||
|
query.last("limit 1");
|
||||||
|
DeviceMaintainDO maintainDO = deviceMaintainMapper.selectOne(query);
|
||||||
|
return CommonResult.success(maintainDO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<DeviceMaintainVO> queryPageListWithCount(DeviceMaintainPageReqVO reqVO) {
|
||||||
|
Long productId = reqVO.getProductId();
|
||||||
|
if(productId != null){
|
||||||
|
List<Long> productIds = deviceProductService.getIdListByIdPath(productId);
|
||||||
|
List<Long> deviceIds = deviceInfomationService.getIdListByProductIdList(productIds);
|
||||||
|
if(!deviceIds.isEmpty()){
|
||||||
|
reqVO.setProductId(null);
|
||||||
|
reqVO.setDeviceIdList(deviceIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Page<DeviceMaintainVO> page = new Page<>(reqVO.getPageNo(), reqVO.getPageSize());
|
||||||
|
|
||||||
|
IPage<DeviceMaintainVO> pageList = deviceMaintainMapper.queryPageListWithCount(page, reqVO);
|
||||||
|
return new PageResult<>(pageList.getRecords(), pageList.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeviceMaintainRespVO createDeviceMaintain(DeviceMaintainSaveReqVO createReqVO) {
|
public DeviceMaintainRespVO createDeviceMaintain(DeviceMaintainSaveReqVO createReqVO) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public interface DeviceProductService {
|
|||||||
/*获取分类树数据*/
|
/*获取分类树数据*/
|
||||||
List<DeviceProductDO> getTreeData(String nodeType);
|
List<DeviceProductDO> getTreeData(String nodeType);
|
||||||
|
|
||||||
|
List<Long> getIdListByIdPath(Long id);
|
||||||
List<DeviceProductDO> listByIdPath(Long id, String nodeType);
|
List<DeviceProductDO> listByIdPath(Long id, String nodeType);
|
||||||
List<DeviceProductDO> listByParId(Long parId, String nodeType);
|
List<DeviceProductDO> listByParId(Long parId, String nodeType);
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,13 @@ public class DeviceProductServiceImpl implements DeviceProductService {
|
|||||||
return CommonResult.success( vo);
|
return CommonResult.success( vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Long> getIdListByIdPath(Long id) {
|
||||||
|
List<DeviceProductDO> productDOList = this.listByIdPath(id, DataTypeConstant.DATA_TYPE_DATA);
|
||||||
|
List<Long> productIds = productDOList.stream().map(DeviceProductDO::getId).toList();
|
||||||
|
return productIds;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DeviceProductDO> listByIdPath(Long id, String nodeType) {
|
public List<DeviceProductDO> listByIdPath(Long id, String nodeType) {
|
||||||
LambdaQueryWrapper<DeviceProductDO> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<DeviceProductDO> query = new LambdaQueryWrapper<>();
|
||||||
|
|||||||
@@ -0,0 +1,127 @@
|
|||||||
|
<?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.DeviceMaintainMapper">
|
||||||
|
|
||||||
|
<resultMap id="DeviceMaintainVO" type="com.zt.plat.module.qms.resource.device.controller.vo.DeviceMaintainVO">
|
||||||
|
|
||||||
|
<result property="deviceName" column="DEV_NAME"/>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<select id="queryMaintainVoById" resultMap="DeviceMaintainVO">
|
||||||
|
select m.*,
|
||||||
|
d.ID,
|
||||||
|
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
|
||||||
|
from T_DEV_MATN 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="DeviceMaintainVO">
|
||||||
|
select
|
||||||
|
d.ID,
|
||||||
|
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,
|
||||||
|
(
|
||||||
|
select count(*) from T_DEV_MATN m
|
||||||
|
where m.DAT_TP = #{param.dataType}
|
||||||
|
<if test="param.checkDate != null and param.checkDate.length>0">
|
||||||
|
and m.CHK_DT between #{param.checkDate[0]} and #{param.checkDate[1]}
|
||||||
|
</if>
|
||||||
|
and m.SBM_FLG = 1
|
||||||
|
and m.DELETED = 0
|
||||||
|
) as finished_count,
|
||||||
|
(
|
||||||
|
select count(*) from T_DEV_MATN m
|
||||||
|
where m.DAT_TP = #{param.dataType}
|
||||||
|
<if test="param.checkDate != null and param.checkDate.length>0">
|
||||||
|
and m.CHK_DT between #{param.checkDate[0]} and #{param.checkDate[1]}
|
||||||
|
</if>
|
||||||
|
and m.SBM_FLG = 0
|
||||||
|
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>
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?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.DeviceMaintainMapper">
|
|
||||||
|
|
||||||
<!--
|
|
||||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
|
||||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
|
||||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
|
||||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
|
||||||
-->
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
Reference in New Issue
Block a user