0952bc5315e2244f736399da0dc754349233eb53.svn-base 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package cn.com.goldenwater.dcproj.controller.sdqa;
  2. import cn.com.goldenwater.dcproj.model.BisInspQaScoreSd;
  3. import cn.com.goldenwater.dcproj.model.BisInspStstnScore;
  4. import cn.com.goldenwater.dcproj.param.BisInspQaScoreSdParam;
  5. import cn.com.goldenwater.dcproj.service.BisInspQaScoreSdService;
  6. import cn.com.goldenwater.core.web.BaseController;
  7. import cn.com.goldenwater.core.web.BaseResponse;
  8. import cn.com.goldenwater.dcproj.service.BisInspStstnScoreService;
  9. import cn.com.goldenwater.dcproj.utils.StringUtils;
  10. import cn.com.goldenwater.id.util.UuidUtil;
  11. import io.swagger.annotations.Api;
  12. import io.swagger.annotations.ApiOperation;
  13. import io.swagger.annotations.ApiParam;
  14. import org.slf4j.Logger;
  15. import org.slf4j.LoggerFactory;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.util.Assert;
  18. import org.springframework.web.bind.annotation.PathVariable;
  19. import org.springframework.web.bind.annotation.RequestBody;
  20. import org.springframework.web.bind.annotation.RequestMapping;
  21. import org.springframework.web.bind.annotation.RequestMethod;
  22. import org.springframework.web.bind.annotation.RequestParam;
  23. import org.springframework.web.bind.annotation.RestController;
  24. import java.lang.reflect.Field;
  25. import java.util.List;
  26. import java.util.stream.Stream;
  27. /**
  28. * @author lhc
  29. * @date 2024-4-7
  30. */
  31. @Api(value = "xxx管理",tags="xxx管理")
  32. @RestController
  33. @RequestMapping("/bis/insp/sdqa/score")
  34. public class BisInspQaScoreSdController extends BaseController {
  35. private Logger logger = LoggerFactory.getLogger(getClass());
  36. @Autowired
  37. private BisInspQaScoreSdService bisInspQaScoreSdService;
  38. @Autowired
  39. private BisInspStstnScoreService bisInspStstnScoreService;
  40. @ApiOperation(value = "添加xxx")
  41. @RequestMapping(value = "", method = RequestMethod.POST)
  42. public BaseResponse<BisInspQaScoreSd> insert(@ApiParam(name = "bisInspQaScoreSd", value = "BisInspQaScoreSd", required = true) @RequestBody BisInspQaScoreSd bisInspQaScoreSd) throws NoSuchFieldException, IllegalAccessException {
  43. bisInspQaScoreSd.setPersId(getCurrentPersId());
  44. bisInspQaScoreSdService.update(bisInspQaScoreSd);
  45. Field[] fields = bisInspQaScoreSd.getClass().getDeclaredFields();
  46. for(Field file : fields){
  47. if(file.getName().indexOf("Note")>-1 && !"note".equals(file.getName())){
  48. Field newFiled = bisInspQaScoreSd.getClass().getDeclaredField(file.getName());
  49. newFiled.setAccessible(true);
  50. BisInspStstnScore bisInspStstnScore = bisInspStstnScoreService.getByCaseScore(bisInspQaScoreSd.getId(), file.getName().replace("Note",""));
  51. if(bisInspStstnScore!=null){
  52. bisInspStstnScore.setExplain(newFiled.get(bisInspQaScoreSd).toString());
  53. bisInspStstnScoreService.update(bisInspStstnScore);
  54. }else{
  55. BisInspStstnScore bisInspStstnScore_n = new BisInspStstnScore();
  56. bisInspStstnScore_n.setCaseId(bisInspQaScoreSd.getId());
  57. bisInspStstnScore_n.setScoreName(file.getName().replace("Note",""));
  58. bisInspStstnScore_n.setExplain(newFiled.get(bisInspQaScoreSd).toString());
  59. bisInspStstnScoreService.insert(bisInspStstnScore_n);
  60. }
  61. }
  62. }
  63. return buildSuccessResponse(bisInspQaScoreSd);
  64. }
  65. @ApiOperation(value = "根据ID删除xxx")
  66. @RequestMapping(value = "delete/{id}", method = RequestMethod.POST)
  67. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  68. int ret = bisInspQaScoreSdService.delete(id);
  69. return buildSuccessResponse();
  70. }
  71. @ApiOperation(value = "根据ID获取xxx(单表)")
  72. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  73. public BaseResponse<BisInspQaScoreSd> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) throws Exception{
  74. BisInspQaScoreSd bisInspQaScoreSd = bisInspQaScoreSdService.get(id);
  75. Field[] fields = bisInspQaScoreSd.getClass().getDeclaredFields();
  76. for(Field file : fields){
  77. if(file.getName().indexOf("Note")>-1 && !"note".equals(file.getName())){
  78. Field newFiled = bisInspQaScoreSd.getClass().getDeclaredField(file.getName());
  79. newFiled.setAccessible(true);
  80. BisInspStstnScore bisInspStstnScore = bisInspStstnScoreService.getByCaseScore(bisInspQaScoreSd.getId(), file.getName().replace("Note",""));
  81. if(bisInspStstnScore!=null){
  82. newFiled.set(bisInspQaScoreSd,bisInspStstnScore.getExplain());
  83. }else{
  84. newFiled.set(bisInspQaScoreSd,"");
  85. }
  86. }
  87. }
  88. return buildSuccessResponse(bisInspQaScoreSd);
  89. }
  90. @ApiOperation(value = "获取工程质量监督履职情况评分")
  91. @RequestMapping(value = "/findList/{rgstrId}", method = RequestMethod.GET)
  92. public BaseResponse<List<BisInspQaScoreSd>> findList(@ApiParam(name = "rgstrId", value = "rgstrId", required = true) @PathVariable String rgstrId) {
  93. BisInspQaScoreSdParam bisInspQaScoreSdParam = new BisInspQaScoreSdParam();
  94. bisInspQaScoreSdParam.setRgstrId(rgstrId);
  95. List<BisInspQaScoreSd> list = bisInspQaScoreSdService.findList(bisInspQaScoreSdParam);
  96. return buildSuccessResponse(list);
  97. }
  98. }