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() + ", 无需生成 ");
}
}
}
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);
}
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);
}
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();
}
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();
}
Aggregations