刀具模块bug修复

master
zpl 4 years ago
parent 5c6ee46dbe
commit 0e7c096137

@ -146,11 +146,11 @@ public class ToolController {
@ResponseBody
@GetMapping("/getOneToolByToolNo")
public R getOneToolByToolNo(String tool) {
public R getOneToolByToolNo(Tool tool) {
try{
return R.ok(toolService.getOneToolByToolNo(tool));
}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
* @return
*/
Tool getOneToolByToolNo(String tool);
Tool getOneToolByToolNo(Tool tool);
/**
*

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

@ -34,10 +34,10 @@ public class ToolHandler extends BaseHandler {
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");
throw BusinessException.build(buffer.toString());
}
}*/
buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n");
return buffer.toString();
@ -61,7 +61,12 @@ public class ToolHandler extends BaseHandler {
jsonObject.put("site", site);
try {
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;
} catch (Exception e) {
params[2] = e.getMessage();

Loading…
Cancel
Save