shiyj1101
2021-11-09 93d8f21bd4a66cdf9d9c29cde675adfea6250999
优化设备信息
5个文件已修改
9个文件已添加
994 ■■■■■ 已修改文件
java110-bean/src/main/java/com/java110/po/machine/MachinePo.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-db/src/main/resources/mapper/common/MachineV1ServiceDaoImplMapper.xml 199 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-generator/src/main/java/com/java110/code/TableToJson.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-generator/src/main/java/com/java110/code/newBack/BackCoderGeneratorStart.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-generator/src/main/java/com/java110/code/newBack/GeneratorApiListener.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-generator/src/main/resources/newBack/template_1.json 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-interface/src/main/java/com/java110/intf/common/IMachineV1InnerServiceSMO.java 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-common/src/main/java/com/java110/common/cmd/machine/DeleteMachineCmd.java 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-common/src/main/java/com/java110/common/cmd/machine/ListMachineCmd.java 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-common/src/main/java/com/java110/common/cmd/machine/SaveMachineCmd.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-common/src/main/java/com/java110/common/cmd/machine/UpdateMachineCmd.java 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-common/src/main/java/com/java110/common/dao/IMachineV1ServiceDao.java 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-common/src/main/java/com/java110/common/dao/impl/MachineV1ServiceDaoImpl.java 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-common/src/main/java/com/java110/common/smo/impl/MachineV1InnerServiceSMOImpl.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-bean/src/main/java/com/java110/po/machine/MachinePo.java
@@ -26,6 +26,8 @@
    private String state;
    private String direction;
    private String typeId;
    private String bId;
    private String statusCd = "0";
    public String getMachineId() {
@@ -139,4 +141,20 @@
    public void setTypeId(String typeId) {
        this.typeId = typeId;
    }
    public String getbId() {
        return bId;
    }
    public void setbId(String bId) {
        this.bId = bId;
    }
    public String getStatusCd() {
        return statusCd;
    }
    public void setStatusCd(String statusCd) {
        this.statusCd = statusCd;
    }
}
java110-db/src/main/resources/mapper/common/MachineV1ServiceDaoImplMapper.xml
New file
@@ -0,0 +1,199 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="machineV1ServiceDaoImpl">
    <!-- 保存设备信息信息 add by wuxw 2018-07-03 -->
    <insert id="saveMachineInfo" parameterType="Map">
        insert into machine(
heartbeat_time,machine_code,auth_code,location_type_cd,machine_version,machine_name,machine_mac,
machine_id,type_id,state,community_id,location_obj_id,machine_type_cd,machine_ip,direction,b_id
) values (
#{heartbeatTime},#{machineCode},#{authCode},#{locationTypeCd},#{machineVersion},#{machineName},#{machineMac},
#{machineId},#{typeId},#{state},#{communityId},#{locationObjId},#{machineTypeCd},#{machineIp},#{direction},#{bId}
)
    </insert>
    <!-- 查询设备信息信息 add by wuxw 2018-07-03 -->
    <select id="getMachineInfo" parameterType="Map" resultType="Map">
        select t.heartbeat_time,t.heartbeat_time heartbeatTime,t.machine_code,t.machine_code
        machineCode,t.auth_code,t.auth_code authCode,t.location_type_cd,t.location_type_cd
        locationTypeCd,t.machine_version,t.machine_version machineVersion,t.status_cd,t.status_cd
        statusCd,t.machine_name,t.machine_name machineName,t.machine_mac,t.machine_mac
        machineMac,t.machine_id,t.machine_id machineId,t.type_id,t.type_id typeId,t.state,t.community_id,t.community_id
        communityId,t.location_obj_id,t.location_obj_id locationObjId,t.machine_type_cd,t.machine_type_cd
        machineTypeCd,t.machine_ip,t.machine_ip machineIp,t.direction
        from machine t
        where 1 =1
        <if test="heartbeatTime !=null and heartbeatTime != ''">
            and t.heartbeat_time= #{heartbeatTime}
        </if>
        <if test="machineCode !=null and machineCode != ''">
            and t.machine_code= #{machineCode}
        </if>
        <if test="authCode !=null and authCode != ''">
            and t.auth_code= #{authCode}
        </if>
        <if test="locationTypeCd !=null and locationTypeCd != ''">
            and t.location_type_cd= #{locationTypeCd}
        </if>
        <if test="machineVersion !=null and machineVersion != ''">
            and t.machine_version= #{machineVersion}
        </if>
        <if test="statusCd !=null and statusCd != ''">
            and t.status_cd= #{statusCd}
        </if>
        <if test="machineName !=null and machineName != ''">
            and t.machine_name= #{machineName}
        </if>
        <if test="machineMac !=null and machineMac != ''">
            and t.machine_mac= #{machineMac}
        </if>
        <if test="machineId !=null and machineId != ''">
            and t.machine_id= #{machineId}
        </if>
        <if test="typeId !=null and typeId != ''">
            and t.type_id= #{typeId}
        </if>
        <if test="state !=null and state != ''">
            and t.state= #{state}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="locationObjId !=null and locationObjId != ''">
            and t.location_obj_id= #{locationObjId}
        </if>
        <if test="machineTypeCd !=null and machineTypeCd != ''">
            and t.machine_type_cd= #{machineTypeCd}
        </if>
        <if test="machineIp !=null and machineIp != ''">
            and t.machine_ip= #{machineIp}
        </if>
        <if test="direction !=null and direction != ''">
            and t.direction= #{direction}
        </if>
        order by t.create_time desc
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
    <!-- 修改设备信息信息 add by wuxw 2018-07-03 -->
    <update id="updateMachineInfo" parameterType="Map">
        update machine t set t.status_cd = #{statusCd}
        <if test="newBId != null and newBId != ''">
            ,t.b_id = #{newBId}
        </if>
        <if test="heartbeatTime !=null and heartbeatTime != ''">
            , t.heartbeat_time= #{heartbeatTime}
        </if>
        <if test="machineCode !=null and machineCode != ''">
            , t.machine_code= #{machineCode}
        </if>
        <if test="authCode !=null and authCode != ''">
            , t.auth_code= #{authCode}
        </if>
        <if test="locationTypeCd !=null and locationTypeCd != ''">
            , t.location_type_cd= #{locationTypeCd}
        </if>
        <if test="machineVersion !=null and machineVersion != ''">
            , t.machine_version= #{machineVersion}
        </if>
        <if test="machineName !=null and machineName != ''">
            , t.machine_name= #{machineName}
        </if>
        <if test="machineMac !=null and machineMac != ''">
            , t.machine_mac= #{machineMac}
        </if>
        <if test="typeId !=null and typeId != ''">
            , t.type_id= #{typeId}
        </if>
        <if test="state !=null and state != ''">
            , t.state= #{state}
        </if>
        <if test="communityId !=null and communityId != ''">
            , t.community_id= #{communityId}
        </if>
        <if test="locationObjId !=null and locationObjId != ''">
            , t.location_obj_id= #{locationObjId}
        </if>
        <if test="machineTypeCd !=null and machineTypeCd != ''">
            , t.machine_type_cd= #{machineTypeCd}
        </if>
        <if test="machineIp !=null and machineIp != ''">
            , t.machine_ip= #{machineIp}
        </if>
        <if test="direction !=null and direction != ''">
            , t.direction= #{direction}
        </if>
        where 1=1
        <if test="machineId !=null and machineId != ''">
            and t.machine_id= #{machineId}
        </if>
    </update>
    <!-- 查询设备信息数量 add by wuxw 2018-07-03 -->
    <select id="queryMachinesCount" parameterType="Map" resultType="Map">
        select count(1) count
        from machine t
        where 1 =1
        <if test="heartbeatTime !=null and heartbeatTime != ''">
            and t.heartbeat_time= #{heartbeatTime}
        </if>
        <if test="machineCode !=null and machineCode != ''">
            and t.machine_code= #{machineCode}
        </if>
        <if test="authCode !=null and authCode != ''">
            and t.auth_code= #{authCode}
        </if>
        <if test="locationTypeCd !=null and locationTypeCd != ''">
            and t.location_type_cd= #{locationTypeCd}
        </if>
        <if test="machineVersion !=null and machineVersion != ''">
            and t.machine_version= #{machineVersion}
        </if>
        <if test="statusCd !=null and statusCd != ''">
            and t.status_cd= #{statusCd}
        </if>
        <if test="machineName !=null and machineName != ''">
            and t.machine_name= #{machineName}
        </if>
        <if test="machineMac !=null and machineMac != ''">
            and t.machine_mac= #{machineMac}
        </if>
        <if test="machineId !=null and machineId != ''">
            and t.machine_id= #{machineId}
        </if>
        <if test="typeId !=null and typeId != ''">
            and t.type_id= #{typeId}
        </if>
        <if test="state !=null and state != ''">
            and t.state= #{state}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="locationObjId !=null and locationObjId != ''">
            and t.location_obj_id= #{locationObjId}
        </if>
        <if test="machineTypeCd !=null and machineTypeCd != ''">
            and t.machine_type_cd= #{machineTypeCd}
        </if>
        <if test="machineIp !=null and machineIp != ''">
            and t.machine_ip= #{machineIp}
        </if>
        <if test="direction !=null and direction != ''">
            and t.direction= #{direction}
        </if>
    </select>
