use of com.eservice.api.model.quality_record_image.QualityRecordImage 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.quality_record_image.QualityRecordImage 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.quality_record_image.QualityRecordImage in project sinsim by WilsonHu.
the class QualityRecordImageController method update.
@PostMapping("/update")
public Result update(String qualityRecordImage) {
QualityRecordImage qualityRecordImage1 = JSON.parseObject(qualityRecordImage, QualityRecordImage.class);
qualityRecordImageService.update(qualityRecordImage1);
return ResultGenerator.genSuccessResult();
}
use of com.eservice.api.model.quality_record_image.QualityRecordImage in project sinsim by WilsonHu.
the class QualityRecordImageController method add.
/**
* 增加 qualityRecordImage 时,也保存了图片,可以多张图片
* (10+ 张图片应该没问题,quality_record_image.image字段长度1000,保存的路径长度不要超过这个值就好)。
* @param qualityRecordImage
* @param files
* @return
*/
@PostMapping("/add")
public Result add(String qualityRecordImage, MultipartFile[] files) {
QualityRecordImage qualityRecordImage1 = JSON.parseObject(qualityRecordImage, QualityRecordImage.class);
Integer taskQualityRecordId = qualityRecordImage1.getTaskQualityRecordId();
File dir = new File(imagesSavedDir);
if (!dir.exists()) {
dir.mkdir();
}
String machineID = searchMachineByTaskQualityRecordId(taskQualityRecordId);
if (null == machineID) {
return ResultGenerator.genFailResult("Error: no machine found by the taskQualityRecordId, no records saved");
}
String orderNum = machineService.searchMachineByTaskQualityRecordId(taskQualityRecordId).getOrderId().toString();
List<String> listResultPath = new ArrayList<>();
for (int i = 0; i < files.length; i++) {
try {
listResultPath.add(commonService.saveFile(imagesSavedDir, files[i], machineID, orderNum, Constant.QUALITY_IMAGE, i));
} catch (IOException e) {
e.printStackTrace();
}
}
if (listResultPath.size() == 0) {
return ResultGenerator.genFailResult("failed to save quality file, no records saved");
} else {
qualityRecordImage1.setImage(listResultPath.toString());
qualityRecordImageService.save(qualityRecordImage1);
}
return ResultGenerator.genSuccessResult();
}
use of com.eservice.api.model.quality_record_image.QualityRecordImage in project sinsim by WilsonHu.
the class QualityRecordImageController method list.
@PostMapping("/list")
public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
PageHelper.startPage(page, size);
List<QualityRecordImage> list = qualityRecordImageService.findAll();
PageInfo pageInfo = new PageInfo(list);
return ResultGenerator.genSuccessResult(pageInfo);
}
Aggregations