Commit a7a87aa7 authored by 赵啸非's avatar 赵啸非

修改工作人员导入

parent 97d9a55b
...@@ -371,4 +371,7 @@ INSERT INTO `mortals_sys_model` VALUES (null, '基础设置平台', 'basic setti ...@@ -371,4 +371,7 @@ INSERT INTO `mortals_sys_model` VALUES (null, '基础设置平台', 'basic setti
INSERT INTO `mortals_xhx_task` VALUES (null, '用户同步', 'syncUserTask', 0, 'SyncUserTask', NULL, NULL, 4, 120, '00', NULL, '127.0.1.1', '2023-01-13 15:41:40', 0, '2022-07-06 10:49:48', 1, '系统管理员'); INSERT INTO `mortals_xhx_task` VALUES (null, '用户同步', 'syncUserTask', 0, 'SyncUserTask', NULL, NULL, 4, 120, '00', NULL, '127.0.1.1', '2023-01-13 15:41:40', 0, '2022-07-06 10:49:48', 1, '系统管理员');
INSERT INTO `mortals_xhx_param` VALUES (null, null, null, null, 'domain', 'http://192.168.2.169:11071', '1', '4', '0', null, null, null, null); INSERT INTO `mortals_xhx_param` VALUES (null, 'domain', null, null, 'domain', 'http://192.168.0.98:11071', '1', '4', '0', null, null, null, null);
\ No newline at end of file
INSERT INTO `mortals_xhx_param` VALUES (null, 'php访问地址', null, null, 'server_http_url', 'http://192.168.0.98:11078', '1', '4', '0', null, null, null, null);
INSERT INTO `mortals_xhx_param` VALUES (null, 'php访问地址', null, null, 'server_php_http_url', 'http://192.168.0.98:8090', '1', '4', '0', null, null, null, null);
\ No newline at end of file
package com.mortals.xhx.module.skin.service.impl; package com.mortals.xhx.module.skin.service.impl;
import cn.hutool.core.net.URLDecoder;
import cn.hutool.core.net.url.UrlBuilder;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.mortals.framework.ap.GlobalSysInfo; import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
...@@ -80,12 +83,18 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk ...@@ -80,12 +83,18 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk
item.setProductCode(productEntity == null ? "" : productEntity.getProductCode()); item.setProductCode(productEntity == null ? "" : productEntity.getProductCode());
item.setImageResolutionValue(imageResolutionMap.get(entity.getImageResolution() == null ? "1" : entity.getImageResolution())); item.setImageResolutionValue(imageResolutionMap.get(entity.getImageResolution() == null ? "1" : entity.getImageResolution()));
item.setSkinFieldList(skinFieldEntities); item.setSkinFieldList(skinFieldEntities);
String domain = GlobalSysInfo.getParamValue(Constant.DOMAIN, "http://192.168.0.98:11071/");
if (!ObjectUtils.isEmpty(item.getPreviewImagePath())) { if (!ObjectUtils.isEmpty(item.getPreviewImagePath())) {
item.setPreviewImagePath(StrUtil.removeAllLineBreaks(GlobalSysInfo.getParamValue(Constant.DOMAIN, "http://192.168.0.98:11071/") )+ item.getPreviewImagePath()); UrlBuilder builder = UrlBuilder.ofHttp(domain, CharsetUtil.CHARSET_UTF_8).addPath(item.getPreviewImagePath());
item.setPreviewImagePath(builder.build());
log.info("cssUrl:" + URLDecoder.decode(item.getPreviewImagePath(), CharsetUtil.CHARSET_UTF_8));
} }
if (!ObjectUtils.isEmpty(item.getCssFilePath())) { if (!ObjectUtils.isEmpty(item.getCssFilePath())) {
item.setCssFilePath(StrUtil.removeAllLineBreaks(GlobalSysInfo.getParamValue(Constant.DOMAIN, "http://192.168.0.98:11071/") )+ item.getCssFilePath()); UrlBuilder builder = UrlBuilder.ofHttp(domain, CharsetUtil.CHARSET_UTF_8).addPath(item.getCssFilePath());
item.setCssFilePath(builder.build());
log.info("cssUrl:" + URLDecoder.decode(item.getCssFilePath(), CharsetUtil.CHARSET_UTF_8));
} }
}); });
super.findAfter(entity, pageInfo, context, list); super.findAfter(entity, pageInfo, context, list);
...@@ -93,7 +102,11 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk ...@@ -93,7 +102,11 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk
private void updateUrl(SkinFieldEntity field) { private void updateUrl(SkinFieldEntity field) {
if ("2".equals(field.getFieldType())) { if ("2".equals(field.getFieldType())) {
field.setFieldValue(StrUtil.removeAllLineBreaks(GlobalSysInfo.getParamValue(Constant.DOMAIN, "http://192.168.0.98:11071/")) + field.getFieldValue()); String domain = GlobalSysInfo.getParamValue(Constant.DOMAIN, "http://192.168.0.98:11071/");
UrlBuilder builder = UrlBuilder.ofHttp(domain, CharsetUtil.CHARSET_UTF_8).addPath(field.getFieldValue());
field.setFieldValue(builder.build());
log.info("setFieldValue:" + URLDecoder.decode(field.getFieldValue(), CharsetUtil.CHARSET_UTF_8));
} }
} }
......
package com.mortals.xhx.module.skin.web; package com.mortals.xhx.module.skin.web;
import cn.hutool.core.net.url.UrlBuilder;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.mortals.framework.ap.GlobalSysInfo; import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
...@@ -25,6 +27,8 @@ import com.mortals.xhx.module.skin.model.SkinBaseQuery; ...@@ -25,6 +27,8 @@ import com.mortals.xhx.module.skin.model.SkinBaseQuery;
import com.mortals.xhx.module.skin.service.SkinBaseService; import com.mortals.xhx.module.skin.service.SkinBaseService;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
import java.net.URLDecoder;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -49,7 +53,6 @@ public class SkinBaseController extends BaseCRUDJsonBodyMappingController<SkinBa ...@@ -49,7 +53,6 @@ public class SkinBaseController extends BaseCRUDJsonBodyMappingController<SkinBa
private ParamService paramService; private ParamService paramService;
@Autowired @Autowired
private ProductService productService; private ProductService productService;
@Autowired @Autowired
private SkinFieldService skinFieldService; private SkinFieldService skinFieldService;
...@@ -90,7 +93,9 @@ public class SkinBaseController extends BaseCRUDJsonBodyMappingController<SkinBa ...@@ -90,7 +93,9 @@ public class SkinBaseController extends BaseCRUDJsonBodyMappingController<SkinBa
private void updateUrl(SkinFieldEntity field) { private void updateUrl(SkinFieldEntity field) {
if ("2".equals(field.getFieldType())) { if ("2".equals(field.getFieldType())) {
field.setFieldValue(StrUtil.removeAllLineBreaks(GlobalSysInfo.getParamValue(Constant.DOMAIN, "http://192.168.0.98:11071/")) + field.getFieldValue()); String domain = GlobalSysInfo.getParamValue(Constant.DOMAIN, "http://192.168.0.98:11071/");
UrlBuilder builder = UrlBuilder.ofHttp(domain, CharsetUtil.CHARSET_UTF_8).addPath(field.getFieldValue());
field.setFieldValue(builder.build());
} }
} }
......
...@@ -89,6 +89,7 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus ...@@ -89,6 +89,7 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
private void pushChangeMsg(WindowBusinessEntity entity) { private void pushChangeMsg(WindowBusinessEntity entity) {
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090"); String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090");
phpUrl+="/api/window/winNameChange";
HashMap<String, Object> paramsMap = new HashMap<>(); HashMap<String, Object> paramsMap = new HashMap<>();
paramsMap.put("windowid", entity.getWindowId()); paramsMap.put("windowid", entity.getWindowId());
paramsMap.put("typeinfo",1); paramsMap.put("typeinfo",1);
......
...@@ -53,6 +53,7 @@ public class WindowMatterServiceImpl extends AbstractCRUDServiceImpl<WindowMatte ...@@ -53,6 +53,7 @@ public class WindowMatterServiceImpl extends AbstractCRUDServiceImpl<WindowMatte
private void pushChangeMsg(WindowMatterEntity entity) { private void pushChangeMsg(WindowMatterEntity entity) {
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090"); String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090");
phpUrl+="/api/window/winNameChange";
HashMap<String, Object> paramsMap = new HashMap<>(); HashMap<String, Object> paramsMap = new HashMap<>();
paramsMap.put("windowid", entity.getWindowId()); paramsMap.put("windowid", entity.getWindowId());
paramsMap.put("typeinfo",0); paramsMap.put("typeinfo",0);
......
...@@ -152,16 +152,31 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W ...@@ -152,16 +152,31 @@ public class WindowServiceImpl extends AbstractCRUDCacheServiceImpl<WindowDao, W
* @throws AppException * @throws AppException
*/ */
@Override @Override
protected void saveAfter(WindowEntity entity, Context context) throws AppException { protected void updateAfter(WindowEntity entity, Context context) throws AppException {
super.updateAfter(entity, context);
pushChangeMsg(entity); pushChangeMsg(entity);
}
/**
* @param entity
* @param context
* @throws AppException
*/
@Override
protected void saveAfter(WindowEntity entity, Context context) throws AppException {
super.saveAfter(entity, context); super.saveAfter(entity, context);
pushChangeMsg(entity);
} }
private void pushChangeMsg(WindowEntity entity) { private void pushChangeMsg(WindowEntity entity) {
log.info("pushChangeMsg:{}",JSON.toJSONString(entity));
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090"); String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://172.15.28.116:8090");
phpUrl+="/api/window/winNameChange";
HashMap<String, Object> paramsMap = new HashMap<>(); HashMap<String, Object> paramsMap = new HashMap<>();
paramsMap.put("windowid", entity.getId()); paramsMap.put("windowid", entity.getId());
paramsMap.put("typeinfo",1); paramsMap.put("typeinfo",1);
phpUrl+="/api/window/winNameChange";
String resp = null; String resp = null;
try { try {
Map<String, String> header = new HashMap<>(); Map<String, String> header = new HashMap<>();
......
package com.mortals.xhx.module.workman.service.impl; package com.mortals.xhx.module.workman.service.impl;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ZipUtil;
import com.mortals.framework.common.Rest; 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;
...@@ -23,6 +24,7 @@ import org.springframework.util.ObjectUtils; ...@@ -23,6 +24,7 @@ import org.springframework.util.ObjectUtils;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -143,71 +145,47 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao, ...@@ -143,71 +145,47 @@ public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao,
*/ */
@Override @Override
public Rest<Void> doImportPic(String picfilePath) throws AppException { public Rest<Void> doImportPic(String picfilePath) throws AppException {
String disPath = filePath+"/pics"; String disPath = filePath+"/pics/" + FileUtil.getPrefix(picfilePath).trim();
String targetFilePath = uploadService.getFilePath(picfilePath);
Thread t = new Thread(new Runnable(){ if (FileUtil.isEmpty(new File(targetFilePath))) {
public void run(){ throw new AppException("文件不存在!");
//解压图片 }
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); ZipUtil.unzip(targetFilePath, disPath, Charset.forName("GBK"));
//读取目录下的所有图片 //读取目录下的所有图片
File[] files = FileUtil.ls(disPath); File[] files = FileUtil.ls(disPath);
for (File file : files) { for (File file : files) {
if (file.isFile()) { if (file.isFile()) {
String fileName = file.getName(); updateWorkmanPic(file);
String[] vals = fileName.split("-"); }
if (vals.length > 1) { if (file.isDirectory()) {
String userName = vals[1]; File[] subFiles = file.listFiles();
//根据用户名查询工作人员名称 for (File subFile : subFiles) {
WorkmanEntity workmanEntity = this.selectOne(new WorkmanQuery().name(userName)); updateWorkmanPic(subFile);
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("解析成功"); return Rest.ok("解析成功");
} }
private void updateWorkmanPic(File file) {
String userName = FileUtil.getPrefix(file).trim();
//根据用户名查询工作人员名称
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, FileUtil.readBytes(file), true, true);
if (bool) {
workmanEntity.setPhotoPath(newName);
workmanService.update(workmanEntity);
}
} catch (IOException e) {
log.error("写入证照异常", e);
}
}
}
} }
\ No newline at end of file
...@@ -114,6 +114,7 @@ public class WorkmanController extends BaseCRUDJsonBodyMappingController<Workman ...@@ -114,6 +114,7 @@ public class WorkmanController extends BaseCRUDJsonBodyMappingController<Workman
public String doImportPic(@RequestBody WorkmanEntity query) { public String doImportPic(@RequestBody WorkmanEntity query) {
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
try { try {
log.info("filePath:"+query.getFilePath());
Rest<Void> rest = this.service.doImportPic(query.getFilePath()); Rest<Void> rest = this.service.doImportPic(query.getFilePath());
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS); ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
recordSysLog(request, getCurUser(), "解析工作人员图片成功!"); recordSysLog(request, getCurUser(), "解析工作人员图片成功!");
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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