</mapper>
java110-generator/src/main/java/com/java110/code/TableToJson.java
@@ -7,25 +7,38 @@
public class TableToJson {
    //show create table c_orders  用这个语句获取
    public static final String createTableSql = "CREATE TABLE `report_custom_component_condition` (\n" +
            "  `condition_id` varchar(30) NOT NULL COMMENT '条件ID',\n" +
            "  `component_id` varchar(30) NOT NULL COMMENT '组件ID',\n" +
            "  `name` varchar(64) NOT NULL COMMENT '名称',\n" +
            "  `holdpace` varchar(64) NOT NULL DEFAULT 'C' COMMENT '提示',\n" +
            "  `param` varchar(64) NOT NULL COMMENT '参数',\n" +
            "  `type` varchar(12) NOT NULL COMMENT '类型 input 输入框',\n" +
            "  `remark` varchar(512) DEFAULT NULL COMMENT '描述',\n" +
    public static final String createTableSql = "CREATE TABLE `machine` (\n" +
            "  `machine_id` varchar(30) NOT NULL COMMENT '设备ID',\n" +
            "  `b_id` varchar(30) NOT NULL COMMENT '业务Id',\n" +
            "  `machine_code` varchar(30) NOT NULL COMMENT '设备编码',\n" +
            "  `machine_version` varchar(30) NOT NULL COMMENT '设备版本',\n" +
            "  `machine_type_cd` varchar(30) NOT NULL COMMENT '设备类型 门禁9999 详情查看t_dict 表',\n" +
            "  `community_id` varchar(30) NOT NULL COMMENT '小区ID',\n" +
            "  `machine_name` varchar(200) NOT NULL COMMENT '设备名称',\n" +
            "  `auth_code` varchar(64) NOT NULL COMMENT '授权码',\n" +
            "  `machine_ip` varchar(64) DEFAULT NULL COMMENT '设备IP',\n" +
            "  `machine_mac` varchar(64) DEFAULT NULL COMMENT '设备mac',\n" +
            "  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',\n" +
            "  `status_cd` varchar(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效'\n" +
            "  `status_cd` varchar(2) NOT NULL DEFAULT '0' COMMENT '数据状态,详细参考c_status表,S 保存,0, 在用 1失效',\n" +
            "  `location_type_cd` varchar(30) NOT NULL COMMENT '位置ID,请查看 community_location',\n" +
            "  `location_obj_id` varchar(30) NOT NULL DEFAULT '-1' COMMENT '对象ID,大门时小区ID,单元门 时单元ID 房屋时房屋ID',\n" +
            "  `state` varchar(12) NOT NULL DEFAULT '1000' COMMENT '设备状态,设备配置同步状态 1000 未同步 1100 同步中 1200 已同步',\n" +
            "  `direction` varchar(12) NOT NULL DEFAULT '3306' COMMENT '设备方向进出,3306 进 3307 出',\n" +
            "  `heartbeat_time` datetime NOT NULL COMMENT '设备心跳时间',\n" +
            "  `type_id` varchar(30) NOT NULL COMMENT '设备类型ID',\n" +
            "  UNIQUE KEY `machine_id` (`machine_id`) USING BTREE,\n" +
            "  KEY `idx_machine_id` (`machine_id`) USING BTREE,\n" +
            "  KEY `idx_machine_b_id` (`b_id`) USING BTREE,\n" +
            "  KEY `i_m_community_id` (`community_id`)\n" +
            ")";
    public static void main(String[] args) {
        String desc = "报表组件条件";
        String id = "conditionId";
        String name = "reportCustomComponentCondition";
        String shareName = "report"; //生成到那个服务下
        String shareColumn = "condition_id";
        String shareParam = "conditionId";
        String desc = "设备信息";
        String id = "machineId";
        String name = "machine";
        String shareName = "common"; //生成到那个服务下
        String shareColumn = "community_id";
        String shareParam = "communityId";
        //业务名称 desc 业务编码名称生成后类名 name 主键 id  需要放到那个服务 shareName
        String newSql = createTableSql.substring(createTableSql.indexOf("(") + 1, createTableSql.lastIndexOf(")"));
        String tableName = createTableSql.substring(createTableSql.indexOf("TABLE") + 5, createTableSql.indexOf("("));
java110-generator/src/main/java/com/java110/code/newBack/BackCoderGeneratorStart.java
@@ -70,7 +70,7 @@
        generatorInnerServiceSMOImpl.generator(data);
        GeneratorDtoBean generatorDtoBean = new GeneratorDtoBean();
        generatorDtoBean.generator(data);
        //generatorDtoBean.generator(data);
        GeneratorIInnerServiceSMO generatorIInnerServiceSMO = new GeneratorIInnerServiceSMO();
        generatorIInnerServiceSMO.generator(data);
java110-generator/src/main/java/com/java110/code/newBack/GeneratorApiListener.java
@@ -14,7 +14,7 @@
     * @param data
     */
    public void generator(Data data) throws Exception {
        genneratorPo(data);             //API DataVo对象
        //genneratorPo(data);             //API DataVo对象
        genneratorSaveCmd(data);            //Api BmoImpl
        genneratorUpdateBmoImpl(data);            //Api BmoImpl
        genneratorDeleteBmoImpl(data);            //Api BmoImpl
java110-generator/src/main/resources/newBack/template_1.json
@@ -1,42 +1,66 @@
{
  "param": {
    "componentId": "component_id",
    "conditionId": "condition_id",
    "param": "param",
    "name": "name",
    "remark": "remark",
    "heartbeatTime": "heartbeat_time",
    "machineCode": "machine_code",
    "authCode": "auth_code",
    "locationTypeCd": "location_type_cd",
    "machineVersion": "machine_version",
    "statusCd": "status_cd",
    "holdpace": "holdpace",
    "type": "type"
    "machineName": "machine_name",
    "machineMac": "machine_mac",
    "machineId": "machine_id",
    "typeId": "type_id",
    "state": "state",
    "communityId": "community_id",
    "locationObjId": "location_obj_id",
    "machineTypeCd": "machine_type_cd",
    "machineIp": "machine_ip",
    "direction": "direction"
  },
  "name": "reportCustomComponentCondition",
  "shareColumn": "condition_id",
  "id": "conditionId",
  "shareName": "report",
  "name": "machine",
  "shareColumn": "community_id",
  "id": "machineId",
  "shareName": "common",
  "autoMove": true,
  "required": [
    {
      "msg": "组件ID不能为空",
      "code": "componentId"
      "msg": "设备ID不能为空",
      "code": "machineId"
    },
    {
      "msg": "名称不能为空",
      "code": "name"
      "msg": "设备编码不能为空",
      "code": "machineCode"
    },
    {
      "msg": "提示不能为空",
      "code": "holdpace"
      "msg": "设备版本不能为空",
      "code": "machineVersion"
    },
    {
      "msg": "参数不能为空",
      "code": "param"
      "msg": "设备类型不能为空",
      "code": "machineTypeCd"
    },
    {
      "msg": "类型不能为空",
      "code": "type"
      "msg": "小区ID不能为空",
      "code": "communityId"
    },
    {
      "msg": "设备名称不能为空",
      "code": "machineName"
    },
    {
      "msg": "授权码不能为空",
      "code": "authCode"
    },
    {
      "msg": "设备方向进出不能为空",
      "code": "direction"
    },
    {
      "msg": "设备类型ID不能为空",
      "code": "typeId"
    }
  ],
  "desc": "报表组件条件",
  "shareParam": "conditionId",
  "tableName": "report_custom_component_condition"
  "desc": "设备信息",
  "shareParam": "communityId",
  "tableName": "machine"
}
java110-interface/src/main/java/com/java110/intf/common/IMachineV1InnerServiceSMO.java
New file
@@ -0,0 +1,68 @@
/*
 * 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.common;
import com.java110.config.feign.FeignConfiguration;
import com.java110.dto.machine.MachineDto;
import com.java110.po.machine.MachinePo;
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 2021-11-09 15:42:41 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 = "common-service", configuration = {FeignConfiguration.class})
@RequestMapping("/machineV1Api")
public interface IMachineV1InnerServiceSMO {
    @RequestMapping(value = "/saveMachine", method = RequestMethod.POST)
    public int saveMachine(@RequestBody  MachinePo machinePo);
    @RequestMapping(value = "/updateMachine", method = RequestMethod.POST)
    public int updateMachine(@RequestBody  MachinePo machinePo);
    @RequestMapping(value = "/deleteMachine", method = RequestMethod.POST)
    public int deleteMachine(@RequestBody  MachinePo machinePo);
    /**
     * <p>查询小区楼信息</p>
     *
     *
     * @param machineDto 数据对象分享
     * @return MachineDto 对象数据
     */
    @RequestMapping(value = "/queryMachines", method = RequestMethod.POST)
    List<MachineDto> queryMachines(@RequestBody MachineDto machineDto);
    /**
     * 查询<p>小区楼</p>总记录数
     *
     * @param machineDto 数据对象分享
     * @return 小区下的小区楼记录数
     */
    @RequestMapping(value = "/queryMachinesCount", method = RequestMethod.POST)
    int queryMachinesCount(@RequestBody MachineDto machineDto);
}
service-common/src/main/java/com/java110/common/cmd/machine/DeleteMachineCmd.java
New file
@@ -0,0 +1,71 @@
/*
 * 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.common.cmd.machine;
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.annotation.Java110Transactional;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.AbstractServiceCmdListener;
import com.java110.core.event.cmd.CmdEvent;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.intf.common.IMachineV1InnerServiceSMO;
import com.java110.po.machine.MachinePo;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * 类表述:删除
 * 服务编码:machine.deleteMachine
 * 请求路劲:/app/machine.DeleteMachine
 * add by 吴学文 at 2021-11-09 15:42:41 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行
 */
@Java110Cmd(serviceCode = "machine.deleteMachine")
public class DeleteMachineCmd extends AbstractServiceCmdListener {
  private static Logger logger = LoggerFactory.getLogger(DeleteMachineCmd.class);
    @Autowired
    private IMachineV1InnerServiceSMO machineV1InnerServiceSMOImpl;
    @Override
    public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
        Assert.hasKeyAndValue(reqJson, "machineId", "machineId不能为空");
Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
    }
    @Override
    @Java110Transactional
    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
       MachinePo machinePo = BeanConvertUtil.covertBean(reqJson, MachinePo.class);
        int flag = machineV1InnerServiceSMOImpl.deleteMachine(machinePo);
        if (flag < 1) {
            throw new CmdException("删除数据失败");
        }
        cmdDataFlowContext.setResponseEntity(ResultVo.success());
    }
}
service-common/src/main/java/com/java110/common/cmd/machine/ListMachineCmd.java
New file
@@ -0,0 +1,84 @@
/*
 * 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.common.cmd.machine;
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.annotation.Java110Transactional;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.AbstractServiceCmdListener;
import com.java110.core.event.cmd.CmdEvent;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.intf.common.IMachineV1InnerServiceSMO;
import com.java110.po.machine.MachinePo;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import com.java110.dto.machine.MachineDto;
import java.util.List;
import java.util.ArrayList;
import org.springframework.http.ResponseEntity;
import org.springframework.http.HttpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * 类表述:查询
 * 服务编码:machine.listMachine
 * 请求路劲:/app/machine.ListMachine
 * add by 吴学文 at 2021-11-09 15:42:41 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行
 */
