Procházet zdrojové kódy

Merge branch 'master' of http://106.15.38.8:3000/yaoyq/imcs-yj-be into master

姚云青 před 3 roky
rodič
revize
f0949743e6

+ 4 - 1
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/OrderService.java

@@ -3,12 +3,12 @@ package com.github.zuihou.business.operationManagementCenter.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.zuihou.base.R;
 import com.github.zuihou.base.service.SuperService;
-import com.github.zuihou.business.operationManagementCenter.dto.OrderSaveDTO;
 import com.github.zuihou.business.operationManagementCenter.dto.OrderUpdateDTO;
 import com.github.zuihou.business.operationManagementCenter.entity.Order;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.security.model.SysUser;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 import java.util.Map;
 
@@ -88,4 +88,7 @@ public interface OrderService extends SuperService<Order> {
      */
     Boolean deleteOrder(Order model);
 
+    void downloadOrderTemplate(HttpServletResponse httpServletResponse);
+
+    R<Boolean> saveExcelOrder(Order order, List<Map> detailList);
 }

+ 288 - 13
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/OrderServiceImpl.java

@@ -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,21 @@ 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.*;
+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 +151,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 +1026,268 @@ 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);
+           style1.setAlignment(HorizontalAlignment.CENTER);
+
+           XSSFCellStyle style2 = wb.createCellStyle();
+           XSSFDataFormat format = wb.createDataFormat();
+           style2.setBorderRight(BorderStyle.THIN);
+           style2.setBorderTop(BorderStyle.THIN);
+           style2.setBorderLeft(BorderStyle.THIN);
+           style2.setBorderBottom(BorderStyle.THIN);
+           style2.setDataFormat(format.getFormat("@"));
+
+           XSSFSheet sheet = wb.createSheet("orderTemplate");
+
+           XSSFRow row0 = sheet.createRow(0);
+           XSSFCell row0cell1 = row0.createCell(0);
+           row0cell1.setCellValue("订单导入:");
+           row0cell1.setCellStyle(style1);
+           // 起始行, 终止行, 起始列, 终止列
+           CellRangeAddress cra =new CellRangeAddress(0, 0, 0, 5);
+           sheet.addMergedRegion(cra);
+
+           // 在第一行插入需要填写的订单信息
+           XSSFRow row1 = sheet.createRow(1);
+
+           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(style1);
+           row1cell2.setCellStyle(style);
+           row1cell3.setCellStyle(style1);
+           row1cell4.setCellStyle(style2);
+           row1cell5.setCellStyle(style1);
+           XSSFDrawing patr1 = sheet.createDrawingPatriarch();
+           // 定义注释的大小和位置,详见文档
+           XSSFComment comment = patr1.createCellComment(new XSSFClientAnchor(1, 3, 1,3, (short) 2, 1, (short) 3, 5));// 设置注释内容
+           XSSFComment comment1 = patr1.createCellComment(new XSSFClientAnchor(4, 6, 4,6, (short) 3, 2, (short) 4, 7));// 设置注释内容
+           comment.setString(new XSSFRichTextString("日期请输入yyyy-MM-dd!"));
+           comment1.setString(new XSSFRichTextString("日期请输入yyyy-MM-dd!"));
+           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(1, 1, 5, 5);
+           XSSFDataValidation zZoneValidation = (XSSFDataValidation) dvHelper.createValidation(zZoneConstraint, zZoneRange);
+           zZoneValidation.setSuppressDropDownArrow(true);
+           zZoneValidation.setShowErrorBox(true);
+           sheet.addValidationData(zZoneValidation);
+
+           // 设置第二行表头
+           XSSFRow row2 = sheet.createRow(2);
+           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);
+
+           // 起始行, 终止行, 起始列, 终止列
+           cra =new CellRangeAddress(2, 2, 4, 5);
+           sheet.addMergedRegion(cra);
+
+           // 设置第三行选中零件
+           XSSFRow row3 = sheet.createRow(3);
+           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(style2);
+           row3cell4.setCellStyle(style2);
+           row3cell5.setCellStyle(style);
+           row3cell6.setCellStyle(style);
+           CellRangeAddress cra1 =new CellRangeAddress(3, 3, 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();
+           }
+       }
+    }
+    @Override
+    public R<Boolean> saveExcelOrder(Order order, List<Map> detailList){
+        //验证是否配置了工序
+        List<String> bomList = detailList.stream().map(p -> p.get("bomId").toString()).collect(Collectors.toList());
+        List<BomProcedure> bomProcedureList = bomProcedureService.list(Wraps.<BomProcedure>lbQ().in(BomProcedure::getBomId,bomList));
+
+        Map<Long,List<BomProcedure>> bomProcedureMap = bomProcedureList.stream().collect(groupingBy(BomProcedure::getBomId, LinkedHashMap::new, toList()));
+
+        isFalse(CollectionUtil.isEmpty(bomProcedureList),"零件尚未配置工序,请确认");
+        for(Long l:bomProcedureMap.keySet()){
+            isFalse(bomProcedureMap.get(l).size()==0,"零件尚未配置工序,请确认");
+        }
+
+        //验证炉号
+        if(detailList != null && detailList.size() > 0){
+            List<String> furnaceBatchList = detailList.stream().map(p -> p.get("furnaceBatchNo").toString()).collect(Collectors.toList());
+            List<MMeterialReceiveLog> meterialReceiveLogList = meterialReceiveLogService.list(Wraps.<MMeterialReceiveLog>lbQ().in(MMeterialReceiveLog::getFurnaceBatchNo,furnaceBatchList));
+            Map<String,MMeterialReceiveLog> meterialReceiveLogMap = meterialReceiveLogList.stream().collect(Collectors.toMap(t->t.getFurnaceBatchNo().toString(), t->t));
+            List<MMeterialReceiveLog>l = new ArrayList<MMeterialReceiveLog>();
+            for(Map map:detailList){
+                String furnaceBatchNo = map.get("furnaceBatchNo")==null?"":map.get("furnaceBatchNo").toString();
+                int bomNum = Double.valueOf(map.get("bomNum").toString()).intValue();
+                MMeterialReceiveLog m = meterialReceiveLogMap.get(furnaceBatchNo);
+                map.put("meterialReceiveId",m.getId());
+                int usedNum = (m.getUsedNum()==null?0:m.getUsedNum());
+                isFalse(bomNum>m.getBatchStand()-usedNum,"零件数超出");
+                m.setUsedNum(bomNum+usedNum);
+                l.add(m);
+            }
+            //修改已用数量
+            meterialReceiveLogService.saveOrUpdateBatch(l);
+        }
+
+        //根据编码规则
+        String no = codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_ORDER);
+        order.setOrderNo(no);
+        super.save(order);
+
+        int productNum = 0;
+        if(detailList != null && detailList.size() > 0){
+            for(Map map:detailList){
+                OrderProduct item = new OrderProduct();
+                item.setOrderId(order.getId());
+                item.setOrderNo(order.getOrderNo());
+                item.setFurnaceBatchNo(map.get("furnaceBatchNo").toString());
+                item.setMeterialReceiveId(Long.parseLong(map.get("meterialReceiveId").toString()));
+                item.setBomId(Long.parseLong(map.get("bomId").toString()));
+                item.setBomNum(Double.valueOf(map.get("bomNum").toString()).intValue());
+                productNum+=item.getBomNum();
+                if(map.get("deliveryTime")!=null){
+                    item.setDeliveryTime(DateUtil.stringToDate3(map.get("deliveryTime").toString()));
+                }
+                item.setRemark(map.get("remark")==null?"":map.get("remark").toString());
+                orderProductService.save(item);
+            }
+        }
+
+        order.setProductNum(productNum);
+        baseMapper.updateAllById(order);
+        return R.success(true);
+    }
 }

