|
@@ -0,0 +1,89 @@
|
|
|
+package com.rongwei.bscommon.sys.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+
|
|
|
+import com.rongwei.bscommon.sys.dao.TestrunDao;
|
|
|
+
|
|
|
+import com.rongwei.bscommon.sys.service.TestrunService;
|
|
|
+
|
|
|
+import com.rongwei.bsentity.domain.TestrunDo;
|
|
|
+
|
|
|
+import com.rongwei.bsentity.vo.TestrunVo;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class TestrunServiceImpl extends ServiceImpl<TestrunDao, TestrunDo> implements TestrunService {
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void DataUpdate(Map<String, Object> map) {
|
|
|
+
|
|
|
+ Object dataObj = map.get("dataList");
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(dataObj)) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ List<TestrunVo> list = convertToTestrunVoList(dataObj);
|
|
|
+ if (list.isEmpty()) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (TestrunVo vo : list){
|
|
|
+
|
|
|
+ TestrunDo testrunDo = convertToTestrunDo(vo);
|
|
|
+ UpdateWrapper<TestrunDo> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.eq("ID", testrunDo.getId()); // 设置更新条件:ID 等于指定值
|
|
|
+
|
|
|
+ if (vo.getISTITLE() == null || vo.getISTITLE().isEmpty()) {
|
|
|
+ // ISTITLE 为空时,只更新 PID 和 STATUS
|
|
|
+ updateWrapper.set("PID", testrunDo.getPid()) // 更新 pid
|
|
|
+ .set("STATUS", testrunDo.getStatus()); // 更新 status
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // ISTITLE 不为空时,更新 PID、STATUS 和 ISTITLE
|
|
|
+ updateWrapper.set("PID", testrunDo.getPid()) // 更新 pid
|
|
|
+ .set("STATUS", testrunDo.getStatus()) // 更新 status
|
|
|
+ .set("ISTITLE", vo.getISTITLE()); // 更新 istitle
|
|
|
+ }
|
|
|
+
|
|
|
+ // 执行更新
|
|
|
+ this.update(null, updateWrapper);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<TestrunVo> convertToTestrunVoList(Object dataObj) {
|
|
|
+ List<TestrunVo> list = new ArrayList<>();
|
|
|
+ if (dataObj instanceof List) {
|
|
|
+ List<Map<String, Object>> mapList = (List<Map<String, Object>>) dataObj;
|
|
|
+ for (Map<String, Object> item : mapList) {
|
|
|
+ TestrunVo vo = new TestrunVo();
|
|
|
+ vo.setID((String) item.get("ID"));
|
|
|
+ vo.setPID((String) item.get("PID"));
|
|
|
+ vo.setSTATUS((String) item.get("STATUS"));
|
|
|
+ vo.setISTITLE((String) item.get("ISTITLE"));
|
|
|
+ list.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ private TestrunDo convertToTestrunDo(TestrunVo vo) {
|
|
|
+
|
|
|
+ TestrunDo testrunDo = new TestrunDo();
|
|
|
+ testrunDo.setPid(vo.getPID());
|
|
|
+ testrunDo.setId(vo.getID());
|
|
|
+ testrunDo.setStatus(vo.getSTATUS());
|
|
|
+ testrunDo.setIstitle(vo.getISTITLE());
|
|
|
+ return testrunDo;
|
|
|
+ }
|
|
|
+}
|