@Java110Cmd(serviceCode = "machine.listMachine")
public class ListMachineCmd extends AbstractServiceCmdListener {
  private static Logger logger = LoggerFactory.getLogger(ListMachineCmd.class);
    @Autowired
    private IMachineV1InnerServiceSMO machineV1InnerServiceSMOImpl;
    @Override
    public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
        super.validatePageInfo(reqJson);
    }
    @Override
    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
           MachineDto machineDto = BeanConvertUtil.covertBean(reqJson, MachineDto.class);
           int count = machineV1InnerServiceSMOImpl.queryMachinesCount(machineDto);
           List<MachineDto> machineDtos = null;
           if (count > 0) {
               machineDtos = machineV1InnerServiceSMOImpl.queryMachines(machineDto);
           } else {
               machineDtos = new ArrayList<>();
           }
           ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, machineDtos);
           ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
           cmdDataFlowContext.setResponseEntity(responseEntity);
    }
}
service-common/src/main/java/com/java110/common/cmd/machine/SaveMachineCmd.java
New file
@@ -0,0 +1,82 @@
/*
 * 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.common.cmd.machine;
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.annotation.Java110Transactional;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.AbstractServiceCmdListener;
import com.java110.core.event.cmd.CmdEvent;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.intf.common.IMachineV1InnerServiceSMO;
import com.java110.po.machine.MachinePo;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * 类表述:保存
 * 服务编码:machine.saveMachine
 * 请求路劲:/app/machine.SaveMachine
 * add by 吴学文 at 2021-11-09 15:42:41 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行
 */
