春风项目四线(合箱线、总装线)
yyt
2024-05-22 696fd55ecc1243bce1d421d95cb9fba4b0a598b1
jcdm-main/src/main/java/com/jcdm/main/om/productionOrde/controller/OmProductionOrdeInfoController.java
@@ -1,9 +1,20 @@
package com.jcdm.main.om.productionOrde.controller;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.jcdm.main.bs.modelNumber.domain.BsModelNumber;
import com.jcdm.main.bs.modelNumber.service.IBsModelNumberService;
import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService;
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo;
import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService;
import com.jcdm.main.webservice.service.ReceivingServices;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -21,6 +32,8 @@
import com.jcdm.common.utils.poi.ExcelUtil;
import com.jcdm.common.core.page.TableDataInfo;
import static org.apache.commons.lang3.SystemUtils.getUserName;
/**
 * 生产工单Controller
 * 
@@ -33,6 +46,12 @@
{
    @Autowired
    private IOmProductionOrdeInfoService omProductionOrdeInfoService;
    @Autowired
    private IBsOrderSchedulingService bsOrderSchedulingService;
    @Autowired
    private IBsModelNumberService bsModelNumberService;
    /**
     * 查询生产工单列表
@@ -70,6 +89,16 @@
    }
    /**
     * 获取生产工单详细信息
     */
    @PreAuthorize("@ss.hasPermi('om:productionOrde:query')")
    @GetMapping("/ids/{ids}")
    public AjaxResult getInfo(@PathVariable Long[] ids)
    {
        return success(omProductionOrdeInfoService.selectOmProductionOrdeInfoByIds(ids));
    }
    /**
     * 新增生产工单
     */
    @PreAuthorize("@ss.hasPermi('om:productionOrde:add')")
@@ -78,6 +107,61 @@
    public AjaxResult add(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
    {
        return toAjax(omProductionOrdeInfoService.insertOmProductionOrdeInfo(omProductionOrdeInfo));
    }
    /**
     * 生成按钮
     */
    @PostMapping("/orderSchedulingForBoxCode")
    public AjaxResult addOrderSchedulingForBoxCode(@RequestBody OmProductionOrdeInfo omProductionOrdeInfo)
    {
        //获取当前时间
        LocalDateTime date= LocalDateTime.now();
        //创建日期时间对象格式化器,日期格式类似: 2023-05-23 22:18:38
        DateTimeFormatter formatter= DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        //将时间转化为对应格式的字符串
        String fomateDate=date.format(formatter).toString();
        Integer startCode = Integer.parseInt(omProductionOrdeInfo.getStartCode());//开始编号
        String dateTimeRule = omProductionOrdeInfo.getDateTimeRule();
        Long[] id=omProductionOrdeInfo.getIdNums();
        OmProductionOrdeInfo ProductionOrde;
        for (int a=0;a<id.length;a++){
            ProductionOrde=omProductionOrdeInfoService.selectOmProductionOrdeInfoById(id[a]);
            Integer planQty = Math.toIntExact(ProductionOrde.getPlanQty());//计划数量
            String engineNo = "";
            if(planQty>0) {
                for (int i = 0; i < planQty; i++) {
                    engineNo = omProductionOrdeInfo.getTypeZ() + " " + dateTimeRule + StringUtils.leftPad(String.valueOf(startCode), 3, "0");
                    BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
                    bsOrderScheduling.setOrderNo(ProductionOrde.getWorkOrderNo());
                    bsOrderScheduling.setModel(ProductionOrde.getTypeZ());
                    bsOrderScheduling.setEngineNo(engineNo);
                    bsOrderScheduling.setProductionStatus("1");
                    bsOrderScheduling.setOperator(getUserName());
                    bsOrderScheduling.setOperateTime(fomateDate);
                    bsOrderScheduling.setProductType(ProductionOrde.getTypeL());//产品类型
                    bsOrderScheduling.setWhetherOrPrint("0");
                    bsOrderSchedulingService.insertBsOrderScheduling(bsOrderScheduling);
                    startCode++;
                }
            }
            //更新工单状态
            ProductionOrde.setOrderStatus("2");
            omProductionOrdeInfoService.updateOmProductionOrdeInfo(ProductionOrde);
        }
        //新增机型序号
        BsModelNumber bsModelNumber = new BsModelNumber();
        bsModelNumber.setModel(omProductionOrdeInfo.getTypeZ());
        bsModelNumber.setModelDate(dateTimeRule);
        bsModelNumber.setMaxnumValue((startCode - 1) + "");
        bsModelNumber.setSaveTime(fomateDate);
        bsModelNumber.setLastNumber((startCode - 1) + "");
        bsModelNumberService.insertBsModelNumber(bsModelNumber);
        return toAjax(1);
    }
    /**
@@ -111,4 +195,25 @@
    {
        return omProductionOrdeInfoService.upDownMove(omProductionOrdeInfo);
    }
    /**
     * 接收工单
     */
    @PreAuthorize("@ss.hasPermi('om:productionOrde:receive')")
    @GetMapping("/getProductionNotice")
    public AjaxResult getProductionNotice(OmProductionOrdeInfo omProductionOrdeInfo)
    {
        String productionNotice = omProductionOrdeInfo.getProductionNotice();
        List<OmProductionOrdeInfo> omProductionOrdeInfos = omProductionOrdeInfoService.selectOmProductionOrdeInfoList(omProductionOrdeInfo);
        if(omProductionOrdeInfos.size() == 0){
            try {
                ReceivingServices.insertWebserviceData(productionNotice);
            } catch (Exception e) {
                return error("接收失败!请检查通知单号");
            }
        }else {
            return warn("该通知单已经接收完毕,不能重复接收!");
        }
        return AjaxResult.success("接收成功!");
    }
}