Browse Source

添加铜管追溯信息导出功能

zhifei 1 year ago
parent
commit
ff5ca568e6

+ 24 - 0
warewms-system/src/main/java/com/warewms/hailiang/contoller/RetroactiveHistoryController.java

@@ -1,17 +1,25 @@
 package com.warewms.hailiang.contoller;
 
+import com.warewms.common.annotation.Log;
 import com.warewms.common.core.domain.R;
 import com.warewms.common.core.domain.base.page.PageDomain;
 import com.warewms.common.core.domain.base.page.TableDataInfo;
+import com.warewms.common.core.domain.entity.SysUser;
+import com.warewms.common.enums.BusinessType;
+import com.warewms.common.utils.poi.ExcelUtil;
+import com.warewms.hailiang.domain.DTO.RetroactiveHistoryDTO;
 import com.warewms.hailiang.domain.RetroactiveHistory;
 import com.warewms.hailiang.domain.RetroactiveNow;
 import com.warewms.hailiang.service.RetroactiveHistoryService;
 import com.warewms.hailiang.service.RetroactiveNowService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 /**
@@ -39,4 +47,20 @@ public class RetroactiveHistoryController {
     public R<List<RetroactiveHistory>> getInfoList(RetroactiveHistory retroactiveHistory){
         return R.ok( retroactiveHistoryService.getHistoryList(retroactiveHistory));
     }
+
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, RetroactiveHistory retroactiveHistory)
+    {
+        List<RetroactiveHistoryDTO> historyList = retroactiveHistoryService.export(retroactiveHistory,null);
+        ExcelUtil<RetroactiveHistoryDTO> util = new ExcelUtil<RetroactiveHistoryDTO>(RetroactiveHistoryDTO.class);
+        util.exportExcel(response, historyList, "铜管信息");
+    }
+
+    @PostMapping("/exportByIds")
+    public void exportByIds(HttpServletResponse response, String  ids)
+    {
+        List<RetroactiveHistoryDTO> historyList = retroactiveHistoryService.export(null,ids);
+        ExcelUtil<RetroactiveHistoryDTO> util = new ExcelUtil<RetroactiveHistoryDTO>(RetroactiveHistoryDTO.class);
+        util.exportExcel(response, historyList, "铜管信息");
+    }
 }

+ 7 - 2
warewms-system/src/main/java/com/warewms/hailiang/contoller/RetroactiveNowController.java

@@ -12,6 +12,7 @@ import com.warewms.hailiang.service.DeviceLogService;
 import com.warewms.hailiang.service.RetroactiveNowService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -39,16 +40,20 @@ public class RetroactiveNowController {
             if (split.length==1){
                 status.add(inStatus);
             }else{
-                status = Arrays.asList(inStatus);
+                status = Arrays.asList(split);
             }
         }
         System.err.println(status);
         return retroactiveNowService.getList(retroactiveNow, pageDomain,status);
     }
 
-
     @GetMapping("/info")
     public R<RetroactiveNow> getInfo(RetroactiveNow retroactiveNow) {
         return R.ok(retroactiveNowService.selectTheOneByParameter(retroactiveNow));
     }
+
+    @PostMapping("/pda/complement")
+    public R complement(RetroactiveNow retroactiveNow){
+        return retroactiveNowService.complement(retroactiveNow);
+    }
 }

+ 69 - 0
warewms-system/src/main/java/com/warewms/hailiang/domain/DTO/RetroactiveHistoryDTO.java

@@ -0,0 +1,69 @@
+package com.warewms.hailiang.domain.DTO;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.warewms.common.annotation.Excel;
+import com.warewms.common.core.domain.base.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 生产历史追溯excel映射表
+ * @TableName retroactive_history
+ */
+@Data
+public class RetroactiveHistoryDTO {
+
+    /**
+     * 历史追溯编号
+     */
+    private Long historyId;
+    /**
+     * 追溯id
+     */
+    @Excel(name = "追溯编号")
+    private String retroactiveId;
+
+    /**
+     * 产线
+     */
+    @Excel(name = "产线")
+    private String productionLine;
+
+    /**
+     * 批次号
+     */
+    @Excel(name = "批次号")
+    private String batchNo;
+
+    /**
+     * 托盘号
+     */
+    @Excel(name = "托盘号")
+    private String lotNo;
+
+    /**
+     * 重量
+     */
+    @Excel(name = "重量(KG)")
+    private Double weight;
+
+    /**
+     * 生产状态
+     */
+    @Excel(name = "生产状态")
+    private String status;
+
+    /**
+     * 设备编号
+     */
+    @Excel(name = "设备编号")
+    private String deviceId;
+
+    /** 完成工艺时间 */
+    @Excel(name = "完成工艺时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Excel.Type.EXPORT)
+    private Date createTime;
+
+}

+ 3 - 0
warewms-system/src/main/java/com/warewms/hailiang/domain/RetroactiveHistory.java

@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
 import java.time.LocalDateTime;
 
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.warewms.common.core.domain.base.BaseEntity;
 import lombok.Data;
 
@@ -22,6 +24,7 @@ public class RetroactiveHistory extends BaseEntity {
      * 历史追溯编号
      */
     @TableId(type = IdType.ASSIGN_ID)
+    @JsonSerialize(using= ToStringSerializer.class)
     private Long historyId;
     /**
      * 追溯id

+ 2 - 0
warewms-system/src/main/java/com/warewms/hailiang/service/RetroactiveHistoryService.java

@@ -2,6 +2,7 @@ package com.warewms.hailiang.service;
 
 import com.warewms.common.core.domain.base.page.PageDomain;
 import com.warewms.common.core.domain.base.page.TableDataInfo;
+import com.warewms.hailiang.domain.DTO.RetroactiveHistoryDTO;
 import com.warewms.hailiang.domain.RetroactiveHistory;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.warewms.hailiang.domain.RetroactiveNow;
@@ -19,4 +20,5 @@ public interface RetroactiveHistoryService extends IService<RetroactiveHistory>
 
     List<RetroactiveHistory> getHistoryList(RetroactiveHistory retroactiveHistory);
 
+    List<RetroactiveHistoryDTO> export(RetroactiveHistory retroactiveHistory, String ids);
 }

+ 3 - 0
warewms-system/src/main/java/com/warewms/hailiang/service/RetroactiveNowService.java

@@ -1,6 +1,7 @@
 package com.warewms.hailiang.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.warewms.common.core.domain.R;
 import com.warewms.common.core.domain.base.page.PageDomain;
 import com.warewms.common.core.domain.base.page.TableDataInfo;
 import com.warewms.hailiang.domain.RetroactiveNow;
@@ -23,4 +24,6 @@ public interface RetroactiveNowService extends IService<RetroactiveNow> {
     int updateData(RetroactiveNow retroactiveNow);
 
     int finishProduce(RetroactiveNow retroactiveNow);
+
+    R complement(RetroactiveNow retroactiveNow);
 }

+ 53 - 0
warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveHistoryServiceImpl.java

@@ -1,18 +1,29 @@
 package com.warewms.hailiang.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.warewms.common.core.domain.base.page.PageDomain;
 import com.warewms.common.core.domain.base.page.TableDataInfo;
+import com.warewms.common.core.domain.entity.SysDictData;
 import com.warewms.common.utils.StringUtils;
+import com.warewms.hailiang.domain.DTO.RetroactiveHistoryDTO;
+import com.warewms.hailiang.domain.Device;
 import com.warewms.hailiang.domain.RetroactiveHistory;
 import com.warewms.hailiang.domain.RetroactiveNow;
+import com.warewms.hailiang.service.DeviceService;
 import com.warewms.hailiang.service.RetroactiveHistoryService;
 import com.warewms.hailiang.mapper.RetroactiveHistoryMapper;
+import com.warewms.system.service.impl.SysDictTypeServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.sql.Wrapper;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
 * @author AD
@@ -26,6 +37,12 @@ public class RetroactiveHistoryServiceImpl extends ServiceImpl<RetroactiveHistor
     @Autowired
     RetroactiveHistoryMapper retroactiveHistoryMapper;
 
+    @Autowired
+    DeviceService deviceService;
+
+    @Autowired
+    SysDictTypeServiceImpl dictTypeService;
+
     @Override
     public TableDataInfo<RetroactiveHistory> getListByPage(RetroactiveHistory retroactiveHistory, PageDomain pageDomain) {
         return TableDataInfo.build(retroactiveHistoryMapper.selectPage(pageDomain.build(),new LambdaQueryWrapper<RetroactiveHistory>()
@@ -46,6 +63,42 @@ public class RetroactiveHistoryServiceImpl extends ServiceImpl<RetroactiveHistor
                 .eq(StringUtils.isNotEmpty(retroactiveHistory.getStatus()),RetroactiveHistory::getStatus,retroactiveHistory.getStatus())
                 .orderByAsc(RetroactiveHistory::getCreateTime));
     }
+
+    @Override
+    public List<RetroactiveHistoryDTO> export(RetroactiveHistory retroactiveHistory, String ids) {
+        LambdaQueryWrapper<RetroactiveHistory> retroactiveHistoryLambdaQueryWrapper = Wrappers.lambdaQuery(RetroactiveHistory.class);
+        List<String> longs = new ArrayList<>();
+        if (StringUtils.isNotEmpty(ids)){
+            String[] split = ids.split(",");
+            if (split.length==1){
+                longs.add(ids);
+            }else{
+                longs = Arrays.asList(split);
+                System.out.println(longs);
+                retroactiveHistoryLambdaQueryWrapper.in(RetroactiveHistory::getHistoryId,longs)
+                        .orderByAsc(RetroactiveHistory::getCreateTime);
+            }
+        }else {
+            retroactiveHistoryLambdaQueryWrapper
+                    .like(StringUtils.isNotEmpty(retroactiveHistory.getRetroactiveId()),RetroactiveHistory::getRetroactiveId,retroactiveHistory.getRetroactiveId())
+                    .eq(StringUtils.isNotEmpty(retroactiveHistory.getStatus()),RetroactiveHistory::getStatus,retroactiveHistory.getStatus())
+                    .orderByAsc(RetroactiveHistory::getCreateTime);
+        }
+        return retroactiveHistoryMapper.selectList(retroactiveHistoryLambdaQueryWrapper).stream().map(itme->{
+            RetroactiveHistoryDTO retroactiveHistoryDTO = BeanUtil.copyProperties(itme, RetroactiveHistoryDTO.class);
+            for (Device device : deviceService.getList()) {
+                if(device.getDeviceId().equals(retroactiveHistoryDTO.getDeviceId())){
+                    retroactiveHistoryDTO.setDeviceId(device.getAbbreviation());
+                }
+            }
+            for (SysDictData process : dictTypeService.selectDictDataByType("process")) {
+                if (process.getDictValue().equals(retroactiveHistoryDTO.getStatus())){
+                    retroactiveHistoryDTO.setStatus(process.getDictLabel());
+                }
+            }
+            return retroactiveHistoryDTO;
+        }).collect(Collectors.toList());
+    }
 }
 
 

+ 6 - 0
warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveNowServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.warewms.common.core.domain.R;
 import com.warewms.common.core.domain.base.page.PageDomain;
 import com.warewms.common.core.domain.base.page.TableDataInfo;
 import com.warewms.common.exception.ServiceException;
@@ -115,6 +116,11 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
         retroactiveHistoryMapper.insert(retroactiveHistory);
         return retroactiveNowMapper.deleteById(baseData);
     }
+
+    @Override
+    public R complement(RetroactiveNow retroactiveNow) {
+        return null;
+    }
 }