Browse Source

功能完善

hlf 4 months ago
parent
commit
d3d6bee2ff

+ 10 - 28
ims-service/ims-eval/src/main/java/com/ims/eval/controller/IndicatorController.java

@@ -3,23 +3,20 @@ package com.ims.eval.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.ims.eval.config.CustomException;
+import com.ims.eval.entity.Indicator;
 import com.ims.eval.entity.dto.request.IndicatorDTO;
 import com.ims.eval.entity.dto.request.IndicatorDictionaryDTO;
 import com.ims.eval.entity.dto.result.R;
-import com.ims.eval.entity.Indicator;
 import com.ims.eval.service.IIndicatorDictionaryService;
 import com.ims.eval.service.IIndicatorService;
 import io.swagger.annotations.ApiOperation;
-import lombok.extern.log4j.Log4j2;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import java.util.Map;
 
 /**
  * <p>
@@ -66,11 +63,10 @@ public class IndicatorController {
 				  @RequestParam(value = "dept", required = false) String dept,
 				  @RequestParam(value = "company", required = false) String company,
 				  @RequestParam(value = "evaluationCycle", required = false) String evaluationCycle) {
-		IPage<Indicator> list = iIndicatorService.list2(pageNum, pageSize, id, indicatorName, indicatorCode, binSection, binStage, dept, company,evaluationCycle);
+		IPage<Indicator> list = iIndicatorService.list2(pageNum, pageSize, id, indicatorName, indicatorCode, binSection, binStage, dept, company, evaluationCycle);
 		return R.ok().data(list);
 	}
 
-
 	/**
 	 * 查询所有数据
 	 *
@@ -94,7 +90,7 @@ public class IndicatorController {
 		@RequestParam(value = "dept", required = false) String dept,
 		@RequestParam(value = "company", required = false) String company,
 		@RequestParam(value = "evaluationCycle", required = false) String evaluationCycle) {
-		List<Indicator> list = iIndicatorService.listAll(id, indicatorName, indicatorCode, binSection, binStage, dept, company,evaluationCycle);
+		List<Indicator> list = iIndicatorService.listAll(id, indicatorName, indicatorCode, binSection, binStage, dept, company, evaluationCycle);
 		return R.ok().data(list);
 	}
 
@@ -107,17 +103,14 @@ public class IndicatorController {
 	@GetMapping(value = "selectByCode")
 	public R selectByCode(
 		@RequestParam(value = "indicatorCede", required = false) String indicatorCode) {
-
 		List<IndicatorDictionaryDTO> list = new ArrayList<>();
 		Indicator indicator = iIndicatorService.selectByCode(indicatorCode);
-		if(indicator != null){
-			 list = indicatorDictionaryService.list(indicator.getId(),"","");
+		if (indicator != null) {
+			list = indicatorDictionaryService.list(indicator.getId(), "", "");
 		}
 		return R.ok().data(list);
 	}
 
-
-
 	/**
 	 * 根据指标id获取主子指标
 	 *
@@ -127,10 +120,8 @@ public class IndicatorController {
 	@GetMapping(value = "selectById")
 	public R selectById(
 		@RequestParam(value = "id", required = false) String id) {
-
 		List<IndicatorDictionaryDTO> list = new ArrayList<>();
 		IndicatorDTO indicator = iIndicatorService.getById(id);
-
 		return R.ok().data(indicator);
 	}
 
@@ -145,7 +136,6 @@ public class IndicatorController {
 	@PostMapping(value = "/save")
 	@ApiOperation(value = "新增(修改)", notes = "新增(修改)")
 	public R addAll(@RequestBody Indicator indicator) {
-
 		try {
 			boolean b = iIndicatorService.saveOrUpdate(indicator);
 			if (b) {
@@ -153,7 +143,7 @@ public class IndicatorController {
 			} else {
 				return R.error().data("保存失败!");
 			}
-		} catch (CustomException e){
+		} catch (CustomException e) {
 			return R.customError(e.getMessage()).data("失败!");
 		}
 	}
@@ -169,9 +159,6 @@ public class IndicatorController {
 	@PostMapping(value = "/saveGroup")
 	@ApiOperation(value = "新增(修改)", notes = "新增(修改)")
 	public R saveGroup(@RequestBody IndicatorDTO indicator) {
-
-
-
 		try {
 			boolean b = iIndicatorService.saveGroup(indicator);
 			if (b) {
@@ -179,18 +166,15 @@ public class IndicatorController {
 			} else {
 				return R.error().data("保存失败!");
 			}
-		} catch (CustomException e){
-			log.error("错误",e);
+		} catch (CustomException e) {
+			log.error("错误", e);
 			return R.customError(e.getMessage()).data("失败!");
-		}catch (Exception e2){
-			log.error("错误",e2);
+		} catch (Exception e2) {
+			log.error("错误", e2);
 			return R.customError(e2.getMessage()).data("失败!");
 		}
 	}
 
-
-
-
 	/**
 	 * 批量删除
 	 *
@@ -209,6 +193,4 @@ public class IndicatorController {
 			return R.error().data("删除失败!");
 		}
 	}
-
-
 }

+ 12 - 14
ims-service/ims-eval/src/main/java/com/ims/eval/controller/IndicatorDictionaryController.java

@@ -2,15 +2,14 @@ package com.ims.eval.controller;
 
 
 import com.ims.eval.config.CustomException;
+import com.ims.eval.entity.IndicatorDictionary;
 import com.ims.eval.entity.dto.request.IndicatorDictionaryDTO;
 import com.ims.eval.entity.dto.result.R;
-import com.ims.eval.entity.IndicatorDictionary;
 import com.ims.eval.service.IIndicatorDictionaryService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -48,7 +47,6 @@ public class IndicatorDictionaryController {
 
 
 	/**
-
 	 * @param indicatorId 指标ID
 	 * @param optionCode  选项编码
 	 * @param optionName  选项名称
@@ -57,9 +55,9 @@ public class IndicatorDictionaryController {
 	//@ImsPreAuth("eval:indicator:view")
 	@RequestMapping(value = "listGroup")
 	public List<IndicatorDictionaryDTO> listGroup(
-										  @RequestParam(value = "indicatorId", required = false) String indicatorId,
-										  @RequestParam(value = "optionCode", required = false) String optionCode,
-										  @RequestParam(value = "optionName", required = false) String optionName) {
+		@RequestParam(value = "indicatorId", required = false) String indicatorId,
+		@RequestParam(value = "optionCode", required = false) String optionCode,
+		@RequestParam(value = "optionName", required = false) String optionName) {
 		List<IndicatorDictionaryDTO> list = indicatorDictionaryService.list(indicatorId, optionCode, optionName);
 		return list;
 	}
@@ -84,7 +82,7 @@ public class IndicatorDictionaryController {
 			} else {
 				return R.error().data("保存失败!");
 			}
-		} catch (CustomException e){
+		} catch (CustomException e) {
 			return R.customError(e.getMessage()).data("失败!");
 		}
 	}
@@ -108,9 +106,9 @@ public class IndicatorDictionaryController {
 			} else {
 				return R.error().data("保存失败!");
 			}
-		} catch (CustomException e){
+		} catch (CustomException e) {
 			return R.customError(e.getMessage()).data("失败!");
-		}catch (Exception e1){
+		} catch (Exception e1) {
 			return R.customError("操作失败").data("失败!");
 		}
 	}
@@ -126,12 +124,12 @@ public class IndicatorDictionaryController {
 	@ApiOperation(value = "删除", notes = "删除")
 	public R deleteAll(@PathVariable("ids") String ids) {
 		String[] strings = ids.split(",");
-		boolean b = indicatorDictionaryService.removeByIds(Arrays.asList(strings));
-		if (b) {
-			return R.ok().data(b);
-		} else {
-			return R.error().data("删除失败!");
+		for (String str : strings){
+			IndicatorDictionary indicatorDictionary = indicatorDictionaryService.getById(str);
+			indicatorDictionary.setDelFlag("0");
+			indicatorDictionaryService.updateById(indicatorDictionary);
 		}
+		return R.ok();
 	}
 
 }

+ 5 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/entity/IndicatorDictionary.java

@@ -5,8 +5,6 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
 import java.util.Date;
 
 /**
@@ -106,5 +104,10 @@ public class IndicatorDictionary extends Model {
 	 */
 	private Boolean  isQuantified;
 
