diff --git a/modules/i3plus-core-api/src/main/java/cn/estsh/i3plus/core/api/iservice/busi/ISysOrganizeService.java b/modules/i3plus-core-api/src/main/java/cn/estsh/i3plus/core/api/iservice/busi/ISysOrganizeService.java index eba7b44..35d468a 100644 --- a/modules/i3plus-core-api/src/main/java/cn/estsh/i3plus/core/api/iservice/busi/ISysOrganizeService.java +++ b/modules/i3plus-core-api/src/main/java/cn/estsh/i3plus/core/api/iservice/busi/ISysOrganizeService.java @@ -82,6 +82,8 @@ public interface ISysOrganizeService { @ApiOperation(value = "查询组织信息",notes = "根据ID查询组织信息") SysOrganize getSysOrganizeById(Long id); + SysOrganize getSysOrganizeByCode(String code); + /** * 查询组织个数 * @return diff --git a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/SystemController.java b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/SystemController.java new file mode 100644 index 0000000..8f13ff1 --- /dev/null +++ b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/SystemController.java @@ -0,0 +1,62 @@ +package cn.estsh.i3plus.core.apiservice.controller.base; + +import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil; +import cn.estsh.impp.framework.boot.exception.ImppBusiException; +import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; +import cn.estsh.impp.framework.boot.util.ResultBean; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections4.MapUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.AbstractEnvironment; +import org.springframework.core.env.Environment; +import org.springframework.core.env.MapPropertySource; +import org.springframework.core.env.PropertySource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.*; + +/** + * @Description : + * @Reference : + * @Author : wei.peng + * @CreateDate : 2019-07-09 下午5:57 + * @Modify: + **/ +@RestController +@Api(description = "系统服务") +@RequestMapping("/system") +public class SystemController { + + @Autowired + private Environment environment; + + @GetMapping("/get-properties") + @ApiOperation(value = "获取系统配置信息", notes = "获取系统配置信息") + public ResultBean getProperties(){ + try { + //条件验证 + String[] profiles = environment.getDefaultProfiles(); + Map map = new HashMap(); + for(Iterator it = ((AbstractEnvironment) environment).getPropertySources().iterator(); it.hasNext(); ) { + PropertySource propertySource = (PropertySource) it.next(); + if (propertySource instanceof MapPropertySource) { + MapPropertySource source = (MapPropertySource) propertySource; + for (String key : source.getPropertyNames()) { + map.put(key,source.getProperty(key)); + } + } + } + + return ResultBean.success("操作成功") + .setResultMap(map) + .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()); + } catch (ImppBusiException busExcep) { + return ResultBean.fail(busExcep); + } catch (Exception e) { + return ImppExceptionBuilder.newInstance().buildExceptionResult(e); + } + } +} diff --git a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysOrganizeController.java b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysOrganizeController.java index 0736aa0..bea6e70 100644 --- a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysOrganizeController.java +++ b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysOrganizeController.java @@ -1,15 +1,20 @@ package cn.estsh.i3plus.core.apiservice.controller.busi; +import cn.estsh.i3plus.core.api.iservice.base.ISystemInitService; import cn.estsh.i3plus.core.api.iservice.busi.ICoreMemTreeService; import cn.estsh.i3plus.core.api.iservice.busi.IPersonnelService; import cn.estsh.i3plus.core.api.iservice.busi.ISysOrganizeService; +import cn.estsh.i3plus.icloud.wms.sdk.IWmsActionGroupCloud; import cn.estsh.i3plus.platform.common.convert.ConvertBean; import cn.estsh.i3plus.platform.common.tool.StringTool; +import cn.estsh.i3plus.platform.common.util.CommonConstWords; import cn.estsh.i3plus.platform.common.util.PlatformConstWords; +import cn.estsh.i3plus.pojo.base.bean.BaseResultBean; import cn.estsh.i3plus.pojo.base.bean.ListPager; import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil; +import cn.estsh.i3plus.pojo.platform.bean.SysConfig; import cn.estsh.i3plus.pojo.platform.bean.SysOrganize; import cn.estsh.i3plus.pojo.platform.bean.SysRefUserDepartment; import cn.estsh.impp.framework.base.controller.CoreBaseController; @@ -21,6 +26,7 @@ import cn.estsh.impp.framework.boot.util.ResultBean; import cn.estsh.impp.framework.boot.util.ValidatorBean; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -52,6 +58,12 @@ public class SysOrganizeController extends CoreBaseController{ @Autowired private ICoreMemTreeService coreMemTreeService; + @Autowired + private ISystemInitService systemInitService; + + @Autowired + private IWmsActionGroupCloud wmsActionGroupCloud; + /** * 新增组织 * @param organize 组织 @@ -75,7 +87,14 @@ public class SysOrganizeController extends CoreBaseController{ } organize = organizeService.insertSysOrganize(organize); - return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultObject(organize); + String resutl = "组织已创建完成"; + + String copyMessage = copyWmsProcess(organize); + resutl = StringUtils.isNotBlank(copyMessage) ? resutl +","+ copyMessage : resutl; + return ResultBean.success("操作成功") + .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()) + .setMsg(resutl) + .setResultObject(organize); } catch (ImppBusiException busExcep) { return ResultBean.fail(busExcep); } catch (Exception e) { @@ -272,4 +291,47 @@ public class SysOrganizeController extends CoreBaseController{ return ImppExceptionBuilder.newInstance().buildExceptionResult(e); } } + + private String copyWmsProcess(SysOrganize organize){ + String result = null; + // 检查是否复制 WMS 流程 + String redisKey = CommonConstWords.REDIS_PREFIX_CACHE_CONFIG + "_" + CommonConstWords.CONFIG_ORGANIZE_INSERT_INIT_WMS_COPY_PROCESS; + SysConfig config = (SysConfig) systemInitService.getDataFromCache(redisKey, SysConfig.class); + + LOGGER.info("Copy Wms Process Config:{}",config); + if(config != null){ + if(config.getConfigValue().equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue())){ + + // 获取目标组织代码 + redisKey = CommonConstWords.REDIS_PREFIX_CACHE_CONFIG + "_" + CommonConstWords.CONFIG_ORGANIZE_INSERT_INIT_WMS_COPY_PROCESS_CODE; + config = (SysConfig) systemInitService.getDataFromCache(redisKey, SysConfig.class); + + LOGGER.info("Copy Wms Process Organize Code Config:{}",config); + if(config != null){ + // 获取组织信息 + SysOrganize tmpOrganize = organizeService.getSysOrganizeByCode(config.getConfigValue()); + + // 检查组织信息是否完整 + if(tmpOrganize != null){ + // 复制WMS 业务流程 + LOGGER.info("Copy Wms Process Template Code :{} Target Code:{}",tmpOrganize.getOrganizeCode(),organize.getOrganizeCode()); + BaseResultBean resultBean = wmsActionGroupCloud.copyWmsActionGroupByOrganizeCode(tmpOrganize.getOrganizeCode(), organize.getOrganizeCode()); + LOGGER.info("Copy Wms Process Template Code :{} Target Code:{} Result Bean:{}",tmpOrganize.getOrganizeCode(),organize.getOrganizeCode(),resultBean); + + if(resultBean != null){ + if(ResourceEnumUtil.MESSAGE.SUCCESS.getCode().equals(resultBean.getCode())){ + result = "流程复制成功"; + }else{ + result = resultBean.getErrorMsg(); + } + }else { + result = "复制流程失败,服务调用返回信息为空"; + } + } + } + } + } + return result; + } + } diff --git a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/SysOrganizeService.java b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/SysOrganizeService.java index 8ddb72f..e301cb2 100644 --- a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/SysOrganizeService.java +++ b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/SysOrganizeService.java @@ -13,6 +13,7 @@ import cn.estsh.i3plus.pojo.platform.bean.SysOrganize; import cn.estsh.i3plus.pojo.platform.bean.SysRefUserDepartment; import cn.estsh.i3plus.pojo.platform.repository.SysOrganizeRepository; import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack; +import cn.estsh.impp.framework.boot.auth.AuthUtil; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum; import cn.estsh.impp.framework.boot.util.ValidatorBean; @@ -111,7 +112,7 @@ public class SysOrganizeService implements ISysOrganizeService { // 检查引用关系 personnelService.checkSysOrganizeRef(id); // 删除数据 - organizeRDao.deleteById(id); + organizeRDao.deleteWeaklyById(id, AuthUtil.getSessionUser().getUserName()); } @Override @@ -130,7 +131,7 @@ public class SysOrganizeService implements ISysOrganizeService { for (Long id : ids) { personnelService.checkSysOrganizeRef(id); } - organizeRDao.deleteByIds(ids); + organizeRDao.deleteWeaklyByIds(ids, AuthUtil.getSessionUser().getUserName()); } } @@ -191,6 +192,11 @@ public class SysOrganizeService implements ISysOrganizeService { } @Override + public SysOrganize getSysOrganizeByCode(String code) { + return null; + } + + @Override public long getSysOrganizeCount() { return organizeRDao.listCount(); }