diff --git a/xymanager_dao/src/main/resources/mappers/MntnCmdHistoryMapper.xml b/xymanager_dao/src/main/resources/mappers/MntnCmdHistoryMapper.xml index 0b774a6..2fb5d01 100644 --- a/xymanager_dao/src/main/resources/mappers/MntnCmdHistoryMapper.xml +++ b/xymanager_dao/src/main/resources/mappers/MntnCmdHistoryMapper.xml @@ -139,26 +139,23 @@ WARNING - @mbg.generated This element is automatically generated by MyBatis Generator, do not modify. --> - - SELECT LAST_INSERT_ID() - - insert into mntn_cmd_history (term_id, `name`, cmd, - `desc`, `status`, create_time, - publish_time) - values (#{termId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{cmd,jdbcType=VARCHAR}, - #{desc,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP}, - #{publishTime,jdbcType=TIMESTAMP}) + insert into mntn_cmd_history (id, term_id, `name`, + cmd, `desc`, `status`, + create_time, publish_time) + values (#{id,jdbcType=BIGINT}, #{termId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, + #{cmd,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT}, + #{createTime,jdbcType=TIMESTAMP}, #{publishTime,jdbcType=TIMESTAMP}) - - SELECT LAST_INSERT_ID() - insert into mntn_cmd_history + + id, + term_id, @@ -182,6 +179,9 @@ + + #{id,jdbcType=BIGINT}, + #{termId,jdbcType=INTEGER}, diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/MntnCmdsServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/MntnCmdsServiceImpl.java index 99a75b7..d6c90c0 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/MntnCmdsServiceImpl.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/MntnCmdsServiceImpl.java @@ -1,7 +1,9 @@ package com.shxy.xymanager_service.impl; +import com.shxy.xymanager_common.entity.MntnCmdHistory; import com.shxy.xymanager_common.entity.MntnCmds; import com.shxy.xymanager_common.entity.MntnCmdsExample; +import com.shxy.xymanager_common.exception.ApiException; import com.shxy.xymanager_common.model.CmdModel; import com.shxy.xymanager_dao.dao.MntnCmdHistoryMapper; import com.shxy.xymanager_dao.dao.MntnCmdsMapper; @@ -12,6 +14,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.Date; import java.util.List; @Service @@ -39,9 +42,30 @@ public class MntnCmdsServiceImpl implements MntnCmdsService { public void send(CmdModel model) throws Exception { switch (model.getAction()) { case "cancel": - cmdsMapper.deleteByPrimaryKey(model.getId()); + this.cancel(model); + break; case "": default: } } + + private void cancel(CmdModel model) { + if (model.getId() == null) { + throw new ApiException("id不能为空"); + } + MntnCmds item = cmdsMapper.selectByPrimaryKey(model.getId()); + if (item != null) { + MntnCmdHistory history = new MntnCmdHistory(); + history.setId(item.getId()); + history.setCmd(item.getCmd()); + history.setDesc(item.getDesc()); + history.setName(item.getName()); + history.setTermId(item.getTermId()); + history.setCreateTime(item.getCreateTime()); + history.setStatus(Byte.valueOf("2")); + history.setPublishTime(new Date()); + historyMapper.insert(history); + cmdsMapper.deleteByPrimaryKey(item.getId()); + } + } }