|
@@ -155,4 +155,43 @@ public class SRepairServiceImpl implements SRepairService {
|
|
|
public SRepair myOrderInfo(String id) {
|
|
|
return sRepairDao.queryById(id);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> closeOrder(MultipartFile[] files, SRepair sRepair) throws IOException {
|
|
|
+ if (Blank.isNotEmpty(files)) {
|
|
|
+ File pathFile = new File(location);
|
|
|
+ if (!pathFile.isDirectory()) {
|
|
|
+ if (!pathFile.mkdirs()) {
|
|
|
+ return SendUtil.send(false, ConstStr.ADD_FAILED, "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ArrayList<String> picPathList = new ArrayList<>();
|
|
|
+ for (MultipartFile file : files) {
|
|
|
+ //获取上传过来的文件名
|
|
|
+ File temporaryFile = new File(location + file.getOriginalFilename());
|
|
|
+ file.transferTo(temporaryFile);
|
|
|
+ String type = FileTypeUtil.getType(temporaryFile);
|
|
|
+ if (!("jpg".equals(type) || "png".equals(type) || "bmp".equals(type) || "jpeg".equals(type))) {
|
|
|
+ return SendUtil.send(false, ConstStr.ADD_FAILED, "上传的格式必须是jpg或png或bmp或jpeg");
|
|
|
+ }
|
|
|
+ String newName = (new Date()).getTime() + ((int) (Math.random() * 9000) + 1000) + "." + type;
|
|
|
+ String filePath = location + newName;
|
|
|
+ File newFile = new File(filePath);
|
|
|
+ if (!temporaryFile.renameTo(newFile)) {
|
|
|
+ return SendUtil.send(false, ConstStr.ADD_FAILED, "");
|
|
|
+ }
|
|
|
+ // 增加数据到s_file表
|
|
|
+ SFile sFile = new SFile();
|
|
|
+ sFile.setPath(newName);
|
|
|
+ sFile.setSuffix(type);
|
|
|
+ if (fileDao.addFile(sFile) <= 0) {
|
|
|
+ return SendUtil.send(false, ConstStr.ADD_FAILED, "");
|
|
|
+ }
|
|
|
+ picPathList.add(sFile.getId().toString());
|
|
|
+ }
|
|
|
+ String picPath = String.join(",", picPathList);
|
|
|
+ sRepair.setResultPic(picPath);
|
|
|
+ }
|
|
|
+ return SendUtil.send(true,sRepairDao.update(sRepair)>0);
|
|
|
+ }
|
|
|
}
|