use of com.eservice.api.model.install_group.InstallGroup in project sinsim by WilsonHu.
the class TaskPlanServiceImpl method addTaskPlans.
// 每新增1个工序,调用一次。
@Transactional(rollbackFor = Exception.class)
public boolean addTaskPlans(@RequestParam List<Integer> taskRecordIds, Integer planType, String machineStrId, Date planDate, Integer userId) {
for (int i = 0; i < taskRecordIds.size(); i++) {
Condition tempCondition = new Condition(TaskPlan.class);
Integer id = taskRecordIds.get(i);
tempCondition.createCriteria().andCondition("task_record_id = ", id);
List<TaskPlan> existPlans = findByCondition(tempCondition);
if (existPlans.size() > 0) {
return false;
}
TaskPlan plan = new TaskPlan();
plan.setCreateTime(new Date());
plan.setUserId(userId);
plan.setTaskRecordId(id);
plan.setPlanType(Constant.DAILY_PLAN);
if (planType.intValue() == Constant.DAILY_PLAN.intValue()) {
plan.setPlanTime(planDate);
} else if (planType.intValue() == Constant.FLEX_PLAN.intValue()) {
plan.setDeadline(planDate);
}
save(plan);
// 更改task record状态为已计划
TaskRecord taskRecord = taskRecordService.findById(id);
if (taskRecord != null) {
// 检查是否为第一个计划项,如果是,需要设置为待安装状态
Integer processRecordId = taskRecord.getProcessRecordId();
ProcessRecord processRecord = processRecordService.findById(processRecordId);
List<LinkDataModel> linkDataList = JSON.parseArray(processRecord.getLinkData(), LinkDataModel.class);
for (LinkDataModel item : linkDataList) {
if (item.getTo().equals(taskRecord.getNodeKey().intValue())) {
if (item.getFrom() == null || item.getFrom() == -1) {
taskRecord.setUpdateTime(new Date());
taskRecord.setStatus(Constant.TASK_INSTALL_WAITING);
break;
} else {
// TODO:如果是重新配置流程项,比如:改单、拆单以后再最后增加了安装项,则需要设置成待安装状态
List<Integer> parentNodeList = new ArrayList<>();
String nodeData = processRecord.getNodeData();
List<NodeDataModel> ndList = JSON.parseArray(nodeData, NodeDataModel.class);
for (LinkDataModel tmp : linkDataList) {
if (tmp.getTo() == taskRecord.getNodeKey().intValue()) {
parentNodeList.add(tmp.getFrom());
}
}
boolean allParentFinished = true;
for (Integer parentNodeKey : parentNodeList) {
for (NodeDataModel nodeDataModel : ndList) {
if (parentNodeKey.intValue() == Integer.valueOf(nodeDataModel.getKey())) {
if (Integer.valueOf(nodeDataModel.getTaskStatus()) != Constant.TASK_QUALITY_DONE.intValue()) {
allParentFinished = false;
break;
}
}
}
if (!allParentFinished) {
break;
}
}
if (allParentFinished) {
taskRecord.setUpdateTime(new Date());
taskRecord.setStatus(Constant.TASK_INSTALL_WAITING);
}
}
}
}
if (taskRecord.getStatus().equals(Constant.TASK_INITIAL)) {
taskRecord.setStatus(Constant.TASK_PLANED);
}
taskRecordService.update(taskRecord);
// 更新task_record以外,但是跟task record相关的状态,机器状态,process_record中的task_status
commonService.updateTaskRecordRelatedStatus(taskRecord);
if (taskRecord.getStatus().equals(Constant.TASK_INSTALL_WAITING)) {
// MQTT 计划后,通知安装组长,可以进行安装
String taskName = taskRecord.getTaskName();
Condition condition = new Condition(Task.class);
condition.createCriteria().andCondition("task_name = ", taskName);
List<Task> taskList = taskService.findByCondition(condition);
if (taskList == null || taskList.size() <= 0) {
throw new RuntimeException();
}
ProcessRecord pr = processRecordService.findById(taskRecord.getProcessRecordId());
Machine machine = machineService.findById(pr.getMachineId());
MachineOrder machineOrder = machineOrderService.findById(machine.getOrderId());
ServerToClientMsg msg = new ServerToClientMsg();
msg.setOrderNum(machineOrder.getOrderNum());
msg.setNameplate(machine.getNameplate());
mqttMessageHelper.sendToClient(Constant.S2C_TASK_INSTALL + taskList.get(0).getGroupId(), JSON.toJSONString(msg));
}
// /在”计划管理“中 添加计划安排时,自动添加了 总装排产 InstallPlan。 (InstallPlanActual则在app扫码完成工序时添加)
// 因为把总装排产,合并到“计划管理”,所以需要在安排计划时 自动生成总装排产(这样在app上扫码完成时,才能有总装完成自动填充完成头数)
InstallPlan installPlan1 = new InstallPlan();
installPlan1.setType(Constant.STR_INSTALL_TYPE_WHOLE);
InstallGroup installGroup = installGroupService.getInstallGroupByTaskName(taskRecord.getTaskName());
installPlan1.setInstallGroupId(installGroup.getId());
installPlan1.setInstallDatePlan(plan.getPlanTime());
ProcessRecord pr = processRecordService.findById(taskRecord.getProcessRecordId());
Machine machine = machineService.findById(pr.getMachineId());
MachineOrder machineOrder = machineOrderService.findById(machine.getOrderId());
installPlan1.setOrderId(machineOrder.getId());
installPlan1.setMachineId(machine.getId());
installPlan1.setValid(Byte.valueOf("1"));
installPlan1.setCreateDate(new Date());
installPlanService.save(installPlan1);
logger.info("自动添加了 总装排产 for 铭牌号: " + machine.getNameplate() + ", 工序: " + taskRecord.getTaskName());
} else {
// 进行事务操作
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
throw new RuntimeException();
}
}
if (taskRecordIds.size() > 0 && machineStrId != null) {
List<Machine> machineList = machineService.selectMachines(null, null, null, machineStrId, null, null, null, null, null, null, false);
if (machineList.size() == 1) {
// 如果机器状态小于计划中,则更新为计划中
Machine machine = machineList.get(0);
if (machine.getStatus() < Constant.MACHINE_PLANING) {
machine.setStatus(Constant.MACHINE_PLANING);
machineService.update(machine);
}
} else {
// 进行事务rollback操作
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
throw new RuntimeException();
}
}
return true;
}
use of com.eservice.api.model.install_group.InstallGroup in project sinsim by WilsonHu.
the class InstallPlanController method checkTheInstallPlanIsSet.
@PostMapping("/checkTheInstallPlanIsSet")
public Result checkTheInstallPlanIsSet(String installPlan) {
InstallPlan installPlan1 = JSON.parseObject(installPlan, InstallPlan.class);
if (installPlan1 == null) {
return ResultGenerator.genFailResult("参数installPlan1不能为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("错误, 该机器是不属于该订单");
}
// 检查该机器是否已经安排了该安装组的计划。
InstallGroup installGroup = installGroupService.findById(installPlan1.getInstallGroupId());
Machine machine = machineService.findById(installPlan1.getMachineId());
if (!isOKtoSetPlan(installGroup.getId(), machine.getId())) {
logger.warn("该机器 " + machine.getNameplate() + " 已经安排了 " + installGroup.getGroupName());
return ResultGenerator.genFailResult("该机器 " + machine.getNameplate() + " 已经安排了 " + installGroup.getGroupName());
}
return ResultGenerator.genSuccessResult("该排产允许添加");
}
use of com.eservice.api.model.install_group.InstallGroup 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_group.InstallGroup in project sinsim by WilsonHu.
the class InstallGroupController method list.
@PostMapping("/list")
public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
PageHelper.startPage(page, size);
List<InstallGroup> list = installGroupService.findAll();
PageInfo pageInfo = new PageInfo(list);
return ResultGenerator.genSuccessResult(pageInfo);
}
use of com.eservice.api.model.install_group.InstallGroup in project sinsim by WilsonHu.
the class InstallGroupController method getInstallGroupByType.
// type是“总装” ”部装“等类型
@PostMapping("/getInstallGroupByType")
public Result getInstallGroupByType(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, @RequestParam String type) {
PageHelper.startPage(page, size);
List<InstallGroup> list = installGroupService.getInstallGroupByType(type);
PageInfo pageInfo = new PageInfo(list);
return ResultGenerator.genSuccessResult(pageInfo);
}
Aggregations