|
@@ -1,726 +1,723 @@
|
|
|
-package com.kexun.controller;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.kexun.common.JsonFile;
|
|
|
-import com.kexun.common.utils.Result;
|
|
|
-import com.kexun.entity.*;
|
|
|
-import com.kexun.service.*;
|
|
|
-//import com.sun.xml.internal.bind.v2.TODO;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
-import java.io.*;
|
|
|
-import java.util.*;
|
|
|
-
|
|
|
-/*
|
|
|
- * 目标:实现对字段组合,用户自定义模型的全部操作
|
|
|
- * 目前:原有功能都已实现,新添加的对字段组合过滤后得到的字段进行模型的逻辑判断功能尚缺
|
|
|
- */
|
|
|
-
|
|
|
-@RestController
|
|
|
-@RequestMapping("admin/model")
|
|
|
-public class ModelController {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private SysRoleRightsService sysRoleRightsService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private SysRoleService sysRoleService;
|
|
|
- @Autowired
|
|
|
- private SysRightsService sysRightsService;
|
|
|
- @Autowired
|
|
|
- private SysUserService sysUserService;
|
|
|
- @Autowired
|
|
|
- private UserInfoService userInfoService;
|
|
|
- @Autowired
|
|
|
- private UserModelService userModelService;
|
|
|
- @Autowired
|
|
|
- private UserApprovalService userApprovalService;
|
|
|
- @Autowired
|
|
|
- private UserFieldService userFieldService;
|
|
|
- @Autowired
|
|
|
- private CustomizedModelService customizedModelService;
|
|
|
- @Autowired
|
|
|
- private FilterResultService parseResultService;
|
|
|
-
|
|
|
-
|
|
|
- private JsonFile jsonFile=new JsonFile();
|
|
|
-
|
|
|
- //给模型复核员提供模型复核
|
|
|
- @GetMapping("listUser")
|
|
|
- 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);
|
|
|
- user_list.add(user_json);
|
|
|
- }
|
|
|
- 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);
|
|
|
-
|
|
|
- }
|
|
|
- /**
|
|
|
- * 读取json文件,返回json串
|
|
|
- * @param fileName
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static String readJsonFile(String fileName) {
|
|
|
- String jsonStr = "";
|
|
|
- try {
|
|
|
- File jsonFile = new File(fileName);
|
|
|
- FileReader fileReader = new FileReader(jsonFile);
|
|
|
-
|
|
|
- Reader reader = new InputStreamReader(new FileInputStream(jsonFile), "utf-8");
|
|
|
- int ch = 0;
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
- while ((ch = reader.read()) != -1) {
|
|
|
- sb.append((char) ch);
|
|
|
- }
|
|
|
-
|
|
|
- fileReader.close();
|
|
|
- reader.close();
|
|
|
- jsonStr = sb.toString();
|
|
|
- return jsonStr;
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
- private static String getType(Object a) {
|
|
|
- return a.getClass().toString();
|
|
|
- }
|
|
|
-
|
|
|
- //上传字段组合
|
|
|
- @PostMapping("addField")
|
|
|
- public Result addField(@RequestBody String json,SysUser sysUser) throws IOException {
|
|
|
- JSONObject req = JSON.parseObject(json);
|
|
|
-
|
|
|
- String field_combine=req.getString("fieldcombine");
|
|
|
-
|
|
|
- //添加异常判断,重名模型名?,yuan尚未实现,先忽略掉
|
|
|
-// JSONObject resJson = new JSONObject();
|
|
|
-// if(userModelService.findByUserAndModel(sysUser.getUserName(),field_combine)!=null) {
|
|
|
-// resJson.put("state", 0);
|
|
|
-// return Result.success("ok",resJson);
|
|
|
-// }
|
|
|
-// //非重名
|
|
|
-// resJson.put("state", 1);
|
|
|
-
|
|
|
-// 此为自定义字段组合所需数据
|
|
|
- String userName=req.getString("username");
|
|
|
- String fieldData=req.getString("fielddata");
|
|
|
-// String fieldCombine = req.getString("fieldcombine");
|
|
|
- String fieldRemark = req.getString("remark");
|
|
|
-// customizedModel.setModelName(modelName);
|
|
|
-// customizedModel.setFieldClass("自定义模型");
|
|
|
-// customizedModel.setIdList(fieldData);
|
|
|
-// customizedModel.setCreatedBy(userName);
|
|
|
-// customizedModel.setModelRemark(modelRemark);
|
|
|
-// customizedModelService.save(customizedModel);
|
|
|
-
|
|
|
- //yuan 将自定义字段加到customizedModel表中,还是启用customizedModel表,只给user_field表插入数据
|
|
|
- UserField yUserField = new UserField();
|
|
|
- yUserField.setFieldCombine(field_combine);
|
|
|
- yUserField.setFieldRemark(fieldRemark);
|
|
|
- yUserField.setUserName(userName);
|
|
|
- yUserField.setFieldData(fieldData);
|
|
|
- yUserField.setFieldState("审批中");
|
|
|
- yUserField.setModelName("暂未指定");
|
|
|
- userFieldService.save(yUserField);
|
|
|
-
|
|
|
-// 好像是初始的字段组合过滤逻辑,现在应该是弃用了
|
|
|
-// String pate="朱家铎_410922199111210030_255632073002334212.txt";
|
|
|
-// String Path="D:/jin_rong/test_data"+"/"+pate;
|
|
|
-//
|
|
|
-// String s = readJsonFile(Path);
|
|
|
-// JSONObject field_json = JSON.parseObject(s);
|
|
|
-//
|
|
|
-//
|
|
|
-// JSONObject filter_json = JSON.parseObject(fieldData);
|
|
|
-// JSONObject filter_dict = new JSONObject();
|
|
|
-//
|
|
|
-// Iterator iter1 = filter_json.entrySet().iterator();
|
|
|
-// while (iter1.hasNext()) {
|
|
|
-// JSONObject field_dict = new JSONObject();
|
|
|
-//
|
|
|
-// Map.Entry entry = (Map.Entry) iter1.next();
|
|
|
-// String temp = entry.getValue().toString();
|
|
|
-// temp = temp.substring(1,temp.length()-1);
|
|
|
-// String[] strarray=temp.split(",");
|
|
|
-//
|
|
|
-// for (int i = 0; i < strarray.length; i++){
|
|
|
-// strarray[i] = strarray[i].substring(1,strarray[i].length()-1);
|
|
|
-// field_dict.put(strarray[i], (field_json.getJSONObject(entry.getKey().toString())).getString(strarray[i]));
|
|
|
-// }
|
|
|
-//
|
|
|
-// filter_dict.put(entry.getKey().toString(),field_dict);
|
|
|
-// }
|
|
|
-// //System.out.println(filter_dict.toString());
|
|
|
-//
|
|
|
-// FileOutputStream fileOutputStream = null;
|
|
|
-// File file = new File("D:/jin_rong/test_data/result.json");
|
|
|
-// if(!file.exists()){
|
|
|
-// file.createNewFile();
|
|
|
-// }
|
|
|
-// fileOutputStream = new FileOutputStream(file);
|
|
|
-// fileOutputStream.write(filter_dict.toString().getBytes("utf-8"));
|
|
|
-// fileOutputStream.flush();
|
|
|
-// fileOutputStream.close();
|
|
|
-
|
|
|
-// 此段代码注掉是因为新增字段组合有一个审批字段,默认为审批通过,但是新增的话会更新为审核中yuan
|
|
|
-
|
|
|
-// UserField userField=userFieldService.findByUserName(userName);
|
|
|
-// if(userField==null)
|
|
|
-// {
|
|
|
-// UserField new_field=new UserField();
|
|
|
-// new_field.setUserName(userName);
|
|
|
-// new_field.setFieldData(fieldData);
|
|
|
-// new_field.setFieldState("审批中");
|
|
|
-// userFieldService.save(new_field);
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// userField.setFieldData(fieldData);
|
|
|
-// userField.setFieldState("审批中");
|
|
|
-// userFieldService.updateById(userField);
|
|
|
-// }
|
|
|
-//yuan
|
|
|
- UserApproval approval=new UserApproval();
|
|
|
- approval.setUserName(sysUser.getUserName());
|
|
|
- approval.setApprovalId((long) 2);
|
|
|
- approval.setData(field_combine);
|
|
|
- approval.setFieldData(fieldData);
|
|
|
- userApprovalService.save(approval);
|
|
|
-
|
|
|
- return Result.success();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //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);
|
|
|
-
|
|
|
- }
|
|
|
- // sxr
|
|
|
- @PostMapping("updateFieldCombineList")
|
|
|
- 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");
|
|
|
-
|
|
|
- UserField userField = userFieldService.findByID(fieldId);
|
|
|
- userField.setFieldCombine(fieldCombine);
|
|
|
- userField.setFieldData(choseData);
|
|
|
- userFieldService.updateById(userField);
|
|
|
- // TODO userApprovalService表更新 id需要改
|
|
|
-
|
|
|
- return Result.success();
|
|
|
- }
|
|
|
-
|
|
|
- // sxr
|
|
|
- @GetMapping("getFieldById")
|
|
|
- public Result getFieldById(Long fieldId) {
|
|
|
- System.out.println( fieldId);
|
|
|
- JSONObject result = new JSONObject();
|
|
|
- UserField userField = userFieldService.findByID(fieldId);
|
|
|
-
|
|
|
- result.put("fieldCombine", userField.getFieldCombine());
|
|
|
- //System.out.println(userField.getFieldCombine());
|
|
|
-
|
|
|
- JSONObject fieldDateJson = new JSONObject();
|
|
|
- String fieldData = userField.getFieldData();
|
|
|
- fieldData = fieldData.substring(1,fieldData.length()-1);
|
|
|
- String[] temp = fieldData.split("]");
|
|
|
- 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 valuetmp[] = (temp[i].split(":")[1].substring(1).split(","));
|
|
|
- String value[] = {};
|
|
|
- for(int j=0;j<valuetmp.length;j++)
|
|
|
- {
|
|
|
-
|
|
|
- System.out.println( valuetmp[j]);
|
|
|
- System.out.println(valuetmp[j].length());
|
|
|
-
|
|
|
- valuetmp[j] = valuetmp[j].substring(1,valuetmp[j].length()-1);
|
|
|
- }
|
|
|
-
|
|
|
- fieldDateJson.put(key, valuetmp);
|
|
|
-
|
|
|
- }
|
|
|
- System.out.println(fieldDateJson);
|
|
|
- result.put("fieldData",fieldDateJson);
|
|
|
-// System.out.println(userField.getFieldData());
|
|
|
- return Result.success("ok", result);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //过滤操作,也被弃用了
|
|
|
-// @PostMapping("parse")
|
|
|
-// public Result parse(@RequestBody String json) throws IOException {
|
|
|
-// JSONObject req = JSON.parseObject(json);
|
|
|
-// ParseResult parseResult = new ParseResult();
|
|
|
-//// 此为自定义模型所需数据
|
|
|
-// String fmodelName=req.getString("fmodelName");
|
|
|
-// String createdBy=req.getString("createdBy");
|
|
|
-// String idList=req.getString("idList");
|
|
|
-// parseResult.setFmodelName(fmodelName);
|
|
|
-// parseResult.setCreatedBy(createdBy);
|
|
|
-//
|
|
|
-// //表示一个文件路径
|
|
|
-// File file = new File("D:/jin_rong/todo/execed_txt");
|
|
|
-// //用数组把文件夹下的文件存起来
|
|
|
-// File[] files = file.listFiles();
|
|
|
-// int l = files.length;
|
|
|
-// System.out.println(l);
|
|
|
-// String pates[] = new String[l];
|
|
|
-// //foreach遍历数组
|
|
|
-// for (int j=0;j<l;j++){
|
|
|
-// pates[j] = files[j].getName();
|
|
|
-// String pate=pates[j];
|
|
|
-// String Path="D:/jin_rong/todo/execed_txt"+"/"+pate;
|
|
|
-// String pathFilter = new String();
|
|
|
-// pathFilter = "D:/jin_rong/test_data/logic/"+pate;
|
|
|
-// parseResult.setReportName(pate);
|
|
|
-// String s = readJsonFile(Path);
|
|
|
-// JSONObject field_json = JSON.parseObject(s);
|
|
|
-//
|
|
|
-//
|
|
|
-// JSONObject filter_json = JSON.parseObject(idList);
|
|
|
-// JSONObject filter_dict = new JSONObject();
|
|
|
-//
|
|
|
-// Iterator iter1 = filter_json.entrySet().iterator();
|
|
|
-// while (iter1.hasNext()) {
|
|
|
-// JSONObject field_dict = new JSONObject();
|
|
|
-//
|
|
|
-// Map.Entry entry = (Map.Entry) iter1.next();
|
|
|
-// String temp = entry.getValue().toString();
|
|
|
-// temp = temp.substring(1,temp.length()-1);
|
|
|
-// String[] strarray=temp.split(",");
|
|
|
-//
|
|
|
-// for (int i = 0; i < strarray.length; i++){
|
|
|
-// strarray[i] = strarray[i].substring(1,strarray[i].length()-1);
|
|
|
-// field_dict.put(strarray[i], (field_json.getJSONObject(entry.getKey().toString())).getString(strarray[i]));
|
|
|
-// }
|
|
|
-//
|
|
|
-// filter_dict.put(entry.getKey().toString(),field_dict);
|
|
|
-// }
|
|
|
-// parseResult.setResultInfo(filter_dict.toString());
|
|
|
-// parseResultService.save(parseResult);
|
|
|
-//
|
|
|
-// FileOutputStream fileOutputStream = null;
|
|
|
-//
|
|
|
-//
|
|
|
-// File fileFilter = new File(pathFilter);
|
|
|
-// if(!fileFilter.exists()){
|
|
|
-// fileFilter.createNewFile();
|
|
|
-// }
|
|
|
-// fileOutputStream = new FileOutputStream(fileFilter);
|
|
|
-// fileOutputStream.write(filter_dict.toString().getBytes("utf-8"));
|
|
|
-// fileOutputStream.flush();
|
|
|
-// fileOutputStream.close();
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// //System.out.println(filter_dict.toString());
|
|
|
-//
|
|
|
-// return Result.success();
|
|
|
-//
|
|
|
-// }
|
|
|
-
|
|
|
- @GetMapping("getField")
|
|
|
- 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","未配置字段");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- resJson.put("fieldData",userField.getFieldData());
|
|
|
- resJson.put("fieldState",userField.getFieldState());
|
|
|
- }
|
|
|
- return Result.success("ok",resJson);
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("getFieldByName")
|
|
|
- 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","未配置字段");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- resJson.put("fieldData",userField.getFieldData());
|
|
|
- resJson.put("fieldState",userField.getFieldState());
|
|
|
- }
|
|
|
- return Result.success("ok",resJson);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //新增自定义模型
|
|
|
- @PostMapping("addModel")
|
|
|
- public Result addModel(@RequestBody String json,SysUser sysUser) throws IOException {
|
|
|
- //获取用户模型,并按json文件保存
|
|
|
- JSONObject req = JSON.parseObject(json);
|
|
|
- String model_name=req.getString("modelname");
|
|
|
- JSONObject resJson = new JSONObject();
|
|
|
- //添加异常判断,重名模型名?
|
|
|
- if(userModelService.findByUserAndModel(sysUser.getUserName(),model_name)!=null) {
|
|
|
- resJson.put("state", 0);
|
|
|
- return Result.success("ok",resJson);
|
|
|
- }
|
|
|
- //非重名
|
|
|
- resJson.put("state", 1);
|
|
|
-
|
|
|
- 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);
|
|
|
-
|
|
|
- // 这个地方应该先加到审批页面上
|
|
|
- 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.setUserName(userName);
|
|
|
- new_model.setModelName(model_name);
|
|
|
- new_model.setModelType(0);
|
|
|
- new_model.setModelState("审批中");
|
|
|
- new_model.setFieldCombine("暂未指定");
|
|
|
- new_model.setSelectData(model_data);
|
|
|
- userModelService.save(new_model);
|
|
|
-
|
|
|
-
|
|
|
- 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());
|
|
|
-// System.out.println(model_list.get(0).getId());
|
|
|
- resJson.put("modelData", model_list);
|
|
|
-
|
|
|
- return Result.success("ok",resJson);
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- // 获取当前模型
|
|
|
- @PostMapping("getModelByName")
|
|
|
- public Result getModelByName(@RequestBody String json,SysUser sysUser)
|
|
|
- {
|
|
|
-
|
|
|
- JSONObject resJson=new JSONObject();
|
|
|
-
|
|
|
- JSONObject req = JSON.parseObject(json);
|
|
|
-
|
|
|
- //user_name+model_name就是文件名
|
|
|
- String model_name=req.getString("modelName");
|
|
|
- String user_name=sysUser.getUserName();
|
|
|
- //读取对应文件
|
|
|
- JSONObject model=jsonFile.ReadJson(user_name+"_"+model_name);
|
|
|
- System.out.println(model);
|
|
|
-
|
|
|
-// resJson.put("model", model);
|
|
|
-
|
|
|
- return Result.success("ok",resJson);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @PostMapping("changeModelByID")
|
|
|
- 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"));
|
|
|
-// System.out.println(id);
|
|
|
-// System.out.println(req.getString("modelid"));
|
|
|
- UserModel model=userModelService.findByID(id);
|
|
|
-
|
|
|
- //删除旧模型(文件)
|
|
|
- String old_name=model.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.setModelState("审批中");
|
|
|
- //重新审批
|
|
|
- UserApproval approval=new UserApproval();
|
|
|
- approval.setUserName(sysUser.getUserName());
|
|
|
- approval.setApprovalId((long) 1);
|
|
|
- approval.setData(model_name);
|
|
|
- userApprovalService.save(approval);
|
|
|
-
|
|
|
- userModelService.updateById(model);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return Result.success();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //修改产品号
|
|
|
- @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.setProductNum(productNum);
|
|
|
- userModelService.updateById(model);
|
|
|
- return Result.success();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //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);
|
|
|
- model.setFieldCombine(field_combine);
|
|
|
- field.setModelName(modelName);
|
|
|
- userModelService.updateById(model);
|
|
|
- userFieldService.updateById(field);
|
|
|
- return Result.success();
|
|
|
- }
|
|
|
-
|
|
|
- //sxr编辑字段
|
|
|
-// @PostMapping("combineFieldModel")
|
|
|
-// public Result combineFieldModel(@RequestBody String json,SysUser sysUser)
|
|
|
-// {
|
|
|
-// JSONObject req=JSON.parseObject(json);
|
|
|
-// String field_id=req.getString("field_id");
|
|
|
-// String field_name=req.getString("field_name");
|
|
|
-// String selected_field_data=req.getString("selected_field_data");
|
|
|
-// String modelName=req.getString("model_name");
|
|
|
-// UserField field=userFieldService.findByFieldCombine(field_combine);
|
|
|
-// field.setModelName(modelName);
|
|
|
-// userFieldService.updateById(field);
|
|
|
-// return Result.success();
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
- //这个接口是将模型从审核通过/暂停改为上线
|
|
|
-// 审批中/已上线/审核通过/暂停使用
|
|
|
- @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");
|
|
|
-
|
|
|
- System.out.println(id);
|
|
|
- UserModel model=userModelService.findByID(id);
|
|
|
-
|
|
|
- model.setModelState(state);
|
|
|
-
|
|
|
- userModelService.updateById(model);
|
|
|
-
|
|
|
- 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"));
|
|
|
- String fieldCombine = req.getString("fieldCombine");
|
|
|
- if(fieldCombine.equals("暂未指定")){
|
|
|
-
|
|
|
- }else{
|
|
|
- UserField field=userFieldService.findByFieldCombine(fieldCombine);
|
|
|
- field.setModelName("暂未指定");
|
|
|
- userFieldService.updateById(field);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- userModelService.removeModelByID(id);
|
|
|
- return Result.success();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // 获取审核模块的详情,主要是模型详情
|
|
|
- @PostMapping("getDetails")
|
|
|
- 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();
|
|
|
- //模型类型
|
|
|
- res.put("model_type",model.getModelType());
|
|
|
- if(model.getModelType()==0) {//自定义模型
|
|
|
- JSONObject model_data = jsonFile.ReadJson(user_name + "_" + model_name);
|
|
|
- if (model_data != null) {
|
|
|
- res.put("error_code", 0);
|
|
|
- res.put("model_data", model_data);
|
|
|
- } else {
|
|
|
- res.put("error_code", 1);
|
|
|
- res.put("error_info", "模型不存在!");
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- else if(model.getModelType()==1 || model.getModelType()==2)
|
|
|
- {
|
|
|
- res.put("output_list",model.getOutputList());
|
|
|
- res.put("other_data",model.getOtherData());
|
|
|
-
|
|
|
- }
|
|
|
- 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
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- 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)
|
|
|
- {
|
|
|
- JSONObject res = new JSONObject();
|
|
|
- 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.setModelState("审核通过");
|
|
|
- userModelService.updateById(model);
|
|
|
- }
|
|
|
- }
|
|
|
- //不通过
|
|
|
- else {
|
|
|
- int reason=jsonrq.getInteger("reason");
|
|
|
- UserModel model = userModelService.findByUserAndModel(user_name, model_name);
|
|
|
- if(model!=null) {
|
|
|
- model.setModelState("审核不通过:"+reason_list[reason]);
|
|
|
- userModelService.updateById(model);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- 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) {
|
|
|
- userField.setFieldState("审核通过");
|
|
|
- userFieldService.updateById(userField);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
- UserField userField=userFieldService.findByUserName(user_name);
|
|
|
- if(userField!=null) {
|
|
|
- userField.setFieldState("审核不通过");
|
|
|
- userFieldService.updateById(userField);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- System.out.println(id);
|
|
|
- userApprovalService.removeById(id);
|
|
|
- return Result.success();
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+package com.kexun.controller;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.kexun.common.JsonFile;
|
|
|
+import com.kexun.common.utils.Result;
|
|
|
+import com.kexun.entity.*;
|
|
|
+import com.kexun.service.*;
|
|
|
+//import com.sun.xml.internal.bind.v2.TODO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.io.*;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/*
|
|
|
+ * 目标:实现对字段组合,用户自定义模型的全部操作
|
|
|
+ * 目前:原有功能都已实现,新添加的对字段组合过滤后得到的字段进行模型的逻辑判断功能尚缺
|
|
|
+ */
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("admin/model")
|
|
|
+public class ModelController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysRoleRightsService sysRoleRightsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysRoleService sysRoleService;
|
|
|
+ @Autowired
|
|
|
+ private SysRightsService sysRightsService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserService sysUserService;
|
|
|
+ @Autowired
|
|
|
+ private UserInfoService userInfoService;
|
|
|
+ @Autowired
|
|
|
+ private UserModelService userModelService;
|
|
|
+ @Autowired
|
|
|
+ private UserApprovalService userApprovalService;
|
|
|
+ @Autowired
|
|
|
+ private UserFieldService userFieldService;
|
|
|
+ @Autowired
|
|
|
+ private CustomizedModelService customizedModelService;
|
|
|
+ @Autowired
|
|
|
+ private FilterResultService parseResultService;
|
|
|
+
|
|
|
+
|
|
|
+ private JsonFile jsonFile=new JsonFile();
|
|
|
+
|
|
|
+ //给模型复核员提供模型复核
|
|
|
+ @GetMapping("listUser")
|
|
|
+ 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);
|
|
|
+ user_list.add(user_json);
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 读取json文件,返回json串
|
|
|
+ * @param fileName
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String readJsonFile(String fileName) {
|
|
|
+ String jsonStr = "";
|
|
|
+ try {
|
|
|
+ File jsonFile = new File(fileName);
|
|
|
+ FileReader fileReader = new FileReader(jsonFile);
|
|
|
+
|
|
|
+ Reader reader = new InputStreamReader(new FileInputStream(jsonFile), "utf-8");
|
|
|
+ int ch = 0;
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ while ((ch = reader.read()) != -1) {
|
|
|
+ sb.append((char) ch);
|
|
|
+ }
|
|
|
+
|
|
|
+ fileReader.close();
|
|
|
+ reader.close();
|
|
|
+ jsonStr = sb.toString();
|
|
|
+ return jsonStr;
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private static String getType(Object a) {
|
|
|
+ return a.getClass().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ //上传字段组合
|
|
|
+ @PostMapping("addField")
|
|
|
+ public Result addField(@RequestBody String json,SysUser sysUser) throws IOException {
|
|
|
+ JSONObject req = JSON.parseObject(json);
|
|
|
+
|
|
|
+ String field_combine=req.getString("fieldcombine");
|
|
|
+
|
|
|
+ //添加异常判断,重名模型名?,yuan尚未实现,先忽略掉
|
|
|
+// JSONObject resJson = new JSONObject();
|
|
|
+// if(userModelService.findByUserAndModel(sysUser.getUserName(),field_combine)!=null) {
|
|
|
+// resJson.put("state", 0);
|
|
|
+// return Result.success("ok",resJson);
|
|
|
+// }
|
|
|
+// //非重名
|
|
|
+// resJson.put("state", 1);
|
|
|
+
|
|
|
+// 此为自定义字段组合所需数据
|
|
|
+ String userName=req.getString("username");
|
|
|
+ String fieldData=req.getString("fielddata");
|
|
|
+// String fieldCombine = req.getString("fieldcombine");
|
|
|
+ String fieldRemark = req.getString("remark");
|
|
|
+// customizedModel.setModelName(modelName);
|
|
|
+// customizedModel.setFieldClass("自定义模型");
|
|
|
+// customizedModel.setIdList(fieldData);
|
|
|
+// customizedModel.setCreatedBy(userName);
|
|
|
+// customizedModel.setModelRemark(modelRemark);
|
|
|
+// customizedModelService.save(customizedModel);
|
|
|
+
|
|
|
+ //yuan 将自定义字段加到customizedModel表中,还是启用customizedModel表,只给user_field表插入数据
|
|
|
+ UserField yUserField = new UserField();
|
|
|
+ yUserField.setFieldCombine(field_combine);
|
|
|
+ yUserField.setFieldRemark(fieldRemark);
|
|
|
+ yUserField.setUserName(userName);
|
|
|
+ yUserField.setFieldData(fieldData);
|
|
|
+ yUserField.setFieldState("审批中");
|
|
|
+ yUserField.setModelName("暂未指定");
|
|
|
+ userFieldService.save(yUserField);
|
|
|
+
|
|
|
+// 好像是初始的字段组合过滤逻辑,现在应该是弃用了
|
|
|
+// String pate="朱家铎_410922199111210030_255632073002334212.txt";
|
|
|
+// String Path="D:/jin_rong/test_data"+"/"+pate;
|
|
|
+//
|
|
|
+// String s = readJsonFile(Path);
|
|
|
+// JSONObject field_json = JSON.parseObject(s);
|
|
|
+//
|
|
|
+//
|
|
|
+// JSONObject filter_json = JSON.parseObject(fieldData);
|
|
|
+// JSONObject filter_dict = new JSONObject();
|
|
|
+//
|
|
|
+// Iterator iter1 = filter_json.entrySet().iterator();
|
|
|
+// while (iter1.hasNext()) {
|
|
|
+// JSONObject field_dict = new JSONObject();
|
|
|
+//
|
|
|
+// Map.Entry entry = (Map.Entry) iter1.next();
|
|
|
+// String temp = entry.getValue().toString();
|
|
|
+// temp = temp.substring(1,temp.length()-1);
|
|
|
+// String[] strarray=temp.split(",");
|
|
|
+//
|
|
|
+// for (int i = 0; i < strarray.length; i++){
|
|
|
+// strarray[i] = strarray[i].substring(1,strarray[i].length()-1);
|
|
|
+// field_dict.put(strarray[i], (field_json.getJSONObject(entry.getKey().toString())).getString(strarray[i]));
|
|
|
+// }
|
|
|
+//
|
|
|
+// filter_dict.put(entry.getKey().toString(),field_dict);
|
|
|
+// }
|
|
|
+// //System.out.println(filter_dict.toString());
|
|
|
+//
|
|
|
+// FileOutputStream fileOutputStream = null;
|
|
|
+// File file = new File("D:/jin_rong/test_data/result.json");
|
|
|
+// if(!file.exists()){
|
|
|
+// file.createNewFile();
|
|
|
+// }
|
|
|
+// fileOutputStream = new FileOutputStream(file);
|
|
|
+// fileOutputStream.write(filter_dict.toString().getBytes("utf-8"));
|
|
|
+// fileOutputStream.flush();
|
|
|
+// fileOutputStream.close();
|
|
|
+
|
|
|
+// 此段代码注掉是因为新增字段组合有一个审批字段,默认为审批通过,但是新增的话会更新为审核中yuan
|
|
|
+
|
|
|
+// UserField userField=userFieldService.findByUserName(userName);
|
|
|
+// if(userField==null)
|
|
|
+// {
|
|
|
+// UserField new_field=new UserField();
|
|
|
+// new_field.setUserName(userName);
|
|
|
+// new_field.setFieldData(fieldData);
|
|
|
+// new_field.setFieldState("审批中");
|
|
|
+// userFieldService.save(new_field);
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// userField.setFieldData(fieldData);
|
|
|
+// userField.setFieldState("审批中");
|
|
|
+// userFieldService.updateById(userField);
|
|
|
+// }
|
|
|
+//yuan
|
|
|
+ UserApproval approval=new UserApproval();
|
|
|
+ approval.setUserName(sysUser.getUserName());
|
|
|
+ approval.setApprovalId((long) 2);
|
|
|
+ approval.setData(field_combine);
|
|
|
+ approval.setFieldData(fieldData);
|
|
|
+ userApprovalService.save(approval);
|
|
|
+
|
|
|
+ return Result.success();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //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);
|
|
|
+
|
|
|
+ }
|
|
|
+ // sxr
|
|
|
+ @PostMapping("updateFieldCombineList")
|
|
|
+ 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");
|
|
|
+
|
|
|
+ UserField userField = userFieldService.findByID(fieldId);
|
|
|
+ userField.setFieldCombine(fieldCombine);
|
|
|
+ userField.setFieldData(choseData);
|
|
|
+ userFieldService.updateById(userField);
|
|
|
+ // TODO userApprovalService表更新 id需要改
|
|
|
+
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ // sxr
|
|
|
+ @GetMapping("getFieldById")
|
|
|
+ public Result getFieldById(Long fieldId) {
|
|
|
+ System.out.println( fieldId);
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ UserField userField = userFieldService.findByID(fieldId);
|
|
|
+
|
|
|
+ result.put("fieldCombine", userField.getFieldCombine());
|
|
|
+ //System.out.println(userField.getFieldCombine());
|
|
|
+
|
|
|
+ JSONObject fieldDateJson = new JSONObject();
|
|
|
+ String fieldData = userField.getFieldData();
|
|
|
+ fieldData = fieldData.substring(1,fieldData.length()-1);
|
|
|
+ String[] temp = fieldData.split("]");
|
|
|
+ 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 valuetmp[] = (temp[i].split(":")[1].substring(1).split(","));
|
|
|
+ String value[] = {};
|
|
|
+ for(int j=0;j<valuetmp.length;j++)
|
|
|
+ {
|
|
|
+
|
|
|
+ System.out.println( valuetmp[j]);
|
|
|
+ System.out.println(valuetmp[j].length());
|
|
|
+
|
|
|
+ valuetmp[j] = valuetmp[j].substring(1,valuetmp[j].length()-1);
|
|
|
+ }
|
|
|
+
|
|
|
+ fieldDateJson.put(key, valuetmp);
|
|
|
+
|
|
|
+ }
|
|
|
+ System.out.println(fieldDateJson);
|
|
|
+ result.put("fieldData",fieldDateJson);
|
|
|
+// System.out.println(userField.getFieldData());
|
|
|
+ return Result.success("ok", result);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //过滤操作,也被弃用了
|
|
|
+// @PostMapping("parse")
|
|
|
+// public Result parse(@RequestBody String json) throws IOException {
|
|
|
+// JSONObject req = JSON.parseObject(json);
|
|
|
+// ParseResult parseResult = new ParseResult();
|
|
|
+//// 此为自定义模型所需数据
|
|
|
+// String fmodelName=req.getString("fmodelName");
|
|
|
+// String createdBy=req.getString("createdBy");
|
|
|
+// String idList=req.getString("idList");
|
|
|
+// parseResult.setFmodelName(fmodelName);
|
|
|
+// parseResult.setCreatedBy(createdBy);
|
|
|
+//
|
|
|
+// //表示一个文件路径
|
|
|
+// File file = new File("D:/jin_rong/todo/execed_txt");
|
|
|
+// //用数组把文件夹下的文件存起来
|
|
|
+// File[] files = file.listFiles();
|
|
|
+// int l = files.length;
|
|
|
+// System.out.println(l);
|
|
|
+// String pates[] = new String[l];
|
|
|
+// //foreach遍历数组
|
|
|
+// for (int j=0;j<l;j++){
|
|
|
+// pates[j] = files[j].getName();
|
|
|
+// String pate=pates[j];
|
|
|
+// String Path="D:/jin_rong/todo/execed_txt"+"/"+pate;
|
|
|
+// String pathFilter = new String();
|
|
|
+// pathFilter = "D:/jin_rong/test_data/logic/"+pate;
|
|
|
+// parseResult.setReportName(pate);
|
|
|
+// String s = readJsonFile(Path);
|
|
|
+// JSONObject field_json = JSON.parseObject(s);
|
|
|
+//
|
|
|
+//
|
|
|
+// JSONObject filter_json = JSON.parseObject(idList);
|
|
|
+// JSONObject filter_dict = new JSONObject();
|
|
|
+//
|
|
|
+// Iterator iter1 = filter_json.entrySet().iterator();
|
|
|
+// while (iter1.hasNext()) {
|
|
|
+// JSONObject field_dict = new JSONObject();
|
|
|
+//
|
|
|
+// Map.Entry entry = (Map.Entry) iter1.next();
|
|
|
+// String temp = entry.getValue().toString();
|
|
|
+// temp = temp.substring(1,temp.length()-1);
|
|
|
+// String[] strarray=temp.split(",");
|
|
|
+//
|
|
|
+// for (int i = 0; i < strarray.length; i++){
|
|
|
+// strarray[i] = strarray[i].substring(1,strarray[i].length()-1);
|
|
|
+// field_dict.put(strarray[i], (field_json.getJSONObject(entry.getKey().toString())).getString(strarray[i]));
|
|
|
+// }
|
|
|
+//
|
|
|
+// filter_dict.put(entry.getKey().toString(),field_dict);
|
|
|
+// }
|
|
|
+// parseResult.setResultInfo(filter_dict.toString());
|
|
|
+// parseResultService.save(parseResult);
|
|
|
+//
|
|
|
+// FileOutputStream fileOutputStream = null;
|
|
|
+//
|
|
|
+//
|
|
|
+// File fileFilter = new File(pathFilter);
|
|
|
+// if(!fileFilter.exists()){
|
|
|
+// fileFilter.createNewFile();
|
|
|
+// }
|
|
|
+// fileOutputStream = new FileOutputStream(fileFilter);
|
|
|
+// fileOutputStream.write(filter_dict.toString().getBytes("utf-8"));
|
|
|
+// fileOutputStream.flush();
|
|
|
+// fileOutputStream.close();
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// //System.out.println(filter_dict.toString());
|
|
|
+//
|
|
|
+// return Result.success();
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+ @GetMapping("getField")
|
|
|
+ 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","未配置字段");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ resJson.put("fieldData",userField.getFieldData());
|
|
|
+ resJson.put("fieldState",userField.getFieldState());
|
|
|
+ }
|
|
|
+ return Result.success("ok",resJson);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("getFieldByName")
|
|
|
+ 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","未配置字段");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ resJson.put("fieldData",userField.getFieldData());
|
|
|
+ resJson.put("fieldState",userField.getFieldState());
|
|
|
+ }
|
|
|
+ return Result.success("ok",resJson);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //新增自定义模型
|
|
|
+ @PostMapping("addModel")
|
|
|
+ public Result addModel(@RequestBody String json,SysUser sysUser) throws IOException {
|
|
|
+ //获取用户模型,并按json文件保存
|
|
|
+ JSONObject req = JSON.parseObject(json);
|
|
|
+ String model_name=req.getString("modelname");
|
|
|
+ JSONObject resJson = new JSONObject();
|
|
|
+ //添加异常判断,重名模型名?
|
|
|
+ if(userModelService.findByUserAndModel(sysUser.getUserName(),model_name)!=null) {
|
|
|
+ resJson.put("state", 0);
|
|
|
+ return Result.success("ok",resJson);
|
|
|
+ }
|
|
|
+ //非重名
|
|
|
+ resJson.put("state", 1);
|
|
|
+
|
|
|
+ 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);
|
|
|
+
|
|
|
+ // 这个地方应该先加到审批页面上
|
|
|
+ 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.setUserName(userName);
|
|
|
+ new_model.setModelName(model_name);
|
|
|
+ new_model.setModelType(0);
|
|
|
+ new_model.setModelState("审批中");
|
|
|
+ new_model.setFieldCombine("暂未指定");
|
|
|
+ new_model.setSelectData(model_data);
|
|
|
+ userModelService.save(new_model);
|
|
|
+
|
|
|
+
|
|
|
+ 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());
|
|
|
+// System.out.println(model_list.get(0).getId());
|
|
|
+ resJson.put("modelData", model_list);
|
|
|
+
|
|
|
+ return Result.success("ok",resJson);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ // 获取当前模型
|
|
|
+ @PostMapping("getModelByName")
|
|
|
+ public Result getModelByName(@RequestBody String json,SysUser sysUser)
|
|
|
+ {
|
|
|
+
|
|
|
+ JSONObject resJson=new JSONObject();
|
|
|
+
|
|
|
+ JSONObject req = JSON.parseObject(json);
|
|
|
+
|
|
|
+ //user_name+model_name就是文件名
|
|
|
+ String model_name=req.getString("modelName");
|
|
|
+ String user_name=sysUser.getUserName();
|
|
|
+ //读取对应文件
|
|
|
+ JSONObject model=jsonFile.ReadJson(user_name+"_"+model_name);
|
|
|
+ System.out.println(model);
|
|
|
+
|
|
|
+// resJson.put("model", model);
|
|
|
+
|
|
|
+ return Result.success("ok",resJson);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("changeModelByID")
|
|
|
+ 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"));
|
|
|
+// System.out.println(id);
|
|
|
+// System.out.println(req.getString("modelid"));
|
|
|
+ UserModel model=userModelService.findByID(id);
|
|
|
+
|
|
|
+ //删除旧模型(文件)
|
|
|
+ String old_name=model.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.setModelState("审批中");
|
|
|
+ //重新审批
|
|
|
+ UserApproval approval=new UserApproval();
|
|
|
+ approval.setUserName(sysUser.getUserName());
|
|
|
+ approval.setApprovalId((long) 1);
|
|
|
+ approval.setData(model_name);
|
|
|
+ userApprovalService.save(approval);
|
|
|
+
|
|
|
+ userModelService.updateById(model);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return Result.success();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改产品号
|
|
|
+ @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.setProductNum(productNum);
|
|
|
+ userModelService.updateById(model);
|
|
|
+ return Result.success();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //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);
|
|
|
+ model.setFieldCombine(field_combine);
|
|
|
+ field.setModelName(modelName);
|
|
|
+ userModelService.updateById(model);
|
|
|
+ userFieldService.updateById(field);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ //sxr编辑字段
|
|
|
+// @PostMapping("combineFieldModel")
|
|
|
+// public Result combineFieldModel(@RequestBody String json,SysUser sysUser)
|
|
|
+// {
|
|
|
+// JSONObject req=JSON.parseObject(json);
|
|
|
+// String field_id=req.getString("field_id");
|
|
|
+// String field_name=req.getString("field_name");
|
|
|
+// String selected_field_data=req.getString("selected_field_data");
|
|
|
+// String modelName=req.getString("model_name");
|
|
|
+// UserField field=userFieldService.findByFieldCombine(field_combine);
|
|
|
+// field.setModelName(modelName);
|
|
|
+// userFieldService.updateById(field);
|
|
|
+// return Result.success();
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ //这个接口是将模型从审核通过/暂停改为上线
|
|
|
+// 审批中/已上线/审核通过/暂停使用
|
|
|
+ @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");
|
|
|
+
|
|
|
+ System.out.println(id);
|
|
|
+ UserModel model=userModelService.findByID(id);
|
|
|
+
|
|
|
+ model.setModelState(state);
|
|
|
+
|
|
|
+ userModelService.updateById(model);
|
|
|
+
|
|
|
+ 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"));
|
|
|
+ String fieldCombine = req.getString("fieldCombine");
|
|
|
+ if(fieldCombine.equals("暂未指定")){
|
|
|
+
|
|
|
+ }else{
|
|
|
+ UserField field=userFieldService.findByFieldCombine(fieldCombine);
|
|
|
+ field.setModelName("暂未指定");
|
|
|
+ userFieldService.updateById(field);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ userModelService.removeModelByID(id);
|
|
|
+ return Result.success();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取审核模块的详情,主要是模型详情
|
|
|
+ @PostMapping("getDetails")
|
|
|
+ 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();
|
|
|
+ //模型类型
|
|
|
+ res.put("model_type",model.getModelType());
|
|
|
+ if(model.getModelType()==0) {//自定义模型
|
|
|
+ JSONObject model_data = jsonFile.ReadJson(user_name + "_" + model_name);
|
|
|
+ if (model_data != null) {
|
|
|
+ res.put("error_code", 0);
|
|
|
+ res.put("model_data", model_data);
|
|
|
+ } else {
|
|
|
+ res.put("error_code", 1);
|
|
|
+ res.put("error_info", "模型不存在!");
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(model.getModelType()==1 || model.getModelType()==2)
|
|
|
+ {
|
|
|
+ res.put("output_list",model.getOutputList());
|
|
|
+ res.put("other_data",model.getOtherData());
|
|
|
+
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ 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)
|
|
|
+ {
|
|
|
+ JSONObject res = new JSONObject();
|
|
|
+ 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.setModelState("审核通过");
|
|
|
+ userModelService.updateById(model);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //不通过
|
|
|
+ else {
|
|
|
+ int reason=jsonrq.getInteger("reason");
|
|
|
+ UserModel model = userModelService.findByUserAndModel(user_name, model_name);
|
|
|
+ if(model!=null) {
|
|
|
+ model.setModelState("审核不通过:"+reason_list[reason]);
|
|
|
+ userModelService.updateById(model);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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) {
|
|
|
+ userField.setFieldState("审核通过");
|
|
|
+ userFieldService.updateById(userField);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ UserField userField=userFieldService.findByUserName(user_name);
|
|
|
+ if(userField!=null) {
|
|
|
+ userField.setFieldState("审核不通过");
|
|
|
+ userFieldService.updateById(userField);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ System.out.println(id);
|
|
|
+ userApprovalService.removeById(id);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|