From cf9a5039e6db9d1d5963e3fe1a37d00169ec2ef7 Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期三, 25 六月 2025 11:18:22 +0800 Subject: [PATCH] 验收报告修改 --- src/main/java/com/whyc/service/MaterialHistoryService.java | 63 +++++++++++++++++++++++++++++++ 1 files changed, 63 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/whyc/service/MaterialHistoryService.java b/src/main/java/com/whyc/service/MaterialHistoryService.java index f7a6bb1..3bc74e4 100644 --- a/src/main/java/com/whyc/service/MaterialHistoryService.java +++ b/src/main/java/com/whyc/service/MaterialHistoryService.java @@ -1,10 +1,21 @@ package com.whyc.service; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.whyc.dto.Response; import com.whyc.mapper.MaterialHistoryMapper; +import com.whyc.pojo.Material; import com.whyc.pojo.MaterialHistory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; @Service public class MaterialHistoryService { @@ -12,7 +23,59 @@ @Resource private MaterialHistoryMapper mapper; + @Autowired + @Lazy + private MaterialService materialService; + public void insert(MaterialHistory mh) { mapper.insert(mh); } + + public void addBatch(List<MaterialHistory> materialHistoryList) { + mapper.insertBatchSomeColumn(materialHistoryList); + } + + //鏍规嵁鐗╂枡id鏌ヨdwg鍘嗗彶 + public Response getDwgHisById(int materialId, int pageCurr, int pageSize) { + PageHelper.startPage(pageCurr,pageSize); + QueryWrapper wrapper=new QueryWrapper(); + wrapper.eq("material_id",materialId); + wrapper.isNotNull("dwg_url"); + wrapper.orderByDesc("create_time"); + List list=mapper.selectList(wrapper); + PageInfo pageInfo=new PageInfo(list); + return new Response().setII(1,list.size()>0,pageInfo,"鏍规嵁鐗╂枡id鏌ヨdwg鍘嗗彶"); + } + + //鏍规嵁鐗╂枡id鏌ヨpic鍘嗗彶 + public Response getPicHisById(int materialId, int pageCurr, int pageSize) { + PageHelper.startPage(pageCurr,pageSize); + QueryWrapper wrapper=new QueryWrapper(); + wrapper.eq("material_id",materialId); + wrapper.isNotNull("picture_url"); + wrapper.orderByDesc("create_time"); + List list=mapper.selectList(wrapper); + PageInfo pageInfo=new PageInfo(list); + return new Response().setII(1,list.size()>0,pageInfo,"鏍规嵁鐗╂枡id鏌ヨpic鍘嗗彶"); + } + + public Response moveFromMaterialTable(int checkNum) { + List<Material> list = materialService.getList(); + list = list.stream().filter(temp-> temp.getPictureUrl()!=null || temp.getDwgUrl()!=null).collect(Collectors.toList()); + List<MaterialHistory> materialHistories = new LinkedList<>(); + Date now = new Date(); + for (Material material : list) { + MaterialHistory history = new MaterialHistory(); + history.setProductId(0); + history.setMaterialId(material.getId()); + history.setPictureUrl(material.getPictureUrl()); + history.setDwgUrl(material.getDwgUrl()); + history.setUpUserId(material.getUpUserId()==null?null:material.getUpUserId().intValue()); + history.setCreateTime(now); + + materialHistories.add(history); + } + mapper.insertBatchSomeColumn(materialHistories); + return new Response().set(1,true,"棣栨鐨勭墿鏂欏浘绾歌浆绉讳繚瀛樺畬鎴�"); + } } -- Gitblit v1.9.1