Browse Source

代码修正

yzc 2 years ago
parent
commit
b538cff771

+ 4 - 1
hx-mes/src/main/java/com/fjhx/mes/entity/border/vo/BorderOfLineVo.java

@@ -20,8 +20,11 @@ public class BorderOfLineVo extends BorderOfLine {
     private String productName;
 
     /**
-     * 物料类型
+     * 物料分类名称
      */
     private String productTypeName;
 
+    /**物料分类id*/
+    private Long classifyId;
+
 }

+ 64 - 43
hx-mes/src/main/java/com/fjhx/mes/service/border/impl/BorderOfLineServiceImpl.java

@@ -1,29 +1,26 @@
 package com.fjhx.mes.service.border.impl;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.item.entity.product.po.ProductClassify;
 import com.fjhx.item.entity.product.po.ProductInfo;
 import com.fjhx.item.service.product.ProductClassifyService;
 import com.fjhx.item.service.product.ProductInfoService;
+import com.fjhx.mes.entity.border.dto.BorderOfLineDto;
+import com.fjhx.mes.entity.border.dto.BorderOfLineSelectDto;
 import com.fjhx.mes.entity.border.po.BorderOfLine;
 import com.fjhx.mes.entity.border.po.BorderOfLineJournal;
-import com.fjhx.mes.entity.border.vo.BorderOfLineJournalVo;
+import com.fjhx.mes.entity.border.vo.BorderOfLineVo;
 import com.fjhx.mes.mapper.border.BorderOfLineMapper;
 import com.fjhx.mes.service.border.BorderOfLineJournalService;
 import com.fjhx.mes.service.border.BorderOfLineService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.wms.entity.stock.po.StockWait;
 import com.fjhx.wms.service.stock.StockWaitService;
-import com.ruoyi.common.core.domain.BaseSelectDto;
-import org.checkerframework.checker.units.qual.A;
+import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.fjhx.mes.entity.border.vo.BorderOfLineVo;
-import com.fjhx.mes.entity.border.dto.BorderOfLineSelectDto;
-import com.ruoyi.common.utils.wrapper.IWrapper;
-import com.fjhx.mes.entity.border.dto.BorderOfLineDto;
-import cn.hutool.core.bean.BeanUtil;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
@@ -37,7 +34,7 @@ import java.util.stream.Collectors;
  * 线边管理 服务实现类
  * </p>
  *
- * @author 
+ * @author
  * @since 2023-03-31
  */
 @Service
