刀具模块bug修复

master
zpl 4 years ago
parent 5c6ee46dbe
commit 0e7c096137

@ -146,11 +146,11 @@ public class ToolController {
@ResponseBody @ResponseBody
@GetMapping("/getOneToolByToolNo") @GetMapping("/getOneToolByToolNo")
public R getOneToolByToolNo(String tool) { public R getOneToolByToolNo(Tool tool) {
try{ try{
return R.ok(toolService.getOneToolByToolNo(tool)); return R.ok(toolService.getOneToolByToolNo(tool));
}catch (Exception e){ }catch (Exception e){
return R.failed("数据查询失败" + e.getMessage()); return R.failed("数据查询失败" + e.getMessage());
} }
} }

@ -38,7 +38,7 @@ public interface ToolService extends IService<Tool> {
* @param tool * @param tool
* @return * @return
*/ */
Tool getOneToolByToolNo(String tool); Tool getOneToolByToolNo(Tool tool);
/** /**
* *

@ -76,10 +76,15 @@ public class ToolServiceImpl extends ServiceImpl<ToolMapper, Tool> implements To
} }
@Override @Override
public Tool getOneToolByToolNo(String tool) { public Tool getOneToolByToolNo(Tool tool) {
String site = CommonMethods.getSite(); String site = CommonMethods.getSite();
String handle = HandleEnum.TOOL.getHandle(site, tool); String handle = HandleEnum.TOOL.getHandle(site, tool.getTool());
return toolMapper.selectById(handle); tool.setHandle(handle);
List<Tool> tools = toolService.selectList(tool);
if (tools.size() == 1){
return tools.get(0);
}
throw BusinessException.build("查询失败!");
} }
@Override @Override
@ -100,7 +105,6 @@ public class ToolServiceImpl extends ServiceImpl<ToolMapper, Tool> implements To
@Override @Override
public String saveOrUpdateToolByImport(JSONObject json, String sqlType) { public String saveOrUpdateToolByImport(JSONObject json, String sqlType) {
String user = CommonMethods.getUser(); String user = CommonMethods.getUser();
Tool target = new Tool();
String site = json.getString("site").trim(); String site = json.getString("site").trim();
String tool = json.getString("tool").trim(); String tool = json.getString("tool").trim();
String handle = HandleEnum.TOOL.getHandle(site, tool).trim(); String handle = HandleEnum.TOOL.getHandle(site, tool).trim();
@ -108,9 +112,13 @@ public class ToolServiceImpl extends ServiceImpl<ToolMapper, Tool> implements To
String specification = json.getString("specification").trim(); String specification = json.getString("specification").trim();
String brand = json.getString("brand").trim(); String brand = json.getString("brand").trim();
String remark = json.getString("remark").trim(); String remark = json.getString("remark").trim();
if (tool==null || tool != ""){ if (tool == null || tool.equals("")){
return "刀具编号不能为空"; return "刀具编号不能为空";
//throw BusinessException.build("刀具编号不能为空!");
} }
Tool target = new Tool();
target.setStatus(Constants.TOOL_STATUS_Y);
target.setSite(site);
switch (sqlType){ switch (sqlType){
case "insert": case "insert":
target.setTool(tool); target.setTool(tool);
@ -121,10 +129,11 @@ public class ToolServiceImpl extends ServiceImpl<ToolMapper, Tool> implements To
target.setCreateUser(user); target.setCreateUser(user);
target.setCreatedDateTime(LocalDateTime.now()); target.setCreatedDateTime(LocalDateTime.now());
toolMapper.insert(target); toolMapper.insert(target);
break; return "新增一条数据成功";
case "update": case "update":
Tool byId = toolMapper.selectById(handle); Tool byId = toolMapper.selectById(handle);
if (byId == null){ if (byId == null){
//throw BusinessException.build("更新失败,刀具编号不存在!");
return "更新失败,刀具编号不存在!"; return "更新失败,刀具编号不存在!";
} }
if (description != ""){ if (description != ""){
@ -140,40 +149,39 @@ public class ToolServiceImpl extends ServiceImpl<ToolMapper, Tool> implements To
byId.setRemark(remark); byId.setRemark(remark);
} }
toolMapper.updateById(byId); toolMapper.updateById(byId);
break; return "更新一条数据成功";
case "both": case "both":
Tool selId = toolMapper.selectById(handle); Tool selId = toolMapper.selectById(handle);
if (selId != null){ if (selId == null){
if (description != ""){ target.setTool(tool);
selId.setDescription(description); target.setHandle(handle);
} target.setDescription(description);
if (specification != ""){ target.setSpecification(specification);
selId.setSpecification(specification); target.setBrand(brand);
} target.setCreateUser(user);
if (brand != ""){ target.setCreatedDateTime(LocalDateTime.now());
selId.setBrand(brand); toolMapper.insert(target);
} return "新增一条数据成功";
if (remark != ""){
selId.setRemark(remark);
}
selId.setModifyUser(user);
selId.setModifiedDateTime(LocalDateTime.now());
toolMapper.updateById(selId);
break;
} }
target.setTool(tool); if (description != ""){
target.setHandle(handle); selId.setDescription(description);
target.setDescription(description); }
target.setSpecification(specification); if (specification != ""){
target.setBrand(brand); selId.setSpecification(specification);
target.setCreateUser(user); }
target.setCreatedDateTime(LocalDateTime.now()); if (brand != ""){
toolMapper.insert(target); selId.setBrand(brand);
break; }
if (remark != ""){
selId.setRemark(remark);
}
selId.setModifyUser(user);
selId.setModifiedDateTime(LocalDateTime.now());
toolMapper.updateById(selId);
return "更新一条数据成功";
default: default:
return "更新/导入类型未找到!"; throw BusinessException.build("更新/导入类型未找到!");
} }
return "导入成功";
} }

@ -34,10 +34,10 @@ public class ToolHandler extends BaseHandler {
buffer.append(e.getMessage() + "\n"); buffer.append(e.getMessage() + "\n");
} }
if (buffer.length() > 0) { /*if (buffer.length() > 0) {
buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n"); buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n");
throw BusinessException.build(buffer.toString()); throw BusinessException.build(buffer.toString());
} }*/
buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n"); buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n");
return buffer.toString(); return buffer.toString();
@ -61,7 +61,12 @@ public class ToolHandler extends BaseHandler {
jsonObject.put("site", site); jsonObject.put("site", site);
try { try {
String msg = toolService.saveOrUpdateToolByImport(jsonObject, mode); String msg = toolService.saveOrUpdateToolByImport(jsonObject, mode);
buffer.append("第" + index + "行:" + msg + "\n"); if (msg.indexOf("成功") == -1){
buffer.append("第" + index + "行【失败】:" + msg + "\n");
failedNumber[0]++;
return 0;
}
buffer.append("第" + index + "行【成功】:" + msg + "\n");
return 1; return 1;
} catch (Exception e) { } catch (Exception e) {
params[2] = e.getMessage(); params[2] = e.getMessage();

Loading…
Cancel
Save