diff --git a/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java b/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java index cd842f93..fe15c86e 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java @@ -131,8 +131,9 @@ public enum HandleEnum { LOAD_INVENTORY("LoadInventoryBO:","LoadInventoryBO:{0},{1}"), /**用户**/ - USR("UserBO","UserBO:{0},{1}"); + USR("UserBO","UserBO:{0},{1}"), + TOOL("ToolBO","ToolBO:{0},{1}"); private String prefix; private String pattern; diff --git a/console/src/test/java/com/foreverwin/mesnac/console/TmdMc.java b/console/src/test/java/com/foreverwin/mesnac/console/TmdMc.java index 2c3c7219..1c158b63 100644 --- a/console/src/test/java/com/foreverwin/mesnac/console/TmdMc.java +++ b/console/src/test/java/com/foreverwin/mesnac/console/TmdMc.java @@ -66,6 +66,7 @@ public class TmdMc { //调用WS ERPAPI.erpWebService().zmesProdordconf(inHolder, outHolder); + //状态: S|成功, E|失败 String status = outHolder.value[1].getRet(); String message = outHolder.value[1].getMsg(); System.out.println("ERP接口返回:状态:" + status + ",消息:" + message); diff --git a/production/src/main/java/com/foreverwin/mesnac/production/controller/ToolController.java b/production/src/main/java/com/foreverwin/mesnac/production/controller/ToolController.java index 6581ac02..f6e1fd84 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/controller/ToolController.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/controller/ToolController.java @@ -1,10 +1,12 @@ package com.foreverwin.mesnac.production.controller; +import com.foreverwin.mesnac.common.enums.HandleEnum; import com.foreverwin.modular.core.util.R; import com.foreverwin.modular.core.util.FrontPage; import com.foreverwin.modular.core.util.CommonMethods; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import oracle.jdbc.proxy.annotation.Post; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -128,4 +130,43 @@ public class ToolController { public R removeByIds(List ids){ return R.ok(toolService.removeByIds(ids)); } + + + /** + * 新增或者更新 + * @param tool 传递的实体 + * @return null 失败 实体成功 + */ + @PostMapping(value = "/saveOrUpdateOne") + public R saveOrUpdateOne(@RequestBody Tool tool) { + try{ + toolService.saveOrUpdateOne(tool); + }catch (Exception e){ + return R.failed("数据保存失败" + e.getMessage()); + } + return R.ok(); + } + + @ResponseBody + @GetMapping("/getOneToolByToolNo") + public R getOneToolByToolNo(String tool) { + try{ + return R.ok(toolService.getOneToolByToolNo(tool)); + }catch (Exception e){ + return R.failed("数据保存失败" + e.getMessage()); + } + } + + + @PostMapping("/deleteInspectionPlanByHandle") + public R deleteInspectionPlanByHandle(@RequestBody String tool){ + try { + toolService.deleteInspectionPlanByHandle(tool); + } catch (Exception e) { + R.failed("计划删除失败:" + e.getMessage()); + } + return R.ok(); + } + + } \ No newline at end of file diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/ToolService.java b/production/src/main/java/com/foreverwin/mesnac/production/service/ToolService.java index c8e20659..944ce12b 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/service/ToolService.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/service/ToolService.java @@ -25,4 +25,24 @@ public interface ToolService extends IService { IPage selectPage(FrontPage frontPage, Tool tool); List selectList(Tool tool); + + /** + * 新增或更新 + * @param tool + */ + void saveOrUpdateOne(Tool tool); + + /** + * 根据编号,查询刀具 + * @param tool + * @return + */ + Tool getOneToolByToolNo(String tool); + + /** + * 删除刀具: + * 仅将状态进行修改,不会删除数据 + */ + void deleteInspectionPlanByHandle(String tool); + } \ No newline at end of file diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/ToolServiceImpl.java b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/ToolServiceImpl.java index 5088a403..04b03f38 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/ToolServiceImpl.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/ToolServiceImpl.java @@ -1,5 +1,8 @@ package com.foreverwin.mesnac.production.service.impl; +import com.foreverwin.mesnac.common.enums.HandleEnum; +import com.foreverwin.modular.core.exception.BusinessException; +import com.foreverwin.modular.core.util.CommonMethods; import com.foreverwin.modular.core.util.FrontPage; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -11,6 +14,7 @@ import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; import java.util.List; /** *

@@ -42,5 +46,49 @@ public class ToolServiceImpl extends ServiceImpl implements To return super.list(queryWrapper); } + @Override + public void saveOrUpdateOne(Tool tool) { + String site = tool.getSite(); + String toolNo = tool.getTool(); + String handle = HandleEnum.TOOL.getHandle(site, toolNo); + String user = CommonMethods.getUser(); + tool.setHandle(handle); + Tool byId = toolMapper.selectById(handle); + if (byId != null){ + tool.setCreateUser(byId.getCreateUser()); + tool.setCreatedDateTime(byId.getCreatedDateTime()); + tool.setModifyUser(user); + tool.setModifiedDateTime(LocalDateTime.now()); + toolMapper.updateById(tool); + }else{ + tool.setCreateUser(user); + tool.setCreatedDateTime(LocalDateTime.now()); + toolMapper.insert(tool); + } + + } + + @Override + public Tool getOneToolByToolNo(String tool) { + String site = CommonMethods.getSite(); + String handle = HandleEnum.TOOL.getHandle(site, tool); + return toolMapper.selectById(handle); + } + + @Override + public void deleteInspectionPlanByHandle(String tool) { + String site = CommonMethods.getSite(); + String handle = HandleEnum.TOOL.getHandle(site, tool); + String user = CommonMethods.getUser(); + Tool byId = toolMapper.selectById(handle); + if (byId == null){ + throw BusinessException.build("刀具编号不存在!"); + } + byId.setStatus("N"); + byId.setModifyUser(user); + byId.setModifiedDateTime(LocalDateTime.now()); + toolMapper.updateById(byId); + } + } \ No newline at end of file