添加了提交核查任务的接口
This commit is contained in:
parent
5b29b80de2
commit
a160ff3ade
@ -6,12 +6,15 @@ import com.xkrs.dao.SysUserDao;
|
|||||||
import com.xkrs.model.entity.FirePointEntity;
|
import com.xkrs.model.entity.FirePointEntity;
|
||||||
import com.xkrs.model.entity.SysUserEntity;
|
import com.xkrs.model.entity.SysUserEntity;
|
||||||
import com.xkrs.model.qo.FirePointQo;
|
import com.xkrs.model.qo.FirePointQo;
|
||||||
|
import com.xkrs.model.vo.AppTaskBodyVo;
|
||||||
import com.xkrs.service.FirePointService;
|
import com.xkrs.service.FirePointService;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -124,4 +127,26 @@ public class FirePointController {
|
|||||||
String fireType = (String) map.get("fireType");
|
String fireType = (String) map.get("fireType");
|
||||||
return firePointService.updateTypeByFireCode(fireCode,fireType,token);
|
return firePointService.updateTypeByFireCode(fireCode,fireType,token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交核查任务
|
||||||
|
* @param files
|
||||||
|
* @param appTaskBodyVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/insertAppTask")
|
||||||
|
public String insertAppTask(@RequestParam("files") MultipartFile[] files, AppTaskBodyVo appTaskBodyVo) throws IOException {
|
||||||
|
// 获取区域信息
|
||||||
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
|
if("".equals(appTaskBodyVo.getFireCode()) || appTaskBodyVo.getFireCode() == null){
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"火点编码不能为空",locale);
|
||||||
|
}
|
||||||
|
if("".equals(appTaskBodyVo.getTaskInformation()) || appTaskBodyVo.getTaskInformation() == null){
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"任务描述不能为空",locale);
|
||||||
|
}
|
||||||
|
if(files == null || files.length == 0 ){
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"图片不能为空",locale);
|
||||||
|
}
|
||||||
|
return firePointService.insertAppTask(files,appTaskBodyVo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,10 @@ package com.xkrs.service;
|
|||||||
import com.xkrs.dao.FirePointDao;
|
import com.xkrs.dao.FirePointDao;
|
||||||
import com.xkrs.model.entity.FirePointEntity;
|
import com.xkrs.model.entity.FirePointEntity;
|
||||||
import com.xkrs.model.qo.FirePointQo;
|
import com.xkrs.model.qo.FirePointQo;
|
||||||
|
import com.xkrs.model.vo.AppTaskBodyVo;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,4 +47,13 @@ public interface FirePointService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String updateTypeByFireCode(String fireCode,String fireType,String token);
|
String updateTypeByFireCode(String fireCode,String fireType,String token);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交核查任务信息
|
||||||
|
* @param files
|
||||||
|
* @param appTaskBodyVo
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
String insertAppTask(MultipartFile[] files, AppTaskBodyVo appTaskBodyVo) throws IOException;
|
||||||
}
|
}
|
||||||
|
@ -2,25 +2,21 @@ package com.xkrs.service.impl;
|
|||||||
|
|
||||||
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
||||||
import com.xkrs.common.tool.TokenUtil;
|
import com.xkrs.common.tool.TokenUtil;
|
||||||
import com.xkrs.dao.FireAndRangerDao;
|
import com.xkrs.dao.*;
|
||||||
import com.xkrs.dao.FirePointDao;
|
import com.xkrs.model.entity.*;
|
||||||
import com.xkrs.dao.ForestRangerDao;
|
|
||||||
import com.xkrs.dao.SysUserDao;
|
|
||||||
import com.xkrs.model.entity.FireAndRanger;
|
|
||||||
import com.xkrs.model.entity.FirePointEntity;
|
|
||||||
import com.xkrs.model.entity.SysUserEntity;
|
|
||||||
import com.xkrs.model.qo.FirePointQo;
|
import com.xkrs.model.qo.FirePointQo;
|
||||||
|
import com.xkrs.model.vo.AppTaskBodyVo;
|
||||||
import com.xkrs.service.FirePointService;
|
import com.xkrs.service.FirePointService;
|
||||||
import com.xkrs.utils.AddressUtils;
|
import com.xkrs.utils.*;
|
||||||
import com.xkrs.utils.DateTimeUtil;
|
|
||||||
import com.xkrs.utils.Query;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -51,6 +47,12 @@ public class FirePointServiceImpl implements FirePointService {
|
|||||||
@Resource
|
@Resource
|
||||||
private ForestRangerDao forestRangerDao;
|
private ForestRangerDao forestRangerDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FireTaskDao fireTaskDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private JdbcUtils jdbcUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加火点信息
|
* 添加火点信息
|
||||||
* @param firePointQo
|
* @param firePointQo
|
||||||
@ -154,4 +156,40 @@ public class FirePointServiceImpl implements FirePointService {
|
|||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"结案",locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"结案",locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交核查任务
|
||||||
|
* @param files
|
||||||
|
* @param appTaskBodyVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Transactional(rollbackOn = Exception.class)
|
||||||
|
@Override
|
||||||
|
public String insertAppTask(MultipartFile[] files, AppTaskBodyVo appTaskBodyVo) throws IOException {
|
||||||
|
// 获取区域信息
|
||||||
|
Locale locale = LocaleContextHolder.getLocale();
|
||||||
|
FirePointEntity byFireCode = firePointDao.findByFireCode(appTaskBodyVo.getFireCode());
|
||||||
|
if(byFireCode == null){
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"火点编码错误,请重新输入",locale);
|
||||||
|
}
|
||||||
|
FireTask byTaskFireCode = fireTaskDao.findByTaskFireCode(appTaskBodyVo.getFireCode());
|
||||||
|
if(byTaskFireCode != null){
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"该火点的任务已经提交,请勿重复提交",locale);
|
||||||
|
}
|
||||||
|
String s = DateTimeUtil.dateTimeToString(LocalDateTime.now());
|
||||||
|
FireTask fireTask = new FireTask();
|
||||||
|
fireTask.setTaskFireCode(appTaskBodyVo.getFireCode());
|
||||||
|
fireTask.setTaskInformation(appTaskBodyVo.getTaskInformation());
|
||||||
|
fireTask.setTaskTime(s);
|
||||||
|
FireTask save = fireTaskDao.save(fireTask);
|
||||||
|
if(save == null){
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"任务提交失败",locale);
|
||||||
|
}
|
||||||
|
List<FireTaskPhoto> fireTaskPhotos = PhotoUtil.uploadImage(files, appTaskBodyVo.getFireCode());
|
||||||
|
List<FireTaskPhoto> fireTaskPhotos1 = jdbcUtils.batchWithJdbcTemplate(fireTaskPhotos);
|
||||||
|
if(fireTaskPhotos1.size() == 0 || fireTaskPhotos1 == null){
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"图片上传失败,任务提交失败",locale);
|
||||||
|
}
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"任务提交成功",locale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
package com.xkrs.utils;
|
package com.xkrs.utils;
|
||||||
|
|
||||||
|
import com.xkrs.model.entity.FireTaskPhoto;
|
||||||
|
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author XinYi Song
|
* @author XinYi Song
|
||||||
@ -17,7 +22,7 @@ public class JdbcUtils {
|
|||||||
* jdbcTemplate,batchUpdate增加,需自己定义sql,需要配置
|
* jdbcTemplate,batchUpdate增加,需自己定义sql,需要配置
|
||||||
* @param list
|
* @param list
|
||||||
*/
|
*/
|
||||||
/*public List<FireTaskPhoto> batchWithJdbcTemplate(List<FireTaskPhoto> list){
|
public List<FireTaskPhoto> batchWithJdbcTemplate(List<FireTaskPhoto> list){
|
||||||
String sql = "Insert into fire_task_photo(photo_fire_code,task_photo) values(?,?)";
|
String sql = "Insert into fire_task_photo(photo_fire_code,task_photo) values(?,?)";
|
||||||
jdbcTemplate.batchUpdate(sql,new BatchPreparedStatementSetter() {
|
jdbcTemplate.batchUpdate(sql,new BatchPreparedStatementSetter() {
|
||||||
@Override
|
@Override
|
||||||
@ -31,5 +36,5 @@ public class JdbcUtils {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return list;
|
return list;
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.xkrs.utils;
|
package com.xkrs.utils;
|
||||||
|
|
||||||
|
import com.xkrs.model.entity.FireTaskPhoto;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@ -62,8 +63,8 @@ public class PhotoUtil {
|
|||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
/*public static List<FireTaskPhoto> uploadImage(MultipartFile[] files, String fireCode) throws IOException {
|
public static List<FireTaskPhoto> uploadImage(MultipartFile[] files, String fireCode) throws IOException {
|
||||||
String uploadPath = "http://139.199.98.175:2099/wfTaskImage/";
|
String uploadPath = "http://139.199.98.175:2099/forestTaskImage/";
|
||||||
String newName = "";
|
String newName = "";
|
||||||
String oldName = "";
|
String oldName = "";
|
||||||
List<FireTaskPhoto> fireTaskPhotos = new ArrayList<>();
|
List<FireTaskPhoto> fireTaskPhotos = new ArrayList<>();
|
||||||
@ -77,12 +78,12 @@ public class PhotoUtil {
|
|||||||
//uuid生成新的文件名
|
//uuid生成新的文件名
|
||||||
newName = UUID.randomUUID().toString() + suffix;
|
newName = UUID.randomUUID().toString() + suffix;
|
||||||
//将图片保存到本地/usr/etc/images/Folder
|
//将图片保存到本地/usr/etc/images/Folder
|
||||||
File file1 = new File("/home/web/wf-fire-service/wfTaskImage/");
|
File file1 = new File("/home/web/wf-fire-service/forestTaskImage/");
|
||||||
//File file1 = new File("E:/wfTaskImage/");
|
//File file1 = new File("E:/wfTaskImage/");
|
||||||
if (!file1.exists()) {
|
if (!file1.exists()) {
|
||||||
file1.mkdirs();
|
file1.mkdirs();
|
||||||
}
|
}
|
||||||
String path = "/home/web/wf-fire-service/wfTaskImage/" + newName;
|
String path = "/home/web/wf-fire-service/forestTaskImage/" + newName;
|
||||||
//String path = "E:/wfTaskImage/" + newName;
|
//String path = "E:/wfTaskImage/" + newName;
|
||||||
String uploadPaths = uploadPath + newName;
|
String uploadPaths = uploadPath + newName;
|
||||||
//实现上传
|
//实现上传
|
||||||
@ -94,7 +95,7 @@ public class PhotoUtil {
|
|||||||
fireTaskPhotos.add(fireTaskPhoto);
|
fireTaskPhotos.add(fireTaskPhoto);
|
||||||
}
|
}
|
||||||
return fireTaskPhotos;
|
return fireTaskPhotos;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user