Commit 13931842 authored by YIyiyi's avatar YIyiyi
parents 73fde25c 88ce81d7
......@@ -103,11 +103,11 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
@Override
protected void updateBefore(SiteEntity entity, Context context) throws AppException {
//校验下前后名称是否一直 如果不一致 同步修改所以关联
SiteEntity siteEntity = this.get(entity.getId(), context);
if(!siteEntity.getSiteName().equals(entity.getSiteName())){
SiteEntity oldSite = this.get(entity.getId(), context);
if(!oldSite.getSiteName().equals(entity.getSiteName())){
//todo
//更新关联站点名称
updateAssociateSiteName(entity, context);
updateAssociateSiteName(oldSite,entity, context);
//通知设备更新站点信息
DevicePdu devicePdu = new DevicePdu();
devicePdu.setSiteId(entity.getId());
......@@ -116,8 +116,15 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
super.updateBefore(entity, context);
}
private void updateAssociateSiteName(SiteEntity entity, Context context) {
List<WindowEntity> windowEntityList = windowService.find(new WindowQuery().siteId(entity.getId()));
private void updateAssociateSiteName(SiteEntity oldSite,SiteEntity newSite, Context context) {
//更新窗口站点名称
WindowEntity windowEntity = new WindowEntity();
windowEntity.setSiteName(newSite.getSiteName());
WindowEntity condition = new WindowEntity();
condition.setSiteName(oldSite.getSiteName());
windowService.updateBatch(windowEntity,condition,context);
/* List<WindowEntity> windowEntityList = windowService.find(new WindowQuery().siteId(entity.getId()));
windowEntityList.forEach(item->item.setSiteName(entity.getSiteName()));
windowService.update(windowEntityList, context);
......@@ -139,7 +146,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
//更新工作人员站点
List<WorkmanEntity> workmanEntities = workmanService.find(new WorkmanQuery().siteId(entity.getId()));
workmanEntities.forEach(item->item.setSiteName(entity.getSiteName()));
workmanService.update(workmanEntities, context);
workmanService.update(workmanEntities, context);*/
}
@Override
......
......@@ -17,6 +17,7 @@ import com.mortals.xhx.module.workman.model.WorkmanQuery;
import com.mortals.xhx.module.workman.service.WorkmanService;
import lombok.Getter;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
......@@ -145,7 +146,7 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao,
*/
@Override
public Rest<Void> doImportPic(String picfilePath) throws AppException {
String disPath = filePath+"/pics/" + FileUtil.getPrefix(picfilePath).trim();
String disPath = filePath + "/pics/" + FileUtil.getPrefix(picfilePath).trim();
String targetFilePath = uploadService.getFilePath(picfilePath);
if (FileUtil.isEmpty(new File(targetFilePath))) {
throw new AppException("文件不存在!");
......@@ -188,4 +189,57 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao,
}
}
/**
* @param list
* @param updateSupport
* @param context
* @return
*/
@Override
public String importList(List<WorkmanEntity> list, Boolean updateSupport, Context context) {
if (ObjectUtils.isEmpty(list)) {
throw new AppException("导入数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
StringBuilder failureDetailMsg = new StringBuilder();
for (WorkmanEntity entity : list) {
try {
entity.setCreateUserId(context == null ? 1L : context.getUser() == null ? 1L : context.getUser().getId());
entity.setCreateTime(new Date());
WorkmanEntity save = this.save(entity, context);
if (save != null) {
successNum++;
}
} catch (Exception e) {
log.error("导入异常", e);
failureNum++;
failureDetailMsg.append("\n");
failureDetailMsg.append(String.format("导入工作人员数据失败!用户名:%s", entity.getName()));
failureDetailMsg.append("\n");
}
}
successMsg.insert(0, "数据导入成功!共 " + successNum + " 条");
if (failureNum > 0) {
failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确");
successMsg.append("\n");
successMsg.append(failureMsg);
successMsg.append(failureDetailMsg);
} else {
}
return successMsg.toString();
}
public static void main(String[] args) throws Exception {
System.out.println(SecurityUtil.md5DoubleEncoding(""));
}
}
\ No newline at end of file
......@@ -69,7 +69,6 @@ public class WorkmanController extends BaseCRUDJsonBodyMappingController<Workman
private UploadService uploadService;
public WorkmanController() {
super.setModuleDesc("工作人员");
}
......@@ -116,7 +115,7 @@ public class WorkmanController extends BaseCRUDJsonBodyMappingController<Workman
public String doImportPic(@RequestBody WorkmanEntity query) {
JSONObject ret = new JSONObject();
try {
log.info("filePath:"+query.getFilePath());
log.info("filePath:" + query.getFilePath());
Rest<Void> rest = this.service.doImportPic(query.getFilePath());
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
recordSysLog(request, getCurUser(), "解析工作人员图片成功!");
......@@ -183,12 +182,12 @@ public class WorkmanController extends BaseCRUDJsonBodyMappingController<Workman
workmanEntity.setSiteName(siteEntity.getSiteName());
}
if(ObjectUtils.isEmpty(workmanEntity.getLoginName())){
String loginName = PinyinUtil.getPinyin(workmanEntity.getName(),"");
if (ObjectUtils.isEmpty(workmanEntity.getLoginName())) {
String loginName = PinyinUtil.getPinyin(StrUtil.cleanBlank(workmanEntity.getName()), "");
workmanEntity.setLoginName(loginName);
}
if(ObjectUtils.isEmpty(workmanEntity.getLoginPwd())){
if (ObjectUtils.isEmpty(workmanEntity.getLoginPwd())) {
workmanEntity.setLoginPwd("123");
}
......@@ -212,18 +211,17 @@ public class WorkmanController extends BaseCRUDJsonBodyMappingController<Workman
workmanEntity.setPicObj(null);
}
} catch (IOException e) {
log.error("写入证照异常",e);
log.error("写入证照异常", e);
}
}
}
super.doImportDataBefore(list, updateSupport, context);
}
public static void main(String[] args) {
System.out.println( StrUtil.removeAllLineBreaks(PinyinUtil.getPinyin("张三","")));
System.out.println(StrUtil.cleanBlank(PinyinUtil.getPinyin("张 三", "")));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment