Search in sources :

Example 6 with InstallPlan

use of com.eservice.api.model.install_plan.InstallPlan in project sinsim by WilsonHu.

the class TaskRecordController method createInstallPlanActual.

/**
 * 根据已完成的工序,自动生成 【对应工序的】的总装排产的实际完成情况
 */
public void createInstallPlanActual(TaskRecord tr) {
    /**
     * 如果机器某个工序已经完成(结束扫码),
     * 则该机器的 对应的总装的 工序的针数头数自动填写为全部完成,
     * 这样app用户就不需要重复去报告总装工序的情况。
     *
     * task_record --> process_record --> machine --> install_plan --> install_plan_actual
     */
    ProcessRecord pr = processRecordService.findById(tr.getProcessRecordId());
    Machine machine = machineService.findById(pr.getMachineId());
    List<InstallPlan> installPlanList = installPlanService.getInstallPlanByMachineId(machine.getId());
    MachineOrder machineOrder = machineOrderService.findById(machine.getOrderId());
    InstallGroup installGroup = installGroupService.getInstallGroupByTaskName(tr.getTaskName());
    for (InstallPlan installplan : installPlanList) {
        if (installGroup.getId() == installplan.getInstallGroupId()) {
            InstallPlanActual installPlanActual = new InstallPlanActual();
            installPlanActual.setCreateDate(new Date());
            installPlanActual.setInstallPlanId(installplan.getId());
            installPlanActual.setHeadCountDone(commonService.getRealSumValue(machineOrder.getHeadNum()));
            installPlanActualService.save(installPlanActual);
            // /这里可以获取id ! ...
            Logger.getLogger("").log(Level.INFO, "自动生成 实际总装 " + installPlanActual.getId() + ", 头数 " + installPlanActual.getHeadCountDone());
            break;
        } else {
        // Logger.getLogger("").log(Level.INFO, installGroup.getGroupName() + ", 无需生成 ");
        }
    }
}
Also used : InstallPlanActual(com.eservice.api.model.install_plan_actual.InstallPlanActual) ProcessRecord(com.eservice.api.model.process_record.ProcessRecord) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) InstallGroup(com.eservice.api.model.install_group.InstallGroup) Machine(com.eservice.api.model.machine.Machine) Date(java.util.Date) InstallPlan(com.eservice.api.model.install_plan.InstallPlan)

Example 7 with InstallPlan

use of com.eservice.api.model.install_plan.InstallPlan in project sinsim by WilsonHu.

the class InstallPlanServiceImpl method sendUnDeliveryInstallPlans.

public Result sendUnDeliveryInstallPlans() {
    /**
     * 通过MQTT 发送所有未发送的且排产日期为明天的排产计划
     */
    ServerToClientMsg msg = new ServerToClientMsg();
    List<InstallPlan> unSendInstallPlans = installPlanService.selectUnSendInstallPlans();
    int sendCount = 0;
    for (int i = 0; i < unSendInstallPlans.size(); i++) {
        Date now = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String nowDate = formatter.format(now);
        String installDatePlanDateString = formatter.format(unSendInstallPlans.get(i).getInstallDatePlan());
        if (getAfterDay(nowDate, 1).equals(installDatePlanDateString)) {
            logger.info(unSendInstallPlans.get(i).getInstallDatePlan() + " 明天要安装:" + machineService.findById(unSendInstallPlans.get(i).getMachineId()).getNameplate());
            msg.setNameplate(machineService.findById(unSendInstallPlans.get(i).getMachineId()).getNameplate());
            msg.setOrderNum(machineOrderService.findById(unSendInstallPlans.get(i).getOrderId()).getOrderNum());
            msg.setType(ServerToClientMsg.MsgType.INSTALL_PLAN);
            msg.setCmtSend(unSendInstallPlans.get(i).getCmtSend());
            msg.setInstallDatePlan(unSendInstallPlans.get(i).getInstallDatePlan());
            // topic结尾加安装组的groupId,并设置发送时间表示已发送。
            mqttMessageHelper.sendToClient(Constant.S2C_INSTALL_PLAN + unSendInstallPlans.get(i).getInstallGroupId(), JSON.toJSONString(msg));
            logger.info("MQTT SEND topic: " + Constant.S2C_INSTALL_PLAN + unSendInstallPlans.get(i).getInstallGroupId() + ", nameplate: " + msg.getNameplate());
            sendCount++;
            unSendInstallPlans.get(i).setSendTime(new Date());
            installPlanService.update(unSendInstallPlans.get(i));
        } else {
        // logger.info("还未到安装提醒时间的机器:"
        // + machineService.findById(unSendInstallPlans.get(i).getMachineId()).getNameplate()
        // + " 安装时间为 " + installDatePlanDateString);
        }
    }
    String str = "还未到安装提醒时间的任务: " + unSendInstallPlans.size() + "条," + "刚刚发送提醒 " + sendCount + "条";
    logger.info(str);
    return ResultGenerator.genSuccessResult(str);
}
Also used : ServerToClientMsg(com.eservice.api.service.mqtt.ServerToClientMsg) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) InstallPlan(com.eservice.api.model.install_plan.InstallPlan)

Example 8 with InstallPlan

use of com.eservice.api.model.install_plan.InstallPlan in project sinsim by WilsonHu.

the class InstallPlanController method getInstallPlanByMachineId.

/**
 * 根据机器ID 去查询排产计划,
 * 可以用于: 如果机器已经完成(结束扫码),--> 是某个工序 扫码完成
 * 则该机器的 【对应工序的】总装工序的 installPlanActurall的针数头数 自动填写为全部完成,
 * 这样app用户就不需要重复去报告总装工序的情况。
 */
@PostMapping("/getInstallPlanByMachineId")
public Result getInstallPlanByMachineId(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, @RequestParam Integer machineId) {
    PageHelper.startPage(page, size);
    List<InstallPlan> list = installPlanService.getInstallPlanByMachineId(machineId);
    PageInfo pageInfo = new PageInfo(list);
    return ResultGenerator.genSuccessResult(pageInfo);
}
Also used : PageInfo(com.github.pagehelper.PageInfo) InstallPlan(com.eservice.api.model.install_plan.InstallPlan)

Example 9 with InstallPlan

use of com.eservice.api.model.install_plan.InstallPlan in project sinsim by WilsonHu.

the class InstallPlanController method update.

@PostMapping("/update")
public Result update(String installPlan) {
    InstallPlan installPlan1 = JSON.parseObject(installPlan, InstallPlan.class);
    if (installPlan1 != null) {
        /**
         * 取消这部分检查,因为update时允许只update部分内容,不需要全部都update.
         */
        // if(installPlan1.getId() == null) {
        // return ResultGenerator.genFailResult("错误,installPlan1 id  为 null!");
        // }
        // if (installPlan1.getInstallGroupId() == null) {
        // return ResultGenerator.genFailResult("错误,getInstallGroupId 为 null!");
        // } else if (installGroupService.findById(installPlan1.getInstallGroupId()) == null) {
        // return ResultGenerator.genFailResult("错误,根据该InstallGroupId " + installPlan1.getInstallGroupId() + " 找不到对应的 installGroup!");
        // }
        // 
        // if (installPlan1.getInstallDatePlan() == null) {
        // return ResultGenerator.genFailResult("错误,InstallDatePlan 为 null!");
        // }
        // 
        // if (installPlan1.getOrderId() == null) {
        // return ResultGenerator.genFailResult("错误,orderId 为 null!");
        // } else if(machineOrderService.findById(installPlan1.getOrderId()) == null){
        // return ResultGenerator.genFailResult("错误,根据该 orderId " + installPlan1.getOrderId() + " 找不到对应的 machineOrder !");
        // }
        /**
         * 检查machine是否存在,并且和订单匹配
         */
        // if (installPlan1.getMachineId() == null) {
        // return ResultGenerator.genFailResult("错误,machineId 为 null!");
        // }  else if(machineService.findById(installPlan1.getMachineId()) == null){
        // return ResultGenerator.genFailResult("错误,根据该 machineId " + installPlan1.getMachineId() + " 找不到对应的 machine !");
        // } else if( !isMachineInTheOrder(installPlan1.getMachineId(), installPlan1.getOrderId())) {
        // return ResultGenerator.genFailResult("错误, 该机器是不属于该订单");
        // }
        installPlan1.setUpdateDate(new Date());
        installPlanService.update(installPlan1);
    } else {
        return ResultGenerator.genFailResult("参数不正确,添加失败!");
    }
    return ResultGenerator.genSuccessResult();
}
Also used : Date(java.util.Date) InstallPlan(com.eservice.api.model.install_plan.InstallPlan)

Example 10 with InstallPlan

use of com.eservice.api.model.install_plan.InstallPlan in project sinsim by WilsonHu.

the class InstallPlanController method add.

@PostMapping("/add")
public Result add(String installPlan) {
    Result result = checkTheInstallPlanIsSet(installPlan);
    if (result.getCode() == ResultCode.FAIL.code) {
        logger.warn("不合法的installPlan: " + result.getMessage());
        return result;
    }
    InstallPlan installPlan1 = JSON.parseObject(installPlan, InstallPlan.class);
    installPlan1.setCreateDate(new Date());
    installPlanService.save(installPlan1);
    Machine machine = machineService.findById(installPlan1.getMachineId());
    InstallGroup installGroup = installGroupService.findById(installPlan1.getInstallGroupId());
    logger.info("add install plan, nameplate: " + machine.getNameplate() + ",组: " + installGroup.getGroupName() + ", date: " + installPlan1.getInstallDatePlan());
    return ResultGenerator.genSuccessResult();
}
Also used : InstallGroup(com.eservice.api.model.install_group.InstallGroup) Date(java.util.Date) Machine(com.eservice.api.model.machine.Machine) Result(com.eservice.api.core.Result) InstallPlan(com.eservice.api.model.install_plan.InstallPlan)

Aggregations

InstallPlan (com.eservice.api.model.install_plan.InstallPlan)10 Date (java.util.Date)6 InstallGroup (com.eservice.api.model.install_group.InstallGroup)4 Machine (com.eservice.api.model.machine.Machine)4 ServerToClientMsg (com.eservice.api.service.mqtt.ServerToClientMsg)3 PageInfo (com.github.pagehelper.PageInfo)3 MachineOrder (com.eservice.api.model.machine_order.MachineOrder)2 ProcessRecord (com.eservice.api.model.process_record.ProcessRecord)2 Result (com.eservice.api.core.Result)1 InstallPlanActual (com.eservice.api.model.install_plan_actual.InstallPlanActual)1 Task (com.eservice.api.model.task.Task)1 TaskPlan (com.eservice.api.model.task_plan.TaskPlan)1 TaskRecord (com.eservice.api.model.task_record.TaskRecord)1 LinkDataModel (com.eservice.api.service.common.LinkDataModel)1 NodeDataModel (com.eservice.api.service.common.NodeDataModel)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Transactional (org.springframework.transaction.annotation.Transactional)1 Condition (tk.mybatis.mapper.entity.Condition)1