|
|
|
@ -85,7 +85,64 @@ public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
return ResultUtils.fail("数据库执行出错,请重试");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//修改
|
|
|
|
|
return ResultUtils.fail("emp_id不能和已有的重复");
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
ResultUtils.fail("请提供完整的xml");
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return ResultUtils.fail();
|
|
|
|
|
}
|
|
|
|
|
return ResultUtils.success().asXML();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String updateAndSub(String tbasic) {
|
|
|
|
|
XmlUtils xmlUtils;
|
|
|
|
|
try {
|
|
|
|
|
//解析xml
|
|
|
|
|
xmlUtils = new XmlUtils(new ByteArrayInputStream(tbasic.getBytes("UTF-8")));
|
|
|
|
|
//解析json映射文件
|
|
|
|
|
String json = JsonUtils.readJsonFile(Codes.JSON_ADDRESS.getMessage());
|
|
|
|
|
Map jsonMap = JSON.parseObject(json, Map.class);
|
|
|
|
|
HashMap<String, Object> tBasicMap = new HashMap<>();
|
|
|
|
|
HashMap<String, Object> tBasicSubMap = new HashMap<>();
|
|
|
|
|
List<SelectColumn> selectColumns = JSON.parseArray(String.valueOf(jsonMap.get(Codes.SELECT_COLUMNS.getMessage())), SelectColumn.class);
|
|
|
|
|
String value;
|
|
|
|
|
for (SelectColumn selectColumn : selectColumns) {
|
|
|
|
|
try {
|
|
|
|
|
value = xmlUtils.getElementText(selectColumn.getQualityColumn()) == null ? null : String.valueOf(xmlUtils.getElementText(selectColumn.getQualityColumn()));
|
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
|
String message = e.getMessage();
|
|
|
|
|
return ResultUtils.fail(message);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(value)) {
|
|
|
|
|
if (selectColumn.getByNull() == 0) {
|
|
|
|
|
return ResultUtils.fail(selectColumn.getQualityColumn() + " 字段不能为空值");
|
|
|
|
|
} else {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (selectColumn.getTableName().equals("t_basic")) {
|
|
|
|
|
tBasicMap.put(selectColumn.getColumnName(), value);
|
|
|
|
|
}
|
|
|
|
|
if (selectColumn.getTableName().equals("t_basic_sub")) {
|
|
|
|
|
tBasicSubMap.put(selectColumn.getColumnName(), value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//处理业务
|
|
|
|
|
TBasic tBasic;
|
|
|
|
|
TBasicSub tBasicSub;
|
|
|
|
|
int insert;
|
|
|
|
|
if (tBasicMap != null && tBasicMap.size() > 0) {
|
|
|
|
|
tBasic = JSON.parseObject(JSON.toJSONString(tBasicMap), TBasic.class);
|
|
|
|
|
if(StringUtils.isNotBlank(tBasic.getEmpId())){
|
|
|
|
|
return ResultUtils.fail("emp_id字段不能为空值");
|
|
|
|
|
}
|
|
|
|
|
TBasic selectTBasic = tBasicMapper.selectOne(new QueryWrapper<TBasic>().eq("emp_id", tBasic.getEmpId()));
|
|
|
|
|
if(selectTBasic!=null){
|
|
|
|
|
insert = tBasicMapper.update(tBasic, new QueryWrapper<TBasic>().eq("emp_id", tBasic.getEmpId()));
|
|
|
|
|
if (insert <= 0) {
|
|
|
|
|
return ResultUtils.fail("数据库执行出错,请重试");
|
|
|
|
@ -99,12 +156,16 @@ public class TBasicWebService implements ITBasicWebService {
|
|
|
|
|
return ResultUtils.fail("数据库执行出错,请重试");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
ResultUtils.fail("修改时,需提供有效的emp_id");
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
ResultUtils.fail("请提供完整的xml");
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return ResultUtils.fail();
|
|
|
|
|
}
|
|
|
|
|
return ResultUtils.success().asXML();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|