@Java110Cmd(serviceCode = "machine.saveMachine")
public class SaveMachineCmd extends AbstractServiceCmdListener {
    private static Logger logger = LoggerFactory.getLogger( SaveMachineCmd.class );
    public static final String CODE_PREFIX_ID = "10";
    @Autowired
    private IMachineV1InnerServiceSMO machineV1InnerServiceSMOImpl;
    @Override
    public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
        Assert.hasKeyAndValue( reqJson, "machineCode", "请求报文中未包含machineCode" );
        Assert.hasKeyAndValue( reqJson, "machineVersion", "请求报文中未包含machineVersion" );
        Assert.hasKeyAndValue( reqJson, "machineTypeCd", "请求报文中未包含machineTypeCd" );
        Assert.hasKeyAndValue( reqJson, "communityId", "请求报文中未包含communityId" );
        Assert.hasKeyAndValue( reqJson, "machineName", "请求报文中未包含machineName" );
        Assert.hasKeyAndValue( reqJson, "authCode", "请求报文中未包含authCode" );
        Assert.hasKeyAndValue( reqJson, "direction", "请求报文中未包含direction" );
        Assert.hasKeyAndValue( reqJson, "typeId", "请求报文中未包含typeId" );
    }
    @Override
    @Java110Transactional
    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
        MachinePo machinePo = BeanConvertUtil.covertBean( reqJson, MachinePo.class );
        machinePo.setMachineId( GenerateCodeFactory.getGeneratorId( CODE_PREFIX_ID ) );
        int flag = machineV1InnerServiceSMOImpl.saveMachine( machinePo );
        if (flag < 1) {
            throw new CmdException( "保存数据失败" );
        }
        cmdDataFlowContext.setResponseEntity( ResultVo.success() );
    }
}
service-common/src/main/java/com/java110/common/cmd/machine/UpdateMachineCmd.java
New file
@@ -0,0 +1,75 @@
/*
 * 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.common.cmd.machine;
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.annotation.Java110Transactional;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.AbstractServiceCmdListener;
import com.java110.core.event.cmd.CmdEvent;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.intf.common.IMachineV1InnerServiceSMO;
import com.java110.po.machine.MachinePo;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * 类表述:更新
 * 服务编码:machine.updateMachine
 * 请求路劲:/app/machine.UpdateMachine
 * add by 吴学文 at 2021-11-09 15:42:41 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行
 */
