Browse Source

工具的功能

master
DouDou 2 years ago
parent
commit
0658e4e777
  1. 18
      src/main/java/com/spring/modules/Tooling/dao/ToolDao.java
  2. 30
      src/main/java/com/spring/modules/Tooling/dao/impl/ToolDaoImpl.java
  3. 18
      src/main/java/com/spring/modules/Tooling/data/IfsToolData.java
  4. 18
      src/main/java/com/spring/modules/Tooling/entity/IfsTool.java
  5. 107
      src/main/java/com/spring/modules/Tooling/service/impl/ToolServiceImpl.java

18
src/main/java/com/spring/modules/Tooling/dao/ToolDao.java

@ -62,7 +62,7 @@ public interface ToolDao {
* @date 2024/8/30 10:30 * @date 2024/8/30 10:30
* @version 1.0 * @version 1.0
*/ */
int insertToolInfo(IfsTool inData);
void insertToolInfo(IfsTool inData);
/** /**
* @description: 修改工具信息 * @description: 修改工具信息
@ -135,4 +135,20 @@ public interface ToolDao {
* @version 1.0 * @version 1.0
*/ */
IfsToolInstanceData getToolInstanceByToolInstance(String site, String toolId, String toolInstance); IfsToolInstanceData getToolInstanceByToolInstance(String site, String toolId, String toolInstance);
/**
* @description: 按照工具信息删除工具实例
* @author LR
* @date 2024/9/3 17:57
* @version 1.0
*/
void deleteToolInstanceByTool(IfsTool inData);
/**
* @description: 按照工具信息删除工具实例的日期
* @author LR
* @date 2024/9/3 17:57
* @version 1.0
*/
void deleteToolInstanceDateByTool(IfsTool inData);
} }

30
src/main/java/com/spring/modules/Tooling/dao/impl/ToolDaoImpl.java

@ -37,7 +37,9 @@ public class ToolDaoImpl implements ToolDao {
Map<String, Object> paramMap = new HashMap<String, Object>(); Map<String, Object> paramMap = new HashMap<String, Object>();
sql.append("SELECT site, tool_id, tool_description toolDesc, c_tool_type toolType, c_calendar_id calendarId, c_sched_capacity schedCapacity,"); 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_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(" dbo.getToolInfoDesc(site, c_alternate_tool_id) alternateToolDesc, dbo.getToolTypeDesc(c_tool_type) toolTypeDesc,");
sql.append(" c_state state,");
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"); sql.append(" FROM tool_header th WHERE 1 = 1");
//判断查询的条件 //判断查询的条件
if(!(null == site || "".equals(site))){ if(!(null == site || "".equals(site))){
@ -135,17 +137,15 @@ public class ToolDaoImpl implements ToolDao {
} }
@Override @Override
public int insertToolInfo(IfsTool inData) {
public void insertToolInfo(IfsTool inData) {
StringBuilder sql = new StringBuilder(); 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("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(" 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(" created_by, c_state, ifs_row_id, ifs_row_version)");
sql.append("VALUES(:site, :toolId, :toolDesc, :toolType, :calendarId, :schedCapacity,"); sql.append("VALUES(:site, :toolId, :toolDesc, :toolType, :calendarId, :schedCapacity,");
sql.append(" :calibrationControl, :calibrationTime, :alternateToolId, :lastUsed, :enabledForControlPlanDb, :noteText, :createDate,"); sql.append(" :calibrationControl, :calibrationTime, :alternateToolId, :lastUsed, :enabledForControlPlanDb, :noteText, :createDate,");
sql.append(" :username)");
parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData), keyHolder);
return keyHolder.getKey().intValue();
sql.append(" :username, :state, :ifsRowId, :ifsRowVersion)");
parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData));
} }
@Override @Override
@ -247,4 +247,20 @@ public class ToolDaoImpl implements ToolDao {
} }
return null; return null;
} }
@Override
public void deleteToolInstanceByTool(IfsTool inData) {
StringBuilder sql = new StringBuilder();
sql.append("DELETE FROM tool_detail");
sql.append(" WHERE site = :site AND tool_id = :toolId");
parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData));
}
@Override
public void deleteToolInstanceDateByTool(IfsTool inData) {
StringBuilder sql = new StringBuilder();
sql.append("DELETE FROM tool_detail_phase_date");
sql.append(" WHERE site = :site AND tool_id = :toolId");
parameterJdbcTemplate.update(sql.toString(), new BeanPropertySqlParameterSource(inData));
}
} }

18
src/main/java/com/spring/modules/Tooling/data/IfsToolData.java