@@ -55,36 +52,60 @@ public class BorderOfLineServiceImpl extends ServiceImpl<BorderOfLineMapper, Bor
     public Page<BorderOfLineVo> getPage(BorderOfLineSelectDto dto) {
         IWrapper<BorderOfLine> wrapper = getWrapper();
         wrapper.orderByDesc("bol", BorderOfLine::getId);
-        wrapper.ne(BorderOfLine::getQuantity,0);
+        wrapper.ne(BorderOfLine::getQuantity, 0);
         Page<BorderOfLineVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         List<BorderOfLineVo> records = page.getRecords();
-        //赋值产品信息
-        List<Long> productIds = records.stream().map(BorderOfLine::getProductId).collect(Collectors.toList());
-        if(ObjectUtil.isNotEmpty(productIds)) {
-            List<ProductInfo> productInfos = productInfoService.listByIds(productIds);
-            if(ObjectUtil.isNotEmpty(productInfos)) {
-                List<Long> productClassifyIds = productInfos.stream().map(ProductInfo::getProductClassifyId).collect(Collectors.toList());
-                if(ObjectUtil.isNotEmpty(productClassifyIds)) {
-                    List<ProductClassify> productClassifies = productClassifyService.listByIds(productClassifyIds);
-                    if(ObjectUtil.isNotEmpty(productClassifies)) {
-                        Map<Long, ProductInfo> productInfoMap = productInfos.stream().collect(Collectors.groupingBy(ProductInfo::getId,
-                                Collectors.collectingAndThen(Collectors.toList(), value -> value.get(0))));
-                        Map<Long, ProductClassify> productClassifyMap = productClassifies.stream().collect(Collectors.groupingBy(ProductClassify::getId,
-                                Collectors.collectingAndThen(Collectors.toList(), value -> value.get(0))));
-                        for (BorderOfLineVo borderOfLineVo : records) {
-                            ProductInfo productInfo = productInfoMap.get(borderOfLineVo.getProductId());
-                            if (ObjectUtil.isNotEmpty(productInfo)){
-                                borderOfLineVo.setProductName(productInfo.getName());
-                                ProductClassify productClassify = productClassifyMap.get(productInfo.getProductClassifyId());
-                                if (ObjectUtil.isNotEmpty(productClassify)){
-                                    borderOfLineVo.setProductTypeName(productClassify.getName());
-                                }
-                            }
-                        }
-                    }
-                }
-            }
+
+        if (records.size() == 0) {
+            return page;
         }
+
+        //赋值产品名称
+        productInfoService.attributeAssign(records, BorderOfLine::getProductId, (item, productInfo) -> {
+            item.setProductName(productInfo.getName());
+            item.setClassifyId(productInfo.getProductClassifyId());
+        });
+
+        //赋值产品分类
+        productClassifyService.attributeAssign(records,BorderOfLineVo::getClassifyId,(item,classify)->{
+            item.setProductTypeName(classify.getName());
+        });
+
+//        //赋值产品信息
+//        List<Long> productIds = records.stream().map(BorderOfLine::getProductId).collect(Collectors.toList());
+//        if (ObjectUtil.isEmpty(productIds)) {
+//            return page;
+//        }
+//
+//        List<ProductInfo> productInfos = productInfoService.listByIds(productIds);
+//        List<Long> productClassifyIds = productInfos.stream().map(ProductInfo::getProductClassifyId).collect(Collectors.toList());
+//        if (ObjectUtil.isEmpty(productClassifyIds)) {
+//            return page;
+//        }
+//
+//        List<ProductClassify> productClassifies = productClassifyService.listByIds(productClassifyIds);
+//        if (ObjectUtil.isNotEmpty(productClassifies)) {
+//            Map<Long, ProductInfo> productInfoMap = productInfos.stream().collect(Collectors.groupingBy(ProductInfo::getId,
+//                    Collectors.collectingAndThen(Collectors.toList(), value -> value.get(0))));
+//            Map<Long, ProductClassify> productClassifyMap = productClassifies.stream().collect(Collectors.groupingBy(ProductClassify::getId,
+//                    Collectors.collectingAndThen(Collectors.toList(), value -> value.get(0))));
+//            for (BorderOfLineVo borderOfLineVo : records) {
+//                ProductInfo productInfo = productInfoMap.get(borderOfLineVo.getProductId());
+//                if (ObjectUtil.isNotEmpty(productInfo)) {
+//
+//                    borderOfLineVo.setProductName(productInfo.getName());
+//
+//                    ProductClassify productClassify = productClassifyMap.get(productInfo.getProductClassifyId());
+//                    if (ObjectUtil.isNotEmpty(productClassify)) {
+//
+//                        borderOfLineVo.setProductTypeName(productClassify.getName());
+//
+//                    }
+//                }
+//            }
+//        }
+
+
         return page;
     }
 
@@ -92,7 +113,7 @@ public class BorderOfLineServiceImpl extends ServiceImpl<BorderOfLineMapper, Bor
     public BorderOfLineVo detail(BorderOfLineDto dto) {
         BorderOfLine borderOfLine = getOne(q -> q.eq(BorderOfLine::getId, dto.getId()).or().eq(BorderOfLine::getProductId, dto.getProductId()));
         BorderOfLineVo result = BeanUtil.toBean(borderOfLine, BorderOfLineVo.class);
-        if(ObjectUtil.isNotEmpty(result)) {
+        if (ObjectUtil.isNotEmpty(result)) {
             ProductInfo productInfo = productInfoService.getById(result.getProductId());
             if (ObjectUtil.isNotEmpty(productInfo)) {
                 result.setProductName(productInfo.getName());
@@ -109,10 +130,10 @@ public class BorderOfLineServiceImpl extends ServiceImpl<BorderOfLineMapper, Bor
     @Override
     public void add(BorderOfLineDto borderOfLineDto) {
         BorderOfLine borderOfLine = getOne(q -> q.eq(BorderOfLine::getProductId, borderOfLineDto.getProductId()));
-        if(ObjectUtil.isNotEmpty(borderOfLine)){
+        if (ObjectUtil.isNotEmpty(borderOfLine)) {
             borderOfLine.setQuantity(borderOfLine.getQuantity().add(borderOfLineDto.getQuantity()));
-        }else {
-            borderOfLine = BeanUtil.toBean(borderOfLineDto,BorderOfLine.class);
+        } else {
+            borderOfLine = BeanUtil.toBean(borderOfLineDto, BorderOfLine.class);
         }
         saveOrUpdate(borderOfLine);
         //创建流水记录
@@ -135,7 +156,7 @@ public class BorderOfLineServiceImpl extends ServiceImpl<BorderOfLineMapper, Bor
         borderOfLineJournal.setType(borderOfLineDto.getType());
         borderOfLineJournalService.save(borderOfLineJournal);
         //如果类型是"回仓"创建待入库数据
-        if(borderOfLineDto.getType()==2){
+        if (borderOfLineDto.getType() == 2) {
             StockWait stockWait = new StockWait();
             stockWait.setType(1);
             stockWait.setBusinessType(1);

+ 3 - 0
hx-oa/src/main/java/com/fjhx/oa/service/schedule/impl/ScheduleDetailsServiceImpl.java

@@ -1,5 +1,7 @@
 package com.fjhx.oa.service.schedule.impl;
 
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.fjhx.common.constant.SourceConstant;
 import com.fjhx.oa.entity.schedule.po.ScheduleDetails;
 import com.fjhx.oa.mapper.schedule.ScheduleDetailsMapper;
 import com.fjhx.oa.service.schedule.ScheduleDetailsService;
@@ -15,6 +17,7 @@ import org.springframework.stereotype.Service;
  * @author 
  * @since 2023-04-03
  */
+@DS(SourceConstant.OA)
 @Service
 public class ScheduleDetailsServiceImpl extends ServiceImpl<ScheduleDetailsMapper, ScheduleDetails> implements ScheduleDetailsService {
 

+ 9 - 4
hx-oa/src/main/java/com/fjhx/oa/utils/Notice.java

@@ -41,7 +41,7 @@ public class Notice {
     public void getNoticeList() {
         TenantHolder.setIgnore(true);
         QueryWrapper queryWrapper = new QueryWrapper();
-        queryWrapper.eq("(date( start_date ) = curdate())",1);
+        queryWrapper.eq("(date( start_date ) = curdate())", 1);
         List<ScheduleInfo> scheduleInfos0 = scheduleInfoService.list(queryWrapper);
         scheduleInfoMap = scheduleInfos0.stream().collect(Collectors.groupingBy(ScheduleInfo::getId,
                 Collectors.collectingAndThen(Collectors.toList(), value -> value.get(0))));
@@ -54,13 +54,17 @@ public class Notice {
      */
     @Scheduled(cron = "0/10 * * * * ?")
     public void sendNoticeTime() {
+        TenantHolder.setIgnore(true);
         List<ScheduleInfo> scheduleInfos = new ArrayList<>();
         for (Map.Entry<Long, ScheduleInfo> entry : scheduleInfoMap.entrySet()) {
             ScheduleInfo scheduleInfo = entry.getValue();
             Date startDate = scheduleInfo.getStartDate();
             Date date = new Date();
-            long diff = date.getTime() - startDate.getTime();
-            long min = diff / 60 / 1000;
+            long diff = startDate.getTime() - date.getTime();
+            long min = (long) Math.ceil(diff / 60.0 / 1000.0);
+            if (min < 0) {
+                scheduleInfoMap.remove(scheduleInfo.getId());
+            }
             //根据类型判断提前多少分钟通知
             if (min == scheduleInfo.getNoticeType()) {
                 scheduleInfoMap.remove(scheduleInfo.getId());
@@ -72,7 +76,7 @@ public class Notice {
             Map<Long, ScheduleInfo> scheduleInfoMap1 = scheduleInfos.stream().collect(Collectors.groupingBy(ScheduleInfo::getId,
                     Collectors.collectingAndThen(Collectors.toList(), value -> value.get(0))));
             List<Long> scheduleInfoIds = scheduleInfos.stream().map(ScheduleInfo::getId).collect(Collectors.toList());
-            List<ScheduleDetails> scheduleDetailsList = scheduleDetailsService.listByIds(scheduleInfoIds);
+            List<ScheduleDetails> scheduleDetailsList = scheduleDetailsService.list(q -> q.in(ScheduleDetails::getScheduleInfoId, scheduleInfoIds));
             for (ScheduleDetails scheduleDetails : scheduleDetailsList) {
                 //发送消息
                 ScheduleInfo scheduleInfo = scheduleInfoMap1.get(scheduleDetails.getScheduleInfoId());
@@ -84,6 +88,7 @@ public class Notice {
                 WebSocketServer.sendInfo(scheduleDetails.getParticipantId(), 1, msgMap);
             }
         }
+        TenantHolder.clear();
     }
 
     /**