171 lines
5.4 KiB
Java
171 lines
5.4 KiB
Java
package com.zcloud.service.firemanager.impl;
|
||
|
||
import java.util.Date;
|
||
import java.util.HashMap;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
|
||
import javax.annotation.Resource;
|
||
|
||
import com.zcloud.service.bus.ImgFilesService;
|
||
import com.zcloud.util.*;
|
||
import org.springframework.stereotype.Service;
|
||
import org.springframework.transaction.annotation.Transactional;
|
||
|
||
import com.zcloud.entity.Page;
|
||
import com.zcloud.entity.PageData;
|
||
import com.zcloud.mapper.datasource.firemanager.FirePointMapper;
|
||
import com.zcloud.service.firemanager.FirePointService;
|
||
import org.springframework.web.multipart.MultipartFile;
|
||
|
||
/**
|
||
* 说明:TODO 作者:wangxuan 官网:www.zcloudchina.com
|
||
*/
|
||
@Service
|
||
public class FirePointServiceImpl implements FirePointService {
|
||
@Resource
|
||
private FirePointMapper firePointMapper;
|
||
@Resource
|
||
private ImgFilesService imgFilesService;
|
||
@Resource
|
||
private InitPageDataUtil initPageDataUtil;
|
||
|
||
@Override
|
||
public List<PageData> list(Page page) {
|
||
|
||
return firePointMapper.datalistPage(page);
|
||
}
|
||
|
||
@Override
|
||
public List<PageData> listForExcel(PageData pd) {
|
||
return firePointMapper.listForExcel(pd);
|
||
}
|
||
|
||
@Override
|
||
public void savePosition(PageData pd)throws Exception{
|
||
firePointMapper.savePosition(pd);
|
||
}
|
||
|
||
@Override
|
||
public PageData findById(PageData pd) {
|
||
return firePointMapper.findById(pd);
|
||
}
|
||
|
||
@Override
|
||
@Transactional(rollbackFor = Exception.class)
|
||
public void updFirePointById(MultipartFile[] files, PageData pd) {
|
||
firePointMapper.updFirePointById(pd);
|
||
String waitRemoveDataIds = pd.getString("WAIT_REMOVE_DATA_IDS",null);
|
||
if (waitRemoveDataIds != null) {
|
||
try {
|
||
imgFilesService.deleteAll(waitRemoveDataIds.split(","));
|
||
} catch (Exception e) {
|
||
throw new RuntimeException(e);
|
||
}
|
||
}
|
||
imgFilesService.uploadPicture(files,"118",pd.getString("FIRE_POINT_ID"));
|
||
}
|
||
|
||
@Override
|
||
@Transactional(rollbackFor = Exception.class)
|
||
public boolean delFirePointByIds(PageData pd) {
|
||
PageData res = firePointMapper.trydelPoint(pd);
|
||
if ("0".equals(String.valueOf(res.get("sum")))) {
|
||
firePointMapper.delFirePointByIds(pd);
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
@Override
|
||
@Transactional(rollbackFor = Exception.class)
|
||
public void savePointInfo(PageData pd) {
|
||
firePointMapper.savePointInfo(pd);
|
||
}
|
||
|
||
@Override
|
||
public List<PageData> getAllPointNameByRegion(PageData pd) {
|
||
return firePointMapper.getAllPointNameByRegion(pd);
|
||
}
|
||
|
||
/**
|
||
* 获取所有的点位信息,并准备给导入excel使用
|
||
*
|
||
* @param pd
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@Override
|
||
public Map<String, PageData> getAllByCorpIdForExcel(PageData pd) throws Exception {
|
||
Map<String, PageData> listAllMap = new HashMap<>();
|
||
List<PageData> listAll = firePointMapper.getAllList(pd);
|
||
for (PageData pageData : listAll) { // 把数据中的数据转换成map 等到 他们使用
|
||
String name = pageData.getString("FIRE_POINT_NAME");
|
||
String bianMa = pageData.getString("FIRE_POINT_CODE");
|
||
String FIRE_REGION_ID = pageData.getString("FIRE_REGION_ID");
|
||
listAllMap.put(name + "--" + bianMa + "--" +FIRE_REGION_ID, pageData);
|
||
}
|
||
return listAllMap;
|
||
}
|
||
|
||
@Override
|
||
public PageData saveFroExcel(String name, String bianma, String qyID, String departId, String userID)
|
||
throws Exception {
|
||
PageData pd = new PageData();
|
||
pd.put("FIRE_POINT_ID", UuidUtil.get32UUID());
|
||
pd.put("CREATOR", Jurisdiction.getUSER_ID());
|
||
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
pd.put("OPERATOR", Jurisdiction.getUSER_ID());
|
||
pd.put("CREATTIME", DateUtil.date2Str(new Date()));
|
||
pd.put("OPERATTIME", DateUtil.date2Str(new Date()));
|
||
pd.put("ISDELETE", DateUtil.date2Str(new Date()));
|
||
pd.put("STATE", "0");
|
||
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
||
|
||
pd.put("FIRE_POINT_NAME", name);
|
||
pd.put("FIRE_POINT_CODE", bianma);
|
||
pd.put("FIRE_REGION_ID", qyID);
|
||
pd.put("DEPARTMENT_ID", departId);
|
||
pd.put("USER_ID", userID);
|
||
pd.put("ISDELETE", DateUtil.date2Str(new Date()));
|
||
this.savePointInfo(pd);
|
||
return pd;
|
||
}
|
||
|
||
@Override
|
||
@Transactional(rollbackFor = Exception.class)
|
||
public void updPointDepAuserByRegId(PageData pageData) {
|
||
initPageDataUtil.initEdit(pageData);
|
||
firePointMapper.updPointDepAuserByRegId(pageData);
|
||
}
|
||
|
||
@Override
|
||
@Transactional(rollbackFor = Exception.class)
|
||
public void removeFirePointByIds(PageData pd) {
|
||
String DATA_IDS = pd.getString("DATA_IDS");
|
||
if (Tools.notEmpty(DATA_IDS)) {
|
||
String ArrayDATA_IDS[] = DATA_IDS.split(",");
|
||
pd.put("ArrayDATA_IDS", ArrayDATA_IDS);
|
||
initPageDataUtil.initEdit(pd);
|
||
firePointMapper.deleteAll(pd);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
@Transactional(rollbackFor = Exception.class)
|
||
public void removeQualifiedByQIds(PageData pd) {
|
||
firePointMapper.removeQualifiedByQIds(pd);
|
||
}
|
||
|
||
@Override
|
||
public List<PageData> getFirePointCheckPhotos(PageData pd) {
|
||
return firePointMapper.getFirePointCheckPhotos(pd);
|
||
}
|
||
|
||
@Override
|
||
public List<PageData> findByIds(List<String> pointIds) {
|
||
return firePointMapper.findByIds(pointIds);
|
||
}
|
||
|
||
}
|