@ -21,6 +21,8 @@ public class IfsToolData extends PageData {
private Date createDate; private Date createDate;
private String username; private String username;
private String state; private String state;
private String toolTypeDesc;
private String alternateToolDesc;
public IfsToolData() { public IfsToolData() {
} }
@ -168,4 +170,20 @@ public class IfsToolData extends PageData {
public void setState(String state) { public void setState(String state) {
this.state = state; this.state = state;
} }
public String getToolTypeDesc() {
return toolTypeDesc;
}
public void setToolTypeDesc(String toolTypeDesc) {
this.toolTypeDesc = toolTypeDesc;
}
public String getAlternateToolDesc() {
return alternateToolDesc;
}
public void setAlternateToolDesc(String alternateToolDesc) {
this.alternateToolDesc = alternateToolDesc;
}
} }

18
src/main/java/com/spring/modules/Tooling/entity/IfsTool.java

@ -21,6 +21,8 @@ public class IfsTool extends PageData {
private String ifsRowId; private String ifsRowId;
private String ifsRowVersion; private String ifsRowVersion;
private Date createDate;// private Date createDate;//
private String username;
private String state;
public IfsTool() { public IfsTool() {
} }
@ -152,4 +154,20 @@ public class IfsTool extends PageData {
public void setCreateDate(Date createDate) { public void setCreateDate(Date createDate) {
this.createDate = 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;
}
} }

107
src/main/java/com/spring/modules/Tooling/service/impl/ToolServiceImpl.java

@ -95,7 +95,9 @@ public class ToolServiceImpl implements ToolService {
//公共参数 //公共参数
String site = inData.getSite(); String site = inData.getSite();
String toolId = inData.getToolId(); String toolId = inData.getToolId();
String toolType = inData.getToolType();
String alternativeToolId = inData.getAlternateToolId(); String alternativeToolId = inData.getAlternateToolId();
String calendarId = inData.getCalendarId();
if(toolId.equals(alternativeToolId)){ if(toolId.equals(alternativeToolId)){
throw new RuntimeException("替代工具和当前工具不能相同!"); throw new RuntimeException("替代工具和当前工具不能相同!");
} }
@ -105,18 +107,27 @@ public class ToolServiceImpl implements ToolService {
if(tool != null){ if(tool != null){
throw new RuntimeException("已存在当前工具信息!"); throw new RuntimeException("已存在当前工具信息!");
} }
IfsToolData alternativeTool = toolDao.getToolInfoByToolId(site, alternativeToolId);
//如果存在
if(alternativeTool == null){
throw new RuntimeException("当前替代工具信息不存在!");
//1.调用存储过程 --校验数据
Map<String, Object> resultMap = this.checkInsertToolInfo(site, toolId, toolType, calendarId, alternativeToolId);
//判断是否检验成功
String resultCode = String.valueOf(resultMap.get("result_code"));
if ("400".equalsIgnoreCase(resultCode)) {
String resultMsg = String.valueOf(resultMap.get("result_msg"));
throw new RuntimeException(resultMsg);
} }
//1.校验存在调用接口
//判断是否存在替代的
String toolURL = apiUrl + "/tool/ifs/syncToolDataToIfs";
//2.校验存在调用接口
/* String toolURL = apiUrl + "/tool/ifs/syncToolDataToIfs";
ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, inData); ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, inData);
if (!"200".equals(toolResponse.getCode())) { if (!"200".equals(toolResponse.getCode())) {
throw new RuntimeException("IFS Tool新增异常:" + toolResponse.getMsg()); 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);
inData.setCreateDate(new Date());
inData.setIfsRowId(ifsTool.getIfsRowId());
inData.setIfsRowVersion(ifsTool.getIfsRowVersion());
//删除工具信息默认的工具实例信息 //删除工具信息默认的工具实例信息
IfsToolInstanceData toolInstance = new IfsToolInstanceData(); IfsToolInstanceData toolInstance = new IfsToolInstanceData();
//属性拷贝 //属性拷贝
@ -126,38 +137,53 @@ public class ToolServiceImpl implements ToolService {
toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, toolInstance); toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, toolInstance);
if (!"200".equals(toolResponse.getCode())) { if (!"200".equals(toolResponse.getCode())) {
throw new RuntimeException("IFS ToolInstance新增异常:" + toolResponse.getMsg()); 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());
}*/
inData.setState("Active");
//2.调用方法保存当前的数据 //2.调用方法保存当前的数据
toolDao.insertToolInfo(inData); toolDao.insertToolInfo(inData);
} }
/**
* @description: 调用存储过程 校验工具新增
* @author LR
* @date 2024/9/3 17:11
* @version 1.0
*/
public Map<String, Object> checkInsertToolInfo(String site, String toolId, String toolType, String calendarId, String alternativeToolId) {
List<Object> params = new ArrayList<>();
params.add(site);
params.add(toolId);
params.add(toolType);
params.add(calendarId);
params.add(alternativeToolId);
//调用存储过程
List<Map<String, Object>> resultList = procedureDao.getProcedureData("checkInsertToolInfo", params);
//处理返回的结果
return resultList.get(0);
}
@Override @Override
@Transactional @Transactional
public void modifyToolInfo(IfsTool inData) { public void modifyToolInfo(IfsTool inData) {
//公共参数 //公共参数
String site = inData.getSite(); String site = inData.getSite();
String toolId = inData.getToolId(); String toolId = inData.getToolId();
String toolType = inData.getToolType();
String alternativeToolId = inData.getAlternateToolId(); String alternativeToolId = inData.getAlternateToolId();
String calendarId = inData.getCalendarId();
if(toolId.equals(alternativeToolId)){ if(toolId.equals(alternativeToolId)){
throw new RuntimeException("替代工具和当前工具不能相同!"); 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.调用存储过程 --校验数据
Map<String, Object> resultMap = this.checkUpdateToolInfo(site, toolId, toolType, calendarId, alternativeToolId);
//判断是否检验成功
String resultCode = String.valueOf(resultMap.get("result_code"));
if ("400".equalsIgnoreCase(resultCode)) {
String resultMsg = String.valueOf(resultMap.get("result_msg"));
throw new RuntimeException(resultMsg);
} }
//1.校验存在调用接口
//判断是否存在替代的
/* //2.校验存在调用接口
String toolURL = apiUrl + "/tool/ifs/modifyToolDataToIfs"; String toolURL = apiUrl + "/tool/ifs/modifyToolDataToIfs";
ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, inData); ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, inData);
if (!"200".equals(toolResponse.getCode())) { if (!"200".equals(toolResponse.getCode())) {
@ -166,10 +192,31 @@ public class ToolServiceImpl implements ToolService {
// 更新 ifs_row_id ifs_row_version // 更新 ifs_row_id ifs_row_version
String objStr = String.valueOf(toolResponse.getObj()); String objStr = String.valueOf(toolResponse.getObj());
IfsToolData ifsTool = JSON.parseObject(objStr, IfsToolData.class); IfsToolData ifsTool = JSON.parseObject(objStr, IfsToolData.class);
inData.setIfsRowId(ifsTool.getIfsRowId());
inData.setIfsRowVersion(ifsTool.getIfsRowVersion());*/
//2.调用方法保存当前的数据 //2.调用方法保存当前的数据
toolDao.updateToolInfo(inData); toolDao.updateToolInfo(inData);
} }
/**
* @description: 调用存储过程 校验工具信息的修改
* @author LR
* @date 2024/9/3 17:41
* @version 1.0
*/
public Map<String, Object> checkUpdateToolInfo(String site, String toolId, String toolType, String calendarId, String alternativeToolId) {
List<Object> params = new ArrayList<>();
params.add(site);
params.add(toolId);
params.add(toolType);
params.add(calendarId);
params.add(alternativeToolId);
//调用存储过程
List<Map<String, Object>> resultList = procedureDao.getProcedureData("checkUpdateToolInfo", params);
//处理返回的结果
return resultList.get(0);
}
@Override @Override
@Transactional @Transactional
public void removeToolInfo(IfsTool inData) { public void removeToolInfo(IfsTool inData) {
@ -183,7 +230,6 @@ public class ToolServiceImpl implements ToolService {
throw new RuntimeException("当前工具信息不存在!"); throw new RuntimeException("当前工具信息不存在!");
} }
//1.调用存储过程判断是否可以删除 //1.调用存储过程判断是否可以删除
//调用存储过程 --向下移动派工单
Map<String, Object> resultMap = this.checkDeleteToolInfo(site, toolId); Map<String, Object> resultMap = this.checkDeleteToolInfo(site, toolId);
//判断是否检验成功 //判断是否检验成功
String resultCode = String.valueOf(resultMap.get("result_code")); String resultCode = String.valueOf(resultMap.get("result_code"));
@ -192,17 +238,16 @@ public class ToolServiceImpl implements ToolService {
throw new RuntimeException(resultMsg); throw new RuntimeException(resultMsg);
} }
//2.校验存在调用接口 //2.校验存在调用接口
//判断是否存在替代的
/*//判断是否存在替代的
String toolURL = apiUrl + "/tool/ifs/removeToolDataToIfs"; String toolURL = apiUrl + "/tool/ifs/removeToolDataToIfs";
ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, inData); ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, inData);
if (!"200".equals(toolResponse.getCode())) { if (!"200".equals(toolResponse.getCode())) {
throw new RuntimeException("IFS Tool删除异常:" + toolResponse.getMsg()); 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.调用方法保存当前的数据
}*/
//3.调用方法保存当前的数据
toolDao.deleteToolInfo(inData); toolDao.deleteToolInfo(inData);
toolDao.deleteToolInstanceByTool(inData);
toolDao.deleteToolInstanceDateByTool(inData);
} }
/** /**

Loading…
Cancel
Save