+ 5 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionReadyCenter/dao/MMeterialReceiveLogMapper.java

@@ -9,6 +9,9 @@ import com.github.zuihou.business.productionReadyCenter.entity.Plate;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * Mapper 接口
@@ -21,4 +24,6 @@ import org.springframework.stereotype.Repository;
 @Repository
 public interface MMeterialReceiveLogMapper extends SuperMapper<MMeterialReceiveLog> {
     IPage<MMeterialReceiveLog> pageList(IPage page, @Param(Constants.WRAPPER) Wrapper<MMeterialReceiveLog> queryWrapper);
+
+    List<Map<String, String>> selectValidMeterialList();
 }

+ 9 - 8
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/ManualTaskOperatorUtil.java

@@ -239,14 +239,11 @@ public class ManualTaskOperatorUtil {
                         setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
                     }else if("move".equals(taskType) && currentIndex == 3){
                         String hostSyetemTaskUrl = hostSyetemUrl + "/api/MoveRobotPosition";
-                        // 查找设备机器人
-                        productionresourcePositions = productionresourcePositions.stream().filter(p->null == p.getGoodsId() && "1".equals(p.getLockStatus())).collect(toList());
-
                         String location = manualInfo.getEndpointId();
                         setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
                     }if("get".equals(taskType) && currentIndex == 4){
                         String hostSyetemTaskUrl = hostSyetemUrl + "/api/GetFlexibleWire";
-                        productionresourcePositions = productionresourcePositions.stream().filter(p->null == p.getGoodsId()).collect(toList());
+                        productionresourcePositions = productionresourcePositions.stream().filter(p->null == p.getGoodsId()  && "1".equals(p.getLockStatus())).collect(toList());
 
                         String location = productionresourcePositions.get(0).getPointId().toString();
                         setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
@@ -281,19 +278,23 @@ public class ManualTaskOperatorUtil {
                         setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
                     }else if("put".equals(taskType) && currentIndex == 2){
                         String hostSyetemTaskUrl = hostSyetemUrl + "/api/SendFlexibleWire";
-                        String location = manualInfo.getStartpointId();
+                        productionresourcePositions = productionresourcePositions.stream().filter(p->null == p.getGoodsId() && "1".equals(p.getLockStatus())).collect(toList());
+
+                        String location = productionresourcePositions.get(0).getPointId().toString();
                         setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
                     }else if("move".equals(taskType) && currentIndex == 3){
                         String hostSyetemTaskUrl = hostSyetemUrl + "/api/MoveRobotPosition";
-                        String location = manualInfo.getStartpointId();
+                        String location = manualInfo.getEndpointId();
                         setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
                     }if("get".equals(taskType) && currentIndex == 4){
                         String hostSyetemTaskUrl = hostSyetemUrl + "/api/GetFlexibleWire";
-                        String location = manualInfo.getStartpointId();
+                        productionresourcePositions = productionresourcePositions.stream().filter(p->null == p.getGoodsId()  && "1".equals(p.getLockStatus())).collect(toList());
+
+                        String location = productionresourcePositions.get(0).getPointId().toString();
                         setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
                     }else if("put".equals(taskType) && currentIndex == 5){
                         String hostSyetemTaskUrl = hostSyetemUrl + "/api/SendFlexibleWire";
-                        String location = manualInfo.getStartpointId();
+                        String location = manualInfo.getEndpointId();
                         setProcessInfo(taskNodes, processInfo, hostSyetemTaskUrl, location, deviceUrl, devicePort);
                     }
                     manualInfo.setNextTaskNodeIndex(nextTaskNodeIndex);

+ 13 - 0
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/productionReadyCenter/MMeterialReceiveLogMapper.xml

@@ -35,4 +35,17 @@
         left join imcs_m_meterial m on l.meterial_id = m.id
         ) s ${ew.customSqlSegment}
     </select>
