春风项目四线(合箱线、总装线)
wujian
2024-07-24 49ca7cac33b124324250f307b12ce84370daa2f3
jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/controller/BsOrderSchedulingController.java
@@ -13,6 +13,7 @@
import com.jcdm.common.core.domain.entity.SysDictData;
import com.jcdm.common.core.page.TableDataInfo;
import com.jcdm.common.enums.BusinessType;
import com.jcdm.common.exception.ServiceException;
import com.jcdm.common.utils.StringUtils;
import com.jcdm.common.utils.poi.ExcelUtil;
import com.jcdm.main.bs.orderScheduling.common.Constants;
@@ -45,10 +46,7 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -215,6 +213,16 @@
        List<BsOrderScheduling> list = new ArrayList<>();
        if (StringUtils.isNotEmpty(bsOrderScheduling.getOrderNo())){
            list = bsOrderSchedulingService.selectBsOrderSchedulingPage(bsOrderScheduling);
            if (CollUtil.isNotEmpty(list)){
                list.forEach(x -> {
                    if (StrUtil.isNotBlank(x.getWorkingHours())){
                        x.setWorkingHoursInt(Integer.parseInt(x.getWorkingHours()));
                    } else {
                        x.setWorkingHoursInt(0);
                    }
                });
                list = list.stream().sorted(Comparator.comparing(BsOrderScheduling::getWorkingHoursInt)).collect(Collectors.toList());
            }
        }
        List<BsOrderScheduling> collect = list.stream().filter(x -> Constants.UN_QUALIFIED.equals(x.getQualityStatus())).collect(Collectors.toList());
        if (CollUtil.isNotEmpty(collect)){
@@ -315,21 +323,35 @@
     */
    @Transactional(rollbackFor = Exception.class)
    @GetMapping("/engineNoIsInModel")
    public R engineNoIsInModel(String engineNo,String model,String orderNo) throws Exception {
    public R engineNoIsInModel(String engineNo,String model,String orderNo,Boolean repairFlag) throws Exception {
        if (StringUtils.isEmpty(engineNo)){
            return R.fail(500,"箱体码为空或已存在,请重试");
            return R.fail(500,"箱体码不能为空,请重试");
        }
        ProductNewPassStation checkStation = new ProductNewPassStation();
        checkStation.setBoxCode(engineNo);
        List<ProductNewPassStation> checkList = productNewPassStationService.getProductPassStationList(checkStation);
        if (!repairFlag){
            if (CollUtil.isNotEmpty(checkList)){
                return R.fail(500,"请勿重复扫描箱体码");
            }
        }
        BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
        bsOrderScheduling.setOrderNo(orderNo);
        List<BsOrderScheduling> allList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling);
        if (CollUtil.isNotEmpty(allList)){
            allList.forEach(x -> {
                if (StrUtil.isNotBlank(x.getWorkingHours())){
                    x.setWorkingHoursInt(Integer.parseInt(x.getWorkingHours()));
                } else {
                    x.setWorkingHoursInt(0);
                }
            });
            allList = allList.stream().sorted(Comparator.comparing(BsOrderScheduling::getWorkingHoursInt)).collect(Collectors.toList());
        }
        List<BsOrderScheduling> dlist = allList.stream().filter(x->x.getProductionStatus().equals(Constants.WAIT_PRODUCTION)).collect(Collectors.toList());
        List<BsOrderScheduling> collect = allList.stream().filter(x -> x.getProductionStatus().equals(Constants.ORDER_STATUS_ING)
                ||x.getProductionStatus().equals(Constants.FINISH_PRODUCTION)).collect(Collectors.toList());
        if (CollUtil.isNotEmpty(checkList)){
            //重复扫码
            ProductNewPassStation productNewPassStation = checkList.get(0);
@@ -347,6 +369,8 @@
            } else {
                //OPC操作
                logger.info("当前站重新扫码,{}",sfcCode);
//                ReadWriteEntity entity3 = new ReadWriteEntity("CFL4HX.OP010.ProductTypeSN",sfcCode);
//                OPCUaSubscription.miloService.writeToOpcUa(entity3);//写产品SN号反馈
                ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP010.Code", sfcCode);
                OPCUaSubscription.miloService.writeToOpcUa(entity);//写SN
                return R.ok();
@@ -363,7 +387,7 @@
                    OmProductionOrdeInfo omProductionOrdeInfo = omProductionOrdeInfos.get(0);
                    Long planQty = omProductionOrdeInfo.getPlanQty();
                    if (planQty<collect.size()){
                        return R.ok(500,"超出计划数量,请检查后重试");
                        return R.fail(500,"超出计划数量,请检查后重试");
                    }
                }
                //插入数据