Commit 6e760759 authored by 赵啸非's avatar 赵啸非

修改工作人员导入

parent 7533a921
...@@ -120,10 +120,10 @@ ...@@ -120,10 +120,10 @@
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace> <profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path> <profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.filepath>/home/mortals/app/data</profiles.filepath> <profiles.filepath>/mortals/app/data</profiles.filepath>
<profiles.log.level>INFO</profiles.log.level> <profiles.log.level>INFO</profiles.log.level>
<package.environment>yibin</package.environment> <package.environment>yibin</package.environment>
<skipUi>true</skipUi> <skipUi>false</skipUi>
</properties> </properties>
</profile> </profile>
......
package com.mortals.xhx.common.key; package com.mortals.xhx.common.key;
import com.mortals.framework.ap.GlobalSysInfo;
public final class Constant { public final class Constant {
/** /**
...@@ -127,6 +129,10 @@ public final class Constant { ...@@ -127,6 +129,10 @@ public final class Constant {
* 服务器http * 服务器http
*/ */
public final static String PARAM_SERVER_HTTP_URL = "server_http_url"; public final static String PARAM_SERVER_HTTP_URL = "server_http_url";
/**
* 服务器http
*/
public final static String PARAM_SERVER_PHP_HTTP_URL = "server_php_http_url";
public final static String CUSTAPP_ROOT_PATH = "app"; public final static String CUSTAPP_ROOT_PATH = "app";
......
...@@ -16,8 +16,10 @@ import com.mortals.xhx.common.code.AreaLevelDxTypeEnum; ...@@ -16,8 +16,10 @@ import com.mortals.xhx.common.code.AreaLevelDxTypeEnum;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.Constant; import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.pdu.RespData; import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.device.DevicePdu;
import com.mortals.xhx.common.pdu.user.UserPdu; import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.common.utils.MatterHtmlParseUtil; import com.mortals.xhx.common.utils.MatterHtmlParseUtil;
import com.mortals.xhx.feign.device.IDeviceFeign;
import com.mortals.xhx.feign.user.IUserFeign; import com.mortals.xhx.feign.user.IUserFeign;
import com.mortals.xhx.module.area.model.AreaEntity; import com.mortals.xhx.module.area.model.AreaEntity;
import com.mortals.xhx.module.area.model.AreaQuery; import com.mortals.xhx.module.area.model.AreaQuery;
...@@ -63,9 +65,8 @@ import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_IMAGE_URL; ...@@ -63,9 +65,8 @@ import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_IMAGE_URL;
* @date 2022-01-12 * @date 2022-01-12
*/ */
@Service("siteService") @Service("siteService")
@Slf4j
public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteEntity, Long> implements SiteService { public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteEntity, Long> implements SiteService {
protected Log log = LogFactory.getLog(this.getClass());
// private List<SiteTreeSelect> siteTreeList; // private List<SiteTreeSelect> siteTreeList;
/** /**
* 根据用户id 暂存对应站点树 默认0为全站点树 * 根据用户id 暂存对应站点树 默认0为全站点树
...@@ -93,12 +94,10 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -93,12 +94,10 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
private SiteThemeMatterService siteThemeMatterService; private SiteThemeMatterService siteThemeMatterService;
@Autowired @Autowired
private SiteMatterService siteMatterService; private SiteMatterService siteMatterService;
@Autowired @Autowired
private WorkmanService workmanService; private WorkmanService workmanService;
@Autowired
private IDeviceFeign deviceFeign;
@Override @Override
...@@ -109,9 +108,10 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -109,9 +108,10 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
//todo //todo
//更新关联站点名称 //更新关联站点名称
updateAssociateSiteName(entity, context); updateAssociateSiteName(entity, context);
//通知设备更新站点信息 //通知设备更新站点信息
DevicePdu devicePdu = new DevicePdu();
devicePdu.setSiteId(entity.getId());
deviceFeign.refreshMessage(devicePdu);
} }
super.updateBefore(entity, context); super.updateBefore(entity, context);
} }
......
package com.mortals.xhx.module.window.service.impl; package com.mortals.xhx.module.window.service.impl;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.util.HttpUtil;
import com.mortals.xhx.common.utils.BeanUtil; import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.module.business.model.BusinessEntity; import com.mortals.xhx.module.business.model.BusinessEntity;
import com.mortals.xhx.module.business.model.BusinessQuery; import com.mortals.xhx.module.business.model.BusinessQuery;
...@@ -12,6 +16,7 @@ import com.mortals.xhx.module.site.model.SiteEntity; ...@@ -12,6 +16,7 @@ import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.window.model.WindowEntity; import com.mortals.xhx.module.window.model.WindowEntity;
import com.mortals.xhx.module.window.model.WindowQuery; import com.mortals.xhx.module.window.model.WindowQuery;
import com.mortals.xhx.module.window.service.WindowService; import com.mortals.xhx.module.window.service.WindowService;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A; import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -25,6 +30,9 @@ import org.springframework.util.ObjectUtils; ...@@ -25,6 +30,9 @@ import org.springframework.util.ObjectUtils;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.mortals.framework.util.HttpUtil.HEADER_CONTENT_TYPE;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_PHP_HTTP_URL;
/** /**
* WindowBusinessService * WindowBusinessService
* 窗口业务 service实现 * 窗口业务 service实现
...@@ -33,6 +41,7 @@ import java.util.stream.Collectors; ...@@ -33,6 +41,7 @@ import java.util.stream.Collectors;
* @date 2022-01-12 * @date 2022-01-12
*/ */
@Service("windowBusinessService") @Service("windowBusinessService")
@Slf4j
public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBusinessDao, WindowBusinessEntity, Long> implements WindowBusinessService { public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBusinessDao, WindowBusinessEntity, Long> implements WindowBusinessService {
@Autowired @Autowired
private WindowService windowService; private WindowService windowService;
...@@ -51,4 +60,47 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus ...@@ -51,4 +60,47 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
} }
super.findAfter(entity, pageInfo, context, list); super.findAfter(entity, pageInfo, context, list);
} }
/**
* @param entity
* @param context
* @throws AppException
*/
@Override
protected void saveAfter(WindowBusinessEntity entity, Context context) throws AppException {
//通知php更新
pushChangeMsg(entity);
super.saveAfter(entity, context);
}
/**
* @param entity
* @param context
* @throws AppException
*/
@Override
protected void updateAfter(WindowBusinessEntity entity, Context context) throws AppException {
pushChangeMsg(entity);
super.updateAfter(entity, context);
}
private void pushChangeMsg(WindowBusinessEntity entity) {
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090");
HashMap<String, Object> paramsMap = new HashMap<>();
paramsMap.put("windowid", entity.getWindowId());
paramsMap.put("typeinfo",1);
String resp = null;
try {
Map<String, String> header = new HashMap<>();
header.put(HEADER_CONTENT_TYPE, "application/json");
log.info("\n thirdPartyUrl=>{} \n reqbody=>{} ", phpUrl, JSON.toJSONString(paramsMap));
resp = HttpUtil.doPost(phpUrl, header, JSON.toJSONString(paramsMap, SerializerFeature.WriteMapNullValue));
log.info("thirdPartyUrl =>resp:{}", resp);
} catch (Exception e) {
log.error("异常:", e);
}
}
} }
\ No newline at end of file
package com.mortals.xhx.module.window.service.impl; package com.mortals.xhx.module.window.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.util.HttpUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.window.dao.WindowMatterDao; import com.mortals.xhx.module.window.dao.WindowMatterDao;
import com.mortals.xhx.module.window.model.WindowMatterEntity; import com.mortals.xhx.module.window.model.WindowMatterEntity;
import com.mortals.xhx.module.window.service.WindowMatterService; import com.mortals.xhx.module.window.service.WindowMatterService;
import java.util.HashMap;
import java.util.Map;
import static com.mortals.framework.util.HttpUtil.HEADER_CONTENT_TYPE;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_PHP_HTTP_URL;
/** /**
* WindowMatterService * WindowMatterService
* 窗口事项 service实现 * 窗口事项 service实现
* *
* @author zxfei * @author zxfei
* @date 2022-01-12 * @date 2022-01-12
*/ */
@Service("windowMatterService") @Service("windowMatterService")
@Slf4j
public class WindowMatterServiceImpl extends AbstractCRUDServiceImpl<WindowMatterDao, WindowMatterEntity, Long> implements WindowMatterService { public class WindowMatterServiceImpl extends AbstractCRUDServiceImpl<WindowMatterDao, WindowMatterEntity, Long> implements WindowMatterService {
/**
* @param entity
* @param context
* @throws AppException
*/
@Override
protected void saveAfter(WindowMatterEntity entity, Context context) throws AppException {
pushChangeMsg(entity);
super.saveAfter(entity, context);
}
/**
* @param entity
* @param context
* @throws AppException
*/
@Override
protected void updateAfter(WindowMatterEntity entity, Context context) throws AppException {
pushChangeMsg(entity);
super.updateAfter(entity, context);
}
private void pushChangeMsg(WindowMatterEntity entity) {
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090");
HashMap<String, Object> paramsMap = new HashMap<>();
paramsMap.put("windowid", entity.getWindowId());
paramsMap.put("typeinfo",0);
String resp = null;
try {
Map<String, String> header = new HashMap<>();
header.put(HEADER_CONTENT_TYPE, "application/json");
log.info("\n thirdPartyUrl=>{} \n reqbody=>{} ", phpUrl, JSON.toJSONString(paramsMap));
resp = HttpUtil.doPost(phpUrl, header, JSON.toJSONString(paramsMap, SerializerFeature.WriteMapNullValue));
log.info("thirdPartyUrl =>resp:{}", resp);
} catch (Exception e) {
log.error("异常:", e);
}
}
} }
\ No newline at end of file
package com.mortals.xhx.module.window.service.impl; package com.mortals.xhx.module.window.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.HttpUtil;
import com.mortals.xhx.common.utils.BeanUtil; import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.module.business.model.BusinessEntity; import com.mortals.xhx.module.business.model.BusinessEntity;
import com.mortals.xhx.module.business.model.BusinessQuery; import com.mortals.xhx.module.business.model.BusinessQuery;
...@@ -18,6 +22,7 @@ import com.mortals.xhx.module.window.service.WindowMatterService; ...@@ -18,6 +22,7 @@ import com.mortals.xhx.module.window.service.WindowMatterService;
import com.mortals.xhx.module.workman.model.WorkmanEntity; import com.mortals.xhx.module.workman.model.WorkmanEntity;
import com.mortals.xhx.module.workman.model.WorkmanQuery; import com.mortals.xhx.module.workman.model.WorkmanQuery;
import com.mortals.xhx.module.workman.service.WorkmanService; import com.mortals.xhx.module.workman.service.WorkmanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -26,12 +31,12 @@ import com.mortals.xhx.module.window.dao.WindowDao; ...@@ -26,12 +31,12 @@ import com.mortals.xhx.module.window.dao.WindowDao;
import com.mortals.xhx.module.window.service.WindowService; import com.mortals.xhx.module.window.service.WindowService;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.Arrays; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.mortals.framework.util.HttpUtil.HEADER_CONTENT_TYPE;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_PHP_HTTP_URL;
/** /**
* WindowService * WindowService
* 站点部门窗口 service实现 * 站点部门窗口 service实现
...@@ -40,6 +45,7 @@ import java.util.stream.Collectors; ...@@ -40,6 +45,7 @@ import java.util.stream.Collectors;
* @date 2022-01-12 * @date 2022-01-12
*/ */
@Service("windowService") @Service("windowService")
@Slf4j
public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, WindowEntity, Long> implements WindowService { public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, WindowEntity, Long> implements WindowService {
@Autowired @Autowired
...@@ -138,4 +144,33 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W ...@@ -138,4 +144,33 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W
} }
super.removeAfter(ids, context, result); super.removeAfter(ids, context, result);
} }
/**
* @param entity
* @param context
* @throws AppException
*/
@Override
protected void saveAfter(WindowEntity entity, Context context) throws AppException {
pushChangeMsg(entity);
super.saveAfter(entity, context);
}
private void pushChangeMsg(WindowEntity entity) {
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090");
HashMap<String, Object> paramsMap = new HashMap<>();
paramsMap.put("windowid", entity.getId());
paramsMap.put("typeinfo",1);
String resp = null;
try {
Map<String, String> header = new HashMap<>();
header.put(HEADER_CONTENT_TYPE, "application/json");
log.info("\n thirdPartyUrl=>{} \n reqbody=>{} ", phpUrl, JSON.toJSONString(paramsMap));
resp = HttpUtil.doPost(phpUrl, header, JSON.toJSONString(paramsMap, SerializerFeature.WriteMapNullValue));
log.info("thirdPartyUrl =>resp:{}", resp);
} catch (Exception e) {
log.error("异常:", e);
}
}
} }
\ No newline at end of file
package com.mortals.xhx.module.window.web; package com.mortals.xhx.module.window.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.OrderCol; import com.mortals.framework.model.OrderCol;
import com.mortals.framework.util.HttpUtil;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.framework.web.BasePhpCRUDJsonMappingController; import com.mortals.framework.web.BasePhpCRUDJsonMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.feign.rsp.ApiResp;
import com.mortals.xhx.module.window.model.WindowMatterEntity; import com.mortals.xhx.module.window.model.WindowMatterEntity;
import com.mortals.xhx.module.window.service.WindowMatterService; import com.mortals.xhx.module.window.service.WindowMatterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static com.mortals.framework.util.HttpUtil.HEADER_CONTENT_TYPE;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_PHP_HTTP_URL;
/** /**
*
* 窗口事项 * 窗口事项
* *
* @author zxfei * @author zxfei
...@@ -24,14 +34,15 @@ import java.util.Map; ...@@ -24,14 +34,15 @@ import java.util.Map;
*/ */
@RestController @RestController
@RequestMapping("window/matter") @RequestMapping("window/matter")
public class WindowMatterController extends BaseCRUDJsonBodyMappingController<WindowMatterService,WindowMatterEntity,Long> { @Slf4j
public class WindowMatterController extends BaseCRUDJsonBodyMappingController<WindowMatterService, WindowMatterEntity, Long> {
@Autowired @Autowired
private ParamService paramService; private ParamService paramService;
public WindowMatterController(){ public WindowMatterController() {
super.setFormClass(WindowMatterForm.class); super.setFormClass(WindowMatterForm.class);
super.setModuleDesc( "窗口事项"); super.setModuleDesc("窗口事项");
} }
...@@ -44,4 +55,30 @@ public class WindowMatterController extends BaseCRUDJsonBodyMappingController<Wi ...@@ -44,4 +55,30 @@ public class WindowMatterController extends BaseCRUDJsonBodyMappingController<Wi
}); });
super.doListBefore(query, model, context); super.doListBefore(query, model, context);
} }
/**
* @param entity
* @param model
* @param context
* @return
* @throws AppException
*/
@Override
protected int saveAfter(WindowMatterEntity entity, Map<String, Object> model, Context context) throws AppException {
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://10.12.185.213:8090");
HashMap<String, Object> paramsMap = new HashMap<>();
paramsMap.put("windowid", entity.getWindowId());
String resp = null;
try {
Map<String, String> header = new HashMap<>();
header.put(HEADER_CONTENT_TYPE, "application/json");
log.info("\n thirdPartyUrl=>{} \n reqbody=>{} ", phpUrl, JSON.toJSONString(paramsMap));
resp = HttpUtil.doPost(phpUrl, header, JSON.toJSONString(paramsMap, SerializerFeature.WriteMapNullValue));
log.info("thirdPartyUrl =>resp:{}", resp);
} catch (Exception e) {
log.error("异常:", e);
}
return super.saveAfter(entity, model, context);
}
} }
\ No newline at end of file
...@@ -24,4 +24,8 @@ public class WorkmanVo extends BaseEntityLong { ...@@ -24,4 +24,8 @@ public class WorkmanVo extends BaseEntityLong {
@Excel(name = "证件图片", type = Excel.Type.IMPORT, cellType = Excel.ColumnType.IMAGE) @Excel(name = "证件图片", type = Excel.Type.IMPORT, cellType = Excel.ColumnType.IMAGE)
@JSONField(serialize = false) @JSONField(serialize = false)
private PictureData picObj; private PictureData picObj;
private String filePath;
} }
\ No newline at end of file
package com.mortals.xhx.module.workman.service; package com.mortals.xhx.module.workman.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ICRUDCacheService; import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
...@@ -40,4 +41,10 @@ public interface WorkmanService extends ICRUDCacheService<WorkmanEntity,Long> { ...@@ -40,4 +41,10 @@ public interface WorkmanService extends ICRUDCacheService<WorkmanEntity,Long> {
boolean updateUserPwd(String loginName, String oldPwd, String newPwd) throws AppException; boolean updateUserPwd(String loginName, String oldPwd, String newPwd) throws AppException;
Rest<Void> doImportPic(String filePath) throws AppException;
} }
\ No newline at end of file
package com.mortals.xhx.module.workman.service.impl; package com.mortals.xhx.module.workman.service.impl;
import cn.hutool.core.io.FileUtil;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.SecurityUtil; import com.mortals.framework.util.SecurityUtil;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.base.system.user.service.UserService; import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.utils.ZipUtils;
import com.mortals.xhx.module.workman.dao.WorkmanDao; import com.mortals.xhx.module.workman.dao.WorkmanDao;
import com.mortals.xhx.module.workman.model.WorkmanEntity; import com.mortals.xhx.module.workman.model.WorkmanEntity;
import com.mortals.xhx.module.workman.model.WorkmanQuery; import com.mortals.xhx.module.workman.model.WorkmanQuery;
import com.mortals.xhx.module.workman.service.WorkmanService; import com.mortals.xhx.module.workman.service.WorkmanService;
import lombok.Getter;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -28,6 +38,14 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao, ...@@ -28,6 +38,14 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao,
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired
private UploadService uploadService;
@Value("${upload.path}")
@Getter
private String filePath;
@Autowired
private WorkmanService workmanService;
@Override @Override
...@@ -61,7 +79,6 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao, ...@@ -61,7 +79,6 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao,
} else { } else {
entity.setLoginPwd(null); entity.setLoginPwd(null);
} }
//判断党员是否其它选项,如果 //判断党员是否其它选项,如果
} }
...@@ -79,7 +96,7 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao, ...@@ -79,7 +96,7 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao,
@Override @Override
public WorkmanEntity doLogin(String loginName, String password,String loginIp) throws AppException { public WorkmanEntity doLogin(String loginName, String password, String loginIp) throws AppException {
WorkmanEntity workmanEntity = this.selectOne(new WorkmanQuery().loginName(loginName)); WorkmanEntity workmanEntity = this.selectOne(new WorkmanQuery().loginName(loginName));
if (workmanEntity == null || !workmanEntity.getLoginName().equals(loginName)) { if (workmanEntity == null || !workmanEntity.getLoginName().equals(loginName)) {
throw new AppException("用户名不存在!"); throw new AppException("用户名不存在!");
...@@ -118,4 +135,79 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao, ...@@ -118,4 +135,79 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao,
dao.update(sysUser); dao.update(sysUser);
return true; return true;
} }
/**
* @param picfilePath
* @return
* @throws AppException
*/
@Override
public Rest<Void> doImportPic(String picfilePath) throws AppException {
String disPath = filePath+"/pics";
Thread t = new Thread(new Runnable(){
public void run(){
//解压图片
ZipUtils.unzip(new File(picfilePath), disPath);
//读取目录下的所有图片
File[] files = FileUtil.ls(disPath);
for (File file : files) {
if (file.isFile()) {
String fileName = file.getName();
String[] vals = fileName.split("-");
if (vals.length > 1) {
String userName = vals[1];
//根据用户名查询工作人员名称
WorkmanEntity workmanEntity = workmanService.selectOne(new WorkmanQuery().name(userName));
if (!ObjectUtils.isEmpty(workmanEntity)) {
String newName = "/file/uploadfile/" + new Date().getTime() + "." + FileUtil.getSuffix(file);
String filePath = uploadService.getFilePath(newName);
try {
boolean bool = com.mortals.framework.util.FileUtil.write(filePath, workmanEntity.getPicObj().getData(), true, true);
if (bool) {
workmanEntity.setPhotoPath(newName);
workmanService.update(workmanEntity);
}
} catch (IOException e) {
log.error("写入证照异常", e);
}
}
}
}
}
}});
t.start();
/*
//解压图片
ZipUtils.unzip(new File(picfilePath), disPath);
//读取目录下的所有图片
File[] files = FileUtil.ls(disPath);
for (File file : files) {
if (file.isFile()) {
String fileName = file.getName();
String[] vals = fileName.split("-");
if (vals.length > 1) {
String userName = vals[1];
//根据用户名查询工作人员名称
WorkmanEntity workmanEntity = this.selectOne(new WorkmanQuery().name(userName));
if (!ObjectUtils.isEmpty(workmanEntity)) {
String newName = "/file/uploadfile/" + new Date().getTime() + "." + FileUtil.getSuffix(file);
String filePath = uploadService.getFilePath(newName);
try {
boolean bool = com.mortals.framework.util.FileUtil.write(filePath, workmanEntity.getPicObj().getData(), true, true);
if (bool) {
workmanEntity.setPhotoPath(newName);
this.update(workmanEntity);
}
} catch (IOException e) {
log.error("写入证照异常", e);
}
}
}
}
}
*/
return Rest.ok("解析成功");
}
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ package com.mortals.xhx.module.workman.web; ...@@ -3,6 +3,7 @@ package com.mortals.xhx.module.workman.web;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth; import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.util.DateUtils; import com.mortals.framework.util.DateUtils;
...@@ -108,6 +109,24 @@ public class WorkmanController extends BaseCRUDJsonBodyMappingController<Workman ...@@ -108,6 +109,24 @@ public class WorkmanController extends BaseCRUDJsonBodyMappingController<Workman
} }
} }
@PostMapping(value = "doImportPic")
public String doImportPic(@RequestBody WorkmanEntity query) {
JSONObject ret = new JSONObject();
try {
Rest<Void> rest = this.service.doImportPic(query.getFilePath());
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
recordSysLog(request, getCurUser(), "解析工作人员图片成功!");
return ret.toJSONString();
} catch (Exception e) {
log.error("解析工作人员错误", e);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
@RequestMapping(value = "change/password", method = RequestMethod.POST) @RequestMapping(value = "change/password", method = RequestMethod.POST)
@UnAuth @UnAuth
public String changePassword(@RequestBody WorkmanEntity query) { public String changePassword(@RequestBody WorkmanEntity query) {
......
package com.mortals.xhx.feign.device;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.device.DevicePdu;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 设备 Feign接口
* @author zxfei
* @date 2022-10-26
*/
@FeignClient(name = "device-manager", path = "/m", fallbackFactory = DeviceFeignFallbackFactory.class)
public interface IDeviceFeign extends IFeign {
/**
* 查看设备列表
*
* @param devicePdu
* @return
*/
@PostMapping(value = "/device/list")
Rest<RespData<List<DevicePdu>>> list(@RequestBody DevicePdu devicePdu);
/**
* 查看设备
*
* @param id
* @return
*/
@GetMapping(value = "/device/info")
Rest<DevicePdu> info(@RequestParam(value = "id") Long id);
/**
* 删除设备
*
* @param ids
* @return
*/
@GetMapping(value = "/device/delete")
Rest<Void> delete(Long[] ids,@RequestHeader("Authorization") String authorization);
/**
* 设备保存更新
*
* @param devicePdu
* @return
*/
@PostMapping(value = "/device/save")
Rest<RespData<DevicePdu>> save(@RequestBody DevicePdu devicePdu,@RequestHeader("Authorization") String authorization);
/**
* 站点变更设备通知
*
* @param devicePdu
* @return
*/
@PostMapping(value = "/notify/refreshMessage")
Rest<Void> refreshMessage(@RequestBody DevicePdu devicePdu);
}
@Slf4j
@Component
class DeviceFeignFallbackFactory implements FallbackFactory<IDeviceFeign> {
@Override
public IDeviceFeign create(Throwable t) {
return new IDeviceFeign() {
@Override
public Rest<RespData<List<DevicePdu>>> list(DevicePdu devicePdu) {
return Rest.fail("暂时无法获取设备列表,请稍后再试!");
}
@Override
public Rest<DevicePdu> info(Long id) {
return Rest.fail("暂时无法获取设备详细,请稍后再试!");
}
@Override
public Rest<Void> delete(Long[] ids, String authorization) {
return Rest.fail("暂时无法删除设备,请稍后再试!");
}
@Override
public Rest<RespData<DevicePdu>> save(DevicePdu devicePdu, String authorization) {
return Rest.fail("暂时无法保存设备,请稍后再试!");
}
/**
* @param devicePdu
* @return
*/
@Override
public Rest<Void> refreshMessage(DevicePdu devicePdu) {
return Rest.fail("暂时无法通知设备,请稍后再试!");
}
};
}
}
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