+    <select id="selectValidMeterialList" resultType="java.util.Map">
+        SELECT
+          izz.name,
+          imm.equipment_name AS equipmentName,
+          immrl.furnace_batch_no  AS furnaceBatchNo,
+          immrl.batch_stand - immrl.used_num AS remindNum
+        FROM imcs_z_zone izz,
+             imcs_m_meterial imm,
+             imcs_m_meterial_receive_log immrl
+        WHERE izz.id = imm.zone_id
+        AND imm.id = immrl.meterial_id
+        AND immrl.batch_stand - immrl.used_num > 0
+    </select>
 </mapper>

+ 163 - 4
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/OrderController.java

@@ -1,8 +1,15 @@
 package com.github.zuihou.business.controller.operationManagementCenter;
 
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.ExcelImportUtil;
+import cn.afterturn.easypoi.excel.entity.ImportParams;
+import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
+import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.authority.dto.auth.UserExcelVO;
+import com.github.zuihou.authority.entity.auth.User;
 import com.github.zuihou.base.request.PageParams;
 import com.github.zuihou.business.operationManagementCenter.entity.Order;
 import com.github.zuihou.business.operationManagementCenter.dto.OrderSaveDTO;
@@ -12,32 +19,54 @@ import com.github.zuihou.business.operationManagementCenter.entity.OrderProduct;
 import com.github.zuihou.business.operationManagementCenter.service.OrderProductService;
 import com.github.zuihou.business.operationManagementCenter.service.OrderService;
 