@Java110Cmd(serviceCode = "machine.updateMachine")
public class UpdateMachineCmd extends AbstractServiceCmdListener {
  private static Logger logger = LoggerFactory.getLogger(UpdateMachineCmd.class);
    @Autowired
    private IMachineV1InnerServiceSMO machineV1InnerServiceSMOImpl;
    @Override
    public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
        Assert.hasKeyAndValue(reqJson, "machineId", "machineId不能为空");
Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
    }
    @Override
    @Java110Transactional
    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
       MachinePo machinePo = BeanConvertUtil.covertBean(reqJson, MachinePo.class);
        int flag = machineV1InnerServiceSMOImpl.updateMachine(machinePo);
        if (flag < 1) {
            throw new CmdException("更新数据失败");
        }
        cmdDataFlowContext.setResponseEntity(ResultVo.success());
    }
}
service-common/src/main/java/com/java110/common/dao/IMachineV1ServiceDao.java
New file
@@ -0,0 +1,77 @@
/*
 * 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.common.dao;
import com.java110.utils.exception.DAOException;
import com.java110.entity.merchant.BoMerchant;
import com.java110.entity.merchant.BoMerchantAttr;
import com.java110.entity.merchant.Merchant;
import com.java110.entity.merchant.MerchantAttr;
import java.util.List;
import java.util.Map;
/**
 * 类表述:
 * add by 吴学文 at 2021-11-09 15:42:41 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行
 */
