package com.thhy.secure.modules.biz.inspect.service.impl;
|
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
import com.thhy.general.common.BasicResult;
|
import com.thhy.general.config.SysUserInfo;
|
import com.thhy.general.utils.UserInfoUtils;
|
import com.thhy.secure.modules.biz.file.service.FileService;
|
import com.thhy.secure.modules.biz.inspect.entity.TSecureInspect;
|
import com.thhy.secure.modules.biz.inspect.entity.TSecureInspectPath;
|
import com.thhy.secure.modules.biz.inspect.entity.dto.SecureInspectDto;
|
import com.thhy.secure.modules.biz.inspect.entity.dto.SecureInspectInfoDto;
|
import com.thhy.secure.modules.biz.inspect.mapper.TSecureInspectMapper;
|
import com.thhy.secure.modules.biz.inspect.service.TSecureInspectService;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import javax.annotation.Resource;
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
@Service
|
public class TSecureInspectServiceImpl implements TSecureInspectService {
|
@Resource
|
private TSecureInspectMapper inspectMapper;
|
@Resource
|
private FileService fileService;
|
|
@Override
|
public BasicResult inspectInsert(Map<String, Object> values) {
|
SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo();
|
//分公司id
|
String companyId = sysUserInfo.getCompanyId();
|
//用户id
|
String userId = sysUserInfo.getUserId();
|
values.put("companyId",companyId);
|
values.put("createUser",userId);
|
values.put("secureInspectId","");
|
inspectMapper.inspectInsert(values);
|
//添加的主键
|
String secureInspectId = values.get("secureInspectId").toString();
|
Integer isType = Integer.valueOf(values.get("isType").toString());
|
List<String> files = (List<String>) values.get("files");
|
for (String file:files){
|
HashMap<String, Object> hashMap = new HashMap<>();
|
hashMap.put("inspectPathId","");
|
hashMap.put("secureInspectId",secureInspectId);
|
hashMap.put("imgPath",file);
|
hashMap.put("isType",isType);
|
inspectMapper.inspectPathInsert(hashMap);
|
}
|
return BasicResult.success("添加成功");
|
}
|
|
@Override
|
public BasicResult inspectList(Map<String, Object> values) {
|
SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo();
|
//分公司id
|
String companyId = sysUserInfo.getCompanyId();
|
values.put("companyId",companyId);
|
List<SecureInspectDto> secureInspectDtos = inspectMapper.inspectList(values);
|
return BasicResult.success(secureInspectDtos);
|
}
|
|
@Override
|
public BasicResult inspectInfo(Map<String, Object> values) {
|
String secureInspectId = values.get("secureInspectId").toString();
|
|
SecureInspectInfoDto secureInspectInfoDto = inspectMapper.inspectInfo(secureInspectId);
|
List<TSecureInspectPath> secureInspectPaths = inspectMapper.secureInspectPath(secureInspectId);
|
secureInspectPaths.stream().forEach(fl->{
|
JSONObject json = new JSONObject();
|
json.put("fullpath",fl.getImgPath());
|
BasicResult basicResult = fileService.fileinfo(json.toJSONString());
|
if(basicResult.isSuccess()){
|
JSONArray jsonArray = JSONArray.parseArray(basicResult.getData().toString());
|
for(Object obj : jsonArray){
|
JSONObject j = JSON.parseObject(obj.toString());
|
if(j.containsKey("name")&&"name".equals(j.getString("name"))){
|
fl.setImgPathName(j.getString("value"));
|
}
|
}
|
}
|
});
|
secureInspectInfoDto.setTSecureInspectPaths(secureInspectPaths);
|
return BasicResult.success(secureInspectInfoDto);
|
}
|
|
@Override
|
@Transactional
|
public BasicResult inspectFeedbackInfo(Map<String, Object> values) {
|
//SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo();
|
//登录人
|
// String userId = sysUserInfo.getUserId();
|
//values.put("userId",userId);
|
values.put("isState",2);
|
Date date = new Date();
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
String format1 = format.format(date);
|
values.put("feedbackTime",format1);
|
inspectMapper.inspectFeedbackInfo(values);
|
///反馈的照片
|
String secureInspectId = values.get("secureInspectId").toString();
|
Integer isType = Integer.valueOf(values.get("isType").toString());
|
List<String> files = (List<String>) values.get("files");
|
for (String file:files){
|
HashMap<String, Object> hashMap = new HashMap<>();
|
hashMap.put("inspectPathId","");
|
hashMap.put("secureInspectId",secureInspectId);
|
hashMap.put("imgPath",file);
|
hashMap.put("isType",isType);
|
inspectMapper.inspectPathInsert(hashMap);
|
}
|
return BasicResult.success("已反馈");
|
}
|
|
@Override
|
public BasicResult rectificationNotice(Map<String, Object> values) {
|
SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo();
|
if(sysUserInfo.getUserType()==2){
|
//登录人
|
String userId = sysUserInfo.getUserId();
|
values.put("userId",userId);
|
List<TSecureInspect> secureInspects = inspectMapper.rectificationNotice(values);
|
return BasicResult.success(secureInspects);
|
}else if(sysUserInfo.getUserType()==1){
|
String companyId = sysUserInfo.getCompanyId();
|
values.put("companyId",companyId);
|
List<TSecureInspect> secureInspects = inspectMapper.rectificationNoticeGuan(values);
|
return BasicResult.success(secureInspects);
|
}
|
return BasicResult.faild("11111","error","类型错误");
|
}
|
}
|