+import java.io.*;
+import java.net.URL;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 import com.github.zuihou.base.controller.SuperController;
 import com.github.zuihou.base.R;
+import com.github.zuihou.common.constant.BizConstant;
+import com.github.zuihou.common.constant.CodeRuleModule;
+import com.github.zuihou.common.constant.DictionaryType;
+import com.github.zuihou.common.util.DateUtil;
 import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
 import com.github.zuihou.log.annotation.SysLog;
+import com.github.zuihou.model.RemoteData;
 import com.github.zuihou.security.annotation.LoginUser;
 import com.github.zuihou.security.model.SysUser;
+import com.github.zuihou.utils.MapHelper;
+import com.github.zuihou.utils.StrPool;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.util.CellRangeAddressList;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.*;
 import com.github.zuihou.security.annotation.PreAuth;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
 import springfox.documentation.annotations.ApiIgnore;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.groups.Default;
+
 
 /**
  * <p>
@@ -194,4 +223,134 @@ public class OrderController extends SuperController<OrderService, Long, Order,
     }
 
 
+    @ApiOperation(value = "下载订单导入模板", notes = "下载订单导入模板")
+    @PostMapping("/downloadOrderTemplate")
+    public void downloadOrderTemplate(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, @RequestBody Map<String,Object> params) throws IOException {
+
+        baseService.downloadOrderTemplate(httpServletResponse);
+
+    }
+
+    @Override
+    public R<Boolean> importExcel(@RequestParam("file") MultipartFile simpleFile, HttpServletRequest request,
+                                  HttpServletResponse response) throws Exception {
+
+        List<List<Object>> excelOrders = getBankListByExcel(simpleFile.getInputStream(), simpleFile.getOriginalFilename());
+        simpleFile.getInputStream().close();
+        if(excelOrders.size() < 3){
+            return this.validFail("导入数据订单明细不能为空");
+        }
+        Order order = new Order();
+        List<Object> orderInfo = excelOrders.get(0);
+        if(orderInfo.size() != 6){
+            return this.validFail("导入订单数据不完整");
+        }
+
+        String zZoneInfo = String.valueOf(orderInfo.get(5));
+        String[] zZoneInfos = zZoneInfo.split("-");
+        if(zZoneInfos.length != 2){
+            return this.validFail("导入订单数据所属产线不正确");
+        }
+        order.setSource("1");
+        order.setOrderStatus("1");
+        order.setStatus("1");
+        order.setOrderName(String.valueOf(orderInfo.get(1)));
+        order.setZoneId(Long.parseLong(zZoneInfos[0]));
+        order.setCustId(Long.parseLong("0"));
+        order.setOrderTime(DateUtil.stringToDate3(String.valueOf(orderInfo.get(3))));
+
+        List<Map> detailList = new ArrayList<>();
+        for(int i = 0; i < excelOrders.size(); i++){
+            // 遍历订单产品
+            if(i > 1){
+                Map orderProduct = new HashedMap();
+                List<Object> line = excelOrders.get(i);
+                // 零件
+                String[] bbomInfos = String.valueOf(line.get(0)).split("-");
+                if(bbomInfos.length != 2){
+                    return this.validFail("导入订单数据第" + "行零件名称不正确");
+                }
+                orderProduct.put("bomId",bbomInfos[0]);
+
+                // 原材料原炉号
+                String[] furnaceBatchNoInfos = String.valueOf(line.get(1)).split("-");
+                if(furnaceBatchNoInfos.length != 4){
+                    return this.validFail("导入订单数据第" + "行零件原材料原炉批号不正确");
+                }
+                orderProduct.put("furnaceBatchNo",furnaceBatchNoInfos[2]);
+                orderProduct.put("bomNum",line.get(2));
+                orderProduct.put("deliveryTime",line.get(3));
+                orderProduct.put("remark",line.get(4));
+
+                detailList.add(orderProduct);
+            }
+        }
+        return baseService.saveExcelOrder(order,detailList);
+
+    }
+
+    /**
+     * 处理上传的文件
+     *
+     * @param in
+     * @param fileName
+     * @return
+     * @throws Exception
+     */
+    private List getBankListByExcel(InputStream in, String fileName) throws Exception {
+        List list = new ArrayList<>();
+        //创建Excel工作薄
+        Workbook work = this.getWorkbook(in, fileName);
+        if (null == work) {
+            throw new Exception("创建Excel工作薄为空!");
+        }
+        Sheet sheet = null;
+        Row row = null;
+        Cell cell = null;
+
+        for (int i = 0; i < work.getNumberOfSheets(); i++) {
+            sheet = work.getSheetAt(i);
+            if (sheet == null) {
+                continue;
+            }
+
+            for (int j = sheet.getFirstRowNum(); j <= sheet.getLastRowNum(); j++) {
+                row = sheet.getRow(j);
+                if (row == null || row.getFirstCellNum() == j) {
+                    continue;
+                }
+
+                List<Object> li = new ArrayList<>();
+                for (int y = row.getFirstCellNum(); y < row.getLastCellNum(); y++) {
+                    cell = row.getCell(y);
+                    li.add(cell);
+                }
+                list.add(li);
+            }
+        }
+        work.close();
+        return list;
+    }
+
+    /**
+     * 判断文件格式
+     *
+     * @param inStr
+     * @param fileName
+     * @return
+     * @throws Exception
+     */
+    private Workbook getWorkbook(InputStream inStr, String fileName) throws Exception {
+        Workbook workbook = null;
+        String fileType = fileName.substring(fileName.lastIndexOf("."));
+        if (".xls".equals(fileType)) {
+            workbook = new HSSFWorkbook(inStr);
+        } else if (".xlsx".equals(fileType)) {
+            workbook = new XSSFWorkbook(inStr);
+        } else {
+            throw new Exception("请上传excel文件!");
+        }
+        return workbook;
+    }
+
 }

+ 0 - 4
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/operationManagementCenter/PlanController.java

@@ -239,7 +239,6 @@ public class PlanController extends SuperController<PlanService, Long, Plan, Pla
         FileOutputStream fos = new FileOutputStream(temp.getAbsolutePath());
 
 
-        BufferedInputStream bis = null;
         OutputStream outputStream = null;
         try {
             // 模板填充数据
@@ -255,9 +254,6 @@ public class PlanController extends SuperController<PlanService, Long, Plan, Pla
         } catch ( IOException e ) {
             e.printStackTrace();
         } finally {
-            if (bis != null) {
-                bis.close();
-            }
             if (outputStream != null) {
                 outputStream.flush();
                 outputStream.close();