diff --git a/hw-modules/hw-dms/src/main/java/com/hw/dms/controller/DmsMobileController.java b/hw-modules/hw-dms/src/main/java/com/hw/dms/controller/DmsMobileController.java index a834b0c..fb7fe4a 100644 --- a/hw-modules/hw-dms/src/main/java/com/hw/dms/controller/DmsMobileController.java +++ b/hw-modules/hw-dms/src/main/java/com/hw/dms/controller/DmsMobileController.java @@ -265,12 +265,10 @@ public class DmsMobileController extends BaseController { @Log(title = "保养工单", businessType = BusinessType.COMPLETE) @PostMapping("/completeMaint") public AjaxResult completeMaint(@RequestBody DmsBillsMaintDetail dmsBillsMaintDetail) { - return success(dmsBillsMaintInstanceService.completeMaint(dmsBillsMaintDetail)); } - /** * 获取最新一条待润滑或润滑中的润滑工单 * diff --git a/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsBillsLubeInstanceServiceImpl.java b/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsBillsLubeInstanceServiceImpl.java index 43c1e13..c50a940 100644 --- a/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsBillsLubeInstanceServiceImpl.java +++ b/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsBillsLubeInstanceServiceImpl.java @@ -3,6 +3,7 @@ package com.hw.dms.service.impl; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; import com.hw.common.core.constant.DmsConstants; import com.hw.common.core.constant.SecurityConstants; @@ -225,8 +226,9 @@ public class DmsBillsLubeInstanceServiceImpl implements IDmsBillsLubeInstanceSer @Override @Transactional(rollbackFor = Exception.class) public int completeLube(DmsBillsLubeDetail dmsBillsLubeDetail) { + Long lubeInstanceId = dmsBillsLubeDetail.getLubeInstanceId(); DmsBillsLubeInstance dmsBillsLubeInstance = dmsBillsLubeInstanceMapper - .selectDmsBillsLubeInstanceByLubeInstanceId(dmsBillsLubeDetail.getLubeInstanceId()); + .selectDmsBillsLubeInstanceByLubeInstanceId(lubeInstanceId); String lubeStatus = StringUtils.isEmpty(dmsBillsLubeInstance.getLubeStatus()) ? DmsConstants.DMS_BILLS_LUBE_INSTANCE_STATUS_TO_LUBE : dmsBillsLubeInstance.getLubeStatus(); if (lubeStatus.equals(DmsConstants.DMS_BILLS_LUBE_INSTANCE_STATUS_COMPLETE)) {//润滑完成 @@ -240,12 +242,25 @@ public class DmsBillsLubeInstanceServiceImpl implements IDmsBillsLubeInstanceSer Date currentDate = new Date(); String userName = SecurityUtils.getUsername(); - //todo:判断是否已都保养完成,修改工单状态 -// dmsBillsMaintInstance.setMaintStatus(DmsConstants.DMS_BILLS_MAINT_INSTANCE_STATUS_MAINTING); -// dmsBillsMaintInstance.setRealBeginTime(currentDate); -// dmsBillsMaintInstance.setUpdateTime(currentDate); -// dmsBillsMaintInstance.setUpdateBy(userName); -// dmsBillsMaintInstanceMapper.updateDmsBillsMaintInstance(dmsBillsMaintInstance); + DmsBillsLubeDetail queryLubeDetail = new DmsBillsLubeDetail(); + queryLubeDetail.setLubeInstanceId(lubeInstanceId); + List lubeDetails = dmsBillsLubeDetailMapper.selectDmsBillsLubeDetailList(queryLubeDetail); + + /**获取未完成的润滑明细,并且需要排除当前提交完成的润滑明细*/ + List inCompleteLubeDetails = lubeDetails.stream(). + filter(lubeDetail -> !lubeDetail.getBillsLubeDetailId().equals(dmsBillsLubeDetail.getBillsLubeDetailId()) + && (lubeDetail.getMaintStatus() == null || lubeDetail.getMaintStatus().equals("") + || lubeDetail.getMaintStatus().equals(DmsConstants.DMS_BILLS_LUBE_INSTANCE_STATUS_TO_LUBE) + || lubeDetail.getMaintStatus().equals(DmsConstants.DMS_BILLS_LUBE_INSTANCE_STATUS_LUBING))).collect(Collectors.toList()); + + /**如果已经没有未完成的,则需要将工单修改成已完成,并更新结束时间*/ + if (inCompleteLubeDetails == null || inCompleteLubeDetails.isEmpty()) { + dmsBillsLubeInstance.setLubeStatus(DmsConstants.DMS_BILLS_LUBE_INSTANCE_STATUS_COMPLETE); + dmsBillsLubeInstance.setRealEndTime(currentDate); + dmsBillsLubeInstance.setUpdateTime(currentDate); + dmsBillsLubeInstance.setUpdateBy(userName); + dmsBillsLubeInstanceMapper.updateDmsBillsLubeInstance(dmsBillsLubeInstance); + } dmsBillsLubeDetail.setEndTime(currentDate); dmsBillsLubeDetail.setUpdateBy(userName); diff --git a/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsBillsMaintInstanceServiceImpl.java b/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsBillsMaintInstanceServiceImpl.java index 11f6d13..e86f414 100644 --- a/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsBillsMaintInstanceServiceImpl.java +++ b/hw-modules/hw-dms/src/main/java/com/hw/dms/service/impl/DmsBillsMaintInstanceServiceImpl.java @@ -4,6 +4,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; import com.hw.common.core.constant.DmsConstants; import com.hw.common.core.constant.SecurityConstants; @@ -245,8 +246,9 @@ public class DmsBillsMaintInstanceServiceImpl implements IDmsBillsMaintInstanceS @Override @Transactional(rollbackFor = Exception.class) public int completeMaint(DmsBillsMaintDetail dmsBillsMaintDetail) { + Long maintInstanceId = dmsBillsMaintDetail.getMaintInstanceId(); DmsBillsMaintInstance dmsBillsMaintInstance = dmsBillsMaintInstanceMapper. - selectDmsBillsMaintInstanceByMaintInstanceId(dmsBillsMaintDetail.getMaintInstanceId()); + selectDmsBillsMaintInstanceByMaintInstanceId(maintInstanceId); Long maintStatus = dmsBillsMaintInstance.getMaintStatus() == null ? DmsConstants.DMS_BILLS_MAINT_INSTANCE_STATUS_TO_MAINT : dmsBillsMaintInstance.getMaintStatus(); if (maintStatus.equals(DmsConstants.DMS_BILLS_MAINT_INSTANCE_STATUS_COMPLETE)) {//保养完成 @@ -260,12 +262,25 @@ public class DmsBillsMaintInstanceServiceImpl implements IDmsBillsMaintInstanceS Date currentDate = new Date(); String userName = SecurityUtils.getUsername(); - //todo:判断是否已都保养完成,修改工单状态 -// dmsBillsMaintInstance.setMaintStatus(DmsConstants.DMS_BILLS_MAINT_INSTANCE_STATUS_MAINTING); -// dmsBillsMaintInstance.setRealBeginTime(currentDate); -// dmsBillsMaintInstance.setUpdateTime(currentDate); -// dmsBillsMaintInstance.setUpdateBy(userName); -// dmsBillsMaintInstanceMapper.updateDmsBillsMaintInstance(dmsBillsMaintInstance); + DmsBillsMaintDetail queryMaintDetail = new DmsBillsMaintDetail(); + queryMaintDetail.setMaintInstanceId(maintInstanceId); + List maintDetails = dmsBillsMaintDetailMapper.selectDmsBillsMaintDetailList(queryMaintDetail); + + /**获取未完成的保养明细,并且需要排除当前提交完成的保养明细*/ + List inCompleteMaintDetails = maintDetails.stream(). + filter(maintDetail -> !maintDetail.getBillsMaintDetailId().equals(dmsBillsMaintDetail.getBillsMaintDetailId()) + && (maintDetail.getMaintStatus() == null || maintDetail.getMaintStatus().equals("") + || maintDetail.getMaintStatus().equals(DmsConstants.DMS_BILLS_MAINT_INSTANCE_STATUS_TO_MAINT) + || maintDetail.getMaintStatus().equals(DmsConstants.DMS_BILLS_MAINT_INSTANCE_STATUS_MAINTING))).collect(Collectors.toList()); + + /**如果已经没有未完成的,则需要将工单修改成已完成,并更新结束时间*/ + if (inCompleteMaintDetails == null || inCompleteMaintDetails.isEmpty()) { + dmsBillsMaintInstance.setMaintStatus(DmsConstants.DMS_BILLS_MAINT_INSTANCE_STATUS_COMPLETE); + dmsBillsMaintInstance.setRealEndTime(currentDate); + dmsBillsMaintInstance.setUpdateTime(currentDate); + dmsBillsMaintInstance.setUpdateBy(userName); + dmsBillsMaintInstanceMapper.updateDmsBillsMaintInstance(dmsBillsMaintInstance); + } dmsBillsMaintDetail.setEndTime(currentDate); dmsBillsMaintDetail.setUpdateBy(userName); diff --git a/hw-modules/hw-dms/src/main/resources/mapper/dms/DmsBillsLubeDetailMapper.xml b/hw-modules/hw-dms/src/main/resources/mapper/dms/DmsBillsLubeDetailMapper.xml index 4ffde44..e23e588 100644 --- a/hw-modules/hw-dms/src/main/resources/mapper/dms/DmsBillsLubeDetailMapper.xml +++ b/hw-modules/hw-dms/src/main/resources/mapper/dms/DmsBillsLubeDetailMapper.xml @@ -152,4 +152,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +