java110 před 3 roky
rodič
revize
d44b66e6d7

+ 43 - 0
java110-interface/src/main/java/com/java110/intf/dev/ICacheV1InnerServiceSMO.java

@@ -0,0 +1,43 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.intf.dev;
+
+import com.java110.config.feign.FeignConfiguration;
+import com.java110.dto.Dict.DictDto;
+import com.java110.po.dict.DictPo;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import java.util.List;
+
+/**
+ * 类表述: 服务之前调用的接口类,不对外提供接口能力 只用于接口建调用
+ * add by 吴学文 at 2022-07-06 20:03:58 mail: 928255095@qq.com
+ * open source address: https://gitee.com/wuxw7/MicroCommunity
+ * 官网:http://www.homecommunity.cn
+ * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
+ * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
+ */
+@FeignClient(name = "dev-service", configuration = {FeignConfiguration.class})
+@RequestMapping("/cacheV1Api")
+public interface ICacheV1InnerServiceSMO {
+
+
+    @RequestMapping(value = "/startFlush", method = RequestMethod.POST)
+    public void startFlush();
+}

+ 4 - 4
java110-interface/src/main/resources/logback.xml

@@ -69,17 +69,17 @@
     </logger>
 
     <!--myibatis log configure-->
-    <logger name="com.apache.ibatis" level="ERROR">
+    <logger name="com.apache.ibatis" level="DEBUG">
         <appender-ref ref="STDOUT_FILE"/>
     </logger>
 
-    <logger name="org.mybatis" level="ERROR">
+    <logger name="org.mybatis" level="DEBUG">
         <appender-ref ref="STDOUT_FILE"/>
     </logger>
-    <logger name="druid.sql.Statement" level="ERROR">
+    <logger name="druid.sql.Statement" level="DEBUG">
         <appender-ref ref="STDOUT_FILE"/>
     </logger>
-    <logger name="druid.sql.ResultSet" level="ERROR">
+    <logger name="druid.sql.ResultSet" level="DEBUG">
         <appender-ref ref="STDOUT_FILE"/>
     </logger>
 

+ 56 - 0
service-dev/src/main/java/com/java110/dev/smo/impl/CacheV1InnerServiceSMOImpl.java

@@ -0,0 +1,56 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.dev.smo.impl;
+
+
+import com.java110.core.base.smo.BaseServiceSMO;
+import com.java110.dev.dao.IDictV1ServiceDao;
+import com.java110.dev.smo.IDevServiceCacheSMO;
+import com.java110.dto.Dict.DictDto;
+import com.java110.dto.PageDto;
+import com.java110.intf.dev.ICacheV1InnerServiceSMO;
+import com.java110.intf.dev.IDictV1InnerServiceSMO;
+import com.java110.po.dict.DictPo;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 类表述: 服务之前调用的接口实现类,不对外提供接口能力 只用于接口建调用
+ * add by 吴学文 at 2022-07-06 20:03:58 mail: 928255095@qq.com
+ * open source address: https://gitee.com/wuxw7/MicroCommunity
+ * 官网:http://www.homecommunity.cn
+ * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
+ * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
+ */
+@RestController
+public class CacheV1InnerServiceSMOImpl extends BaseServiceSMO implements ICacheV1InnerServiceSMO {
+
+    @Autowired
+    private IDevServiceCacheSMO devServiceCacheSMOImpl;
+
+
+    @Override
+    public void startFlush() {
+        devServiceCacheSMOImpl.startFlush();
+
+    }
+
+
+}

+ 53 - 30
springboot/src/main/java/com/java110/boot/BootApplicationStart.java

@@ -16,40 +16,29 @@
 package com.java110.boot;
 
 import com.java110.core.annotation.Java110CmdDiscovery;
-import com.java110.core.annotation.Java110ListenerDiscovery;
 import com.java110.core.client.RestTemplate;
 import com.java110.core.context.Environment;
 import com.java110.core.event.cmd.ServiceCmdEventPublishing;
-import com.java110.core.event.service.api.ServiceDataFlowEventPublishing;
 import com.java110.core.log.LoggerFactory;
 import com.java110.core.trace.Java110FeignClientInterceptor;
 import com.java110.core.trace.Java110RestTemplateInterceptor;
+import com.java110.intf.dev.ICacheV1InnerServiceSMO;
 import com.java110.service.init.ServiceStartInit;
-import io.swagger.annotations.ApiOperation;
+import com.java110.utils.factory.ApplicationContextFactory;
+import com.java110.utils.util.StringUtil;
 import okhttp3.ConnectionPool;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
 import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
-import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.http.converter.StringHttpMessageConverter;
 import org.springframework.scheduling.annotation.EnableAsync;
-import springfox.documentation.builders.ApiInfoBuilder;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
 
 import javax.annotation.Resource;
 import java.nio.charset.Charset;
@@ -59,23 +48,24 @@ import java.util.concurrent.TimeUnit;
 /**
  * 这个服务是将 系统部署为spring boot版
  * 如果是spring cloud 微服务部署 不用启动这个类
- *
+ * <p>
  * excludeName = {
- "com.java110.intf.acct",
- "com.java110.intf.code",
- "com.java110.intf.common",
- "com.java110.intf.community",
- "com.java110.intf.demo",
- "com.java110.intf.dev",
- "com.java110.intf.fee",
- "com.java110.intf.goods",
- "com.java110.intf.job",
- "com.java110.intf.oa",
- "com.java110.intf.order",
- "com.java110.intf.report",
- "com.java110.intf.store",
- "com.java110.intf.user"
- }
+ * "com.java110.intf.acct",
+ * "com.java110.intf.code",
+ * "com.java110.intf.common",
+ * "com.java110.intf.community",
+ * "com.java110.intf.demo",
+ * "com.java110.intf.dev",
+ * "com.java110.intf.fee",
+ * "com.java110.intf.goods",
+ * "com.java110.intf.job",
+ * "com.java110.intf.oa",
+ * "com.java110.intf.order",
+ * "com.java110.intf.report",
+ * "com.java110.intf.store",
+ * "com.java110.intf.user"
+ * }
+ *
  * @version v0.1
  * @auther com.java110.wuxw
  * @mail 928255095@qq.com
@@ -174,9 +164,42 @@ public class BootApplicationStart {
             ServiceStartInit.initSystemConfig(context);
 
             Environment.setSystemStartWay(Environment.SPRING_BOOT);
+
+            //刷新缓存
+            flushMainCache(args);
         } catch (Throwable e) {
             logger.error("系统启动失败", e);
         }
     }
 
+    /**
+     * 刷新主要的缓存
+     *
+     * @param args
+     */
+    private static void flushMainCache(String[] args) {
+
+        logger.debug("判断是否需要刷新日志,参数 args 为 {}", args);
+
+        //因为好多朋友启动时 不加 参数-Dcache 所以启动时检测 redis 中是否存在 java110_hc_version
+        //String mapping = MappingCache.getValue("java110_hc_version");
+        String mapping = "";
+        if (StringUtil.isEmpty(mapping)) {
+            ICacheV1InnerServiceSMO devServiceCacheSMOImpl = (ICacheV1InnerServiceSMO) ApplicationContextFactory.getBean(ICacheV1InnerServiceSMO.class);
+            devServiceCacheSMOImpl.startFlush();
+            return;
+        }
+
+        if (args == null || args.length == 0) {
+            return;
+        }
+        for (int i = 0; i < args.length; i++) {
+            if (args[i].equalsIgnoreCase("-Dcache")) {
+                logger.debug("开始刷新日志,入参为:{}", args[i]);
+                ICacheV1InnerServiceSMO devServiceCacheSMOImpl = (ICacheV1InnerServiceSMO) ApplicationContextFactory.getBean(ICacheV1InnerServiceSMO.class);
+                devServiceCacheSMOImpl.startFlush();
+            }
+        }
+    }
+
 }

+ 35 - 0
springboot/src/main/java/com/java110/boot/components/owner/AddOwnerRoomBindingComponent.java

@@ -0,0 +1,35 @@
+package com.java110.boot.components.owner;
+
+import com.java110.boot.smo.addOwner.IAddOwnerRoomBindingSMO;
+import com.java110.core.context.IPageData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+
+/**
+ * 添加添加业主组件
+ */
+@Component("addOwnerRoomBinding")
+public class AddOwnerRoomBindingComponent {
+
+    @Autowired
+    private IAddOwnerRoomBindingSMO addOwnerRoomBindingSMOImpl;
+
+    /**
+     * 添加添加业主数据
+     *
+     * @param pd 页面数据封装
+     * @return ResponseEntity 对象
+     */
+    public ResponseEntity<String> binding(IPageData pd) {
+        return addOwnerRoomBindingSMOImpl.bindingAddOwnerRoom(pd);
+    }
+
+    public IAddOwnerRoomBindingSMO getAddOwnerRoomBindingSMOImpl() {
+        return addOwnerRoomBindingSMOImpl;
+    }
+
+    public void setAddOwnerRoomBindingSMOImpl(IAddOwnerRoomBindingSMO addOwnerRoomBindingSMOImpl) {
+        this.addOwnerRoomBindingSMOImpl = addOwnerRoomBindingSMOImpl;
+    }
+}

+ 19 - 0
springboot/src/main/java/com/java110/boot/smo/addOwner/IAddOwnerRoomBindingSMO.java