+	/**
+	 * 删除标志(1存在 0删除)
+	 */
+	private String  delFlag;
+
 
 }

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/IndicatorDictionaryServiceImpl.java

@@ -46,7 +46,6 @@ public class IndicatorDictionaryServiceImpl extends ServiceImpl<IndicatorDiction
 		if (StringUtils.isNotEmpty(optionName)) {
 			qw.lambda().like(IndicatorDictionary::getOptionName, optionName);
 		}
-
 		qw.lambda().orderByAsc(IndicatorDictionary::getOptionOrder);
 
 		List<IndicatorDictionary> list = baseMapper.selectList(qw);
@@ -138,6 +137,7 @@ public class IndicatorDictionaryServiceImpl extends ServiceImpl<IndicatorDiction
 		if (StringUtils.isNotEmpty(optionName)) {
 			qw.lambda().like(IndicatorDictionary::getOptionName, optionName);
 		}
+		qw.lambda().eq(IndicatorDictionary::getDelFlag, "1");
 		qw.lambda().orderByAsc(IndicatorDictionary::getOptionOrder);
 
 		List<IndicatorDictionary> list = baseMapper.selectList(qw);

+ 30 - 24
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/IndicatorServiceImpl.java

@@ -144,7 +144,6 @@ public class IndicatorServiceImpl extends ServiceImpl<IndicatorMapper, Indicator
 			if (null != list && list.size() > 0) {
 				throw new CustomException("当前指标code已存在");
 			}
