|
@@ -2,7 +2,7 @@ package com.github.zuihou.business.operationManagementCenter.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
-import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGAlterTableAlterColumnSetNotNull;
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -10,16 +10,15 @@ import com.github.zuihou.authority.dao.auth.StationUserLoginInfoMapper;
|
|
|
import com.github.zuihou.authority.dao.auth.UserMapper;
|
|
|
import com.github.zuihou.authority.entity.auth.StationUserLoginInfo;
|
|
|
import com.github.zuihou.authority.entity.auth.User;
|
|
|
-import com.github.zuihou.authority.entity.common.DictionaryItem;
|
|
|
import com.github.zuihou.authority.service.common.ParameterService;
|
|
|
import com.github.zuihou.base.R;
|
|
|
import com.github.zuihou.base.service.SuperServiceImpl;
|
|
|
import com.github.zuihou.business.DemoLine.DemoCacheKey;
|
|
|
import com.github.zuihou.business.DemoLine.DemoLineConstant;
|
|
|
import com.github.zuihou.business.aps.algorithm.ga.GAScheduler;
|
|
|
-import com.github.zuihou.business.aps.instance.domain.basicdata.*;
|
|
|
-import com.github.zuihou.business.classSchedule.entity.ScheduleUser;
|
|
|
-import com.github.zuihou.business.edgeLibrary.entity.StockInfo;
|
|
|
+import com.github.zuihou.business.aps.instance.domain.basicdata.CandidateProcess;
|
|
|
+import com.github.zuihou.business.aps.instance.domain.basicdata.Instance;
|
|
|
+import com.github.zuihou.business.aps.instance.domain.basicdata.Machine;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dao.*;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dto.OrderProductUpdateDTO;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dto.OrderUpdateDTO;
|
|
@@ -29,21 +28,24 @@ import com.github.zuihou.business.productionReadyCenter.dao.BBomMapper;
|
|
|
import com.github.zuihou.business.productionReadyCenter.dao.BomProcedureProductionresourceMapper;
|
|
|
import com.github.zuihou.business.productionReadyCenter.dao.BomProcedureProgramMapper;
|
|
|
import com.github.zuihou.business.productionReadyCenter.dao.MMeterialReceiveLogMapper;
|
|
|
-import com.github.zuihou.business.productionReadyCenter.entity.*;
|
|
|
+import com.github.zuihou.business.productionReadyCenter.entity.BBom;
|
|
|
+import com.github.zuihou.business.productionReadyCenter.entity.BomProcedure;
|
|
|
+import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureProductionresource;
|
|
|
+import com.github.zuihou.business.productionReadyCenter.entity.MMeterialReceiveLog;
|
|
|
import com.github.zuihou.business.productionReadyCenter.service.AutoNodeService;
|
|
|
-import com.github.zuihou.business.productionReadyCenter.service.BBomService;
|
|
|
import com.github.zuihou.business.productionReadyCenter.service.BomProcedureService;
|
|
|
import com.github.zuihou.business.productionReadyCenter.service.MMeterialReceiveLogService;
|
|
|
import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
|
|
|
import com.github.zuihou.business.productionResourceCenter.dao.ZZoneMapper;
|
|
|
import com.github.zuihou.business.productionResourceCenter.entity.Productionresource;
|
|
|
-import com.github.zuihou.business.productionResourceCenter.entity.Repair;
|
|
|
import com.github.zuihou.business.productionResourceCenter.entity.ZZone;
|
|
|
import com.github.zuihou.business.productionResourceCenter.service.RepairService;
|
|
|
import com.github.zuihou.business.util.DynamicRabbitMq;
|
|
|
-import com.github.zuihou.common.constant.*;
|
|
|
+import com.github.zuihou.common.constant.BizConstant;
|
|
|
+import com.github.zuihou.common.constant.CodeRuleModule;
|
|
|
+import com.github.zuihou.common.constant.ParameterKey;
|
|
|
+import com.github.zuihou.common.constant.RepeatCacheKey;
|
|
|
import com.github.zuihou.common.util.DateUtil;
|
|
|
-import com.github.zuihou.common.util.StringUtil;
|
|
|
import com.github.zuihou.database.mybatis.auth.DataScope;
|
|
|
import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
|
import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
@@ -53,14 +55,23 @@ import com.github.zuihou.tenant.service.CodeRuleService;
|
|
|
import com.github.zuihou.utils.BeanPlusUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.hssf.usermodel.*;
|
|
|
+import org.apache.poi.ss.usermodel.BorderStyle;
|
|
|
+import org.apache.poi.ss.usermodel.FillPatternType;
|
|
|
+import org.apache.poi.ss.usermodel.IndexedColors;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddressList;
|
|
|
+import org.apache.poi.xssf.usermodel.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.sql.Timestamp;
|
|
|
-import java.time.LocalDateTime;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -142,6 +153,8 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
|
|
private UserMapper userMapper;
|
|
|
@Autowired
|
|
|
private ProductionresourceBizMapper productionresourceBizMapper;
|
|
|
+ @Autowired
|
|
|
+ private MMeterialReceiveLogMapper mMeterialReceiveLogMapper;
|
|
|
|
|
|
@Override
|
|
|
public IPage<Order> pageList(IPage page,String sustDesc, LbqWrapper<Order> wrapper) {
|
|
@@ -1015,4 +1028,186 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
|
|
s = s.substring(0,list.size());
|
|
|
return s;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void downloadOrderTemplate(HttpServletResponse httpServletResponse){
|
|
|
+ String name = "orderTemplate.xlsx";
|
|
|
+ FileOutputStream fileOut = null;
|
|
|
+ OutputStream outputStream = null;
|
|
|
+ File temp = null;
|
|
|
+ try {
|
|
|
+ temp = File.createTempFile("orderTemplate", ".xlsx");
|
|
|
+ // 文件初始化
|
|
|
+ XSSFWorkbook wb = new XSSFWorkbook ();
|
|
|
+ XSSFCellStyle style = wb.createCellStyle();
|
|
|
+ style.setBorderRight(BorderStyle.THIN);
|
|
|
+ style.setBorderTop(BorderStyle.THIN);
|
|
|
+ style.setBorderLeft(BorderStyle.THIN);
|
|
|
+ style.setBorderBottom(BorderStyle.THIN);
|
|
|
+
|
|
|
+ XSSFCellStyle style1 = wb.createCellStyle();
|
|
|
+ style1.setBorderRight(BorderStyle.THIN);
|
|
|
+ style1.setBorderTop(BorderStyle.THIN);
|
|
|
+ style1.setBorderLeft(BorderStyle.THIN);
|
|
|
+ style1.setBorderBottom(BorderStyle.THIN);
|
|
|
+ style1.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); //设置背景色
|
|
|
+ style1.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
|
+
|
|
|
+
|
|
|
+ XSSFSheet sheet = wb.createSheet("orderTemplate");
|
|
|
+ for (int i = 0; i <= 5; i++)
|
|
|
+ {
|
|
|
+ sheet.autoSizeColumn((short)i,true); //调整列宽
|
|
|
+ }
|
|
|
+ // 在第一行插入需要填写的订单信息
|
|
|
+ XSSFRow row1 = sheet.createRow(0);
|
|
|
+
|
|
|
+ XSSFCell row1cell1 = row1.createCell(0);
|
|
|
+ XSSFCell row1cell2 = row1.createCell(1);
|
|
|
+ XSSFCell row1cell3 = row1.createCell(2);
|
|
|
+ XSSFCell row1cell4 = row1.createCell(3);
|
|
|
+ XSSFCell row1cell5 = row1.createCell(4);
|
|
|
+ XSSFCell row1cell6 = row1.createCell(5);
|
|
|
+ row1cell1.setCellValue("订单名称:");
|
|
|
+ row1cell3.setCellValue("下单时间:");
|
|
|
+ row1cell5.setCellValue("所属产线:");
|
|
|
+ row1cell6.setCellValue("请选择");
|
|
|
+ row1cell1.setCellStyle(style);
|
|
|
+ row1cell2.setCellStyle(style);
|
|
|
+ row1cell3.setCellStyle(style);
|
|
|
+ row1cell4.setCellStyle(style);
|
|
|
+ row1cell5.setCellStyle(style);
|
|
|
+ row1cell6.setCellStyle(style);
|
|
|
+ // 生成下拉框内容
|
|
|
+ QueryWrapper<ZZone> zZoneWrapper = new QueryWrapper<ZZone>();
|
|
|
+ zZoneWrapper.eq("status",1);
|
|
|
+ List<ZZone> zZones = zZoneMapper.selectList(zZoneWrapper);
|
|
|
+ List<String> zZoneList = new ArrayList<>();
|
|
|
+ for(ZZone zZone: zZones){
|
|
|
+ zZoneList.add(zZone.getId() + "-"+ zZone.getName());
|
|
|
+ }
|
|
|
+ String[] zZoneInfos = new String[zZoneList.size()];
|
|
|
+ zZoneList.toArray(zZoneInfos);
|
|
|
+
|
|
|
+ XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper((XSSFSheet)sheet);
|
|
|
+ XSSFDataValidationConstraint zZoneConstraint = (XSSFDataValidationConstraint) dvHelper
|
|
|
+ .createExplicitListConstraint(zZoneInfos);
|
|
|
+ CellRangeAddressList zZoneRange = new CellRangeAddressList(0, 0, 5, 5);
|
|
|
+ XSSFDataValidation zZoneValidation = (XSSFDataValidation) dvHelper.createValidation(zZoneConstraint, zZoneRange);
|
|
|
+ zZoneValidation.setSuppressDropDownArrow(true);
|
|
|
+ zZoneValidation.setShowErrorBox(true);
|
|
|
+ sheet.addValidationData(zZoneValidation);
|
|
|
+
|
|
|
+ // 设置第二行表头
|
|
|
+ XSSFRow row2 = sheet.createRow(1);
|
|
|
+ XSSFCell row2cell1 = row2.createCell(0);
|
|
|
+ XSSFCell row2cell2 = row2.createCell(1);
|
|
|
+ XSSFCell row2cell3 = row2.createCell(2);
|
|
|
+ XSSFCell row2cell4 = row2.createCell(3);
|
|
|
+ XSSFCell row2cell5 = row2.createCell(4);
|
|
|
+ row2cell1.setCellValue("零件名称");
|
|
|
+ row2cell2.setCellValue("原炉批号");
|
|
|
+ row2cell3.setCellValue("数量");
|
|
|
+ row2cell4.setCellValue("交货日期");
|
|
|
+ row2cell5.setCellValue("备注");
|
|
|
+ row2cell1.setCellStyle(style1);
|
|
|
+ row2cell2.setCellStyle(style1);
|
|
|
+ row2cell3.setCellStyle(style1);
|
|
|
+ row2cell4.setCellStyle(style1);
|
|
|
+ row2cell5.setCellStyle(style1);
|
|
|
+ // 起始行, 终止行, 起始列, 终止列
|
|
|
+ CellRangeAddress cra =new CellRangeAddress(1, 1, 4, 5);
|
|
|
+ sheet.addMergedRegion(cra);
|
|
|
+
|
|
|
+ // 设置第三行选中零件
|
|
|
+ XSSFRow row3 = sheet.createRow(2);
|
|
|
+ XSSFCell row3cell1 = row3.createCell(0);
|
|
|
+ XSSFCell row3cell2 = row3.createCell(1);
|
|
|
+ XSSFCell row3cell3 = row3.createCell(2);
|
|
|
+ XSSFCell row3cell4 = row3.createCell(3);
|
|
|
+ XSSFCell row3cell5 = row3.createCell(4);
|
|
|
+ XSSFCell row3cell6 = row3.createCell(5);
|
|
|
+ row3cell1.setCellValue("请选择");
|
|
|
+ row3cell2.setCellValue("请选择");
|
|
|
+ row3cell1.setCellStyle(style);
|
|
|
+ row3cell2.setCellStyle(style);
|
|
|
+ row3cell3.setCellStyle(style);
|
|
|
+ row3cell4.setCellStyle(style);
|
|
|
+ row3cell5.setCellStyle(style);
|
|
|
+ row3cell6.setCellStyle(style);
|
|
|
+ CellRangeAddress cra1 =new CellRangeAddress(2, 2, 4, 5);
|
|
|
+ sheet.addMergedRegion(cra1);
|
|
|
+
|
|
|
+ QueryWrapper<BBom> bBomWrapper = new QueryWrapper<BBom>();
|
|
|
+ bBomWrapper.eq("audit_status",2);
|
|
|
+ bBomWrapper.eq("status",1);
|
|
|
+ List<BBom> bBoms = bBomMapper.selectList(bBomWrapper);
|
|
|
+ List<String> bBomList = new ArrayList<>();
|
|
|
+ for(BBom bBom: bBoms){
|
|
|
+ bBomList.add(bBom.getId() + "-"+ bBom.getName());
|
|
|
+ }
|
|
|
+ String[] bBomInfos = new String[bBomList.size()];
|
|
|
+ bBomList.toArray(bBomInfos);
|
|
|
+
|
|
|
+ // 设置第三行选中零件
|
|
|
+ List<Map<String,String>> mMeterials = mMeterialReceiveLogMapper.selectValidMeterialList();
|
|
|
+ List<String> mMeterialsList = new ArrayList<>();
|
|
|
+ for(Map data: mMeterials){
|
|
|
+ mMeterialsList.add(data.get("name") + "-"+ data.get("equipmentName") + "-" + data.get("furnaceBatchNo") + "-" + data.get("remindNum") );
|
|
|
+ }
|
|
|
+ String[] mMeterialses = new String[mMeterialsList.size()];
|
|
|
+ mMeterialsList.toArray(mMeterialses);
|
|
|
+
|
|
|
+ XSSFDataValidationConstraint bomConstraint = (XSSFDataValidationConstraint) dvHelper
|
|
|
+ .createExplicitListConstraint(bBomInfos);
|
|
|
+ CellRangeAddressList bomRange = new CellRangeAddressList(2, 10, 0, 0);
|
|
|
+ XSSFDataValidation bomValidation = (XSSFDataValidation) dvHelper.createValidation(bomConstraint, bomRange);
|
|
|
+ bomValidation.setSuppressDropDownArrow(true);
|
|
|
+ bomValidation.setShowErrorBox(true);
|
|
|
+ sheet.addValidationData(bomValidation);
|
|
|
+
|
|
|
+ XSSFDataValidationConstraint mMeterialsesConstraint = (XSSFDataValidationConstraint) dvHelper
|
|
|
+ .createExplicitListConstraint(mMeterialses);
|
|
|
+ CellRangeAddressList mMeterialsesRange = new CellRangeAddressList(2, 10, 1, 1);
|
|
|
+ XSSFDataValidation mMeterialsesRangeValidation = (XSSFDataValidation) dvHelper.createValidation(mMeterialsesConstraint, mMeterialsesRange);
|
|
|
+ mMeterialsesRangeValidation.setSuppressDropDownArrow(true);
|
|
|
+ mMeterialsesRangeValidation.setShowErrorBox(true);
|
|
|
+ sheet.addValidationData(mMeterialsesRangeValidation);
|
|
|
+
|
|
|
+
|
|
|
+ // 写入文件
|
|
|
+ fileOut = new FileOutputStream(temp.getAbsolutePath());
|
|
|
+ wb.write(fileOut);
|
|
|
+ fileOut.flush();
|
|
|
+ outputStream = httpServletResponse.getOutputStream();
|
|
|
+ httpServletResponse.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ httpServletResponse.setHeader("Content-Disposition", "attachment; filename=\"" + name + "\"");
|
|
|
+ httpServletResponse.addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
|
|
+ httpServletResponse.addHeader("charset", "utf-8");
|
|
|
+ httpServletResponse.addHeader("Pragma", "no-cache");
|
|
|
+ wb.write(outputStream);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if(null != fileOut){
|
|
|
+ try {
|
|
|
+ fileOut.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (null != outputStream) {
|
|
|
+ try {
|
|
|
+ outputStream.flush();
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 删除零时文件
|
|
|
+ if (null != outputStream ) {
|
|
|
+// temp.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|