@@ -0,0 +1,19 @@
+package com.java110.boot.smo.addOwner;
+
+import com.java110.core.context.IPageData;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * 添加添加业主接口
+ *
+ * add by wuxw 2019-06-30
+ */
+public interface IAddOwnerRoomBindingSMO {
+
+    /**
+     * 添加添加业主
+     * @param pd 页面数据封装
+     * @return ResponseEntity 对象
+     */
+    ResponseEntity<String> bindingAddOwnerRoom(IPageData pd);
+}

+ 102 - 0
springboot/src/main/java/com/java110/boot/smo/addOwner/impl/AddOwnerRoomBindingSMOImpl.java

@@ -0,0 +1,102 @@
+package com.java110.boot.smo.addOwner.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.boot.smo.DefaultAbstractComponentSMO;
+import com.java110.boot.smo.addOwner.IAddOwnerRoomBindingSMO;
+import com.java110.core.context.IPageData;
+import com.java110.entity.component.ComponentValidateResult;
+import com.java110.utils.constant.PrivilegeCodeConstant;
+import com.java110.utils.util.Assert;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * 添加小区服务实现类
+ * add by wuxw 2019-06-30
+ */
+@Service("addOwnerRoomBindingSMOImpl")
+public class AddOwnerRoomBindingSMOImpl extends DefaultAbstractComponentSMO implements IAddOwnerRoomBindingSMO {
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Override
+    protected void validate(IPageData pd, JSONObject paramIn) {
+
+        //super.validatePageInfo(pd);
+        JSONArray infos = paramIn.getJSONArray("data");
+        Assert.hasKeyAndValue(paramIn, "communityId", "未包含小区信息");
+
+        if (infos.size() != 3) {
+            throw new IllegalArgumentException("数据被篡改");
+        }
+
+        Assert.hasKeyByFlowData(infos, "viewFloorInfo", "floorId", "必填,未选择楼栋");
+        Assert.hasKeyByFlowData(infos, "sellRoomSelectRoom", "roomId", "必填,未选择房屋");
+        Assert.hasKeyByFlowData(infos, "viewOwnerInfo", "ownerId", "必填,未包含业主信息");
+
+
+        super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.ADD_OWNER_ROOM);
+
+    }
+
+    @Override
+    protected ResponseEntity<String> doBusinessProcess(IPageData pd, JSONObject paramIn) {
+        ResponseEntity<String> responseEntity = null;
+        ComponentValidateResult result = super.validateStoreStaffCommunityRelationship(pd, restTemplate);
+
+        JSONArray infos = paramIn.getJSONArray("data");
+        //JSONObject viewFloorInfo = getObj(infos, "viewFloorInfo");
+        JSONObject sellRoomSelectRoom = getObj(infos, "sellRoomSelectRoom");
+        JSONObject viewOwnerInfo = getObj(infos, "viewOwnerInfo");
+        JSONObject newParamIn = new JSONObject();
+        String communityId = paramIn.getString("communityId");
+        newParamIn.put("ownerId", viewOwnerInfo.getString("ownerId"));
+        newParamIn.put("roomId", sellRoomSelectRoom.getString("roomId"));
+        newParamIn.put("communityId", communityId);
+        newParamIn.put("userId", pd.getUserId());
+        newParamIn.put("storeId", result.getStoreId());
+        newParamIn.put("state", "2001");
+        responseEntity = this.callCenterService(restTemplate, pd, newParamIn.toJSONString(),
+                "room.sellRoom",
+                HttpMethod.POST);
+        return responseEntity;
+    }
+
+
+    private JSONObject getObj(JSONArray infos, String flowComponent) {
+
+        JSONObject serviceInfo = null;
+
+        for (int infoIndex = 0; infoIndex < infos.size(); infoIndex++) {
+
+            Assert.hasKeyAndValue(infos.getJSONObject(infoIndex), "flowComponent", "未包含服务流程组件名称");
+
+            if (flowComponent.equals(infos.getJSONObject(infoIndex).getString("flowComponent"))) {
+                serviceInfo = infos.getJSONObject(infoIndex);
+                Assert.notNull(serviceInfo, "未包含服务信息");
+                return serviceInfo;
+            }
+        }
+
+        throw new IllegalArgumentException("未找到组件编码为【" + flowComponent + "】数据");
+    }
+
+
+    @Override
+    public ResponseEntity<String> bindingAddOwnerRoom(IPageData pd) {
+        return super.businessProcess(pd);
+    }
+
+    public RestTemplate getRestTemplate() {
+        return restTemplate;
+    }
+
+    public void setRestTemplate(RestTemplate restTemplate) {
+        this.restTemplate = restTemplate;
+    }
+}