public interface IMachineV1ServiceDao {
    /**
     * 保存 设备信息信息
     * @param info
     * @throws DAOException DAO异常
     */
    int saveMachineInfo(Map info) throws DAOException;
    /**
     * 查询设备信息信息(instance过程)
     * 根据bId 查询设备信息信息
     * @param info bId 信息
     * @return 设备信息信息
     * @throws DAOException DAO异常
     */
    List<Map> getMachineInfo(Map info) throws DAOException;
    /**
     * 修改设备信息信息
     * @param info 修改信息
     * @throws DAOException DAO异常
     */
    int updateMachineInfo(Map info) throws DAOException;
    /**
     * 查询设备信息总数
     *
     * @param info 设备信息信息
     * @return 设备信息数量
     */
    int queryMachinesCount(Map info);
}
service-common/src/main/java/com/java110/common/dao/impl/MachineV1ServiceDaoImpl.java
New file
@@ -0,0 +1,112 @@
/*
 * 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.common.dao.impl;
import com.alibaba.fastjson.JSONObject;
import com.java110.utils.constant.ResponseConstant;
import com.java110.utils.exception.DAOException;
import com.java110.utils.util.DateUtil;
import com.java110.core.base.dao.BaseServiceDao;
import com.java110.common.dao.IMachineV1ServiceDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
 * 类表述:
 * add by 吴学文 at 2021-11-09 15:42:41 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行
 */
