diff --git a/src/main/java/com/spring/modules/Tooling/controller/ToolController.java b/src/main/java/com/spring/modules/Tooling/controller/ToolController.java new file mode 100644 index 00000000..b935a957 --- /dev/null +++ b/src/main/java/com/spring/modules/Tooling/controller/ToolController.java @@ -0,0 +1,202 @@ +package com.spring.modules.Tooling.controller; + +import com.spring.common.utils.PageUtils; +import com.spring.common.utils.R; +import com.spring.modules.Tooling.data.*; +import com.spring.modules.Tooling.entity.IfsTool; +import com.spring.modules.Tooling.entity.IfsToolInstance; +import com.spring.modules.Tooling.entity.IfsToolInstanceDate; +import com.spring.modules.Tooling.service.ToolService; +import com.spring.modules.Tooling.service.ToolingApplyService; +import com.spring.modules.quotation.service.QuotationHeaderService; +import com.spring.modules.quotation.vo.QuotationHeaderVo; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** +* @description: 工具的接口 +* @author LR +* @date 2024/8/27 16:43 +* @version 1.0 +*/ +@RestController +@RequestMapping("/plm/tool") +public class ToolController { + + @Autowired + private ToolService toolService; + + /** + * @description: 获取工具的信息列表 + * @author LR + * @date 2024/8/27 16:51 + * @version 1.0 + */ + @RequestMapping(value = "getToolInfoList") + public R getToolInfoList(@RequestBody IfsTool inData){ + List resultList = toolService.getToolInfoList(inData); + int total = toolService.countToolInfoListForPage(inData); + return R.ok() + .put("code", 200) + .put("msg", "") + .put("rows", resultList) + .put("total", total); + } + + /** + * @description: 查询工具实力的列表 + * @author LR + * @date 2024/8/29 15:09 + * @version 1.0 + */ + @RequestMapping(value = "getToolInstanceList") + public R getToolInstanceList(@RequestBody IfsToolInstance inData){ + List resultList = toolService.getToolInstanceList(inData); + return R.ok() + .put("code", 200) + .put("msg", "") + .put("rows", resultList) + .put("total", resultList.size()); + } + + /** + * @description: 查询工具实例的日期 + * @author LR + * @date 2024/8/29 17:53 + * @version 1.0 + */ + @RequestMapping(value = "getToolInstanceDates") + public R getToolInstanceList(@RequestBody IfsToolInstanceDate inData){ + List resultList = toolService.getToolInstanceDates(inData); + return R.ok() + .put("code", 200) + .put("msg", "") + .put("rows", resultList) + .put("total", resultList.size()); + } + + /** + * @description:新增工具信息 + * @author LR + * @date 2024/8/30 9:42 + * @version 1.0 + */ + @RequestMapping(value = "insertToolInfo") + public R insertToolInfo(@RequestBody IfsTool inData){ + toolService.insertToolInfo(inData); + return R.ok() + .put("code", 200) + .put("msg", ""); + } + + /** + * @description: 修改工具信息 + * @author LR + * @date 2024/8/30 13:41 + * @version 1.0 + */ + @RequestMapping(value = "modifyToolInfo") + public R modifyToolInfo(@RequestBody IfsTool inData){ + toolService.modifyToolInfo(inData); + return R.ok() + .put("code", 200) + .put("msg", ""); + } + + /** + * @description: 删除工具的信息 + * @author LR + * @date 2024/8/30 15:29 + * @version 1.0 + */ + public R removeToolInfo(@RequestBody IfsTool inData){ + toolService.removeToolInfo(inData); + return R.ok() + .put("code", 200) + .put("msg", ""); + } + + /** + * @description: 新增工具实例信息 + * @author LR + * @date 2024/8/30 15:32 + * @version 1.0 + */ + public R insertToolInstance(@RequestBody IfsToolInstance inData){ + toolService.insertToolInstance(inData); + return R.ok() + .put("code", 200) + .put("msg", ""); + } + + /** + * @description: 修改工具实例信息 + * @author LR + * @date 2024/8/30 15:53 + * @version 1.0 + */ + public R modifyToolInstance(@RequestBody IfsToolInstance inData){ + toolService.modifyToolInstance(inData); + return R.ok() + .put("code", 200) + .put("msg", ""); + } + + /** + * @description: 删除工具实例信息 + * @author LR + * @date 2024/8/30 15:57 + * @version 1.0 + */ + public R removeToolInstance(@RequestBody IfsToolInstance inData){ + toolService.removeToolInstance(inData); + return R.ok() + .put("code", 200) + .put("msg", ""); + } + + /** + * @description: 新增工具实例日期信息 + * @author LR + * @date 2024/8/30 16:00 + * @version 1.0 + */ + public R insertToolInstanceDate(@RequestBody IfsToolInstanceDate inData){ + toolService.insertToolInstanceDate(inData); + return R.ok() + .put("code", 200) + .put("msg", ""); + } + + /** + * @description: 修改工具实例日期信息 + * @author LR + * @date 2024/8/31 15:12 + * @version 1.0 + */ + public R modifyToolInstanceDate(@RequestBody IfsToolInstanceDate inData){ + toolService.modifyToolInstanceDate(inData); + return R.ok() + .put("code", 200) + .put("msg", ""); + } + + /** + * @description: 删除工具实例日期信息 + * @author LR + * @date 2024/8/31 15:13 + * @version 1.0 + */ + public R removeToolInstanceDate(@RequestBody IfsToolInstanceDate inData){ + toolService.removeToolInstanceDate(inData); + return R.ok() + .put("code", 200) + .put("msg", ""); + } + +} diff --git a/src/main/java/com/spring/modules/Tooling/dao/ToolDao.java b/src/main/java/com/spring/modules/Tooling/dao/ToolDao.java new file mode 100644 index 00000000..6fd5ac85 --- /dev/null +++ b/src/main/java/com/spring/modules/Tooling/dao/ToolDao.java @@ -0,0 +1,138 @@ +package com.spring.modules.Tooling.dao; + +import com.spring.modules.Tooling.data.IfsToolData; +import com.spring.modules.Tooling.data.IfsToolInstanceData; +import com.spring.modules.Tooling.data.IfsToolInstanceDateData; +import com.spring.modules.Tooling.entity.IfsTool; +import com.spring.modules.Tooling.entity.IfsToolInstance; +import com.spring.modules.Tooling.entity.IfsToolInstanceDate; + +import java.util.List; + +/** +* @description: 工具dao的接口 +* @author LR +* @date 2024/8/27 17:02 +* @version 1.0 +*/ +public interface ToolDao { + /** + * @description: 查询工具的信息 + * @author LR + * @date 2024/8/27 17:06 + * @version 1.0 + */ + List getToolInfoList(String site, String toolId, String toolType, int pageIndex, int pageSize); + + /** + * @description: 统计工具的信息 + * @author LR + * @date 2024/8/27 17:18 + * @version 1.0 + */ + int countToolInfoListForPage(String site, String toolId, String toolType); + + /** + * @description: 查询工具实力的列表 + * @author LR + * @date 2024/8/29 15:12 + * @version 1.0 + */ + List getToolInstanceList(String site, String toolId); + + /** + * @description: 查询工具实力的日期信息 + * @author LR + * @date 2024/8/29 17:55 + * @version 1.0 + */ + List getToolInstanceDates(String site, String toolId, String toolInstance); + + /** + * @description: 按照工具的id查询工具信息 + * @author LR + * @date 2024/8/30 9:55 + * @version 1.0 + */ + IfsToolData getToolInfoByToolId(String site, String toolId); + + /** + * @description: 新增工具信息 + * @author LR + * @date 2024/8/30 10:30 + * @version 1.0 + */ + int insertToolInfo(IfsTool inData); + + /** + * @description: 修改工具信息 + * @author LR + * @date 2024/8/30 13:51 + * @version 1.0 + */ + int updateToolInfo(IfsTool inData); + + /** + * @description: 删除工具的信息 + * @author LR + * @date 2024/8/30 13:53 + * @version 1.0 + */ + int deleteToolInfo(IfsTool inData); + + /** + * @description: 插入工具实例的信息 + * @author LR + * @date 2024/8/30 14:28 + * @version 1.0 + */ + int insertToolInstance(IfsToolInstance inData); + + /** + * @description: 修改工具实例的信息 + * @author LR + * @date 2024/8/30 14:29 + * @version 1.0 + */ + int updateToolInstance(IfsToolInstance inData); + + /** + * @description: 删除工具实例的信息 + * @author LR + * @date 2024/8/30 14:29 + * @version 1.0 + */ + int deleteToolInstance(IfsToolInstance inData); + + /** + * @description: 插入工具实力的日期 + * @author LR + * @date 2024/8/30 14:43 + * @version 1.0 + */ + int insertToolInstanceDate(IfsToolInstanceDate inData); + + /** + * @description: 修改工具实例的日期信息 + * @author LR + * @date 2024/8/30 14:44 + * @version 1.0 + */ + int updateToolInstanceDate(IfsToolInstanceDate inData); + + /** + * @description: 删除工具实例的日期信息 + * @author LR + * @date 2024/8/30 14:44 + * @version 1.0 + */ + int deleteToolInstanceDate(IfsToolInstanceDate inData); + + /** + * @description: 按照工具实例查询数据 + * @author LR + * @date 2024/8/30 15:35 + * @version 1.0 + */ + IfsToolInstanceData getToolInstanceByToolInstance(String site, String toolId, String toolInstance); +} diff --git a/src/main/java/com/spring/modules/Tooling/dao/impl/ToolDaoImpl.java b/src/main/java/com/spring/modules/Tooling/dao/impl/ToolDaoImpl.java new file mode 100644 index 00000000..68aba3f8 --- /dev/null +++ b/src/main/java/com/spring/modules/Tooling/dao/impl/ToolDaoImpl.java @@ -0,0 +1,250 @@ +package com.spring.modules.Tooling.dao.impl; + +import com.spring.modules.Tooling.dao.ToolDao; +import com.spring.modules.Tooling.data.IfsToolData; +import com.spring.modules.Tooling.data.IfsToolInstanceData; +import com.spring.modules.Tooling.data.IfsToolInstanceDateData; +import com.spring.modules.Tooling.entity.IfsTool; +import com.spring.modules.Tooling.entity.IfsToolInstance; +import com.spring.modules.Tooling.entity.IfsToolInstanceDate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.BeanPropertyRowMapper; +import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource; +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; +import org.springframework.jdbc.support.GeneratedKeyHolder; +import org.springframework.jdbc.support.KeyHolder; +import org.springframework.stereotype.Repository; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** +* @description: 工具dao的接口实现 +* @author LR +* @date 2024/8/27 17:04 +* @version 1.0 +*/ +@Repository +public class ToolDaoImpl implements ToolDao { + + @Autowired + private NamedParameterJdbcTemplate parameterJdbcTemplate; + + @Override + public List getToolInfoList(String site, String toolId, String toolType, int pageIndex, int pageSize) { + StringBuilder sql = new StringBuilder(); + Map paramMap = new HashMap(); + sql.append("SELECT site, tool_id, tool_description toolDesc, c_tool_type toolType, c_calendar_id calendarId, c_sched_capacity schedCapacity,"); + sql.append(" c_calibration_control calibrationControl, c_calibration_time calibrationTime, c_alternate_tool_id alternateToolId, c_last_used lastUsed,"); + sql.append(" c_enabled_for_control_plan_db enabledForControlPlanDb, c_note_text noteText"); + sql.append(" FROM tool_header th WHERE 1 = 1"); + //判断查询的条件 + if(!(null == site || "".equals(site))){ + sql.append(" AND th.site = :site"); + paramMap.put("site", site); + } + if(!(null == toolId || "".equals(toolId))){ + sql.append(" AND th.tool_id = :toolId"); + paramMap.put("toolId", toolId); + } + if(!(null == toolType || "".equals(toolType))){ + sql.append(" AND th.c_tool_type = :toolType"); + paramMap.put("toolType", toolType); + } + //排序 + sql.append(" ORDER BY th.tool_id ASC"); + //添加分页 + sql.append(" OFFSET "+(pageIndex - 1)*pageSize+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY"); + return parameterJdbcTemplate.query(sql.toString(), paramMap, new BeanPropertyRowMapper<>(IfsToolData.class)); + } + + @Override + public int countToolInfoListForPage(String site, String toolId, String toolType) { + StringBuilder sql = new StringBuilder(); + Map paramMap = new HashMap(); + sql.append("SELECT COUNT(1)"); + sql.append(" FROM tool_header th WHERE 1 = 1"); + //判断查询的条件 + if(!(null == site || "".equals(site))){ + sql.append(" AND th.site = :site"); + paramMap.put("site", site); + } + if(!(null == toolId || "".equals(toolId))){ + sql.append(" AND th.tool_id = :toolId"); + paramMap.put("toolId", toolId); + } + if(!(null == toolType || "".equals(toolType))){ + sql.append(" AND th.c_tool_type = :toolType"); + paramMap.put("toolType", toolType); + } + return parameterJdbcTemplate.queryForObject(sql.toString(), paramMap, Integer.class); + } + + @Override + public List getToolInstanceList(String site, String toolId) { + StringBuilder sql = new StringBuilder(); + Map paramMap = new HashMap(); + sql.append("SELECT site, tool_id toolId, tool_instance_id toolInstance, work_center_no normalWorkCenterNo, c_desc desc,"); + sql.append(" c_last_calibration_date lastCalibrationDate, c_object_id objectId, c_normal_production_line normalProductionLine,"); + sql.append(" c_note_text noteText, c_tool_discrimination toolDiscrimination, c_tool_linearity toolLinearity, c_tool_repeatability toolRepeatability,"); + sql.append(" c_tool_bias toolBias, c_tool_stability toolStability, c_tool_reproducibility toolReproducibility"); + sql.append(" FROM tool_detail td"); + sql.append(" WHERE td.site = :site AND td.tool_id = :toolId"); + paramMap.put("site", site); + paramMap.put("toolId", toolId); + return parameterJdbcTemplate.query(sql.toString(), paramMap, new BeanPropertyRowMapper<>(IfsToolInstanceData.class)); + } + + @Override + public List getToolInstanceDates(String site, String toolId, String toolInstance) { + StringBuilder sql = new StringBuilder(); + Map paramMap = new HashMap(); + sql.append("SELECT id, site, tool_id, tool_instance, begin_date, end_date,"); + sql.append(" ifs_row_id, ifs_row_version FROM tool_detail_phase_date"); + sql.append(" WHERE td.site = :site AND td.tool_id = :toolId AND tool_instance = :toolInstance"); + paramMap.put("site", site); + paramMap.put("toolId", toolId); + paramMap.put("toolInstance", toolInstance); + return parameterJdbcTemplate.query(sql.toString(), paramMap, new BeanPropertyRowMapper<>(IfsToolInstanceDateData.class)); + } + + @Override + public IfsToolData getToolInfoByToolId(String site, String toolId) { + StringBuilder sql = new StringBuilder(); + Map paramMap = new HashMap(); + sql.append("SELECT site, tool_id, tool_description toolDesc, c_tool_type toolType, c_calendar_id calendarId, c_sched_capacity schedCapacity,"); + sql.append(" c_calibration_control calibrationControl, c_calibration_time calibrationTime, c_alternate_tool_id alternateToolId, c_last_used lastUsed,"); + sql.append(" c_enabled_for_control_plan_db enabledForControlPlanDb, c_note_text noteText"); + sql.append(" FROM tool_header th WHERE 1 = 1"); + //判断查询的条件 + if(!(null == site || "".equals(site))){ + sql.append(" AND th.site = :site"); + paramMap.put("site", site); + } + if(!(null == toolId || "".equals(toolId))){ + sql.append(" AND th.tool_id = :toolId"); + paramMap.put("toolId", toolId); + } + List resultList = parameterJdbcTemplate.query(sql.toString(), paramMap, new BeanPropertyRowMapper<>(IfsToolData.class)); + //返回结果集 + if(resultList.size() > 0){ + return resultList.get(0); + } + return null; + } + + @Override + public int insertToolInfo(IfsTool inData) { + StringBuilder sql = new StringBuilder(); + KeyHolder keyHolder = new GeneratedKeyHolder(); + sql.append("INSERT INTO tool_header(site, tool_id, tool_description, c_tool_type, c_calendar_id, c_sched_capacity,"); + sql.append(" c_calibration_control, c_calibration_time, c_alternate_tool_id, c_last_used, c_enabled_for_control_plan_db, c_note_text, create_date,"); + sql.append(" created_by)"); + sql.append("VALUES(:site, :toolId, :toolDesc, :toolType, :calendarId, :schedCapacity,"); + sql.append(" :calibrationControl, :calibrationTime, :alternateToolId, :lastUsed, :enabledForControlPlanDb, :noteText, :createDate,"); + sql.append(" :username)"); + parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData), keyHolder); + return keyHolder.getKey().intValue(); + } + + @Override + public int updateToolInfo(IfsTool inData) { + StringBuilder sql = new StringBuilder(); + sql.append("UPDATE tool_header SET tool_description = :toolDesc, c_tool_type = :toolType, c_calendar_id = :calendarId,"); + sql.append(" c_sched_capacity = :schedCapacity, c_calibration_control = :calibrationControl, c_calibration_time = :calibrationTime, c_alternate_tool_id = :alternateToolId,"); + sql.append(" c_last_used = :lastUsed, last_update_by = :username, c_enabled_for_control_plan_db = :enabledForControlPlanDb, c_note_text = :noteText"); + sql.append(" WHERE site = :site AND tool_id = :toolId"); + return parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData)); + } + + @Override + public int deleteToolInfo(IfsTool inData) { + StringBuilder sql = new StringBuilder(); + sql.append("DELETE FROM tool_header"); + sql.append(" WHERE site = :site AND tool_id = :toolId"); + return parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData)); + } + + @Override + public int insertToolInstance(IfsToolInstance inData) { + StringBuilder sql = new StringBuilder(); + KeyHolder keyHolder = new GeneratedKeyHolder(); + sql.append("INSERT INTO tool_detail(site, tool_id, tool_instance_id, work_center_no, c_desc, c_last_calibration_date,"); + sql.append(" c_object_id, c_normal_production_line, c_note_text, c_tool_discrimination, c_tool_linearity, c_tool_repeatability, c_tool_bias, c_tool_stability,"); + sql.append(" c_tool_reproducibility)"); + sql.append(" VALUES(:site, :toolId, :toolInstance, :normalWorkCenterNo, :desc, :lastCalibrationDate,"); + sql.append(" :objectId, :normalProductionLine, :noteText, :toolDiscrimination, :toolLinearity, :toolRepeatability, :toolBias, :toolStability,"); + sql.append(" :toolReproducibility)"); + parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData), keyHolder); + return keyHolder.getKey().intValue(); + } + + @Override + public int updateToolInstance(IfsToolInstance inData) { + StringBuilder sql = new StringBuilder(); + sql.append("UPDATE tool_detail SET work_center_no = :normalWorkCenterNo, c_desc = :desc, c_last_calibration_date = :lastCalibrationDate,"); + sql.append(" c_object_id = :objectId, c_normal_production_line = :normalProductionLine, c_note_text = :noteText, c_tool_discrimination = :toolDiscrimination,"); + sql.append(" c_tool_linearity = :toolLinearity, c_tool_repeatability = :toolRepeatability, c_tool_bias = :toolBias,"); + sql.append(" c_tool_stability = :toolStability, c_tool_reproducibility = :toolReproducibility"); + sql.append(" WHERE site = :site AND tool_id = :toolId AND tool_instance_id = :toolInstance"); + return parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData)); + } + + @Override + public int deleteToolInstance(IfsToolInstance inData) { + StringBuilder sql = new StringBuilder(); + sql.append("DELETE FROM tool_detail"); + sql.append(" WHERE site = :site AND tool_id = :toolId AND tool_instance_id = :toolInstance"); + return parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData)); + } + + @Override + public int insertToolInstanceDate(IfsToolInstanceDate inData) { + StringBuilder sql = new StringBuilder(); + KeyHolder keyHolder = new GeneratedKeyHolder(); + sql.append("INSERT INTO tool_detail_phase_date(site, tool_id, tool_instance, begin_date, end_date, ifs_row_id,"); + sql.append(" ifs_row_version)"); + sql.append(" VALUES(:site, :toolId, :toolInstance, :beginDate, :endDate, :ifsRowId,"); + sql.append(" :ifsRowVersion)"); + parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData), keyHolder); + return keyHolder.getKey().intValue(); + } + + @Override + public int updateToolInstanceDate(IfsToolInstanceDate inData) { + StringBuilder sql = new StringBuilder(); + sql.append("UPDATE tool_detail_phase_date SET end_date = :endDate, ifs_row_id = :ifsRowId, ifs_row_version = :ifsRowVersion"); + sql.append(" WHERE id = :id"); + return parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData)); + } + + @Override + public int deleteToolInstanceDate(IfsToolInstanceDate inData) { + StringBuilder sql = new StringBuilder(); + sql.append("DELETE FROM tool_detail_phase_date"); + sql.append(" WHERE id = :id"); + return parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData)); + } + + @Override + public IfsToolInstanceData getToolInstanceByToolInstance(String site, String toolId, String toolInstance) { + StringBuilder sql = new StringBuilder(); + Map paramMap = new HashMap(); + sql.append("SELECT site, tool_id toolId, , work_center_no normalWorkCenterNo, c_desc desc,"); + sql.append(" c_last_calibration_date lastCalibrationDate, c_object_id objectId, c_normal_production_line normalProductionLine,"); + sql.append(" c_note_text noteText, c_tool_discrimination toolDiscrimination, c_tool_linearity toolLinearity, c_tool_repeatability toolRepeatability,"); + sql.append(" c_tool_bias toolBias, c_tool_stability toolStability, c_tool_reproducibility toolReproducibility"); + sql.append(" FROM tool_detail td"); + sql.append(" WHERE td.site = :site AND td.tool_id = :toolId AND tool_instance_id = :toolInstance"); + paramMap.put("site", site); + paramMap.put("toolId", toolId); + paramMap.put("toolInstance", toolInstance); + List resultList = parameterJdbcTemplate.query(sql.toString(), paramMap, new BeanPropertyRowMapper<>(IfsToolInstanceData.class)); + //返回结果集 + if(resultList.size() > 0){ + return resultList.get(0); + } + return null; + } +} diff --git a/src/main/java/com/spring/modules/Tooling/data/IfsToolData.java b/src/main/java/com/spring/modules/Tooling/data/IfsToolData.java new file mode 100644 index 00000000..abb84912 --- /dev/null +++ b/src/main/java/com/spring/modules/Tooling/data/IfsToolData.java @@ -0,0 +1,171 @@ +package com.spring.modules.Tooling.data; + +import java.util.Date; + +public class IfsToolData extends PageData { + private int id; + private String site; + private String toolId; + private String toolDesc; + private String toolType; + private String calendarId; + private String schedCapacity; + private String alternateToolId; + private String calibrationControl; + private String calibrationTime; + private String enabledForControlPlanDb; + private String lastUsed;// 备注 + private String noteText;// 备注 + private String ifsRowId; + private String ifsRowVersion; + private Date createDate; + private String username; + private String state; + + public IfsToolData() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getSite() { + return site; + } + + public void setSite(String site) { + this.site = site; + } + + public String getToolId() { + return toolId; + } + + public void setToolId(String toolId) { + this.toolId = toolId; + } + + public String getToolDesc() { + return toolDesc; + } + + public void setToolDesc(String toolDesc) { + this.toolDesc = toolDesc; + } + + public String getToolType() { + return toolType; + } + + public void setToolType(String toolType) { + this.toolType = toolType; + } + + public String getCalendarId() { + return calendarId; + } + + public void setCalendarId(String calendarId) { + this.calendarId = calendarId; + } + + public String getSchedCapacity() { + return schedCapacity; + } + + public void setSchedCapacity(String schedCapacity) { + this.schedCapacity = schedCapacity; + } + + public String getAlternateToolId() { + return alternateToolId; + } + + public void setAlternateToolId(String alternateToolId) { + this.alternateToolId = alternateToolId; + } + + public String getCalibrationControl() { + return calibrationControl; + } + + public void setCalibrationControl(String calibrationControl) { + this.calibrationControl = calibrationControl; + } + + public String getCalibrationTime() { + return calibrationTime; + } + + public void setCalibrationTime(String calibrationTime) { + this.calibrationTime = calibrationTime; + } + + public String getEnabledForControlPlanDb() { + return enabledForControlPlanDb; + } + + public void setEnabledForControlPlanDb(String enabledForControlPlanDb) { + this.enabledForControlPlanDb = enabledForControlPlanDb; + } + + public String getLastUsed() { + return lastUsed; + } + + public void setLastUsed(String lastUsed) { + this.lastUsed = lastUsed; + } + + public String getNoteText() { + return noteText; + } + + public void setNoteText(String noteText) { + this.noteText = noteText; + } + + public String getIfsRowId() { + return ifsRowId; + } + + public void setIfsRowId(String ifsRowId) { + this.ifsRowId = ifsRowId; + } + + public String getIfsRowVersion() { + return ifsRowVersion; + } + + public void setIfsRowVersion(String ifsRowVersion) { + this.ifsRowVersion = ifsRowVersion; + } + + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } +} diff --git a/src/main/java/com/spring/modules/Tooling/data/IfsToolInstanceData.java b/src/main/java/com/spring/modules/Tooling/data/IfsToolInstanceData.java new file mode 100644 index 00000000..37cc70b6 --- /dev/null +++ b/src/main/java/com/spring/modules/Tooling/data/IfsToolInstanceData.java @@ -0,0 +1,128 @@ +package com.spring.modules.Tooling.data; + +public class IfsToolInstanceData extends IfsToolData { + private String toolInstance; + private String desc; + private String lastCalibrationDate; + private String objectId; + private String normalWorkCenterNo; + private String normalProductionLine; + private String noteText;// 备注 + + private String toolDiscrimination; + private String toolLinearity; + private String toolRepeatability; + private String toolBias; + private String toolStability; + private String toolReproducibility; + + public IfsToolInstanceData() { + super(); + // TODO Auto-generated constructor stub + } + + public String getToolInstance() { + return toolInstance; + } + + public void setToolInstance(String toolInstance) { + this.toolInstance = toolInstance; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public String getLastCalibrationDate() { + return lastCalibrationDate; + } + + public void setLastCalibrationDate(String lastCalibrationDate) { + this.lastCalibrationDate = lastCalibrationDate; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getNormalWorkCenterNo() { + return normalWorkCenterNo; + } + + public void setNormalWorkCenterNo(String normalWorkCenterNo) { + this.normalWorkCenterNo = normalWorkCenterNo; + } + + public String getNormalProductionLine() { + return normalProductionLine; + } + + public void setNormalProductionLine(String normalProductionLine) { + this.normalProductionLine = normalProductionLine; + } + + public String getNoteText() { + return noteText; + } + + public void setNoteText(String noteText) { + this.noteText = noteText; + } + + public String getToolDiscrimination() { + return toolDiscrimination; + } + + public void setToolDiscrimination(String toolDiscrimination) { + this.toolDiscrimination = toolDiscrimination; + } + + public String getToolLinearity() { + return toolLinearity; + } + + public void setToolLinearity(String toolLinearity) { + this.toolLinearity = toolLinearity; + } + + public String getToolRepeatability() { + return toolRepeatability; + } + + public void setToolRepeatability(String toolRepeatability) { + this.toolRepeatability = toolRepeatability; + } + + public String getToolBias() { + return toolBias; + } + + public void setToolBias(String toolBias) { + this.toolBias = toolBias; + } + + public String getToolStability() { + return toolStability; + } + + public void setToolStability(String toolStability) { + this.toolStability = toolStability; + } + + public String getToolReproducibility() { + return toolReproducibility; + } + + public void setToolReproducibility(String toolReproducibility) { + this.toolReproducibility = toolReproducibility; + } + +} diff --git a/src/main/java/com/spring/modules/Tooling/data/IfsToolInstanceDateData.java b/src/main/java/com/spring/modules/Tooling/data/IfsToolInstanceDateData.java new file mode 100644 index 00000000..2dd244f5 --- /dev/null +++ b/src/main/java/com/spring/modules/Tooling/data/IfsToolInstanceDateData.java @@ -0,0 +1,27 @@ +package com.spring.modules.Tooling.data; + +public class IfsToolInstanceDateData extends IfsToolInstanceData { + private String beginDate; + private String endDate; + + public IfsToolInstanceDateData() { + super(); + // TODO Auto-generated constructor stub + } + + public String getBeginDate() { + return beginDate; + } + + public void setBeginDate(String beginDate) { + this.beginDate = beginDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } +} diff --git a/src/main/java/com/spring/modules/Tooling/data/PageData.java b/src/main/java/com/spring/modules/Tooling/data/PageData.java new file mode 100644 index 00000000..738a6e84 --- /dev/null +++ b/src/main/java/com/spring/modules/Tooling/data/PageData.java @@ -0,0 +1,49 @@ +package com.spring.modules.Tooling.data; + +/** + * @author LR + * @version 1.0 + * @description: 分页参数 + * @date 2024/6/7 14:31 + */ +public class PageData { + private int pageSize;// 分页数量 + private int pageIndex;//页下标 + private boolean exportFlag; + private boolean searchFlag; + + public PageData() { + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageIndex() { + return pageIndex; + } + + public void setPageIndex(int pageIndex) { + this.pageIndex = pageIndex; + } + + public boolean isExportFlag() { + return exportFlag; + } + + public void setExportFlag(boolean exportFlag) { + this.exportFlag = exportFlag; + } + + public boolean isSearchFlag() { + return searchFlag; + } + + public void setSearchFlag(boolean searchFlag) { + this.searchFlag = searchFlag; + } +} diff --git a/src/main/java/com/spring/modules/Tooling/entity/IfsTool.java b/src/main/java/com/spring/modules/Tooling/entity/IfsTool.java new file mode 100644 index 00000000..ad5160b8 --- /dev/null +++ b/src/main/java/com/spring/modules/Tooling/entity/IfsTool.java @@ -0,0 +1,155 @@ +package com.spring.modules.Tooling.entity; + +import com.spring.modules.Tooling.data.PageData; + +import java.util.Date; + +public class IfsTool extends PageData { + private int id; + private String site; + private String toolId; + private String toolDesc; + private String toolType; + private String calendarId; + private String schedCapacity; + private String alternateToolId; + private String calibrationControl; + private String calibrationTime; + private String enabledForControlPlanDb; + private String lastUsed;// 备注 + private String noteText;// 备注 + private String ifsRowId; + private String ifsRowVersion; + private Date createDate;// + + public IfsTool() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getSite() { + return site; + } + + public void setSite(String site) { + this.site = site; + } + + public String getToolId() { + return toolId; + } + + public void setToolId(String toolId) { + this.toolId = toolId; + } + + public String getToolDesc() { + return toolDesc; + } + + public void setToolDesc(String toolDesc) { + this.toolDesc = toolDesc; + } + + public String getToolType() { + return toolType; + } + + public void setToolType(String toolType) { + this.toolType = toolType; + } + + public String getCalendarId() { + return calendarId; + } + + public void setCalendarId(String calendarId) { + this.calendarId = calendarId; + } + + public String getSchedCapacity() { + return schedCapacity; + } + + public void setSchedCapacity(String schedCapacity) { + this.schedCapacity = schedCapacity; + } + + public String getAlternateToolId() { + return alternateToolId; + } + + public void setAlternateToolId(String alternateToolId) { + this.alternateToolId = alternateToolId; + } + + public String getCalibrationControl() { + return calibrationControl; + } + + public void setCalibrationControl(String calibrationControl) { + this.calibrationControl = calibrationControl; + } + + public String getCalibrationTime() { + return calibrationTime; + } + + public void setCalibrationTime(String calibrationTime) { + this.calibrationTime = calibrationTime; + } + + public String getEnabledForControlPlanDb() { + return enabledForControlPlanDb; + } + + public void setEnabledForControlPlanDb(String enabledForControlPlanDb) { + this.enabledForControlPlanDb = enabledForControlPlanDb; + } + + public String getLastUsed() { + return lastUsed; + } + + public void setLastUsed(String lastUsed) { + this.lastUsed = lastUsed; + } + + public String getNoteText() { + return noteText; + } + + public void setNoteText(String noteText) { + this.noteText = noteText; + } + + public String getIfsRowId() { + return ifsRowId; + } + + public void setIfsRowId(String ifsRowId) { + this.ifsRowId = ifsRowId; + } + + public String getIfsRowVersion() { + return ifsRowVersion; + } + + public void setIfsRowVersion(String ifsRowVersion) { + this.ifsRowVersion = ifsRowVersion; + } + + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } +} diff --git a/src/main/java/com/spring/modules/Tooling/entity/IfsToolInstance.java b/src/main/java/com/spring/modules/Tooling/entity/IfsToolInstance.java new file mode 100644 index 00000000..b8edfe4d --- /dev/null +++ b/src/main/java/com/spring/modules/Tooling/entity/IfsToolInstance.java @@ -0,0 +1,143 @@ +package com.spring.modules.Tooling.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +public class IfsToolInstance extends IfsTool { + private String toolInstance; + private String desc; + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd") + private Date lastCalibrationDate; + private String objectId; + private String normalWorkCenterNo; + private String normalProductionLine; + private String noteText;// 备注 + + private String toolDiscrimination; + private String toolLinearity; + private String toolRepeatability; + private String toolBias; + private String toolStability; + private String toolReproducibility; + private Date createDate; + + public IfsToolInstance() { + super(); + // TODO Auto-generated constructor stub + } + + public String getToolInstance() { + return toolInstance; + } + + public void setToolInstance(String toolInstance) { + this.toolInstance = toolInstance; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public Date getLastCalibrationDate() { + return lastCalibrationDate; + } + + public void setLastCalibrationDate(Date lastCalibrationDate) { + this.lastCalibrationDate = lastCalibrationDate; + } + + public String getObjectId() { + return objectId; + } + + public void setObjectId(String objectId) { + this.objectId = objectId; + } + + public String getNormalWorkCenterNo() { + return normalWorkCenterNo; + } + + public void setNormalWorkCenterNo(String normalWorkCenterNo) { + this.normalWorkCenterNo = normalWorkCenterNo; + } + + public String getNormalProductionLine() { + return normalProductionLine; + } + + public void setNormalProductionLine(String normalProductionLine) { + this.normalProductionLine = normalProductionLine; + } + + public String getNoteText() { + return noteText; + } + + public void setNoteText(String noteText) { + this.noteText = noteText; + } + + public String getToolDiscrimination() { + return toolDiscrimination; + } + + public void setToolDiscrimination(String toolDiscrimination) { + this.toolDiscrimination = toolDiscrimination; + } + + public String getToolLinearity() { + return toolLinearity; + } + + public void setToolLinearity(String toolLinearity) { + this.toolLinearity = toolLinearity; + } + + public String getToolRepeatability() { + return toolRepeatability; + } + + public void setToolRepeatability(String toolRepeatability) { + this.toolRepeatability = toolRepeatability; + } + + public String getToolBias() { + return toolBias; + } + + public void setToolBias(String toolBias) { + this.toolBias = toolBias; + } + + public String getToolStability() { + return toolStability; + } + + public void setToolStability(String toolStability) { + this.toolStability = toolStability; + } + + public String getToolReproducibility() { + return toolReproducibility; + } + + public void setToolReproducibility(String toolReproducibility) { + this.toolReproducibility = toolReproducibility; + } + + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } +} diff --git a/src/main/java/com/spring/modules/Tooling/entity/IfsToolInstanceDate.java b/src/main/java/com/spring/modules/Tooling/entity/IfsToolInstanceDate.java new file mode 100644 index 00000000..91bd58c4 --- /dev/null +++ b/src/main/java/com/spring/modules/Tooling/entity/IfsToolInstanceDate.java @@ -0,0 +1,36 @@ +package com.spring.modules.Tooling.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +public class IfsToolInstanceDate extends IfsToolInstance { + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd") + private Date beginDate; + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd") + private Date endDate; + + public IfsToolInstanceDate() { + super(); + // TODO Auto-generated constructor stub + } + + public Date getBeginDate() { + return beginDate; + } + + public void setBeginDate(Date beginDate) { + this.beginDate = beginDate; + } + + public Date getEndDate() { + return endDate; + } + + public void setEndDate(Date endDate) { + this.endDate = endDate; + } +} diff --git a/src/main/java/com/spring/modules/Tooling/service/ToolService.java b/src/main/java/com/spring/modules/Tooling/service/ToolService.java new file mode 100644 index 00000000..b906f32a --- /dev/null +++ b/src/main/java/com/spring/modules/Tooling/service/ToolService.java @@ -0,0 +1,122 @@ +package com.spring.modules.Tooling.service; + +import com.spring.modules.Tooling.data.IfsToolData; +import com.spring.modules.Tooling.data.IfsToolInstanceData; +import com.spring.modules.Tooling.data.IfsToolInstanceDateData; +import com.spring.modules.Tooling.entity.IfsTool; +import com.spring.modules.Tooling.entity.IfsToolInstance; +import com.spring.modules.Tooling.entity.IfsToolInstanceDate; + +import java.util.List; + +/** +* @description: 工具的接口 +* @author LR +* @date 2024/8/27 16:44 +* @version 1.0 +*/ +public interface ToolService { + /** + * @description: 获取工具的信息列表 + * @author LR + * @date 2024/8/27 16:53 + * @version 1.0 + */ + List getToolInfoList(IfsTool inData); + + /** + * @description: 统计工具信息的数量 + * @author LR + * @date 2024/8/27 16:53 + * @version 1.0 + */ + int countToolInfoListForPage(IfsTool inData); + + /** + * @description: 查询工具实力的列表 + * @author LR + * @date 2024/8/29 15:10 + * @version 1.0 + */ + List getToolInstanceList(IfsToolInstance inData); + + /** + * @description: 查询工具实例的日期 + * @author LR + * @date 2024/8/29 17:54 + * @version 1.0 + */ + List getToolInstanceDates(IfsToolInstanceDate inData); + + /** + * @description: 新增工具信息 + * @author LR + * @date 2024/8/30 9:50 + * @version 1.0 + */ + void insertToolInfo(IfsTool inData); + + /** + * @description: 修改工具信息 + * @author LR + * @date 2024/8/30 13:41 + * @version 1.0 + */ + void modifyToolInfo(IfsTool inData); + + /** + * @description: 删除工具的信息 + * @author LR + * @date 2024/8/30 15:29 + * @version 1.0 + */ + void removeToolInfo(IfsTool inData); + + /** + * @description: 新增工具实例信息 + * @author LR + * @date 2024/8/30 15:33 + * @version 1.0 + */ + void insertToolInstance(IfsToolInstance inData); + + /** + * @description: 修改工具实例信息 + * @author LR + * @date 2024/8/30 15:54 + * @version 1.0 + */ + void modifyToolInstance(IfsToolInstance inData); + + /** + * @description: 删除工具实例信息 + * @author LR + * @date 2024/8/30 15:57 + * @version 1.0 + */ + void removeToolInstance(IfsToolInstance inData); + + /** + * @description: 新增工具实例日期信息 + * @author LR + * @date 2024/8/30 16:00 + * @version 1.0 + */ + void insertToolInstanceDate(IfsToolInstanceDate inData); + + /** + * @description: 修改工具实例日期信息 + * @author LR + * @date 2024/8/31 15:13 + * @version 1.0 + */ + void modifyToolInstanceDate(IfsToolInstanceDate inData); + + /** + * @description: 删除工具实例日期信息 + * @author LR + * @date 2024/8/31 15:14 + * @version 1.0 + */ + void removeToolInstanceDate(IfsToolInstanceDate inData); +} diff --git a/src/main/java/com/spring/modules/Tooling/service/impl/ToolServiceImpl.java b/src/main/java/com/spring/modules/Tooling/service/impl/ToolServiceImpl.java new file mode 100644 index 00000000..deac9923 --- /dev/null +++ b/src/main/java/com/spring/modules/Tooling/service/impl/ToolServiceImpl.java @@ -0,0 +1,480 @@ +package com.spring.modules.Tooling.service.impl; + +import com.alibaba.fastjson.JSON; +import com.spring.modules.Tooling.data.IfsToolData; +import com.spring.modules.Tooling.dao.ToolDao; +import com.spring.modules.Tooling.data.IfsToolInstanceData; +import com.spring.modules.Tooling.data.IfsToolInstanceDateData; +import com.spring.modules.Tooling.entity.IfsTool; +import com.spring.modules.Tooling.entity.IfsToolInstance; +import com.spring.modules.Tooling.entity.IfsToolInstanceDate; +import com.spring.modules.Tooling.service.ToolService; +import com.spring.modules.base.utils.DateUtils; +import com.spring.modules.base.utils.HttpClientUtil; +import com.spring.modules.base.utils.ResponseData; +import com.spring.modules.report.dao.ProcedureDao; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** +* @description: 工具的接口的实现 +* @author LR +* @date 2024/8/27 16:45 +* @version 1.0 +*/ +@Service +public class ToolServiceImpl implements ToolService { + + @Autowired + private ToolDao toolDao; + @Autowired + private ProcedureDao procedureDao; + + @Value("${ifs-api.api-url}") + private String apiUrl; + + @Override + public List getToolInfoList(IfsTool inData) { + //公共参数 + boolean searchFlag = inData.isSearchFlag(); + int pageIndex = inData.getPageIndex(); + int pageSize = inData.getPageSize(); + String site = inData.getSite(); + String toolId = inData.getToolId(); + String toolType = inData.getToolType(); + boolean exportFlag = inData.isExportFlag(); + //是否查询 + if(searchFlag) { + return new ArrayList<>(); + } + return toolDao.getToolInfoList(site, toolId, toolType, pageIndex, pageSize); + } + + @Override + public int countToolInfoListForPage(IfsTool inData) { + //公共参数 + boolean searchFlag = inData.isSearchFlag(); + String site = inData.getSite(); + String toolId = inData.getToolId(); + String toolType = inData.getToolType(); + //是否查询 + if(searchFlag) { + return 0; + } + return toolDao.countToolInfoListForPage(site, toolId, toolType); + } + + @Override + public List getToolInstanceList(IfsToolInstance inData) { + //公共参数 + String site = inData.getSite(); + String toolId = inData.getToolId(); + return toolDao.getToolInstanceList(site, toolId); + } + + @Override + public List getToolInstanceDates(IfsToolInstanceDate inData) { + //公共参数 + String site = inData.getSite(); + String toolId = inData.getToolId(); + String toolInstance = inData.getToolInstance(); + return toolDao.getToolInstanceDates(site, toolId, toolInstance); + } + + @Override + @Transactional + public void insertToolInfo(IfsTool inData) { + //公共参数 + String site = inData.getSite(); + String toolId = inData.getToolId(); + String alternativeToolId = inData.getAlternateToolId(); + if(toolId.equals(alternativeToolId)){ + throw new RuntimeException("替代工具和当前工具不能相同!"); + } + //查询是否存在 + IfsToolData tool = toolDao.getToolInfoByToolId(site, toolId); + //如果存在 + if(tool != null){ + throw new RuntimeException("已存在当前工具信息!"); + } + IfsToolData alternativeTool = toolDao.getToolInfoByToolId(site, alternativeToolId); + //如果存在 + if(alternativeTool == null){ + throw new RuntimeException("当前替代工具信息不存在!"); + } + //1.校验存在调用接口 + //判断是否存在替代的 + String toolURL = apiUrl + "/tool/ifs/syncToolDataToIfs"; + ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, inData); + if (!"200".equals(toolResponse.getCode())) { + throw new RuntimeException("IFS Tool新增异常:" + toolResponse.getMsg()); + } + //删除工具信息默认的工具实例信息 + IfsToolInstanceData toolInstance = new IfsToolInstanceData(); + //属性拷贝 + BeanUtils.copyProperties(inData, toolInstance); + toolInstance.setToolInstance(toolId); + toolURL = apiUrl + "/tool/ifs/removeToolInstanceToIfs"; + toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, toolInstance); + if (!"200".equals(toolResponse.getCode())) { + throw new RuntimeException("IFS ToolInstance新增异常:" + toolResponse.getMsg()); + } + // 更新 ifs_row_id ifs_row_version + String objStr = String.valueOf(toolResponse.getObj()); + IfsToolData ifsTool = JSON.parseObject(objStr, IfsToolData.class); + inData.setCreateDate(new Date()); + //2.调用方法保存当前的数据 + toolDao.insertToolInfo(inData); + } + + @Override + @Transactional + public void modifyToolInfo(IfsTool inData) { + //公共参数 + String site = inData.getSite(); + String toolId = inData.getToolId(); + String alternativeToolId = inData.getAlternateToolId(); + if(toolId.equals(alternativeToolId)){ + throw new RuntimeException("替代工具和当前工具不能相同!"); + } + //查询是否存在 + IfsToolData tool = toolDao.getToolInfoByToolId(site, toolId); + //如果存在 + if(tool == null){ + throw new RuntimeException("当前工具信息不存在!"); + } + IfsToolData alternativeTool = toolDao.getToolInfoByToolId(site, alternativeToolId); + //如果存在 + if(alternativeTool == null){ + throw new RuntimeException("当前替代工具信息不存在!"); + } + //1.校验存在调用接口 + //判断是否存在替代的 + String toolURL = apiUrl + "/tool/ifs/modifyToolDataToIfs"; + ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, inData); + if (!"200".equals(toolResponse.getCode())) { + throw new RuntimeException("IFS Tool修改异常:" + toolResponse.getMsg()); + } + // 更新 ifs_row_id ifs_row_version + String objStr = String.valueOf(toolResponse.getObj()); + IfsToolData ifsTool = JSON.parseObject(objStr, IfsToolData.class); + //2.调用方法保存当前的数据 + toolDao.updateToolInfo(inData); + } + + @Override + @Transactional + public void removeToolInfo(IfsTool inData) { + //公共参数 + String site = inData.getSite(); + String toolId = inData.getToolId(); + //查询是否存在 + IfsToolData tool = toolDao.getToolInfoByToolId(site, toolId); + //如果存在 + if(tool == null){ + throw new RuntimeException("当前工具信息不存在!"); + } + //1.调用存储过程判断是否可以删除 + //调用存储过程 --向下移动派工单 + Map resultMap = this.checkDeleteToolInfo(site, toolId); + //判断是否检验成功 + String resultCode = String.valueOf(resultMap.get("result_code")); + if ("400".equalsIgnoreCase(resultCode)) { + String resultMsg = String.valueOf(resultMap.get("result_msg")); + throw new RuntimeException(resultMsg); + } + //2.校验存在调用接口 + //判断是否存在替代的 + String toolURL = apiUrl + "/tool/ifs/removeToolDataToIfs"; + ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, inData); + if (!"200".equals(toolResponse.getCode())) { + throw new RuntimeException("IFS Tool删除异常:" + toolResponse.getMsg()); + } + // 更新 ifs_row_id ifs_row_version + String objStr = String.valueOf(toolResponse.getObj()); + IfsToolData ifsTool = JSON.parseObject(objStr, IfsToolData.class); + //2.调用方法保存当前的数据 + toolDao.deleteToolInfo(inData); + } + + /** + * @description: 调用存储过程删除工具的信息 + * @author LR + * @date 2024/8/30 15:46 + * @version 1.0 + */ + public Map checkDeleteToolInfo(String site, String toolId) { + List params = new ArrayList<>(); + params.add(site); + params.add(toolId); + //调用存储过程 + List> resultList = procedureDao.getProcedureData("checkDeleteToolInfo", params); + //处理返回的结果 + return resultList.get(0); + } + + @Override + @Transactional + public void insertToolInstance(IfsToolInstance inData) { + //公共参数 + String site = inData.getSite(); + String toolId = inData.getToolId(); + String toolInstance = inData.getToolInstance(); + Date lastCalibrationDate = inData.getLastCalibrationDate(); + //查询是否存在 + IfsToolInstanceData toolInstanceData = toolDao.getToolInstanceByToolInstance(site, toolId, toolInstance); + //如果存在 + if(toolInstanceData != null){ + throw new RuntimeException("已存在当前工具实例!"); + } + toolInstanceData = new IfsToolInstanceDateData(); + //拷贝属性 设置参数 + BeanUtils.copyProperties(inData, toolInstanceData); + String lastCalibrationTime = ""; + if(lastCalibrationDate != null){ + lastCalibrationTime = DateUtils.getStringDate(lastCalibrationDate, "yyyy-MM-dd"); + } + toolInstanceData.setLastCalibrationDate(lastCalibrationTime); + + //1.校验存在调用接口 + String toolURL = apiUrl + "/tool/ifs/syncToolInstanceToIfs"; + ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, inData); + if (!"200".equals(toolResponse.getCode())) { + throw new RuntimeException("IFS ToolInstance新增异常:" + toolResponse.getMsg()); + } + String objStr = String.valueOf(toolResponse.getObj()); + IfsToolData ifsTool = JSON.parseObject(objStr, IfsToolData.class); + inData.setCreateDate(new Date()); + //2.调用方法保存当前的数据 + toolDao.insertToolInstance(inData); + } + + @Override + public void modifyToolInstance(IfsToolInstance inData) { + //公共参数 + String site = inData.getSite(); + String toolId = inData.getToolId(); + String toolInstance = inData.getToolInstance(); + Date lastCalibrationDate = inData.getLastCalibrationDate(); + //查询是否存在 + IfsToolInstanceData toolInstanceData = toolDao.getToolInstanceByToolInstance(site, toolId, toolInstance); + //如果存在 + if(toolInstanceData == null){ + throw new RuntimeException("当前工具实例不存在!"); + } + + toolInstanceData = new IfsToolInstanceDateData(); + //拷贝属性 设置参数 + BeanUtils.copyProperties(inData, toolInstanceData); + String lastCalibrationTime = ""; + if(lastCalibrationDate != null){ + lastCalibrationTime = DateUtils.getStringDate(lastCalibrationDate, "yyyy-MM-dd"); + } + toolInstanceData.setLastCalibrationDate(lastCalibrationTime); + //1.校验存在调用接口 + String toolURL = apiUrl + "/tool/ifs/modifyToolInstanceToIfs"; + ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, inData); + if (!"200".equals(toolResponse.getCode())) { + throw new RuntimeException("IFS ToolInstance修改异常:" + toolResponse.getMsg()); + } + String objStr = String.valueOf(toolResponse.getObj()); + IfsToolData ifsTool = JSON.parseObject(objStr, IfsToolData.class); + inData.setCreateDate(new Date()); + //2.调用方法保存当前的数据 + toolDao.updateToolInstance(inData); + } + + @Override + @Transactional + public void removeToolInstance(IfsToolInstance inData) { + //公共参数 + String site = inData.getSite(); + String toolId = inData.getToolId(); + String toolInstance = inData.getToolInstance(); + //查询是否存在 + IfsToolInstanceData toolInstanceData = toolDao.getToolInstanceByToolInstance(site, toolId, toolInstance); + //如果存在 + if(toolInstanceData == null){ + throw new RuntimeException("当前工具实例不存在!"); + } + + //1.校验存在调用接口 + String toolURL = apiUrl + "/tool/ifs/removeToolInstanceToIfs"; + ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, inData); + if (!"200".equals(toolResponse.getCode())) { + throw new RuntimeException("IFS ToolInstance删除异常:" + toolResponse.getMsg()); + } + //2.调用方法保存当前的数据 + toolDao.deleteToolInstance(inData); + } + + @Override + @Transactional + public void insertToolInstanceDate(IfsToolInstanceDate inData) { + //公共参数 + String site = inData.getSite(); + String toolId = inData.getToolId(); + String toolInstance = inData.getToolInstance(); + Date beginDate = inData.getBeginDate(); + Date endDate = inData.getEndDate(); + + //判断前后时间是否有问题 + if(endDate != null && beginDate.getTime() > endDate.getTime()){ + throw new RuntimeException("开始时间不能大于结束时间!"); + } + //调用存储查询 时间的数据是都在有效的范围之内 + String beginTime = DateUtils.getStringDate(beginDate, "yyyy-MM-dd"); + String endTime = ""; + if(endDate != null){ + endTime = DateUtils.getStringDate(endDate, "yyyy-MM-dd"); + } + //调用存储过程 验证时间是否在有效范围之内 + Map resultMap = this.checkInsertToolInstanceDate(site, toolId, toolInstance, beginTime, endTime); + //判断是否检验成功 + String resultCode = String.valueOf(resultMap.get("result_code")); + if ("400".equalsIgnoreCase(resultCode)) { + String resultMsg = String.valueOf(resultMap.get("result_msg")); + throw new RuntimeException(resultMsg); + } + IfsToolInstanceDateData instanceDateData = new IfsToolInstanceDateData(); + //属性拷贝 + BeanUtils.copyProperties(inData, instanceDateData); + //设置时间的信息 + instanceDateData.setBeginDate(beginTime); + instanceDateData.setEndDate(endTime); + //2.校验存在调用接口 + String toolURL = apiUrl + "/tool/ifs/syncToolInstanceDateToIfs"; + ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, instanceDateData); + if (!"200".equals(toolResponse.getCode())) { + throw new RuntimeException("IFS ToolInstance删除异常:" + toolResponse.getMsg()); + } + // 更新 ifs_row_id ifs_row_version + String objStr = String.valueOf(toolResponse.getObj()); + IfsToolInstanceDateData ifsTool = JSON.parseObject(objStr, IfsToolInstanceDateData.class); + inData.setIfsRowId(ifsTool.getIfsRowId()); + inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); + //保存新增的数据 + toolDao.insertToolInstanceDate(inData); + } + + /** + * @description: 调用存储过程 检查是否可以插入工具实例的日期 + * @author LR + * @date 2024/8/30 17:41 + * @version 1.0 + */ + public Map checkInsertToolInstanceDate(String site, String toolId, String toolInstance, String beginTime, String endTime) { + List params = new ArrayList<>(); + params.add(site); + params.add(toolId); + params.add(toolInstance); + params.add(beginTime); + params.add(endTime); + //调用存储过程 + List> resultList = procedureDao.getProcedureData("checkInsertToolInstanceDate", params); + //处理返回的结果 + return resultList.get(0); + } + + @Override + @Transactional + public void modifyToolInstanceDate(IfsToolInstanceDate inData) { + //公共参数 + String site = inData.getSite(); + String toolId = inData.getToolId(); + String toolInstance = inData.getToolInstance(); + Date beginDate = inData.getBeginDate(); + Date endDate = inData.getEndDate(); + int id = inData.getId(); + + //判断前后时间是否有问题 + if(endDate != null && beginDate.getTime() > endDate.getTime()){ + throw new RuntimeException("开始时间不能大于结束时间!"); + } + //调用存储查询 时间的数据是都在有效的范围之内 + String beginTime = DateUtils.getStringDate(beginDate, "yyyy-MM-dd"); + String endTime = ""; + if(endDate != null){ + endTime = DateUtils.getStringDate(endDate, "yyyy-MM-dd"); + } + //调用存储过程 验证时间是否在有效范围之内 + Map resultMap = this.checkUpdateToolInstanceDate(site, toolId, toolInstance, beginTime, endTime, id); + //判断是否检验成功 + String resultCode = String.valueOf(resultMap.get("result_code")); + if ("400".equalsIgnoreCase(resultCode)) { + String resultMsg = String.valueOf(resultMap.get("result_msg")); + throw new RuntimeException(resultMsg); + } + IfsToolInstanceDateData instanceDateData = new IfsToolInstanceDateData(); + //属性拷贝 + BeanUtils.copyProperties(inData, instanceDateData); + //设置时间的信息 + instanceDateData.setBeginDate(beginTime); + instanceDateData.setEndDate(endTime); + //2.校验存在调用接口 + String toolURL = apiUrl + "/tool/ifs/modifyToolInstanceDateToIfs"; + ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, instanceDateData); + if (!"200".equals(toolResponse.getCode())) { + throw new RuntimeException("IFS ToolInstance删除异常:" + toolResponse.getMsg()); + } + // 更新 ifs_row_id ifs_row_version + String objStr = String.valueOf(toolResponse.getObj()); + IfsToolInstanceDateData ifsTool = JSON.parseObject(objStr, IfsToolInstanceDateData.class); + inData.setIfsRowId(ifsTool.getIfsRowId()); + inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); + //保存新增的数据 + toolDao.updateToolInstanceDate(inData); + } + + /** + * @description: 调用存储过程 检查是否可以修改工具实例的日期参数 + * @author LR + * @date 2024/8/31 15:19 + * @version 1.0 + */ + public Map checkUpdateToolInstanceDate(String site, String toolId, String toolInstance, String beginTime, String endTime, int id) { + List params = new ArrayList<>(); + params.add(site); + params.add(toolId); + params.add(toolInstance); + params.add(beginTime); + params.add(endTime); + params.add(id); + //调用存储过程 + List> resultList = procedureDao.getProcedureData("checkUpdateToolInstanceDate", params); + //处理返回的结果 + return resultList.get(0); + } + + @Override + @Transactional + public void removeToolInstanceDate(IfsToolInstanceDate inData) { + //公共参数 + String site = inData.getSite(); + String toolId = inData.getToolId(); + String toolInstance = inData.getToolInstance(); + Date beginDate = inData.getBeginDate(); + Date endDate = inData.getEndDate(); + int id = inData.getId(); + + IfsToolInstanceDateData instanceDateData = new IfsToolInstanceDateData(); + //属性拷贝 + BeanUtils.copyProperties(inData, instanceDateData); + //2.校验存在调用接口 + String toolURL = apiUrl + "/tool/ifs/removeToolInstanceDateToIfs"; + ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, instanceDateData); + if (!"200".equals(toolResponse.getCode())) { + throw new RuntimeException("IFS ToolInstanceDate删除异常:" + toolResponse.getMsg()); + } + //保存新增的数据 + toolDao.deleteToolInstanceDate(inData); + } +}