Browse Source

试车检查按模板导入

wangbo 9 tháng trước cách đây
mục cha
commit
2ce089bf53

+ 9 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/TestrunDao.java

@@ -0,0 +1,9 @@
+package com.rongwei.bscommon.sys.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.rongwei.bsentity.domain.DebtfreeDo;
+import com.rongwei.bsentity.domain.TestrunDo;
+
+
+public interface TestrunDao extends BaseMapper<TestrunDo> {
+}

+ 20 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/TestrunService.java

@@ -0,0 +1,20 @@
+package com.rongwei.bscommon.sys.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwei.bsentity.domain.DebtfreeDo;
+import com.rongwei.bsentity.domain.TestrunDo;
+
+import java.util.Map;
+
+
+public interface TestrunService extends IService<TestrunDo> {
+
+
+
+    void DataUpdate(Map<String, Object> map);
+
+
+
+
+
+}

+ 89 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/TestrunServiceImpl.java

@@ -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;
+    }
+}

+ 21 - 0
business-entity/src/main/java/com/rongwei/bsentity/domain/TestrunDo.java

@@ -0,0 +1,21 @@
+package com.rongwei.bsentity.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.rongwei.rwcommon.base.BaseDo;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+@TableName("ZHCX_COMMISSION_CHECK_BASE_INFO_DETAIL")
+public class TestrunDo extends BaseDo {
+    @TableField("ID")
+    private String id;
+    @TableField("STATUS")
+    private String  status;
+    @TableField("PID")
+    private String pid;
+    @TableField("ISTITLE")
+    private String istitle;
+}

+ 11 - 0
business-entity/src/main/java/com/rongwei/bsentity/vo/TestrunVo.java

@@ -0,0 +1,11 @@
+package com.rongwei.bsentity.vo;
+
+import lombok.Data;
+
+@Data
+public class TestrunVo {
+    private String  STATUS;
+    private String  PID;
+    private String ID;
+    private String ISTITLE;
+}

+ 22 - 0
business-server/src/main/java/com/rongwei/bsserver/controller/TestrunController.java

@@ -0,0 +1,22 @@
+package com.rongwei.bsserver.controller;
+
+import com.rongwei.bscommon.sys.service.TestrunService;
+import com.rongwei.rwcommon.base.R;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+@RestController
+@RequestMapping("/testrun")
+@Slf4j
+public class TestrunController {
+  @Autowired TestrunService testrunService;
+    @PostMapping("/dataImport")
+    @ResponseBody
+    public R dataImport(@RequestBody Map<String,Object> map) {
+            testrunService.DataUpdate(map);
+        return R.ok();
+    }
+}