@Service("machineV1ServiceDaoImpl")
public class MachineV1ServiceDaoImpl extends BaseServiceDao implements IMachineV1ServiceDao {
    private static Logger logger = LoggerFactory.getLogger(MachineV1ServiceDaoImpl.class);
    /**
     * 保存设备信息信息 到 instance
     * @param info   bId 信息
     * @throws DAOException DAO异常
     */
    @Override
    public int saveMachineInfo(Map info) throws DAOException {
        logger.debug("保存 saveMachineInfo 入参 info : {}",info);
        int saveFlag = sqlSessionTemplate.insert("machineV1ServiceDaoImpl.saveMachineInfo",info);
        return saveFlag;
    }
    /**
     * 查询设备信息信息(instance)
     * @param info bId 信息
     * @return List<Map>
     * @throws DAOException DAO异常
     */
    @Override
    public List<Map> getMachineInfo(Map info) throws DAOException {
        logger.debug("查询 getMachineInfo 入参 info : {}",info);
        List<Map> businessMachineInfos = sqlSessionTemplate.selectList("machineV1ServiceDaoImpl.getMachineInfo",info);
        return businessMachineInfos;
    }
    /**
     * 修改设备信息信息
     * @param info 修改信息
     * @throws DAOException DAO异常
     */
    @Override
    public int updateMachineInfo(Map info) throws DAOException {
        logger.debug("修改 updateMachineInfo 入参 info : {}",info);
        int saveFlag = sqlSessionTemplate.update("machineV1ServiceDaoImpl.updateMachineInfo",info);
        return saveFlag;
    }
     /**
     * 查询设备信息数量
     * @param info 设备信息信息
     * @return 设备信息数量
     */
    @Override
    public int queryMachinesCount(Map info) {
        logger.debug("查询 queryMachinesCount 入参 info : {}",info);
        List<Map> businessMachineInfos = sqlSessionTemplate.selectList("machineV1ServiceDaoImpl.queryMachinesCount", info);
        if (businessMachineInfos.size() < 1) {
            return 0;
        }
        return Integer.parseInt(businessMachineInfos.get(0).get("count").toString());
    }
}
service-common/src/main/java/com/java110/common/smo/impl/MachineV1InnerServiceSMOImpl.java
New file
@@ -0,0 +1,89 @@
/*
 * 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.common.smo.impl;
import com.java110.common.dao.IMachineV1ServiceDao;
import com.java110.intf.common.IMachineV1InnerServiceSMO;
import com.java110.dto.machine.MachineDto;
import com.java110.po.machine.MachinePo;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.user.UserDto;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
 * 类表述: 服务之前调用的接口实现类,不对外提供接口能力 只用于接口建调用
 * add by 吴学文 at 2021-11-09 15:42:41 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 MachineV1InnerServiceSMOImpl extends BaseServiceSMO implements IMachineV1InnerServiceSMO {
    @Autowired
    private IMachineV1ServiceDao machineV1ServiceDaoImpl;
    @Override
    public int saveMachine(@RequestBody  MachinePo machinePo) {
        int saveFlag = machineV1ServiceDaoImpl.saveMachineInfo(BeanConvertUtil.beanCovertMap(machinePo));
        return saveFlag;
    }
     @Override
    public int updateMachine(@RequestBody  MachinePo machinePo) {
        int saveFlag = machineV1ServiceDaoImpl.updateMachineInfo(BeanConvertUtil.beanCovertMap(machinePo));
        return saveFlag;
    }
     @Override
    public int deleteMachine(@RequestBody  MachinePo machinePo) {
       machinePo.setStatusCd("1");
       int saveFlag = machineV1ServiceDaoImpl.updateMachineInfo(BeanConvertUtil.beanCovertMap(machinePo));
       return saveFlag;
    }
    @Override
    public List<MachineDto> queryMachines(@RequestBody  MachineDto machineDto) {
        //校验是否传了 分页信息
        int page = machineDto.getPage();
        if (page != PageDto.DEFAULT_PAGE) {
            machineDto.setPage((page - 1) * machineDto.getRow());
        }
        List<MachineDto> machines = BeanConvertUtil.covertBeanList(machineV1ServiceDaoImpl.getMachineInfo(BeanConvertUtil.beanCovertMap(machineDto)), MachineDto.class);
        return machines;
    }
    @Override
    public int queryMachinesCount(@RequestBody MachineDto machineDto) {
        return machineV1ServiceDaoImpl.queryMachinesCount(BeanConvertUtil.beanCovertMap(machineDto));    }
}