diff --git a/src/main/java/com/spring/modules/Tooling/controller/ToolController.java b/src/main/java/com/spring/modules/Tooling/controller/ToolController.java index 3cabda01..4413478c 100644 --- a/src/main/java/com/spring/modules/Tooling/controller/ToolController.java +++ b/src/main/java/com/spring/modules/Tooling/controller/ToolController.java @@ -1,6 +1,5 @@ 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; 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 1e723fc4..718509f6 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, c_property_no propertyNo,"); + sql.append(" c_state state, c_property_no propertyNo, created_by, create_date, updated_by, updated_date,"); 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,7 +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_property_no propertyNo, created_by, created_date, updated_by, updated_date,"); 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"); @@ -106,7 +106,7 @@ public class ToolDaoImpl implements ToolDao { 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("SELECT id, site, tool_id, tool_instance, begin_date, end_date, created_by, created_date, updated_by, updated_date,"); sql.append(" ifs_row_id, ifs_row_version FROM tool_detail_phase_date thd"); sql.append(" WHERE thd.site = :site AND thd.tool_id = :toolId AND thd.tool_instance = :toolInstance"); paramMap.put("site", site); @@ -144,11 +144,11 @@ public class ToolDaoImpl implements ToolDao { public void insertToolInfo(IfsTool inData) { 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, c_property_no, ifs_row_id, ifs_row_version)"); + sql.append(" c_calibration_control, c_calibration_time, c_alternate_tool_id, c_last_used, c_enabled_for_control_plan_db, c_note_text,"); + sql.append(" created_by, create_date, 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, :propertyNo, :ifsRowId, :ifsRowVersion)"); + sql.append(" :calibrationControl, :calibrationTime, :alternateToolId, :lastUsed, :enabledForControlPlanDb, :noteText,"); + sql.append(" :username, :createDate, :state, :propertyNo, :ifsRowId, :ifsRowVersion)"); parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData)); } @@ -157,6 +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(" updated_by = :username, updated_date = :updatedDate,"); 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"); @@ -176,9 +177,11 @@ 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(" created_by, created_date,"); 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(" :username, :createdDate,"); sql.append(" :toolReproducibility, :nextCalibrationDate, :state, :propertyNo, :ifsRowId, :ifsRowVersion)"); parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData)); } @@ -190,6 +193,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(" updated_by = :username, updated_date = :updatedDate,"); 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"); @@ -209,8 +213,10 @@ public class ToolDaoImpl implements ToolDao { 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(" created_by, created_date,"); sql.append(" ifs_row_version)"); sql.append(" VALUES(:site, :toolId, :toolInstance, :beginDate, :endDate, :ifsRowId,"); + sql.append(" :username, :createdDate,"); sql.append(" :ifsRowVersion)"); parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData), keyHolder); return keyHolder.getKey().intValue(); @@ -219,7 +225,8 @@ public class ToolDaoImpl implements ToolDao { @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("UPDATE tool_detail_phase_date SET end_date = :endDate, ifs_row_id = :ifsRowId, ifs_row_version = :ifsRowVersion,"); + sql.append(" updated_by = :username, updated_date = :updatedDate"); sql.append(" WHERE id = :id"); return parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(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 index 7983260c..df210cf4 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 @@ -120,6 +120,13 @@ public class ToolServiceImpl implements ToolService { } inData.setState("Active"); inData.setCreateDate(new Date()); + //3.校验是否需要插入属性模版的数据 + if(propertyNo != null && !propertyNo.equals("")){ + this.processToolInfoPropertyTemplate(site, toolId, "", propertyNo, 1); + } + //4.调用方法保存当前的数据 + toolDao.insertToolInfo(inData); + //对象拷贝 IfsToolData ifsToolData = new IfsToolData(); //属性拷贝 @@ -147,12 +154,6 @@ public class ToolServiceImpl implements ToolService { throw new RuntimeException("IFS ToolInstance新增异常:" + toolResponse.getMsg()); } } - //3.校验是否需要插入属性模版的数据 - if(propertyNo != null && !propertyNo.equals("")){ - this.processToolInfoPropertyTemplate(site, toolId, "", propertyNo, 1); - } - //4.调用方法保存当前的数据 - toolDao.insertToolInfo(inData); } /** @@ -187,11 +188,15 @@ public class ToolServiceImpl implements ToolService { if(toolId.equals(alternativeToolId)){ throw new RuntimeException("替代工具和当前工具不能相同!"); } + //判断null if(alternativeToolId == null){ alternativeToolId = ""; } + if(propertyNo == null){ + propertyNo = ""; + } //1.调用存储过程 --校验数据 Map resultMap = this.checkUpdateToolInfo(site, toolId, toolType, calendarId, alternativeToolId); //判断是否检验成功 @@ -201,7 +206,7 @@ public class ToolServiceImpl implements ToolService { throw new RuntimeException(resultMsg); } inData.setState("Active"); - inData.setCreateDate(new Date()); + inData.setUpdatedDate(new Date()); //对象拷贝 IfsToolData ifsToolData = new IfsToolData(); //属性拷贝 @@ -354,6 +359,14 @@ public class ToolServiceImpl implements ToolService { String resultMsg = String.valueOf(resultMap.get("result_msg")); throw new RuntimeException(resultMsg); } + //3.校验是否需要插入属性模版的数据 + if(propertyNo != null && !propertyNo.equals("")){ + this.processToolInstancePropertyTemplate(site, toolId, toolInstance, "", propertyNo, 1); + } + //设置时间 + inData.setCreatedDate(new Date()); + //4.调用方法保存当前的数据 + toolDao.insertToolInstance(inData); //2.校验存在调用接口 if (controlFlag) { toolInstanceData = new IfsToolInstanceDateData(); @@ -380,12 +393,6 @@ public class ToolServiceImpl implements ToolService { inData.setIfsRowId(ifsTool.getIfsRowId()); inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); } - //3.校验是否需要插入属性模版的数据 - if(propertyNo != null && !propertyNo.equals("")){ - this.processToolInstancePropertyTemplate(site, toolId, toolInstance, "", propertyNo, 1); - } - //4.调用方法保存当前的数据 - toolDao.insertToolInstance(inData); } /** @@ -466,7 +473,7 @@ public class ToolServiceImpl implements ToolService { inData.setNextCalibrationDate(lastCalibrationDate); } toolInstanceData.setLastCalibrationDate(lastCalibrationTime); - inData.setCreateDate(new Date()); + inData.setUpdatedDate(new Date()); inData.setState("Active"); //2.校验存在调用接口 if (controlFlag) { @@ -581,6 +588,9 @@ public class ToolServiceImpl implements ToolService { //设置时间的信息 instanceDateData.setBeginDate(beginTime); instanceDateData.setEndDate(endTime); + //保存新增的数据 + inData.setCreatedDate(new Date()); + toolDao.insertToolInstanceDate(inData); if (controlFlag) { //2.校验存在调用接口 String toolURL = apiUrl + "/tool/ifs/syncToolInstanceDateToIfs"; @@ -594,8 +604,6 @@ public class ToolServiceImpl implements ToolService { inData.setIfsRowId(ifsTool.getIfsRowId()); inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); } - //保存新增的数据 - toolDao.insertToolInstanceDate(inData); } /** @@ -652,6 +660,7 @@ public class ToolServiceImpl implements ToolService { //设置时间的信息 instanceDateData.setBeginDate(beginTime); instanceDateData.setEndDate(endTime); + inData.setUpdatedDate(new Date()); if (controlFlag) { //2.校验存在调用接口 String toolURL = apiUrl + "/tool/ifs/modifyToolInstanceDateToIfs";