From 666181924a7deee3cc2b927949cac6b6d88a41c9 Mon Sep 17 00:00:00 2001 From: ZY <zc857179121@qq.com> Date: 星期四, 18 七月 2024 17:09:58 +0800 Subject: [PATCH] 中间表代码提交 --- src/main/java/com/zy/asrs/controller/StaDescController.java | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/StaDescController.java b/src/main/java/com/zy/asrs/controller/StaDescController.java index 8d85caf..c743311 100644 --- a/src/main/java/com/zy/asrs/controller/StaDescController.java +++ b/src/main/java/com/zy/asrs/controller/StaDescController.java @@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.mapper.Wrapper; import com.baomidou.mybatisplus.plugins.Page; import com.zy.asrs.entity.StaDesc; +import com.zy.asrs.entity.param.StaDescInitParam; +import com.zy.asrs.mapper.StaDescMapper; import com.zy.asrs.service.StaDescService; import com.zy.common.web.BaseController; import com.core.annotations.ManagerAuth; @@ -13,6 +15,9 @@ import com.core.common.Cools; import com.core.common.DateUtils; import com.core.common.R; +import org.apache.ibatis.session.ExecutorType; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -23,6 +28,59 @@ @Autowired private StaDescService staDescService; + @Autowired + private SqlSessionFactory sqlSessionFactory; + + @RequestMapping(value = "/staDesc/init/auth") + @ManagerAuth(memo = "鍒濆鍖栫珯鐐硅矾寰�") + public R init(StaDescInitParam param) { + SqlSession sqlSession = null; + try{ + if (param.getTypeDesc()==1){ + staDescService.delete(new EntityWrapper<>()); + } + String[] startStaList = param.getStartStaList().split(";"); + String[] endStaList = param.getEndStaList().split(";"); + List<StaDesc> staDescList = new ArrayList<>(); + sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH,false); + StaDescMapper sqlSessionMapper = sqlSession.getMapper(StaDescMapper.class); + for (String startSta : startStaList){ + for (String endSta : endStaList){ + for (Integer type:param.getType()){ + int sameRes = staDescService.selectCount(new EntityWrapper<StaDesc>() + .eq("type_no", type) + .eq("stn_no", Integer.parseInt(startSta)) + .eq("crn_no", param.getCrnNo()) + .eq("crn_stn", Integer.parseInt(endSta))); + if (sameRes > 0) { + continue; + } + StaDesc staDesc = new StaDesc(); + staDesc.setCrnNo(param.getCrnNo()); + staDesc.setTypeNo(type); + staDesc.setStnNo(Integer.parseInt(startSta)); + staDesc.setCrnStn(Integer.parseInt(endSta)); + staDesc.setModiUser(getUserId()); + staDesc.setModiTime(new Date()); + staDesc.setAppeUser(getUserId()); + staDesc.setAppeTime(new Date()); + sqlSessionMapper.insert(staDesc); +// staDescList.add(staDesc); + } + } + } + sqlSession.flushStatements(); + sqlSession.clearCache(); + +// staDescService.insertBatch(staDescList); + }catch (Exception e){ + return R.error(e.getMessage()); + }finally { + sqlSession.close(); + } + + return R.ok("ok1").add("ok2"); + } @RequestMapping(value = "/staDesc/{id}/auth") @ManagerAuth -- Gitblit v1.9.1