diff --git a/op-modules/op-device/src/main/java/com/op/device/controller/EquSpareApplyController.java b/op-modules/op-device/src/main/java/com/op/device/controller/EquSpareApplyController.java index 995dbf72..8aa3ab8e 100644 --- a/op-modules/op-device/src/main/java/com/op/device/controller/EquSpareApplyController.java +++ b/op-modules/op-device/src/main/java/com/op/device/controller/EquSpareApplyController.java @@ -94,7 +94,7 @@ public class EquSpareApplyController extends BaseController { @Log(title = "申领记录", businessType = BusinessType.DELETE) @DeleteMapping("/{applyIds}") public AjaxResult remove(@PathVariable String[] applyIds) { - return toAjax(equSpareApplyService.deleteEquSpareApplyByApplyIds(applyIds)); + return equSpareApplyService.deleteEquSpareApplyByApplyIds(applyIds); } /** diff --git a/op-modules/op-device/src/main/java/com/op/device/mapper/EquRepairWorkOrderMapper.java b/op-modules/op-device/src/main/java/com/op/device/mapper/EquRepairWorkOrderMapper.java index c8eb3aed..3393c5aa 100644 --- a/op-modules/op-device/src/main/java/com/op/device/mapper/EquRepairWorkOrderMapper.java +++ b/op-modules/op-device/src/main/java/com/op/device/mapper/EquRepairWorkOrderMapper.java @@ -97,4 +97,11 @@ public interface EquRepairWorkOrderMapper { //更新维修工单状态 void updateWorkStatus(String repairCode); + + /** + * 通过维修工单号查询维修单 + * @param workCode + * @return + */ + EquRepairWorkOrder selectEquRepairWorkOrderByWorkCode(String workCode); } diff --git a/op-modules/op-device/src/main/java/com/op/device/mapper/EquSpareApplyMapper.java b/op-modules/op-device/src/main/java/com/op/device/mapper/EquSpareApplyMapper.java index e6924a08..c4e8580b 100644 --- a/op-modules/op-device/src/main/java/com/op/device/mapper/EquSpareApplyMapper.java +++ b/op-modules/op-device/src/main/java/com/op/device/mapper/EquSpareApplyMapper.java @@ -81,4 +81,16 @@ public interface EquSpareApplyMapper { * @param orderIds */ void delEquSpareApplyByorderIds(String[] orderIds); + + /** + * 逻辑删除申领记录 + * @param applyIds + */ + void delEquSpareApplyByIds(String[] applyIds); + + /** + * 逻辑删除领用单 + * @param id + */ + void delEquSpareApplyByApplyId(String id); } diff --git a/op-modules/op-device/src/main/java/com/op/device/service/IEquSpareApplyService.java b/op-modules/op-device/src/main/java/com/op/device/service/IEquSpareApplyService.java index 12933168..024cdd41 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/IEquSpareApplyService.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/IEquSpareApplyService.java @@ -51,7 +51,7 @@ public interface IEquSpareApplyService { * @param applyIds 需要删除的申领记录主键集合 * @return 结果 */ - public int deleteEquSpareApplyByApplyIds(String[] applyIds); + public AjaxResult deleteEquSpareApplyByApplyIds(String[] applyIds); /** * 删除申领记录信息 diff --git a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquOrderServiceImpl.java b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquOrderServiceImpl.java index b56c698f..c982cff2 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquOrderServiceImpl.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquOrderServiceImpl.java @@ -371,15 +371,13 @@ public class EquOrderServiceImpl implements IEquOrderService { return error(500,"工单已进行修改!不可删除!"); } if (order.getPlanType().equals("maintenance")) { - List applyList = equSpareApplyMapper.selectEquSpareApplyListByWorkCode(order.getWorkCode()); + List applyList = equSpareApplyMapper.selectEquSpareApplyListByWorkCode(order.getOrderCode()); for (EquSpareApply apply : applyList) { // 返回备件数量 sparePartsLedgerMapper.updateSpareNumAdd(apply); } } } - // 逻辑删除工单 - equOrderMapper.delEquOrderByOrderIds(orderIds); // 逻辑删除获取人员 equOrderPersonMapper.delEquOrderPersonByorderIds(orderIds); // 逻辑删除标准信息 @@ -388,6 +386,8 @@ public class EquOrderServiceImpl implements IEquOrderService { equOrderDetailMapper.delEquOrderDetailByorderIds(orderIds); // 逻辑删除备件信息 equSpareApplyMapper.delEquSpareApplyByorderIds(orderIds); + // 逻辑删除工单 + equOrderMapper.delEquOrderByOrderIds(orderIds); return success(); } diff --git a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquSpareApplyServiceImpl.java b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquSpareApplyServiceImpl.java index aa29e13d..68faf2eb 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquSpareApplyServiceImpl.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquSpareApplyServiceImpl.java @@ -9,8 +9,11 @@ import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.uuid.IdUtils; import com.op.common.core.web.domain.AjaxResult; import com.op.common.security.utils.SecurityUtils; +import com.op.device.domain.EquOrder; import com.op.device.domain.EquRepairWorkOrder; import com.op.device.domain.SparePartsLedger; +import com.op.device.mapper.EquOrderMapper; +import com.op.device.mapper.EquRepairWorkOrderMapper; import com.op.device.mapper.SparePartsLedgerMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -23,6 +26,7 @@ import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; import static com.op.common.core.web.domain.AjaxResult.error; +import static com.op.common.core.web.domain.AjaxResult.success; /** * 申领记录Service业务层处理 @@ -36,10 +40,14 @@ public class EquSpareApplyServiceImpl implements IEquSpareApplyService { private EquSpareApplyMapper equSpareApplyMapper; @Autowired private SparePartsLedgerMapper sparePartsLedgerMapper; + @Autowired + private EquRepairWorkOrderMapper equRepairWorkOrderMapper; + @Autowired + private EquOrderMapper equOrderMapper; /** * 查询申领记录 - * + * * @param applyId 申领记录主键 * @return 申领记录 */ @@ -51,7 +59,7 @@ public class EquSpareApplyServiceImpl implements IEquSpareApplyService { /** * 查询申领记录列表 - * + * * @param equSpareApply 申领记录 * @return 申领记录 */ @@ -71,7 +79,7 @@ public class EquSpareApplyServiceImpl implements IEquSpareApplyService { /** * 新增申领记录 - * + * * @param equSpareApply 申领记录 * @return 结果 */ @@ -80,7 +88,7 @@ public class EquSpareApplyServiceImpl implements IEquSpareApplyService { public AjaxResult insertEquSpareApply(EquSpareApply equSpareApply) { try { //equSpareApply.getSpareApplyLists().size() 是在申领备件的时候进行的操作 - if(equSpareApply.getSpareApplyLists().size() >= 1){ + if(equSpareApply.getSpareApplyLists().size() >= 1){ List list = equSpareApply.getSpareApplyLists(); for(EquSpareApply applyList:list){ applyList.setApplyId(IdUtils.fastSimpleUUID()); @@ -113,7 +121,7 @@ public class EquSpareApplyServiceImpl implements IEquSpareApplyService { equSpareApply.setCreateBy(SecurityUtils.getUsername()); equSpareApplyMapper.insertEquSpareApply(equSpareApply); } - return AjaxResult.success("新增申领记录成功!"); + return success("新增申领记录成功!"); } catch (Exception e) { return error(); } @@ -121,7 +129,7 @@ public class EquSpareApplyServiceImpl implements IEquSpareApplyService { /** * 修改申领记录 - * + * * @param equSpareApply 申领记录 * @return 结果 */ @@ -134,20 +142,55 @@ public class EquSpareApplyServiceImpl implements IEquSpareApplyService { } /** - * 批量删除申领记录 - * + * TODO 批量删除申领记录 + * * @param applyIds 需要删除的申领记录主键 * @return 结果 */ @Override @DS("#header.poolName") - public int deleteEquSpareApplyByApplyIds(String[] applyIds) { - return equSpareApplyMapper.deleteEquSpareApplyByApplyIds(applyIds); + public AjaxResult deleteEquSpareApplyByApplyIds(String[] applyIds) { + boolean check = true; + // 校验 + for (String id : applyIds) { + EquSpareApply apply = equSpareApplyMapper.selectEquSpareApplyByApplyId(id); + if (apply.getWorkCode() != null) { + if (!apply.getWorkCode().isEmpty()) { + EquRepairWorkOrder workOrder = equRepairWorkOrderMapper.selectEquRepairWorkOrderByWorkCode(apply.getWorkCode()); + if (workOrder != null) { + if (workOrder.getWorkStatus().equals("1")) { + check = false; + } + }else { + return error(500,"未查询到对应维修工单信息!删除失败!"); + } + EquOrder order = equOrderMapper.selectEquOrderByOrderCode(apply.getWorkCode()); + if (order != null) { + if (order.getOrderStatus().equals("1")){ + check = false; + } + }else { + return error(500,"未查询到对应保养工单信息!删除失败!"); + } + } + } + + if (check) { + // 回填数据 + sparePartsLedgerMapper.updateSpareNumAdd(apply); + // 逻辑删除领用单 + equSpareApplyMapper.delEquSpareApplyByApplyId(id); + }else { + return error(500,"关联工单状态已完成,不可删除!"); + } + + } + return success(); } /** * 删除申领记录信息 - * + * * @param applyId 申领记录主键 * @return 结果 */ diff --git a/op-modules/op-device/src/main/resources/mapper/device/EquRepairWorkOrderMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/EquRepairWorkOrderMapper.xml index 82886724..6ca06eb6 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/EquRepairWorkOrderMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/EquRepairWorkOrderMapper.xml @@ -447,7 +447,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where source_id = #{sourceId} - + + + INSERT INTO base_file(file_id, file_name, file_address, source_id, remark, create_by, create_time,image_type) VALUES diff --git a/op-modules/op-device/src/main/resources/mapper/device/EquSpareApplyMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/EquSpareApplyMapper.xml index b7b6f4dd..12dcaf84 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/EquSpareApplyMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/EquSpareApplyMapper.xml @@ -176,6 +176,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) + + update equ_spare_apply set del_flag = '1' + where apply_id in + + #{id} + + + + + update equ_spare_apply set del_flag = '1' where apply_id = #{id} + +