use of com.eservice.api.model.task_quality_record.TaskQualityRecord in project sinsim by WilsonHu.
the class TaskQualityRecordController method updateTaskQualityRecordDetail.
/**
* 根据传入的strTaskQualityRecordDetail,更新对应多表:
* "machine_id":"", --> machine.machine_id
* "检验是否合格":"", --> task_quality_record.status 质检结果: "1"==>通过; “0”==>不通过
* "不合格原因":"", --> task_quality_record.comment
* "不合格照片":"", --> quality_record_image.image
* "检验完成":"", --> task_record.status task状态,“1”==>未开始, “2”==>进行中,“3”==>安装完成, “4”==>质检完成,“5“===>异常
* @param strTaskQualityRecordDetail
* @return
*/
@PostMapping("updateTaskQualityRecordDetail")
public Result updateTaskQualityRecordDetail(@RequestParam String strTaskQualityRecordDetail) {
TaskQualityRecordDetail taskQualityRecordDetail = JSON.parseObject(strTaskQualityRecordDetail, TaskQualityRecordDetail.class);
Integer taskQualityRecordDetail_ID = taskQualityRecordDetail.getId();
TaskQualityRecord taskQualityRecord = taskQualityRecordService.findById(taskQualityRecordDetail_ID);
taskQualityRecord.setTaskRecordId(taskQualityRecordDetail.getTaskRecordId());
taskQualityRecord.setName(taskQualityRecordDetail.getName());
taskQualityRecord.setStatus(taskQualityRecordDetail.getStatus());
taskQualityRecord.setCreateTime(taskQualityRecordDetail.getCreateTime());
taskQualityRecord.setComment(taskQualityRecordDetail.getComment());
QualityRecordImage qualityRecordImage = taskQualityRecordDetail.getQualityRecordImage();
TaskRecord taskRecord = taskQualityRecordDetail.getTaskRecord();
taskQualityRecordService.update(taskQualityRecord);
qualityRecordImageService.update(qualityRecordImage);
taskRecordService.update(taskRecord);
return ResultGenerator.genSuccessResult();
}
use of com.eservice.api.model.task_quality_record.TaskQualityRecord in project sinsim by WilsonHu.
the class TaskRecordController method addTrTqrQri.
/**
* 3个表 task_record/TaskQualityRecord/QualityRecordImage 更新。
* app端,上传质检异常状态,task_record(update),增加 TaskQualityRecord(add), QualityRecordImage (add)
* 没有质检员了,这个接口没在用。
*/
@Transactional(rollbackFor = Exception.class)
@PostMapping("/addTrTqrQri")
public Result addTrTqrQri(@RequestParam String taskRecord, @RequestParam String taskQualityRecord, @RequestParam MultipartFile[] files) {
// task_record(update)
TaskRecord taskRecord1 = JSON.parseObject(taskRecord, TaskRecord.class);
taskRecordService.update(taskRecord1);
TaskQualityRecord taskQualityRecord1 = JSON.parseObject(taskQualityRecord, TaskQualityRecord.class);
// 质检异常类型,目前未使用,default值为1
taskQualityRecord1.setAbnormalType(1);
taskQualityRecordService.saveAndGetID(taskQualityRecord1);
// 获取保存后分配到的id
Integer taskQualityRecordId = taskQualityRecord1.getId();
// 构建 qualityRecordImage1
QualityRecordImage qualityRecordImage1 = new QualityRecordImage();
File dir = new File(qualityImagesSavedDir);
if (!dir.exists()) {
dir.mkdir();
}
String machineID = machineService.searchMachineByTaskQualityRecordId(taskQualityRecordId).getMachineStrId();
Integer orderId = machineService.searchMachineByTaskQualityRecordId(taskQualityRecordId).getOrderId();
String orderNum = machineOrderService.findById(orderId).getOrderNum();
List<String> listResultPath = new ArrayList<>();
for (int i = 0; i < files.length; i++) {
try {
listResultPath.add(commonService.saveFile(qualityImagesSavedDir, files[i], machineID, orderNum, Constant.QUALITY_IMAGE, i));
} catch (IOException e) {
e.printStackTrace();
// 抛异常引发回滚,防止数据只更新了前面部分。
throw new RuntimeException();
}
}
if (listResultPath.size() != files.length) {
throw new RuntimeException();
} else {
qualityRecordImage1.setTaskQualityRecordId(taskQualityRecordId);
qualityRecordImage1.setImage(listResultPath.toString());
qualityRecordImage1.setCreateTime(taskQualityRecord1.getCreateTime());
qualityRecordImageService.save(qualityRecordImage1);
}
// 找到工序对应的quality_user_id
String taskName = taskRecord1.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();
}
Integer prId = taskRecord1.getProcessRecordId();
if (prId == null || prId < 0) {
Logger.getLogger("").log(Level.INFO, "processrecord Id 为空");
} else {
// Update task record相关的状态
if (!commonService.updateTaskRecordRelatedStatus(taskRecord1)) {
// 更新出错进行事务回退
throw new RuntimeException();
}
}
ProcessRecord pr = processRecordService.findById(prId);
Machine machine = machineService.findById(pr.getMachineId());
MachineOrder machineOrder = machineOrderService.findById(machine.getOrderId());
ServerToClientMsg msg = new ServerToClientMsg();
msg.setOrderNum(machineOrder.getOrderNum());
msg.setNameplate(machine.getNameplate());
if (taskRecord1.getStatus().equals(Constant.TASK_QUALITY_ABNORMAL)) {
// MQTT 发生质检异常时,通知安装组长以及生产部管理员
mqttMessageHelper.sendToClient(Constant.S2C_QUALITY_ABNORMAL + taskList.get(0).getGroupId(), JSON.toJSONString(msg));
}
return ResultGenerator.genSuccessResult("3个表 task_record + TaskQualityRecord + QualityRecordImage 更新成功");
}
use of com.eservice.api.model.task_quality_record.TaskQualityRecord in project sinsim by WilsonHu.
the class TaskQualityRecordController method update.
/**
* web在提交解决方案时“在用”,但是因为 app没有在用, 即没有提交质检结果的地方。所以实际上没有作用。
* 三期采用新的质检体系,这些都不会再被用
*/
// /
@PostMapping("/update")
public Result update(String taskQualityRecord) {
TaskQualityRecord taskQualityRecord1 = JSON.parseObject(taskQualityRecord, TaskQualityRecord.class);
taskQualityRecord1.setSolveTime(new Date());
// 修改对应工序的状态为“质检中”
TaskQualityRecord completeInfo = taskQualityRecordService.findById(taskQualityRecord1.getId());
Integer taskRecordId = completeInfo.getTaskRecordId();
if (taskRecordId != null && taskRecordId > 0) {
TaskRecord tr = taskRecordService.findById(taskRecordId);
// MQTT 异常解决后,通知工序的质检员
String taskName = tr.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();
}
tr.setStatus(Constant.TASK_QUALITY_DOING);
taskRecordService.update(tr);
// 更新task record状态时候,必须去更新process record中对应task的状态
commonService.updateTaskRecordRelatedStatus(tr);
ProcessRecord pr = processRecordService.findById(tr.getProcessRecordId());
Machine machine = machineService.findById(pr.getMachineId());
ServerToClientMsg msg = new ServerToClientMsg();
MachineOrder machineOrder = machineOrderService.findById(machine.getOrderId());
msg.setOrderNum(machineOrder.getOrderNum());
msg.setNameplate(machine.getNameplate());
mqttMessageHelper.sendToClient(Constant.S2C_QUALITY_ABNORMAL_RESOLVE + taskList.get(0).getQualityUserId(), JSON.toJSONString(msg));
} else {
throw new RuntimeException();
}
taskQualityRecordService.update(taskQualityRecord1);
return ResultGenerator.genSuccessResult();
}
use of com.eservice.api.model.task_quality_record.TaskQualityRecord in project sinsim by WilsonHu.
the class TaskQualityRecordController method list.
@PostMapping("/list")
public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
PageHelper.startPage(page, size);
List<TaskQualityRecord> list = taskQualityRecordService.findAll();
PageInfo pageInfo = new PageInfo(list);
return ResultGenerator.genSuccessResult(pageInfo);
}
use of com.eservice.api.model.task_quality_record.TaskQualityRecord in project sinsim by WilsonHu.
the class TaskQualityRecordController method add.
@PostMapping("/add")
public Result add(String taskQualityRecord) {
TaskQualityRecord taskQualityRecord1 = JSON.parseObject(taskQualityRecord, TaskQualityRecord.class);
taskQualityRecordService.save(taskQualityRecord1);
return ResultGenerator.genSuccessResult();
}
Aggregations