-
 			dto.setCreateTime(new Date());
 		} else {
 			dto.setUpdateTime(new Date());
@@ -162,36 +161,43 @@ public class IndicatorServiceImpl extends ServiceImpl<IndicatorMapper, Indicator
 			}
 			for (IndicatorDictionary i : dto2.getList()) {
 
+				IndicatorDictionary indicatorDictionary = new IndicatorDictionary();
+
 				String decode = URLDecoder.decode(i.getFormula(), "UTF-8");
 				String formula = decode.replaceAll(" ", "+");
 
-				if (null != i && (null == i.getId() || "".equals(i.getId().trim()))) {
-					QueryWrapper<IndicatorDictionary> qw = new QueryWrapper<>();
-					qw.lambda().eq(IndicatorDictionary::getIndicatorId, dto.getId());
-					qw.lambda().eq(IndicatorDictionary::getChildCode, dto2.getChildCode());
-					qw.lambda().eq(IndicatorDictionary::getOptionCode, i.getOptionCode());
-					List<IndicatorDictionary> list2 = indicatorDictionaryMapper.selectList(qw);
-					if (null != list2 && list2.size() > 0) {
+				QueryWrapper<IndicatorDictionary> qw = new QueryWrapper<>();
+				qw.lambda().eq(IndicatorDictionary::getIndicatorId, dto.getId());
+				qw.lambda().eq(IndicatorDictionary::getChildCode, dto2.getChildCode());
+				qw.lambda().eq(IndicatorDictionary::getOptionCode, i.getOptionCode());
+				qw.lambda().eq(IndicatorDictionary::getDelFlag, "1");
+				List<IndicatorDictionary> list2 = indicatorDictionaryMapper.selectList(qw);
+
+				if (null != list2 && list2.size() > 0) {
+					if (null == i.getId()) {
 						throw new CustomException("当前属性code已存在");
+					} else {
+						for (IndicatorDictionary idic : list2){
+							idic.setDelFlag("0");
+							indicatorDictionaryService.updateById(idic);
+						}
 					}
-					i.setIndicatorId(dto.getId());
-					i.setOptionOrder(i.getOptionOrder());
-					i.setChildCode(dto2.getChildCode());
-					i.setChildName(dto2.getChildName());
-					i.setFormula(formula);
-					i.setCreateTime(new Date());
-					i.setOptionName(null == CacheContext.ddNameMap.get(i.getOptionCode()) ? "未知属性" : CacheContext.ddNameMap.get(i.getOptionCode()));
-				} else {
-					i.setIndicatorId(dto.getId());
-					i.setOptionOrder(i.getOptionOrder());
-					i.setChildCode(dto2.getChildCode());
-					i.setChildName(dto2.getChildName());
-					i.setFormula(formula);
-					i.setOptionName(null == CacheContext.ddNameMap.get(i.getOptionCode()) ? "未知属性" : CacheContext.ddNameMap.get(i.getOptionCode()));
-					i.setUpdateTime(new Date());
 				}
 
-				b = indicatorDictionaryService.saveOrUpdate(i);
+				indicatorDictionary.setIndicatorId(dto.getId());
+				indicatorDictionary.setChildName(dto2.getChildName());
+				indicatorDictionary.setChildCode(dto2.getChildCode());
+				indicatorDictionary.setOptionName(null == CacheContext.ddNameMap.get(i.getOptionCode()) ? "未知属性" : CacheContext.ddNameMap.get(i.getOptionCode()));
+				indicatorDictionary.setOptionCode(i.getOptionCode());
+				indicatorDictionary.setOptionOrder(i.getOptionOrder());
+				indicatorDictionary.setDes(i.getDes());
+				indicatorDictionary.setCreateTime(new Date());
+				indicatorDictionary.setFormula(formula);
+				indicatorDictionary.setIsShow(i.getIsShow());
+				indicatorDictionary.setIsQuantified(i.getIsQuantified());
+				indicatorDictionary.setDelFlag("1");
+
+				b = indicatorDictionaryService.save(indicatorDictionary);
 				if (!b) {
 					throw new CustomException("指标明细存失败");
 				}