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 index 68a8adc5..1e723fc4 100644 --- a/src/main/java/com/spring/modules/Tooling/dao/impl/ToolDaoImpl.java +++ b/src/main/java/com/spring/modules/Tooling/dao/impl/ToolDaoImpl.java @@ -38,7 +38,7 @@ public class ToolDaoImpl implements ToolDao { 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(" dbo.getToolInfoDesc(site, c_alternate_tool_id) alternateToolDesc, dbo.getToolTypeDesc(c_tool_type) toolTypeDesc,"); - sql.append(" c_state state,"); + sql.append(" c_state state, c_property_no propertyNo,"); sql.append(" c_enabled_for_control_plan_db enabledForControlPlanDb, c_note_text noteText, ifs_row_id, ifs_row_version"); sql.append(" FROM tool_header th WHERE 1 = 1"); //判断查询的条件 @@ -92,6 +92,7 @@ public class ToolDaoImpl implements ToolDao { sql.append(" c_note_text noteText, c_tool_discrimination toolDiscrimination, c_tool_linearity toolLinearity, c_tool_repeatability toolRepeatability,"); //后续添加的字段 sql.append(" c_next_calibration_date nextCalibrationDate, '' toolResourceId, '' toolResourceDesc, dbo.get_workCenter_desc(site, work_center_no) normalWorkCenterDesc,"); + sql.append(" c_property_no propertyNo,"); sql.append(" c_state state, dbo.getProductionLineDesc(site, c_normal_production_line) normalProductionLineDesc, '' toolResourceId, '' toolResourceDesc,"); sql.append(" c_tool_bias toolBias, c_tool_stability toolStability, c_tool_reproducibility toolReproducibility"); sql.append(" FROM tool_detail td"); @@ -120,7 +121,7 @@ public class ToolDaoImpl implements ToolDao { 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(" c_enabled_for_control_plan_db enabledForControlPlanDb, c_property_no propertyNo, c_note_text noteText"); sql.append(" FROM tool_header th WHERE 1 = 1"); //判断查询的条件 if(!(null == site || "".equals(site))){ @@ -144,10 +145,10 @@ public class ToolDaoImpl implements ToolDao { StringBuilder sql = new StringBuilder(); 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, c_state, ifs_row_id, ifs_row_version)"); + sql.append(" created_by, c_state, c_property_no, ifs_row_id, ifs_row_version)"); sql.append("VALUES(:site, :toolId, :toolDesc, :toolType, :calendarId, :schedCapacity,"); sql.append(" :calibrationControl, :calibrationTime, :alternateToolId, :lastUsed, :enabledForControlPlanDb, :noteText, :createDate,"); - sql.append(" :username, :state, :ifsRowId, :ifsRowVersion)"); + sql.append(" :username, :state, :propertyNo, :ifsRowId, :ifsRowVersion)"); parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData)); } @@ -156,7 +157,7 @@ public class ToolDaoImpl implements ToolDao { 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(" ifs_row_id = :ifsRowId, ifs_row_version = :ifsRowVersion,"); + sql.append(" c_property_no = :propertyNo, ifs_row_id = :ifsRowId, ifs_row_version = :ifsRowVersion,"); 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)); @@ -175,10 +176,10 @@ public class ToolDaoImpl implements ToolDao { StringBuilder sql = new StringBuilder(); 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, c_next_calibration_date, c_state, ifs_row_id, ifs_row_version)"); + sql.append(" c_tool_reproducibility, c_next_calibration_date, c_state, c_property_no, ifs_row_id, ifs_row_version)"); sql.append(" VALUES(:site, :toolId, :toolInstance, :normalWorkCenterNo, :description, :lastCalibrationDate,"); sql.append(" :objectId, :normalProductionLine, :noteText, :toolDiscrimination, :toolLinearity, :toolRepeatability, :toolBias, :toolStability,"); - sql.append(" :toolReproducibility, :nextCalibrationDate, :state, :ifsRowId, :ifsRowVersion)"); + sql.append(" :toolReproducibility, :nextCalibrationDate, :state, :propertyNo, :ifsRowId, :ifsRowVersion)"); parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData)); } @@ -189,7 +190,7 @@ public class ToolDaoImpl implements ToolDao { sql.append(" c_next_calibration_date = :nextCalibrationDate, c_state = :state,"); 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(" ifs_row_id = :ifsRowId, ifs_row_version = :ifsRowVersion,"); + sql.append(" c_property_no = :propertyNo, ifs_row_id = :ifsRowId, ifs_row_version = :ifsRowVersion,"); 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)); @@ -238,7 +239,7 @@ public class ToolDaoImpl implements ToolDao { sql.append("SELECT site, tool_id toolId, tool_instance_id toolInstance, work_center_no normalWorkCenterNo, c_desc description,"); 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(" c_tool_bias toolBias, c_tool_stability toolStability, c_property_no propertyNo, 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); diff --git a/src/main/java/com/spring/modules/Tooling/data/IfsToolData.java b/src/main/java/com/spring/modules/Tooling/data/IfsToolData.java index ea1a72c2..f1705228 100644 --- a/src/main/java/com/spring/modules/Tooling/data/IfsToolData.java +++ b/src/main/java/com/spring/modules/Tooling/data/IfsToolData.java @@ -24,6 +24,7 @@ public class IfsToolData extends PageData { private String state; private String toolTypeDesc; private String alternateToolDesc; + private String propertyNo; public IfsToolData() { } @@ -196,4 +197,12 @@ public class IfsToolData extends PageData { public void setAlternateToolDesc(String alternateToolDesc) { this.alternateToolDesc = alternateToolDesc; } + + public String getPropertyNo() { + return propertyNo; + } + + public void setPropertyNo(String propertyNo) { + this.propertyNo = propertyNo; + } } diff --git a/src/main/java/com/spring/modules/Tooling/entity/IfsTool.java b/src/main/java/com/spring/modules/Tooling/entity/IfsTool.java index b4373acd..20975ccb 100644 --- a/src/main/java/com/spring/modules/Tooling/entity/IfsTool.java +++ b/src/main/java/com/spring/modules/Tooling/entity/IfsTool.java @@ -23,6 +23,7 @@ public class IfsTool extends PageData { private Date createDate;// private String username; private String state; + private String propertyNo; public IfsTool() { } @@ -170,4 +171,12 @@ public class IfsTool extends PageData { public void setState(String state) { this.state = state; } + + public String getPropertyNo() { + return propertyNo; + } + + public void setPropertyNo(String propertyNo) { + this.propertyNo = propertyNo; + } } 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 index 38c9d1e7..a4075a28 100644 --- a/src/main/java/com/spring/modules/Tooling/service/impl/ToolServiceImpl.java +++ b/src/main/java/com/spring/modules/Tooling/service/impl/ToolServiceImpl.java @@ -9,6 +9,7 @@ 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.entity.PersonnelLevel; import com.spring.modules.base.utils.DateUtils; import com.spring.modules.base.utils.HttpClientUtil; import com.spring.modules.base.utils.ResponseData; @@ -100,6 +101,7 @@ public class ToolServiceImpl implements ToolService { String toolType = inData.getToolType(); String alternativeToolId = inData.getAlternateToolId(); String calendarId = inData.getCalendarId(); + String propertyNo = inData.getPropertyNo(); if(toolId.equals(alternativeToolId)){ throw new RuntimeException("替代工具和当前工具不能相同!"); } @@ -146,7 +148,11 @@ public class ToolServiceImpl implements ToolService { throw new RuntimeException("IFS ToolInstance新增异常:" + toolResponse.getMsg()); } } - //2.调用方法保存当前的数据 + //3.校验是否需要插入属性模版的数据 + if(propertyNo != null && !propertyNo.equals("")){ + this.processToolInfoPropertyTemplate(site, toolId, "", propertyNo, 1); + } + //4.调用方法保存当前的数据 toolDao.insertToolInfo(inData); } @@ -178,9 +184,15 @@ public class ToolServiceImpl implements ToolService { String toolType = inData.getToolType(); String alternativeToolId = inData.getAlternateToolId(); String calendarId = inData.getCalendarId(); + String propertyNo = inData.getPropertyNo(); if(toolId.equals(alternativeToolId)){ throw new RuntimeException("替代工具和当前工具不能相同!"); } + //判断null + if(alternativeToolId == null){ + alternativeToolId = ""; + } + //1.调用存储过程 --校验数据 Map resultMap = this.checkUpdateToolInfo(site, toolId, toolType, calendarId, alternativeToolId); //判断是否检验成功 @@ -209,10 +221,38 @@ public class ToolServiceImpl implements ToolService { inData.setIfsRowId(ifsTool.getIfsRowId()); inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); } - //2.调用方法保存当前的数据 + //查询数据 + IfsToolData checkData = toolDao.getToolInfoByToolId(site, toolId); + String rawPropertyNo = checkData.getPropertyNo(); + //判断是否需要存在 + if(rawPropertyNo == null){ + rawPropertyNo = ""; + } + //3.调用存储过程处理 工具的属性模版数据 + this.processToolInfoPropertyTemplate(site, toolId, rawPropertyNo, propertyNo, 0); + //4.调用方法保存当前的数据 toolDao.updateToolInfo(inData); } + /** + * @description: 调用存储过程处理 工具的属性模版数据 + * @author LR + * @date 2024/9/24 9:11 + * @version 1.0 + */ + public Map processToolInfoPropertyTemplate(String site, String toolId, String rawPropertyNo, String propertyNo, int addFlag) { + List params = new ArrayList<>(); + params.add(site); + params.add(toolId); + params.add(rawPropertyNo); + params.add(propertyNo); + params.add(addFlag); + //调用存储过程 + List> resultList = procedureDao.getProcedureData("processToolInfoPropertyTemplate", params); + //处理返回的结果 + return resultList.get(0); + } + /** * @description: 调用存储过程 校验工具信息的修改 * @author LR @@ -300,6 +340,7 @@ public class ToolServiceImpl implements ToolService { String objectId = inData.getObjectId(); String normalWorkCenterNo = inData.getNormalWorkCenterNo(); String normalProductionLine = inData.getNormalProductionLine(); + String propertyNo = inData.getPropertyNo(); //查询是否存在 IfsToolInstanceData toolInstanceData = toolDao.getToolInstanceByToolInstance(site, toolId, toolInstance); //如果存在 @@ -314,8 +355,8 @@ public class ToolServiceImpl implements ToolService { String resultMsg = String.valueOf(resultMap.get("result_msg")); throw new RuntimeException(resultMsg); } + //2.校验存在调用接口 if (controlFlag) { - //2.校验存在调用接口 toolInstanceData = new IfsToolInstanceDateData(); inData.setCreateDate(new Date()); inData.setState("Active"); @@ -340,10 +381,34 @@ public class ToolServiceImpl implements ToolService { inData.setIfsRowId(ifsTool.getIfsRowId()); inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); } - //2.调用方法保存当前的数据 + //3.校验是否需要插入属性模版的数据 + if(propertyNo != null && !propertyNo.equals("")){ + this.processToolInstancePropertyTemplate(site, toolId, toolInstance, "", propertyNo, 1); + } + //4.调用方法保存当前的数据 toolDao.insertToolInstance(inData); } + /** + * @description: 调用存储过程 处理工具实例的模版属性参数 + * @author LR + * @date 2024/9/24 11:02 + * @version 1.0 + */ + public Map processToolInstancePropertyTemplate(String site, String toolId, String toolInstance, String rawPropertyNo, String propertyNo, int addFlag) { + List params = new ArrayList<>(); + params.add(site); + params.add(toolId); + params.add(toolInstance); + params.add(rawPropertyNo); + params.add(propertyNo); + params.add(addFlag); + //调用存储过程 + List> resultList = procedureDao.getProcedureData("processToolInstancePropertyTemplate", params); + //处理返回的结果 + return resultList.get(0); + } + /** * @description: 调用存储过程 检查插入工具实例 * @author LR @@ -374,6 +439,7 @@ public class ToolServiceImpl implements ToolService { String objectId = inData.getObjectId(); String normalWorkCenterNo = inData.getNormalWorkCenterNo(); String normalProductionLine = inData.getNormalProductionLine(); + String propertyNo = inData.getPropertyNo(); //查询是否存在 IfsToolInstanceData toolInstanceData = toolDao.getToolInstanceByToolInstance(site, toolId, toolInstance); //如果存在 @@ -403,8 +469,8 @@ public class ToolServiceImpl implements ToolService { toolInstanceData.setLastCalibrationDate(lastCalibrationTime); inData.setCreateDate(new Date()); inData.setState("Active"); + //2.校验存在调用接口 if (controlFlag) { - //2.校验存在调用接口 String toolURL = apiUrl + "/tool/ifs/modifyToolInstanceToIfs"; ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, toolInstanceData); if (!"200".equals(toolResponse.getCode())) { @@ -416,7 +482,16 @@ public class ToolServiceImpl implements ToolService { inData.setIfsRowId(ifsTool.getIfsRowId()); inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); } - //2.调用方法保存当前的数据 + //查询数据 + IfsToolInstanceData checkData = toolDao.getToolInstanceByToolInstance(site, toolId, toolInstance); + String rawPropertyNo = checkData.getPropertyNo(); + //判断是否需要存在 + if(rawPropertyNo == null){ + rawPropertyNo = ""; + } + //3.调用存储过程处理 工具的属性模版数据 + this.processToolInstancePropertyTemplate(site, toolId, toolInstance, rawPropertyNo, propertyNo, 0); + //4.调用方法保存当前的数据 toolDao.updateToolInstance(inData); }