提交 876b55e4 authored 作者: 马晨俊's avatar 马晨俊

Merge branch 'master' of git.yfzx.zjtys.com.cn:912-system/monitor/inspect

package com.zjty.inspect.controller;
import com.zjty.inspect.entity.Evaluation;
import com.zjty.inspect.entity.PageResult;
import com.zjty.inspect.entity.RuleQo;
import com.zjty.inspect.service.EvaluationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@RequestMapping("/evaluation")
@Api(value = "评估报告管理接口",description = "评估报告管理接口,提供页面的增、删、改、查")
public class EvaluationController {
@Autowired
private EvaluationService evaluationService;
/**
* 新增评估报告
* @param evaluation 评估报告
* @return
*/
@PostMapping
@ApiOperation("新增评估报告")
public ResponseEntity rule(@RequestBody Evaluation evaluation){
evaluationService.save(evaluation);
return ResponseEntity.ok(200);
}
/**
* 修改评估报告
* @param evaluation 规则封装
* @param id id
* @return
*/
@PostMapping(value = "/{id}")
@ApiOperation("修改评估报告")
public ResponseEntity update(@RequestBody Evaluation evaluation,@PathVariable String id){
evaluation.setId(id);
evaluationService.update(evaluation);
return ResponseEntity.ok(200);
}
/**
* 根据id删除评估报告
* @param id id
* @return
*/
@ApiOperation("根据id删除评估报告")
@DeleteMapping(value = "/{id}")
public ResponseEntity deleteById(@PathVariable String id){
evaluationService.delete(id);
return ResponseEntity.ok(200);
}
/**
* 分页+多条件查询
* @param searchMap 查询条件封装
* @param page 页码
* @param size 页大小
* @return 分页结果
*/
@ApiOperation("分页查询页面列表")
@ApiImplicitParams({
@ApiImplicitParam(name="page",value = "页码",required=true,paramType="path",dataType="int"),
@ApiImplicitParam(name="size",value = "每页记录数",required=true,paramType="path",dataType="int")
})
@RequestMapping(value="/search/{page}/{size}",method= RequestMethod.POST)
public ResponseEntity findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){
Page<Evaluation> pageList = evaluationService.findSearch(searchMap, page, size);
return ResponseEntity.ok(new PageResult<Evaluation>(pageList.getTotalElements(), pageList.getContent()) );
}
}
......@@ -3,10 +3,7 @@ package com.zjty.inspect.controller;
import com.alibaba.fastjson.JSON;
import com.zjty.inspect.dao.TechnologyDao;
import com.zjty.inspect.entity.*;
import com.zjty.inspect.service.InspectService;
import com.zjty.inspect.service.ParameterService;
import com.zjty.inspect.service.ReportService;
import com.zjty.inspect.service.TechnologyService;
import com.zjty.inspect.service.*;
import com.zjty.inspect.utils.*;
import freemarker.template.TemplateException;
import io.swagger.annotations.Api;
......@@ -16,8 +13,11 @@ import org.apache.commons.io.FileUtils;
import org.apache.tomcat.util.http.fileupload.disk.DiskFileItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
......@@ -37,6 +37,8 @@ import java.util.*;
public class InspectController {
@Autowired
private InspectService inspectService;
@Autowired
private EvaluationService evaluationService;
@Autowired
private TechnologyService technologyService;
......@@ -230,6 +232,7 @@ public class InspectController {
List<TechnologyContent> technologyContents = new ArrayList<>();
for (Warn warn:warns) {
TechnologyContent technologyContent = new TechnologyContent();
//technologyContent.setLocal(warn.get);
technologyContent.setFile(warn.getFilePath());
technologyContent.setKeyWord(warn.getRule());
technologyContent.setPosition(warn.getLineNum().toString());
......@@ -334,11 +337,22 @@ public class InspectController {
assessmentReport.setDifficultyAssessment(difficultyAssessment);
WorkLoadUtil workLoadUtil = new WorkLoadUtil();
//r:人工费
RestTemplate restTemplate = new RestTemplate();
//restTemplate.exchange("localhost:8079/config", HttpMethod.GET,new HttpEntity<>())
//计算f
Budget budget = inspect.getBudgets().getBudget().get(0);
double f = budget.getProportion()*budget.getSysFund()*budget.getMoneyRate()*budget.getCoefficient();
System.out.println("F:"+f);
workLoadUtil.result(reform, assessmentReport, f, 120);
Evaluation evaluation=new Evaluation();
//输入参数
String in = JSON.toJSONString(reform);
//输出参数
String out = JSON.toJSONString(assessmentReport);
evaluation.setInEva(in);
evaluation.setOutEva(out);
evaluation.setUsername(reform.getUsername());
evaluationService.save(evaluation);
return ResponseEntity.ok(assessmentReport);
}
......
package com.zjty.inspect.dao;
import com.zjty.inspect.entity.Evaluation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface EvaluationDao extends JpaRepository<Evaluation,String>, JpaSpecificationExecutor<Evaluation> {
Evaluation findByUsernameAndIdNot(String username,String id);
}
......@@ -29,6 +29,11 @@ public class BrowserDifficulty {
*/
private double difficulty = 1.1;
/**
* 工作量
*/
private double load = 0.0;
/**
* 样式
*/
......
......@@ -32,6 +32,11 @@ public class DatabaseDifficulty {
*/
private double difficulty = 1.1;
/**
* 工作量
*/
private double load = 0.0;
/**
* 依赖
*/
......
package com.zjty.inspect.entity;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Generated;
import org.hibernate.annotations.GenerationTime;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.sql.Timestamp;
import java.util.Date;
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Data
@ApiModel(description = "评估报告管理类")
public class Evaluation {
@Id
@Column( length = 48)
private String id;
private String username;
@Column(columnDefinition = "TEXT")
private String inEva;
@Column(columnDefinition = "TEXT")
private String outEva;
/**
* 数据创建时间
*/
@Column(name="create_time",columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP",insertable = false,updatable = false)
@CreatedDate
private Date createDate;
/**
* 数据更新时间
*/
@Column(name="update_time",columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP",insertable = false)
@LastModifiedDate
private Date updateDate;
}
......@@ -30,6 +30,11 @@ public class FrameDifficulty {
*/
private double difficulty = 1.1;
/**
* 工作量
*/
private double load = 0.0;
/**
* 详情 1:混合 2:前后端分离
*/
......
......@@ -32,6 +32,11 @@ public class MiddlewareDifficulty {
*/
private double difficulty = 1.1;
/**
* 工作量
*/
private double load = 0.0;
/**
* 依赖详情
*/
......
......@@ -32,6 +32,11 @@ public class ProgramDifficulty {
*/
private double difficulty = 1.1;
/**
* 工作量
*/
private double load = 0.0;
/**
* 依赖详情
*/
......
......@@ -144,7 +144,7 @@ public class Reform {
private Database database;
/**
* 迁移策略 1:休息日 2:晚间切换
* 迁移策略 1:休息日 2:晚间切换 3:短暂停止
*/
private Integer strategy;
/**
......
package com.zjty.inspect.service;
import com.zjty.inspect.entity.Evaluation;
import com.zjty.inspect.entity.Rule;
import org.springframework.data.domain.Page;
import java.util.List;
import java.util.Map;
public interface EvaluationService {
void save(Evaluation evaluation);
void update(Evaluation evaluation);
void delete(String id);
Page<Evaluation> findSearch(Map searchMap, int page, int size);
}
......@@ -5,9 +5,11 @@ import com.zjty.inspect.entity.Category;
import com.zjty.inspect.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class CategoryServiceImpl implements CategoryService {
@Autowired
private CategoryDao categoryDao;
......
......@@ -5,12 +5,14 @@ import com.zjty.inspect.entity.Config;
import com.zjty.inspect.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@Service
@Transactional(rollbackFor = Exception.class)
public class ConfigServiceImpl implements ConfigService {
@Autowired
......
package com.zjty.inspect.service.impl;
import com.zjty.inspect.dao.EvaluationDao;
import com.zjty.inspect.entity.Evaluation;
import com.zjty.inspect.entity.Rule;
import com.zjty.inspect.service.EvaluationService;
import com.zjty.inspect.utils.TimeUtil;
import com.zjty.inspect.utils.UUIDUtil;
import io.netty.util.internal.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
@Transactional(rollbackFor = Exception.class)
public class EvaluationServiceImpl implements EvaluationService {
@Autowired
private EvaluationDao evaluationDao;
@Override
public void save(Evaluation evaluation) {
String uuid = UUIDUtil.getUUID();
evaluation.setId(uuid);
Evaluation evaluation1 = evaluationDao.findByUsernameAndIdNot(evaluation.getUsername(),evaluation.getId());
if(evaluation1!=null){
return;
}
evaluationDao.save(evaluation);
}
@Override
public void update(Evaluation evaluation) {
Evaluation evaluation1 = evaluationDao.findByUsernameAndIdNot(evaluation.getUsername(),evaluation.getId());
if(evaluation1!=null){
return;
}
if(StringUtil.isNullOrEmpty(evaluation.getInEva())) {
return;
}
if(StringUtil.isNullOrEmpty(evaluation.getOutEva())) {
return;
}
evaluationDao.save(evaluation);
}
@Override
public void delete(String id) {
evaluationDao.deleteById(id);
}
@Override
public Page<Evaluation> findSearch(Map searchMap, int page, int size) {
Specification<Evaluation> specification = createSpecification(searchMap);
PageRequest pageRequest = PageRequest.of(page - 1, size);
return evaluationDao.findAll(specification, pageRequest);
}
/**
* 动态条件构建
*
* @param searchMap
* @return
*/
private Specification<Evaluation> createSpecification(Map searchMap) {
return new Specification<Evaluation>() {
@Override
public Predicate toPredicate(Root<Evaluation> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
List<Predicate> predicateList = new ArrayList<Predicate>();
if (searchMap.get("username") != null && !"".equals(searchMap.get("username"))) {
predicateList.add(cb.like(root.get("username").as(String.class), "%" + (String) searchMap.get("username") + "%"));
}
return cb.and(predicateList.toArray(new Predicate[predicateList.size()]));
}
};
}
}
......@@ -50,7 +50,7 @@ spring.resources.static-locations=classpath:/uploads/
# mysql\u6570\u636E\u5E93\u914D\u7F6E
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.url=jdbc:mysql://192.168.1.249:3306/bservice?useSSL=false&serverTimezone=UTC&autoReconnect=true&characterEncoding=utf-8
spring.datasource.url=jdbc:mysql://localhost:3306/adaptation?useSSL=false&serverTimezone=UTC&autoReconnect=true&characterEncoding=utf-8
spring.datasource.url=jdbc:mysql://120.55.57.35:3306/adaptation?useSSL=false&serverTimezone=UTC&autoReconnect=true&characterEncoding=utf-8
spring.datasource.username=root
spring.datasource.password=root
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论