|
@@ -47,43 +47,42 @@ public class ModelController {
|
|
|
private FilterResultService parseResultService;
|
|
|
|
|
|
|
|
|
- private JsonFile jsonFile=new JsonFile();
|
|
|
+ private JsonFile jsonFile = new JsonFile();
|
|
|
|
|
|
//给模型复核员提供模型复核
|
|
|
@GetMapping("listUser")
|
|
|
- public Result listUser(SysUser sysUser)
|
|
|
- {
|
|
|
+ public Result listUser(SysUser sysUser) {
|
|
|
QueryWrapper<SysUser> w = new QueryWrapper<>();
|
|
|
- w.eq("role_id",4);
|
|
|
- List<SysUser> list=sysUserService.list(w);
|
|
|
- List<JSONObject> user_list =new ArrayList<>();
|
|
|
- for(int i=0;i<list.size();i++)
|
|
|
- {
|
|
|
- String user_name=list.get(i).getUserName();
|
|
|
- JSONObject user_json=new JSONObject();
|
|
|
- List<UserModel> model_list=userModelService.findByUserName(user_name);
|
|
|
- UserField userField=userFieldService.findByUserName(user_name);
|
|
|
-
|
|
|
- user_json.put("userName",user_name);
|
|
|
- user_json.put("modelList",model_list);
|
|
|
- user_json.put("userField",userField);
|
|
|
+ w.eq("role_id", 4);
|
|
|
+ List<SysUser> list = sysUserService.list(w);
|
|
|
+ List<JSONObject> user_list = new ArrayList<>();
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ String user_name = list.get(i).getUserName();
|
|
|
+ JSONObject user_json = new JSONObject();
|
|
|
+ List<ModelEntity> model_Entity_list = userModelService.findByUserName(user_name);
|
|
|
+ UserField userField = userFieldService.findByUserName(user_name);
|
|
|
+
|
|
|
+ user_json.put("userName", user_name);
|
|
|
+ user_json.put("modelList", model_Entity_list);
|
|
|
+ user_json.put("userField", userField);
|
|
|
user_list.add(user_json);
|
|
|
}
|
|
|
- return Result.success("ok",user_list);
|
|
|
+ return Result.success("ok", user_list);
|
|
|
}
|
|
|
|
|
|
|
|
|
@GetMapping("getApproval")
|
|
|
- public Result getApproval()
|
|
|
- {
|
|
|
- JSONObject resJson=new JSONObject();
|
|
|
- List<UserApproval> approval_list=userApprovalService.list();
|
|
|
- resJson.put("approval_list",approval_list);
|
|
|
- return Result.success("ok",resJson);
|
|
|
+ public Result getApproval() {
|
|
|
+ JSONObject resJson = new JSONObject();
|
|
|
+ List<UserApproval> approval_list = userApprovalService.list();
|
|
|
+ resJson.put("approval_list", approval_list);
|
|
|
+ return Result.success("ok", resJson);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 读取json文件,返回json串
|
|
|
+ *
|
|
|
* @param fileName
|
|
|
* @return
|
|
|
*/
|
|
@@ -96,7 +95,7 @@ public class ModelController {
|
|
|
Reader reader = new InputStreamReader(new FileInputStream(jsonFile), "utf-8");
|
|
|
int ch = 0;
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
- while ((ch = reader.read()) != -1) {
|
|
|
+ while((ch = reader.read()) != -1) {
|
|
|
sb.append((char) ch);
|
|
|
}
|
|
|
|
|
@@ -109,16 +108,17 @@ public class ModelController {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
private static String getType(Object a) {
|
|
|
return a.getClass().toString();
|
|
|
}
|
|
|
|
|
|
//上传字段组合
|
|
|
@PostMapping("addField")
|
|
|
- public Result addField(@RequestBody String json,SysUser sysUser) throws IOException {
|
|
|
+ public Result addField(@RequestBody String json, SysUser sysUser) throws IOException {
|
|
|
JSONObject req = JSON.parseObject(json);
|
|
|
|
|
|
- String field_combine=req.getString("fieldcombine");
|
|
|
+ String field_combine = req.getString("fieldcombine");
|
|
|
|
|
|
//添加异常判断,重名模型名?,yuan尚未实现,先忽略掉
|
|
|
// JSONObject resJson = new JSONObject();
|
|
@@ -130,8 +130,8 @@ public class ModelController {
|
|
|
// resJson.put("state", 1);
|
|
|
|
|
|
// 此为自定义字段组合所需数据
|
|
|
- String userName=req.getString("username");
|
|
|
- String fieldData=req.getString("fielddata");
|
|
|
+ String userName = req.getString("username");
|
|
|
+ String fieldData = req.getString("fielddata");
|
|
|
// String fieldCombine = req.getString("fieldcombine");
|
|
|
String fieldRemark = req.getString("remark");
|
|
|
// customizedModel.setModelName(modelName);
|
|
@@ -208,7 +208,7 @@ public class ModelController {
|
|
|
// userFieldService.updateById(userField);
|
|
|
// }
|
|
|
//yuan
|
|
|
- UserApproval approval=new UserApproval();
|
|
|
+ UserApproval approval = new UserApproval();
|
|
|
approval.setUserName(sysUser.getUserName());
|
|
|
approval.setApprovalId((long) 2);
|
|
|
approval.setData(field_combine);
|
|
@@ -222,20 +222,21 @@ public class ModelController {
|
|
|
//yuan 前端获取user_field表的信息,但是在获取id时,会进行四舍五入操作导致id错误,因此通过字段组合名更新
|
|
|
@GetMapping("fieldCombineList")
|
|
|
public Result fieldCombineList() {
|
|
|
- JSONObject resJson=new JSONObject();
|
|
|
- List<UserField> list=userFieldService.list();
|
|
|
- resJson.put("field_combine_list",list);
|
|
|
- return Result.success("ok",resJson);
|
|
|
+ JSONObject resJson = new JSONObject();
|
|
|
+ List<UserField> list = userFieldService.list();
|
|
|
+ resJson.put("field_combine_list", list);
|
|
|
+ return Result.success("ok", resJson);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
// sxr
|
|
|
@PostMapping("updateFieldCombineList")
|
|
|
- public Result updateFieldCombineList(@RequestBody String json,SysUser sysUser) {
|
|
|
+ public Result updateFieldCombineList(@RequestBody String json, SysUser sysUser) {
|
|
|
JSONObject req = JSON.parseObject(json);
|
|
|
|
|
|
- long fieldId=Long.valueOf(req.getString("fieldId")) ;
|
|
|
- String fieldCombine=req.getString("fieldCombine");
|
|
|
- String choseData=req.getString("choseData");
|
|
|
+ long fieldId = Long.valueOf(req.getString("fieldId"));
|
|
|
+ String fieldCombine = req.getString("fieldCombine");
|
|
|
+ String choseData = req.getString("choseData");
|
|
|
|
|
|
UserField userField = userFieldService.findByID(fieldId);
|
|
|
userField.setFieldCombine(fieldCombine);
|
|
@@ -249,7 +250,7 @@ public class ModelController {
|
|
|
// sxr
|
|
|
@GetMapping("getFieldById")
|
|
|
public Result getFieldById(Long fieldId) {
|
|
|
- System.out.println( fieldId);
|
|
|
+ System.out.println(fieldId);
|
|
|
JSONObject result = new JSONObject();
|
|
|
UserField userField = userFieldService.findByID(fieldId);
|
|
|
|
|
@@ -258,30 +259,31 @@ public class ModelController {
|
|
|
|
|
|
JSONObject fieldDateJson = new JSONObject();
|
|
|
String fieldData = userField.getFieldData();
|
|
|
- fieldData = fieldData.substring(1,fieldData.length()-1);
|
|
|
+ fieldData = fieldData.substring(1, fieldData.length() - 1);
|
|
|
String[] temp = fieldData.split("]");
|
|
|
- for(int i=0;i< temp.length;i++)
|
|
|
- {
|
|
|
+ for (int i = 0; i < temp.length; i++) {
|
|
|
System.out.println(temp[i]);
|
|
|
- String key="";
|
|
|
- if(i==0){ key = temp[i].split(":")[0].substring(1, temp[i].split(":")[0].length()-1);}
|
|
|
- else{ key = temp[i].split(":")[0].substring(2, temp[i].split(":")[0].length()-1);}
|
|
|
+ String key = "";
|
|
|
+ if (i == 0) {
|
|
|
+ key = temp[i].split(":")[0].substring(1, temp[i].split(":")[0].length() - 1);
|
|
|
+ } else {
|
|
|
+ key = temp[i].split(":")[0].substring(2, temp[i].split(":")[0].length() - 1);
|
|
|
+ }
|
|
|
String valuetmp[] = (temp[i].split(":")[1].substring(1).split(","));
|
|
|
String value[] = {};
|
|
|
- for(int j=0;j<valuetmp.length;j++)
|
|
|
- {
|
|
|
+ for (int j = 0; j < valuetmp.length; j++) {
|
|
|
|
|
|
- System.out.println( valuetmp[j]);
|
|
|
+ System.out.println(valuetmp[j]);
|
|
|
System.out.println(valuetmp[j].length());
|
|
|
|
|
|
- valuetmp[j] = valuetmp[j].substring(1,valuetmp[j].length()-1);
|
|
|
+ valuetmp[j] = valuetmp[j].substring(1, valuetmp[j].length() - 1);
|
|
|
}
|
|
|
|
|
|
fieldDateJson.put(key, valuetmp);
|
|
|
|
|
|
}
|
|
|
System.out.println(fieldDateJson);
|
|
|
- result.put("fieldData",fieldDateJson);
|
|
|
+ result.put("fieldData", fieldDateJson);
|
|
|
// System.out.println(userField.getFieldData());
|
|
|
return Result.success("ok", result);
|
|
|
}
|
|
@@ -362,155 +364,146 @@ public class ModelController {
|
|
|
// }
|
|
|
|
|
|
@GetMapping("getField")
|
|
|
- public Result getField(SysUser sysUser)
|
|
|
- {
|
|
|
+ public Result getField(SysUser sysUser) {
|
|
|
JSONObject resJson = new JSONObject();
|
|
|
- String userName=sysUser.getUserName();
|
|
|
- UserField userField=userFieldService.findByUserName(userName);
|
|
|
- if(userField==null)
|
|
|
- {
|
|
|
- resJson.put("fieldData","暂无申请字段");
|
|
|
- resJson.put("fieldState","未配置字段");
|
|
|
+ String userName = sysUser.getUserName();
|
|
|
+ UserField userField = userFieldService.findByUserName(userName);
|
|
|
+ if (userField == null) {
|
|
|
+ resJson.put("fieldData", "暂无申请字段");
|
|
|
+ resJson.put("fieldState", "未配置字段");
|
|
|
+ } else {
|
|
|
+ resJson.put("fieldData", userField.getFieldData());
|
|
|
+ resJson.put("fieldState", userField.getFieldState());
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- resJson.put("fieldData",userField.getFieldData());
|
|
|
- resJson.put("fieldState",userField.getFieldState());
|
|
|
- }
|
|
|
- return Result.success("ok",resJson);
|
|
|
+ return Result.success("ok", resJson);
|
|
|
}
|
|
|
|
|
|
@PostMapping("getFieldByName")
|
|
|
- public Result getFieldByName(@RequestBody String json)
|
|
|
- {
|
|
|
- JSONObject req=JSON.parseObject(json);
|
|
|
+ public Result getFieldByName(@RequestBody String json) {
|
|
|
+ JSONObject req = JSON.parseObject(json);
|
|
|
JSONObject resJson = new JSONObject();
|
|
|
- String userName= req.getString("username");
|
|
|
- UserField userField=userFieldService.findByUserName(userName);
|
|
|
- if(userField==null)
|
|
|
- {
|
|
|
- resJson.put("fieldData","暂无申请字段");
|
|
|
- resJson.put("fieldState","未配置字段");
|
|
|
+ String userName = req.getString("username");
|
|
|
+ UserField userField = userFieldService.findByUserName(userName);
|
|
|
+ if (userField == null) {
|
|
|
+ resJson.put("fieldData", "暂无申请字段");
|
|
|
+ resJson.put("fieldState", "未配置字段");
|
|
|
+ } else {
|
|
|
+ resJson.put("fieldData", userField.getFieldData());
|
|
|
+ resJson.put("fieldState", userField.getFieldState());
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- resJson.put("fieldData",userField.getFieldData());
|
|
|
- resJson.put("fieldState",userField.getFieldState());
|
|
|
- }
|
|
|
- return Result.success("ok",resJson);
|
|
|
+ return Result.success("ok", resJson);
|
|
|
}
|
|
|
|
|
|
|
|
|
//新增自定义模型
|
|
|
@PostMapping("addModel")
|
|
|
- public Result addModel(@RequestBody String json,SysUser sysUser) throws IOException {
|
|
|
+ public Result addModel(@RequestBody String json, SysUser sysUser) throws IOException {
|
|
|
//获取用户模型,并按json文件保存
|
|
|
JSONObject req = JSON.parseObject(json);
|
|
|
- String model_name=req.getString("modelname");
|
|
|
+ String model_name = req.getString("modelname");
|
|
|
JSONObject resJson = new JSONObject();
|
|
|
//添加异常判断,重名模型名?
|
|
|
- if(userModelService.findByUserAndModel(sysUser.getUserName(),model_name)!=null) {
|
|
|
+ if (userModelService.findByUserAndModel(sysUser.getUserName(), model_name) != null) {
|
|
|
resJson.put("state", 0);
|
|
|
- return Result.success("ok",resJson);
|
|
|
+ return Result.success("ok", resJson);
|
|
|
}
|
|
|
//非重名
|
|
|
resJson.put("state", 1);
|
|
|
|
|
|
- String model_data=req.getString("modeldata");
|
|
|
- JSONObject model_json=JSON.parseObject(model_data);
|
|
|
+ String model_data = req.getString("modeldata");
|
|
|
+ JSONObject model_json = JSON.parseObject(model_data);
|
|
|
|
|
|
// String select_data = model_json.getJSONArray("select_data").toString();
|
|
|
|
|
|
- String file_name=sysUser.getUserName()+"_"+model_name;
|
|
|
- jsonFile.writerFile(model_json,file_name);
|
|
|
+ String file_name = sysUser.getUserName() + "_" + model_name;
|
|
|
+ jsonFile.writerFile(model_json, file_name);
|
|
|
|
|
|
// 这个地方应该先加到审批页面上
|
|
|
- UserApproval approval=new UserApproval();
|
|
|
+ UserApproval approval = new UserApproval();
|
|
|
approval.setUserName(sysUser.getUserName());
|
|
|
approval.setApprovalId((long) 1);
|
|
|
approval.setData(model_name);
|
|
|
userApprovalService.save(approval);
|
|
|
//写入数据库
|
|
|
- String userName=sysUser.getUserName();
|
|
|
- UserModel new_model=new UserModel();
|
|
|
- new_model.setCreateBy(userName);
|
|
|
- new_model.setModelName(model_name);
|
|
|
- new_model.setModelType(0);
|
|
|
- new_model.setStatus("审批中");
|
|
|
+ String userName = sysUser.getUserName();
|
|
|
+ ModelEntity new_modelEntity = new ModelEntity();
|
|
|
+ new_modelEntity.setCreateBy(sysUser.getId());
|
|
|
+ new_modelEntity.setModelName(model_name);
|
|
|
+ new_modelEntity.setModelType(0);
|
|
|
+ new_modelEntity.setStatus("审批中");
|
|
|
// new_model.setFieldCombine("暂未指定");
|
|
|
- new_model.setModelRule(model_data);
|
|
|
- userModelService.save(new_model);
|
|
|
+ new_modelEntity.setModelRule(model_data);
|
|
|
+ userModelService.save(new_modelEntity);
|
|
|
|
|
|
|
|
|
- return Result.success("ok",resJson);
|
|
|
+ return Result.success("ok", resJson);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
//列举usermodel
|
|
|
@GetMapping("getUserModel")
|
|
|
- public Result getUserModel(SysUser sysUser)
|
|
|
- {
|
|
|
- JSONObject resJson=new JSONObject();
|
|
|
- List<UserModel> model_list=userModelService.findByUserName(sysUser.getUserName());
|
|
|
+ public Result getUserModel(SysUser sysUser) {
|
|
|
+ JSONObject resJson = new JSONObject();
|
|
|
+ List<ModelEntity> model_Entity_list = userModelService.findByUserName(sysUser.getUserName());
|
|
|
// System.out.println(model_list.get(0).getId());
|
|
|
- resJson.put("modelData", model_list);
|
|
|
+ resJson.put("modelData", model_Entity_list);
|
|
|
|
|
|
- return Result.success("ok",resJson);
|
|
|
+ return Result.success("ok", resJson);
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
// 获取当前模型
|
|
|
@PostMapping("getModelByName")
|
|
|
- public Result getModelByName(@RequestBody String json,SysUser sysUser)
|
|
|
- {
|
|
|
+ public Result getModelByName(@RequestBody String json, SysUser sysUser) {
|
|
|
|
|
|
- JSONObject resJson=new JSONObject();
|
|
|
+ JSONObject resJson = new JSONObject();
|
|
|
|
|
|
JSONObject req = JSON.parseObject(json);
|
|
|
//user_name+model_name就是文件名
|
|
|
- String model_name=req.getString("modelName");
|
|
|
- String user_name=sysUser.getUserName();
|
|
|
+ String model_name = req.getString("modelName");
|
|
|
+ String user_name = sysUser.getUserName();
|
|
|
//读取对应文件
|
|
|
- JSONObject model=jsonFile.ReadJson(user_name+"_"+model_name);
|
|
|
+ JSONObject model = jsonFile.ReadJson(user_name + "_" + model_name);
|
|
|
System.out.println(model);
|
|
|
|
|
|
// resJson.put("model", model);
|
|
|
|
|
|
- return Result.success("ok",resJson);
|
|
|
+ return Result.success("ok", resJson);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@PostMapping("changeModelByID")
|
|
|
- public Result changeModelByID(@RequestBody String json,SysUser sysUser) throws IOException {
|
|
|
+ public Result changeModelByID(@RequestBody String json, SysUser sysUser) throws IOException {
|
|
|
//获取参数
|
|
|
- JSONObject resJson=new JSONObject();
|
|
|
- JSONObject req=JSON.parseObject(json);
|
|
|
- String model_name=req.getString("modelname");
|
|
|
- String model_data=req.getString("modeldata");
|
|
|
- long id=Long.parseLong( req.getString("modelid"));
|
|
|
+ JSONObject resJson = new JSONObject();
|
|
|
+ JSONObject req = JSON.parseObject(json);
|
|
|
+ String model_name = req.getString("modelname");
|
|
|
+ String model_data = req.getString("modeldata");
|
|
|
+ long id = Long.parseLong(req.getString("modelid"));
|
|
|
// System.out.println(id);
|
|
|
// System.out.println(req.getString("modelid"));
|
|
|
- UserModel model=userModelService.findByID(id);
|
|
|
+ ModelEntity modelEntity = userModelService.findByID(id);
|
|
|
|
|
|
//删除旧模型(文件)
|
|
|
- String old_name=model.getModelName();
|
|
|
+ String old_name = modelEntity.getModelName();
|
|
|
|
|
|
|
|
|
//新模型写入
|
|
|
- JSONObject model_json=JSON.parseObject(model_data);
|
|
|
- String file_name=sysUser.getUserName()+"_"+model_name;
|
|
|
- jsonFile.writerFile(model_json,file_name);
|
|
|
- model.setModelName(model_name);
|
|
|
- model.setStatus("审批中");
|
|
|
+ JSONObject model_json = JSON.parseObject(model_data);
|
|
|
+ String file_name = sysUser.getUserName() + "_" + model_name;
|
|
|
+ jsonFile.writerFile(model_json, file_name);
|
|
|
+ modelEntity.setModelName(model_name);
|
|
|
+ modelEntity.setStatus("审批中");
|
|
|
//重新审批
|
|
|
- UserApproval approval=new UserApproval();
|
|
|
+ UserApproval approval = new UserApproval();
|
|
|
approval.setUserName(sysUser.getUserName());
|
|
|
approval.setApprovalId((long) 1);
|
|
|
approval.setData(model_name);
|
|
|
userApprovalService.save(approval);
|
|
|
|
|
|
- userModelService.updateById(model);
|
|
|
-
|
|
|
+ userModelService.updateById(modelEntity);
|
|
|
|
|
|
|
|
|
return Result.success();
|
|
@@ -519,40 +512,40 @@ public class ModelController {
|
|
|
|
|
|
//修改产品号
|
|
|
@PostMapping("changeProduct")
|
|
|
- public Result changeProduct(@RequestBody String json,SysUser sysUser)
|
|
|
- {
|
|
|
- JSONObject req=JSON.parseObject(json);
|
|
|
- long id= Long.parseLong(req.getString("modelid"));
|
|
|
- String productNum=req.getString("productnum");
|
|
|
- UserModel model=userModelService.findByID(id);
|
|
|
- model.setModelNo(productNum);
|
|
|
- userModelService.updateById(model);
|
|
|
+ public Result changeProduct(@RequestBody String json, SysUser sysUser) {
|
|
|
+ JSONObject req = JSON.parseObject(json);
|
|
|
+ long id = Long.parseLong(req.getString("modelid"));
|
|
|
+ String productNum = req.getString("productnum");
|
|
|
+ ModelEntity modelEntity = userModelService.findByID(id);
|
|
|
+ modelEntity.setModelNo(productNum);
|
|
|
+ userModelService.updateById(modelEntity);
|
|
|
return Result.success();
|
|
|
|
|
|
}
|
|
|
+
|
|
|
//mqy add changeModelName
|
|
|
@PostMapping("changeModelName")
|
|
|
- public Result changeModelName(@RequestBody String json){
|
|
|
- JSONObject req=JSON.parseObject(json);
|
|
|
- long modelNo= Long.parseLong(req.getString("modelNo"));
|
|
|
- String modelName=req.getString("modelName");
|
|
|
+ public Result changeModelName(@RequestBody String json) {
|
|
|
+ JSONObject req = JSON.parseObject(json);
|
|
|
+ long modelNo = Long.parseLong(req.getString("modelNo"));
|
|
|
+ String modelName = req.getString("modelName");
|
|
|
System.out.println(modelNo);
|
|
|
System.out.println(modelName);
|
|
|
- userModelService.changeModelName(modelName,modelNo);
|
|
|
+ userModelService.changeModelName(modelName, modelNo);
|
|
|
return Result.success("ok");
|
|
|
}
|
|
|
+
|
|
|
//yuan修改组合对应模型号
|
|
|
@PostMapping("combineReleModel")
|
|
|
- public Result combineReleModel(@RequestBody String json,SysUser sysUser)
|
|
|
- {
|
|
|
- JSONObject req=JSON.parseObject(json);
|
|
|
- String field_combine=req.getString("field_combine");
|
|
|
- String modelName=req.getString("model_name");
|
|
|
- UserField field=userFieldService.findByFieldCombine(field_combine);
|
|
|
- UserModel model = userModelService.findByModelName(modelName);
|
|
|
+ public Result combineReleModel(@RequestBody String json, SysUser sysUser) {
|
|
|
+ JSONObject req = JSON.parseObject(json);
|
|
|
+ String field_combine = req.getString("field_combine");
|
|
|
+ String modelName = req.getString("model_name");
|
|
|
+ UserField field = userFieldService.findByFieldCombine(field_combine);
|
|
|
+ ModelEntity modelEntity = userModelService.findByModelName(modelName);
|
|
|
// model.setFieldCombine(field_combine);
|
|
|
field.setModelName(modelName);
|
|
|
- userModelService.updateById(model);
|
|
|
+ userModelService.updateById(modelEntity);
|
|
|
userFieldService.updateById(field);
|
|
|
return Result.success();
|
|
|
}
|
|
@@ -576,28 +569,26 @@ public class ModelController {
|
|
|
//这个接口是将模型从审核通过/暂停改为上线
|
|
|
// 审批中/已上线/审核通过/暂停使用
|
|
|
@PostMapping("changeState")
|
|
|
- public Result changeState(@RequestBody String json,SysUser sysUser)
|
|
|
- {
|
|
|
- JSONObject req=JSON.parseObject(json);
|
|
|
- long id= Long.parseLong(req.getString("modelid"));
|
|
|
- String state=req.getString("modelstate");
|
|
|
+ public Result changeState(@RequestBody String json, SysUser sysUser) {
|
|
|
+ JSONObject req = JSON.parseObject(json);
|
|
|
+ long id = Long.parseLong(req.getString("modelid"));
|
|
|
+ String state = req.getString("modelstate");
|
|
|
|
|
|
System.out.println(id);
|
|
|
- UserModel model=userModelService.findByID(id);
|
|
|
+ ModelEntity modelEntity = userModelService.findByID(id);
|
|
|
|
|
|
- model.setStatus(state);
|
|
|
+ modelEntity.setStatus(state);
|
|
|
|
|
|
- userModelService.updateById(model);
|
|
|
+ userModelService.updateById(modelEntity);
|
|
|
|
|
|
return Result.success();
|
|
|
|
|
|
}
|
|
|
|
|
|
@PostMapping("deleteModel")
|
|
|
- public Result deleteModel(@RequestBody String json,SysUser sysUser)
|
|
|
- {
|
|
|
- JSONObject req=JSON.parseObject(json);
|
|
|
- long id= Long.parseLong(req.getString("modelid"));
|
|
|
+ public Result deleteModel(@RequestBody String json, SysUser sysUser) {
|
|
|
+ JSONObject req = JSON.parseObject(json);
|
|
|
+ long id = Long.parseLong(req.getString("modelid"));
|
|
|
String fieldCombine = req.getString("fieldCombine");
|
|
|
// if(fieldCombine.equals("暂未指定")){
|
|
|
//
|
|
@@ -607,8 +598,8 @@ public class ModelController {
|
|
|
// userFieldService.updateById(field);
|
|
|
// }
|
|
|
|
|
|
- UserModel model=userModelService.findByID(id);
|
|
|
- String oldFilePath=model.getFilePath();
|
|
|
+ ModelEntity modelEntity = userModelService.findByID(id);
|
|
|
+ String oldFilePath = modelEntity.getFilePath();
|
|
|
File oldFile = new File(oldFilePath);
|
|
|
|
|
|
if (oldFile.exists()) {
|
|
@@ -618,8 +609,7 @@ public class ModelController {
|
|
|
} catch (IOException e) {
|
|
|
System.out.println("file delete fail: " + e.getMessage());
|
|
|
}
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
System.out.println("file not exist");
|
|
|
}
|
|
|
|
|
@@ -630,21 +620,21 @@ public class ModelController {
|
|
|
|
|
|
// 获取审核模块的详情,主要是模型详情
|
|
|
@PostMapping("getDetails")
|
|
|
- public Result getDetails(@RequestBody String json)
|
|
|
- {
|
|
|
- JSONObject jsonrq=JSON.parseObject(json);
|
|
|
- int type=jsonrq.getInteger("type");
|
|
|
- if(type==1)
|
|
|
- {
|
|
|
+ public Result getDetails(@RequestBody String json) {
|
|
|
+ JSONObject jsonrq = JSON.parseObject(json);
|
|
|
+ int type = jsonrq.getInteger("type");
|
|
|
+ if (type == 1) {
|
|
|
//首先获取对应模型
|
|
|
JSONObject res = new JSONObject();
|
|
|
- String user_name=jsonrq.getString("username");
|
|
|
- String model_name=jsonrq.getString("modelname");
|
|
|
- UserModel model=userModelService.findByUserAndModel(user_name,model_name);
|
|
|
- if(model==null) return Result.error();
|
|
|
+ String user_name = jsonrq.getString("username");
|
|
|
+ String model_name = jsonrq.getString("modelname");
|
|
|
+ ModelEntity modelEntity = userModelService.findByUserAndModel(user_name, model_name);
|
|
|
+ if (modelEntity == null) {
|
|
|
+ return Result.error();
|
|
|
+ }
|
|
|
//模型类型
|
|
|
- res.put("model_type",model.getModelType());
|
|
|
- if(model.getModelType()==0) {//自定义模型
|
|
|
+ res.put("model_type", modelEntity.getModelType());
|
|
|
+ if (modelEntity.getModelType() == 0) {//自定义模型
|
|
|
JSONObject model_data = jsonFile.ReadJson(user_name + "_" + model_name);
|
|
|
if (model_data != null) {
|
|
|
res.put("error_code", 0);
|
|
@@ -654,90 +644,75 @@ public class ModelController {
|
|
|
res.put("error_info", "模型不存在!");
|
|
|
|
|
|
}
|
|
|
- }
|
|
|
- else if(model.getModelType()==1 || model.getModelType()==2)
|
|
|
- {
|
|
|
+ } else if (modelEntity.getModelType() == 1 || modelEntity.getModelType() == 2) {
|
|
|
//res.put("output_list",model.getOutputList());
|
|
|
//res.put("other_data",model.getOtherData());
|
|
|
|
|
|
}
|
|
|
- return Result.success("ok",res);
|
|
|
- }
|
|
|
- else if(type==2)
|
|
|
- {
|
|
|
+ return Result.success("ok", res);
|
|
|
+ } else if (type == 2) {
|
|
|
//字段信息 直接获取 不用这一步
|
|
|
// JSONObject res = new JSONObject();
|
|
|
// String user_name=jsonrq.getString("username");
|
|
|
// String field_data=jsonrq.getString("modelname");
|
|
|
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
|
|
|
}
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
|
@PostMapping("doApproval")
|
|
|
- public Result doApproval(@RequestBody String json)
|
|
|
- {
|
|
|
- String reason_list[]={"错误字段选择","错误模型逻辑","其他"};
|
|
|
- JSONObject jsonrq=JSON.parseObject(json);
|
|
|
- int type=jsonrq.getInteger("type");
|
|
|
- long id= Long.parseLong(jsonrq.getString("id"));
|
|
|
-
|
|
|
- if(type==1)
|
|
|
- {
|
|
|
+ public Result doApproval(@RequestBody String json) {
|
|
|
+ String reason_list[] = {"错误字段选择", "错误模型逻辑", "其他"};
|
|
|
+ JSONObject jsonrq = JSON.parseObject(json);
|
|
|
+ int type = jsonrq.getInteger("type");
|
|
|
+ long id = Long.parseLong(jsonrq.getString("id"));
|
|
|
+
|
|
|
+ if (type == 1) {
|
|
|
JSONObject res = new JSONObject();
|
|
|
- String user_name=jsonrq.getString("username");
|
|
|
- String model_name=jsonrq.getString("data");
|
|
|
- int pass=jsonrq.getInteger("pass");
|
|
|
+ String user_name = jsonrq.getString("username");
|
|
|
+ String model_name = jsonrq.getString("data");
|
|
|
+ int pass = jsonrq.getInteger("pass");
|
|
|
//通过
|
|
|
- if(pass==1)
|
|
|
- {
|
|
|
- UserModel model=userModelService.findByUserAndModel(user_name,model_name);
|
|
|
- if(model!=null) {
|
|
|
- model.setStatus("审核通过");
|
|
|
- userModelService.updateById(model);
|
|
|
+ if (pass == 1) {
|
|
|
+ ModelEntity modelEntity = userModelService.findByUserAndModel(user_name, model_name);
|
|
|
+ if (modelEntity != null) {
|
|
|
+ modelEntity.setStatus("审核通过");
|
|
|
+ userModelService.updateById(modelEntity);
|
|
|
}
|
|
|
}
|
|
|
//不通过
|
|
|
else {
|
|
|
- int reason=jsonrq.getInteger("reason");
|
|
|
- UserModel model = userModelService.findByUserAndModel(user_name, model_name);
|
|
|
- if(model!=null) {
|
|
|
- model.setStatus("审核不通过:"+reason_list[reason]);
|
|
|
- userModelService.updateById(model);
|
|
|
+ int reason = jsonrq.getInteger("reason");
|
|
|
+ ModelEntity modelEntity = userModelService.findByUserAndModel(user_name, model_name);
|
|
|
+ if (modelEntity != null) {
|
|
|
+ modelEntity.setStatus("审核不通过:" + reason_list[reason]);
|
|
|
+ userModelService.updateById(modelEntity);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else if(type==2)
|
|
|
- {
|
|
|
- String user_name=jsonrq.getString("username");
|
|
|
- String user_field=jsonrq.getString("data");
|
|
|
- int pass=jsonrq.getInteger("pass");
|
|
|
+ } else if (type == 2) {
|
|
|
+ String user_name = jsonrq.getString("username");
|
|
|
+ String user_field = jsonrq.getString("data");
|
|
|
+ int pass = jsonrq.getInteger("pass");
|
|
|
|
|
|
System.out.println("审核了字段");
|
|
|
System.out.println(user_name);
|
|
|
- if(pass==1)
|
|
|
- {
|
|
|
- UserField userField=userFieldService.findByFieldCombine(user_field);
|
|
|
- if(userField!=null) {
|
|
|
+ if (pass == 1) {
|
|
|
+ UserField userField = userFieldService.findByFieldCombine(user_field);
|
|
|
+ if (userField != null) {
|
|
|
userField.setFieldState("审核通过");
|
|
|
userFieldService.updateById(userField);
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
- else {
|
|
|
- UserField userField=userFieldService.findByUserName(user_name);
|
|
|
- if(userField!=null) {
|
|
|
+ } else {
|
|
|
+ UserField userField = userFieldService.findByUserName(user_name);
|
|
|
+ if (userField != null) {
|
|
|
userField.setFieldState("审核不通过");
|
|
|
userFieldService.updateById(userField);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
|
|
|
}
|
|
|
System.out.println(id);
|