Browse Source

加入线程同步

wuxw 6 years ago
parent
commit
259530d8ee
15 changed files with 706 additions and 269 deletions
  1. 13 5
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/HardwareAdapationServiceApplicationStart.java
  2. 19 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/dao/IMachineTranslateServiceDao.java
  3. 12 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/dao/impl/MachineTranslateServiceDaoImpl.java
  4. 84 5
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/thread/TranslateOwnerToMachine.java
  5. 155 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/thread/TranslateOwnerToMachineChangeMachine.java
  6. 16 0
      HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/thread/TranslateOwnerToMachineFactory.java
  7. 13 1
      OrderService/src/main/java/com/java110/order/OrderServiceApplicationStart.java
  8. 11 0
      OrderService/src/main/java/com/java110/order/dao/ICenterServiceDAO.java
  9. 14 0
      OrderService/src/main/java/com/java110/order/dao/impl/CenterServiceDAOImpl.java
  10. 9 0
      OrderService/src/main/java/com/java110/order/smo/impl/OrderInnerServiceSMOImpl.java
  11. 9 1
      java110-bean/src/main/java/com/java110/dto/hardwareAdapation/MachineDto.java
  12. 13 0
      java110-core/src/main/java/com/java110/core/smo/order/IOrderInnerServiceSMO.java
  13. 114 65
      java110-db/src/main/resources/mapper/center/CenterServiceDAOImplMapper.xml
  14. 196 192
      java110-db/src/main/resources/mapper/hardwareAdapation/MachineServiceDaoImplMapper.xml
  15. 28 0
      java110-db/src/main/resources/mapper/hardwareAdapation/MachineTranslateServiceDaoImplMapper.xml

+ 13 - 5
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/HardwareAdapationServiceApplicationStart.java

@@ -2,6 +2,7 @@ package com.java110.hardwareAdapation;
 
 import com.java110.core.annotation.Java110ListenerDiscovery;
 import com.java110.event.service.BusinessServiceDataFlowEventPublishing;
+import com.java110.hardwareAdapation.thread.TranslateOwnerToMachineFactory;
 import com.java110.service.init.ServiceStartInit;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -29,11 +30,15 @@ import java.nio.charset.Charset;
  * @tag
  */
 @SpringBootApplication(scanBasePackages = {"com.java110.service", "com.java110.hardwareAdapation",
-        "com.java110.core", "com.java110.cache", "com.java110.config.properties.code","com.java110.db"})
+        "com.java110.core", "com.java110.cache", "com.java110.config.properties.code", "com.java110.db"})
 @EnableDiscoveryClient
 @Java110ListenerDiscovery(listenerPublishClass = BusinessServiceDataFlowEventPublishing.class,
         basePackages = {"com.java110.hardwareAdapation.listener"})
-@EnableFeignClients(basePackages = {"com.java110.core.smo.user"})
+@EnableFeignClients(basePackages = {
+        "com.java110.core.smo.user",
+        "com.java110.core.smo.order",
+        "com.java110.core.smo.owner"
+})
 public class HardwareAdapationServiceApplicationStart {
 
     private static Logger logger = LoggerFactory.getLogger(HardwareAdapationServiceApplicationStart.class);
@@ -53,11 +58,14 @@ public class HardwareAdapationServiceApplicationStart {
     }
 
     public static void main(String[] args) throws Exception {
-        try{
+        try {
             ApplicationContext context = SpringApplication.run(HardwareAdapationServiceApplicationStart.class, args);
             ServiceStartInit.initSystemConfig(context);
-        }catch (Throwable e){
-            logger.error("系统启动失败",e);
+
+            //启动线程
+            TranslateOwnerToMachineFactory.startOwnerToMachine();
+        } catch (Throwable e) {
+            logger.error("系统启动失败", e);
         }
     }
 }

+ 19 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/dao/IMachineTranslateServiceDao.java

@@ -85,4 +85,23 @@ public interface IMachineTranslateServiceDao {
      */
     int updateMachineTranslateState(Map info);
 
+
+    /**
+     * 保存 硬件传输
+     * @param info
+     * @throws DAOException
+     */
+    void saveMachineTranslate(Map info) throws DAOException;
+
+
+    /**
+     * 修改 硬件传输
+     * @param info
+     * @throws DAOException
+     */
+    void updateMachineTranslate(Map info) throws DAOException;
+
+
+
+
 }

+ 12 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/dao/impl/MachineTranslateServiceDaoImpl.java

@@ -134,5 +134,17 @@ public class MachineTranslateServiceDaoImpl extends BaseServiceDao implements IM
         return saveFlag;
     }
 
+    @Override
+    public void saveMachineTranslate(Map info) throws DAOException {
+        logger.debug("saveMachineTranslate 入参 info : {}",info);
+         sqlSessionTemplate.update("machineTranslateServiceDaoImpl.saveMachineTranslate",info);
+    }
+
+    @Override
+    public void updateMachineTranslate(Map info) throws DAOException {
+        logger.debug("updateMachineTranslate 入参 info : {}",info);
+        sqlSessionTemplate.update("machineTranslateServiceDaoImpl.updateMachineTranslate",info);
+    }
+
 
 }

+ 84 - 5
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/thread/TranslateOwnerToMachine.java

@@ -1,19 +1,24 @@
 package com.java110.hardwareAdapation.thread;
 
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.core.smo.hardwareAdapation.IMachineInnerServiceSMO;
 import com.java110.core.smo.order.IOrderInnerServiceSMO;
 import com.java110.core.smo.owner.IOwnerInnerServiceSMO;
-import com.java110.core.smo.user.IUserInnerServiceSMO;
 import com.java110.dto.OwnerDto;
+import com.java110.dto.hardwareAdapation.MachineDto;
 import com.java110.dto.order.OrderDto;
+import com.java110.hardwareAdapation.dao.IMachineTranslateServiceDao;
 import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.StatusConstant;
 import com.java110.utils.factory.ApplicationContextFactory;
-import com.java110.utils.util.CacheUtil;
 import com.java110.utils.util.StringUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.core.annotation.Order;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 从订单中同步业主信息至设备中间表
@@ -26,10 +31,15 @@ public class TranslateOwnerToMachine implements Runnable {
 
     private IOrderInnerServiceSMO orderInnerServiceSMOImpl;
     private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
+    private IMachineInnerServiceSMO machineInnerServiceSMOImpl;
+
+    private IMachineTranslateServiceDao machineTranslateServiceDaoImpl;
 
     public TranslateOwnerToMachine() {
         orderInnerServiceSMOImpl = ApplicationContextFactory.getBean("orderInnerServiceSMOImpl", IOrderInnerServiceSMO.class);
         ownerInnerServiceSMOImpl = ApplicationContextFactory.getBean("ownerInnerServiceSMOImpl", IOwnerInnerServiceSMO.class);
+        machineInnerServiceSMOImpl = ApplicationContextFactory.getBean("machineInnerServiceSMOImpl", IMachineInnerServiceSMO.class);
+        machineTranslateServiceDaoImpl = ApplicationContextFactory.getBean("machineTranslateServiceDaoImpl", IMachineTranslateServiceDao.class);
 
     }
 
@@ -62,14 +72,83 @@ public class TranslateOwnerToMachine implements Runnable {
                 ownerDto = new OwnerDto();
                 ownerDto.setbId(tmpOrderDto.getbId());
                 List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwners(ownerDto);
-                dealData(tmpOrderDto, ownerDtos);
+                if (ownerDtos == null || ownerDtos.size() == 0) {
+                    continue;
+                }
+                dealData(tmpOrderDto, ownerDtos.get(0));
+                //刷新 状态为C1
+                orderInnerServiceSMOImpl.updateBusinessStatusCd(tmpOrderDto);
             } catch (Exception e) {
                 logger.error("执行订单任务失败", e);
             }
         }
     }
 
-    private void dealData(OrderDto tmpOrderDto, List<OwnerDto> ownerDtos) {
+    /**
+     * 将业主数据同步给所有该小区设备
+     *
+     * @param tmpOrderDto
+     * @param ownerDto
+     */
+    private void dealData(OrderDto tmpOrderDto, OwnerDto ownerDto) {
+
+        //拿到小区ID
+        String communityId = ownerDto.getCommunityId();
+
+        //根据小区ID查询现有设备
+        MachineDto machineDto = new MachineDto();
+        machineDto.setCommunityId(communityId);
+        List<MachineDto> machineDtos = machineInnerServiceSMOImpl.queryMachines(machineDto);
+
+        for (MachineDto tmpMachineDto : machineDtos) {
+            if (BusinessTypeConstant.BUSINESS_TYPE_SAVE_OWNER_INFO.equals(tmpOrderDto.getBusinessTypeCd())) {
+                saveMachineTranslate(tmpMachineDto, ownerDto);
+            } else if (BusinessTypeConstant.BUSINESS_TYPE_UPDATE_OWNER_INFO.equals(tmpOrderDto.getBusinessTypeCd())) {
+                updateMachineTranslate(tmpMachineDto, ownerDto);
+            } else if (BusinessTypeConstant.BUSINESS_TYPE_DELETE_OWNER_INFO.equals(tmpOrderDto.getBusinessTypeCd())) {
+                deleteMachineTranslate(tmpMachineDto, ownerDto);
+            } else {
+
+            }
+        }
+
+    }
+
+    private void saveMachineTranslate(MachineDto tmpMachineDto, OwnerDto ownerDto) {
+        Map info = new HashMap();
+        //machine_id,machine_code,status_cd,type_cd,machine_translate_id,obj_id,obj_name,state,community_id,b_id
+        info.put("machineTranslateId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_machineTranslateId));
+        info.put("machineId", tmpMachineDto.getMachineId());
+        info.put("machineCode", tmpMachineDto.getMachineCode());
+        info.put("typeCd", "8899");
+        info.put("objId", ownerDto.getMemberId());
+        info.put("objName", ownerDto.getName());
+        info.put("state", "10000");
+        info.put("communityId", ownerDto.getCommunityId());
+        info.put("bId", "-1");
+        machineTranslateServiceDaoImpl.saveMachineTranslate(info);
+
+    }
+
+    private void updateMachineTranslate(MachineDto tmpMachineDto, OwnerDto ownerDto) {
+        Map info = new HashMap();
+        //machine_id,machine_code,status_cd,type_cd,machine_translate_id,obj_id,obj_name,state,community_id,b_id
+        info.put("machineId", tmpMachineDto.getMachineId());
+        info.put("objId", ownerDto.getMemberId());
+        info.put("state", "10000");
+        info.put("communityId", ownerDto.getCommunityId());
+        machineTranslateServiceDaoImpl.updateMachineTranslate(info);
+
+    }
+
+    private void deleteMachineTranslate(MachineDto tmpMachineDto, OwnerDto ownerDto) {
+        Map info = new HashMap();
+        //machine_id,machine_code,status_cd,type_cd,machine_translate_id,obj_id,obj_name,state,community_id,b_id
+        info.put("machineId", tmpMachineDto.getMachineId());
+        info.put("objId", ownerDto.getMemberId());
+        info.put("statusCd", StatusConstant.STATUS_CD_INVALID);
+        info.put("communityId", ownerDto.getCommunityId());
+        machineTranslateServiceDaoImpl.updateMachineTranslate(info);
 
     }
 

+ 155 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/thread/TranslateOwnerToMachineChangeMachine.java

@@ -0,0 +1,155 @@
+package com.java110.hardwareAdapation.thread;
+
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.core.smo.hardwareAdapation.IMachineInnerServiceSMO;
+import com.java110.core.smo.order.IOrderInnerServiceSMO;
+import com.java110.core.smo.owner.IOwnerInnerServiceSMO;
+import com.java110.dto.OwnerDto;
+import com.java110.dto.hardwareAdapation.MachineDto;
+import com.java110.dto.order.OrderDto;
+import com.java110.hardwareAdapation.dao.IMachineTranslateServiceDao;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.factory.ApplicationContextFactory;
+import com.java110.utils.util.StringUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 从订单中同步业主信息至设备中间表
+ * add by wuxw 2019-11-14
+ */
+public class TranslateOwnerToMachineChangeMachine implements Runnable {
+    Logger logger = LoggerFactory.getLogger(TranslateOwnerToMachineChangeMachine.class);
+    public static final long DEFAULT_WAIT_SECOND = 5000 * 6; // 默认30秒执行一次
+    public static boolean TRANSLATE_STATE = false;
+
+    private IOrderInnerServiceSMO orderInnerServiceSMOImpl;
+    private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
+    private IMachineInnerServiceSMO machineInnerServiceSMOImpl;
+
+    private IMachineTranslateServiceDao machineTranslateServiceDaoImpl;
+
+    public TranslateOwnerToMachineChangeMachine() {
+        orderInnerServiceSMOImpl = ApplicationContextFactory.getBean("orderInnerServiceSMOImpl", IOrderInnerServiceSMO.class);
+        ownerInnerServiceSMOImpl = ApplicationContextFactory.getBean("ownerInnerServiceSMOImpl", IOwnerInnerServiceSMO.class);
+        machineInnerServiceSMOImpl = ApplicationContextFactory.getBean("machineInnerServiceSMOImpl", IMachineInnerServiceSMO.class);
+        machineTranslateServiceDaoImpl = ApplicationContextFactory.getBean("machineTranslateServiceDaoImpl", IMachineTranslateServiceDao.class);
+
+    }
+
+    @Override
+    public void run() {
+        long waitTime = DEFAULT_WAIT_SECOND;
+        while (TRANSLATE_STATE) {
+            try {
+                executeTask();
+                waitTime = StringUtil.isNumber(MappingCache.getValue("DEFAULT_WAIT_SECOND")) ?
+                        Long.parseLong(MappingCache.getValue("DEFAULT_WAIT_SECOND")) : DEFAULT_WAIT_SECOND;
+                Thread.sleep(waitTime);
+            } catch (Throwable e) {
+                logger.error("执行订单中同步业主信息至设备中失败", e);
+            }
+        }
+    }
+
+    /**
+     * 执行任务
+     */
+    private void executeTask() {
+        MachineDto machineDto = null;
+        //查询订单信息
+        OrderDto orderDto = new OrderDto();
+        List<OrderDto> orderDtos = orderInnerServiceSMOImpl.queryOwenrOrders(orderDto);
+        for (OrderDto tmpOrderDto : orderDtos) {
+            try {
+                //根据bId 查询硬件信息
+                machineDto = new MachineDto();
+                machineDto.setbId(tmpOrderDto.getbId());
+                List<MachineDto> machineDtos = machineInnerServiceSMOImpl.queryMachines(machineDto);
+                if (machineDtos == null || machineDtos.size() == 0) {
+                    continue;
+                }
+                dealData(tmpOrderDto, machineDtos.get(0));
+                //刷新 状态为C1
+                orderInnerServiceSMOImpl.updateBusinessStatusCd(tmpOrderDto);
+            } catch (Exception e) {
+                logger.error("执行订单任务失败", e);
+            }
+        }
+    }
+
+    /**
+     * 将业主数据同步给所有该小区设备
+     *
+     * @param tmpOrderDto
+     * @param machineDto
+     */
+    private void dealData(OrderDto tmpOrderDto, MachineDto machineDto) {
+
+        //拿到小区ID
+        String communityId = machineDto.getCommunityId();
+
+        //根据小区ID查询现有设备
+        OwnerDto ownerDto = new OwnerDto();
+        ownerDto.setCommunityId(communityId);
+        List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwnerMembers(ownerDto);
+
+        for (OwnerDto tmpOwnerDto : ownerDtos) {
+            if (BusinessTypeConstant.BUSINESS_TYPE_SAVE_MACHINE.equals(tmpOrderDto.getBusinessTypeCd())) {
+                saveMachineTranslate(machineDto, tmpOwnerDto);
+            } else if (BusinessTypeConstant.BUSINESS_TYPE_UPDATE_MACHINE.equals(tmpOrderDto.getBusinessTypeCd())) {
+                updateMachineTranslate(machineDto, tmpOwnerDto);
+            } else if (BusinessTypeConstant.BUSINESS_TYPE_DELETE_MACHINE.equals(tmpOrderDto.getBusinessTypeCd())) {
+                deleteMachineTranslate(machineDto, tmpOwnerDto);
+            } else {
+
+            }
+        }
+
+    }
+
+    private void saveMachineTranslate(MachineDto tmpMachineDto, OwnerDto ownerDto) {
+        Map info = new HashMap();
+        //machine_id,machine_code,status_cd,type_cd,machine_translate_id,obj_id,obj_name,state,community_id,b_id
+        info.put("machineTranslateId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_machineTranslateId));
+        info.put("machineId", tmpMachineDto.getMachineId());
+        info.put("machineCode", tmpMachineDto.getMachineCode());
+        info.put("typeCd", "8899");
+        info.put("objId", ownerDto.getMemberId());
+        info.put("objName", ownerDto.getName());
+        info.put("state", "10000");
+        info.put("communityId", ownerDto.getCommunityId());
+        info.put("bId", "-1");
+        machineTranslateServiceDaoImpl.saveMachineTranslate(info);
+
+    }
+
+    private void updateMachineTranslate(MachineDto tmpMachineDto, OwnerDto ownerDto) {
+        Map info = new HashMap();
+        //machine_id,machine_code,status_cd,type_cd,machine_translate_id,obj_id,obj_name,state,community_id,b_id
+        info.put("machineId", tmpMachineDto.getMachineId());
+        info.put("objId", ownerDto.getMemberId());
+        info.put("state", "10000");
+        info.put("communityId", ownerDto.getCommunityId());
+        machineTranslateServiceDaoImpl.updateMachineTranslate(info);
+
+    }
+
+    private void deleteMachineTranslate(MachineDto tmpMachineDto, OwnerDto ownerDto) {
+        Map info = new HashMap();
+        //machine_id,machine_code,status_cd,type_cd,machine_translate_id,obj_id,obj_name,state,community_id,b_id
+        info.put("machineId", tmpMachineDto.getMachineId());
+        info.put("objId", ownerDto.getMemberId());
+        info.put("statusCd", StatusConstant.STATUS_CD_INVALID);
+        info.put("communityId", ownerDto.getCommunityId());
+        machineTranslateServiceDaoImpl.updateMachineTranslate(info);
+
+    }
+
+}

+ 16 - 0
HardwareAdapationService/src/main/java/com/java110/hardwareAdapation/thread/TranslateOwnerToMachineFactory.java

@@ -0,0 +1,16 @@
+package com.java110.hardwareAdapation.thread;
+
+public class TranslateOwnerToMachineFactory {
+
+    public static void startOwnerToMachine(){
+        //启动业主信息同步 线程 变更业主的场景
+        TranslateOwnerToMachine ownerMachine = new TranslateOwnerToMachine();
+        Thread ownerToMachineThread = new Thread(ownerMachine,"TranslateOwnerToMachineThread");
+        ownerToMachineThread.start();
+
+        // 变更 门禁的场景
+        TranslateOwnerToMachineChangeMachine machine = new TranslateOwnerToMachineChangeMachine();
+        Thread ownerToMachineChangeThread = new Thread(machine,"TranslateOwnerToMachineChangeMachineThread");
+        ownerToMachineChangeThread.start();
+    }
+}

+ 13 - 1
OrderService/src/main/java/com/java110/order/OrderServiceApplicationStart.java

@@ -38,7 +38,19 @@ import java.nio.charset.Charset;
 //@EnableConfigurationProperties(EventProperties.class)
 @Java110ListenerDiscovery(listenerPublishClass = DataFlowEventPublishing.class,
         basePackages = {"com.java110.order.listener"})
-@EnableFeignClients(basePackages = {"com.java110.core.smo.code","com.java110.core.smo.user"})
+@EnableFeignClients(basePackages = {
+        "com.java110.core.smo.code",
+        "com.java110.core.smo.user",
+        "com.java110.core.smo.app",
+        "com.java110.core.smo.common",
+        "com.java110.core.smo.community",
+        "com.java110.core.smo.fee",
+        "com.java110.core.smo.floor",
+        "com.java110.core.smo.menu",
+        "com.java110.core.smo.owner",
+        "com.java110.core.smo.room",
+        "com.java110.core.smo.unit",
+})
 public class OrderServiceApplicationStart {
 
     private  static Logger logger = LoggerFactory.getLogger(OrderServiceApplicationStart.class);

+ 11 - 0
OrderService/src/main/java/com/java110/order/dao/ICenterServiceDAO.java

@@ -148,6 +148,17 @@ public interface ICenterServiceDAO {
      * @return
      */
     public List<Map> queryOwenrOrders(Map info);
+    /**
+     * 查询业主 添加 修改 删除订单
+     * @param info
+     * @return
+     */
+    public int updateBusinessStatusCd(Map info);
+
+
+
+    public List<Map> queryManchineOrders(Map info);
+
 
 
 

+ 14 - 0
OrderService/src/main/java/com/java110/order/dao/impl/CenterServiceDAOImpl.java

@@ -287,6 +287,20 @@ public class CenterServiceDAOImpl extends BaseServiceDao implements ICenterServi
         return sqlSessionTemplate.selectList("centerServiceDAOImpl.queryOwenrOrders");
     }
 
+    public int updateBusinessStatusCd(Map Info){
+        return sqlSessionTemplate.update("centerServiceDAOImpl.updateBusinessStatusCd");
+    }
+
+    /**
+     * 查询业主订单
+     * @param info
+     * @return
+     */
+    @Override
+    public List<Map> queryManchineOrders(Map info) {
+        return sqlSessionTemplate.selectList("centerServiceDAOImpl.queryManchineOrders");
+    }
+
     /**
      * 根据oId 查询Business
      * @param info

+ 9 - 0
OrderService/src/main/java/com/java110/order/smo/impl/OrderInnerServiceSMOImpl.java

@@ -60,6 +60,15 @@ public class OrderInnerServiceSMOImpl extends BaseServiceSMO implements IOrderIn
         return BeanConvertUtil.covertBeanList(centerServiceDAOImpl.queryOwenrOrders(BeanConvertUtil.beanCovertMap(orderDto)), OrderDto.class);
     }
 
+    public int updateBusinessStatusCd(@RequestBody OrderDto orderDto){
+        return centerServiceDAOImpl.updateBusinessStatusCd(BeanConvertUtil.beanCovertMap(orderDto));
+    }
+
+    @Override
+    public List<OrderDto> queryMachineOrders(@RequestBody OrderDto orderDto) {
+        return BeanConvertUtil.covertBeanList(centerServiceDAOImpl.queryManchineOrders(BeanConvertUtil.beanCovertMap(orderDto)), OrderDto.class);
+    }
+
 
     public IUserInnerServiceSMO getUserInnerServiceSMOImpl() {
         return userInnerServiceSMOImpl;

+ 9 - 1
java110-bean/src/main/java/com/java110/dto/hardwareAdapation/MachineDto.java

@@ -24,7 +24,7 @@ public class MachineDto extends PageDto implements Serializable {
     private String machineName;
     private String machineTypeCd;
     private String machineIp;
-
+    private String bId;
 
     private Date createTime;
 
@@ -119,4 +119,12 @@ public class MachineDto extends PageDto implements Serializable {
     public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
+
+    public String getbId() {
+        return bId;
+    }
+
+    public void setbId(String bId) {
+        this.bId = bId;
+    }
 }

+ 13 - 0
java110-core/src/main/java/com/java110/core/smo/order/IOrderInnerServiceSMO.java

@@ -48,4 +48,17 @@ public interface IOrderInnerServiceSMO {
      */
     @RequestMapping(value = "/queryOwenrOrders", method = RequestMethod.POST)
     List<OrderDto> queryOwenrOrders(@RequestBody OrderDto orderDto);
+
+    @RequestMapping(value = "/updateBusinessStatusCd", method = RequestMethod.POST)
+    int updateBusinessStatusCd(@RequestBody OrderDto orderDto);
+
+
+    /**
+     * <p>查询上级组织信息</p>
+     *
+     * @param orderDto 数据对象分享
+     * @return OrderDto 对象数据
+     */
+    @RequestMapping(value = "/queryMachineOrders", method = RequestMethod.POST)
+    List<OrderDto> queryMachineOrders(@RequestBody OrderDto orderDto);
 }

+ 114 - 65
java110-db/src/main/resources/mapper/center/CenterServiceDAOImplMapper.xml

@@ -7,91 +7,111 @@
     <!--保存订单信息 c_orders 中 -->
     <insert id="saveOrder" parameterType="Map">
         <![CDATA[
-            insert into c_orders(o_id,app_id,ext_transaction_id,user_id,request_time,order_type_cd,remark,status_cd)
-            values(#{oId},#{appId},#{extTransactionId},#{userId},#{requestTime},#{orderTypeCd},#{remark},#{statusCd})
+
+                    insert into c_orders(o_id,app_id,ext_transaction_id,user_id,request_time,order_type_cd,remark,status_cd)
+                    values(#{oId},#{appId},#{extTransactionId},#{userId},#{requestTime},#{orderTypeCd},#{remark},#{statusCd})
+
         ]]>
     </insert>
     <!-- 保存属性信息c_orders_attrs 中-->
     <insert id="saveOrderAttrs" parameterType="Map">
         <![CDATA[
-            insert into c_orders_attrs(o_id,attr_id,spec_cd,value)
-            values(#{oId},#{attrId},#{specCd},#{value})
+
+                    insert into c_orders_attrs(o_id,attr_id,spec_cd,value)
+                    values(#{oId},#{attrId},#{specCd},#{value})
+
         ]]>
     </insert>
     <!-- 保存订单项信息 c_business -->
     <insert id="saveBusiness" parameterType="Map">
         <![CDATA[
-            insert into c_business(b_id,o_id,business_type_cd,remark,status_cd)
-            values(#{bId},#{oId},#{businessTypeCd},#{remark},#{statusCd})
+
+                    insert into c_business(b_id,o_id,business_type_cd,remark,status_cd)
+                    values(#{bId},#{oId},#{businessTypeCd},#{remark},#{statusCd})
+
         ]]>
     </insert>
     <!-- 保存属性信息 c_business_attrs -->
     <insert id="saveBusinessAttrs" parameterType="Map">
         <![CDATA[
-            insert into c_business_attrs(b_id,attr_id,spec_cd,value)
-            values(#{bId},#{attrId},#{specCd},#{value})
+
+                    insert into c_business_attrs(b_id,attr_id,spec_cd,value)
+                    values(#{bId},#{attrId},#{specCd},#{value})
+
         ]]>
     </insert>
     <!-- 更新订单信息(一般就更新订单状态) -->
-    <update id="updateOrder" parameterType="Map" >
+    <update id="updateOrder" parameterType="Map">
         <![CDATA[
-            update c_orders co set
-            co.status_cd=#{statusCd},
-            co.finish_time=#{finishTime}
-            where co.o_id=#{oId}
-         ]]>
+
+                    update c_orders co set
+                    co.status_cd=#{statusCd},
+                    co.finish_time=#{finishTime}
+                    where co.o_id=#{oId}
+
+        ]]>
     </update>
     <!-- 更新订单项信息(一般就更新订单项状态)-->
     <update id="updateBusiness" parameterType="Map">
         <![CDATA[
-            update c_business cb set
-            cb.status_cd=#{statusCd},
-            cb.finish_time=#{finishTime}
-            where cb.o_id=#{oId}
-         ]]>
+
+                    update c_business cb set
+                    cb.status_cd=#{statusCd},
+                    cb.finish_time=#{finishTime}
+                    where cb.o_id=#{oId}
+
+        ]]>
     </update>
     <!--根据bId 修改业务项信息-->
     <update id="updateBusinessByBId" parameterType="Map">
         <![CDATA[
-            update c_business cb set
-            cb.status_cd=#{statusCd},
-            cb.finish_time=#{finishTime}
-            where cb.b_id in (#{bId})
-            and cb.status_cd not in ('E')
-         ]]>
+
+                    update c_business cb set
+                    cb.status_cd=#{statusCd},
+                    cb.finish_time=#{finishTime}
+                    where cb.b_id in (#{bId})
+                    and cb.status_cd not in ('E')
+
+        ]]>
     </update>
     <!-- 当所有业务动作是否都是C,将订单信息改为 C-->
-    <update id="completeOrderByBId" parameterType="String" >
+    <update id="completeOrderByBId" parameterType="String">
         <![CDATA[
-            update c_orders co set co.status_cd = 'C' where co.status_cd='S'
-                and not exists(
-                        select 1 from c_business cb where cb.status_cd <> 'C'
-                        and cb.o_id = co.o_id
-                        and cb.b_id in (#{bId})
-                )
+
+                    update c_orders co set co.status_cd = 'C' where co.status_cd='S'
+                        and not exists(
+                                select 1 from c_business cb where cb.status_cd <> 'C'
+                                and cb.o_id = co.o_id
+                                and cb.b_id in (#{bId})
+                        )
+
         ]]>
     </update>
 
     <!-- 当所有业务动作是否都是C,将订单信息改为 C-->
-    <update id="completeOrderByOId" parameterType="String" >
+    <update id="completeOrderByOId" parameterType="String">
         <![CDATA[
-            update c_orders co set co.status_cd = 'C' where co.status_cd='S'
-                and co.o_id = #{oId}
-                and not exists(
-                        select 1 from c_business cb where cb.status_cd <> 'C'
-                        and cb.o_id = co.o_id
-                )
+
+                    update c_orders co set co.status_cd = 'C' where co.status_cd='S'
+                        and co.o_id = #{oId}
+                        and not exists(
+                                select 1 from c_business cb where cb.status_cd <> 'C'
+                                and cb.o_id = co.o_id
+                        )
+
         ]]>
     </update>
 
     <select id="getOrderInfoByBId" parameterType="String" resultType="Map">
         <![CDATA[
-        select co.* from c_orders co where 1 = 1 and exists
-        (
-            select 1 from c_business cb where cb.o_id = co.o_id
-            and cb.b_id = #{bId}
-        )
-    ]]>
+
+                select co.* from c_orders co where 1 = 1 and exists
+                (
+                    select 1 from c_business cb where cb.o_id = co.o_id
+                    and cb.b_id = #{bId}
+                )
+
+        ]]>
     </select>
     <!-- 根据 OID 查询 business -->
     <select id="getBusinessByOId" parameterType="map" resultType="map">
@@ -100,48 +120,56 @@
         WHERE co.`o_id` = cb.`o_id`
         AND cb.`business_type_cd` NOT IN ('DO')
         <if test="statusCd != null and statusCd != ''">
-        AND cb.`status_cd` = #{statusCd}
+            AND cb.`status_cd` = #{statusCd}
         </if>
         <if test="oId != null and oId != ''">
-        AND co.`o_id` = #{oId}
+            AND co.`o_id` = #{oId}
         </if>
     </select>
 
     <select id="getDeleteOrderBusinessByOId" parameterType="String" resultType="Map">
         <![CDATA[
-           select cb.b_id,cb.o_id,cb.business_type_cd,cb.status_cd from c_orders co,c_business cb where co.o_id = cb.o_id and cb.business_type_cd = 'DO' and cb.status_cd = 'DO'
-           and co.o_id = #{oId}
+
+                   select cb.b_id,cb.o_id,cb.business_type_cd,cb.status_cd from c_orders co,c_business cb where co.o_id = cb.o_id and cb.business_type_cd = 'DO' and cb.status_cd = 'DO'
+                   and co.o_id = #{oId}
+
         ]]>
     </select>
 
     <!-- 获取同个订单中已经完成的订单项-->
     <select id="getCommonOrderCompledBusinessByBId" parameterType="String" resultType="Map">
         <![CDATA[
-            select * from c_business cb where cb.finish_time is not null
-            and cb.o_id in (
-                select cb1.o_id from c_business cb1 where cb1.b_id = #{bId}
-            )
+
+                    select * from c_business cb where cb.finish_time is not null
+                    and cb.o_id in (
+                        select cb1.o_id from c_business cb1 where cb1.b_id = #{bId}
+                    )
+
         ]]>
     </select>
     <!--查询 所有有效 app信息-->
     <select id="getAppRouteAndServiceInfoAll" resultType="Map">
         <![CDATA[
-             SELECT ca.app_id,ca.name,ca.security_code,ca.while_list_ip,ca.black_list_ip,cr.invoke_limit_times,
-            cr.order_type_cd,cs.service_id,cs.business_type_cd,cr.invoke_model,cs.is_instance,
-            cs.messageQueueName,cs.method,cs.name,cs.provide_app_id,cs.retry_count,cs.seq,cs.service_code,
-            cs.timeout,cs.url FROM c_app ca,c_route cr,c_service cs
-            WHERE ca.status_cd = '0'
-            AND ca.app_id = cr.app_id
-            AND cr.status_cd = '0'
-            AND cr.service_id = cs.service_id
-            AND cs.status_cd = '0'
+
+                     SELECT ca.app_id,ca.name,ca.security_code,ca.while_list_ip,ca.black_list_ip,cr.invoke_limit_times,
+                    cr.order_type_cd,cs.service_id,cs.business_type_cd,cr.invoke_model,cs.is_instance,
+                    cs.messageQueueName,cs.method,cs.name,cs.provide_app_id,cs.retry_count,cs.seq,cs.service_code,
+                    cs.timeout,cs.url FROM c_app ca,c_route cr,c_service cs
+                    WHERE ca.status_cd = '0'
+                    AND ca.app_id = cr.app_id
+                    AND cr.status_cd = '0'
+                    AND cr.service_id = cs.service_id
+                    AND cs.status_cd = '0'
+
         ]]>
 
     </select>
 
     <select id="getMappingInfoAll" resultType="com.java110.entity.mapping.Mapping">
         <![CDATA[
-             SELECT cm.domain,cm.name,cm.key,cm.value,cm.remark from c_mapping cm where cm.status_cd = '0'
+
+                     SELECT cm.domain,cm.name,cm.key,cm.value,cm.remark from c_mapping cm where cm.status_cd = '0'
+
         ]]>
     </select>
 
@@ -171,8 +199,29 @@
 
     <!---->
     <select id="queryOwenrOrders" parameterType="map">
-        select cb.b_id bId,co.o_id oId,cb.business_type_cd businessTypeCd  from c_orders co,c_business cb where co.o_id = cb.o_id
-        and cb.business_type_cd in ('110100030001','110100040001','110100050001')
+        <![CDATA[
+
+                    select cb.b_id bId,co.o_id oId,cb.business_type_cd businessTypeCd  from c_orders co,c_business cb where co.o_id = cb.o_id
+                    and cb.business_type_cd in ('110100030001','110100040001','110100050001')
+                    and cb.status_cd <> 'C1'
+
+        ]]>
+    </select>
+
+    <select id="queryManchineOrders" parameterType="map">
+        <![CDATA[
+
+                select cb.b_id bId,co.o_id oId,cb.business_type_cd businessTypeCd  from c_orders co,c_business cb where co.o_id = cb.o_id
+                and cb.business_type_cd in ('200200030001','200200040001','200200050001')
+                and cb.status_cd <> 'C1'
+
+        ]]>
     </select>
 
+    <update id="updateBusinessStatusCd" parameterType="Map">
+        update c_business cb set cb.status_cd = 'C1'
+        where cb.b_id = #{bId}
+    </update>
+
+
 </mapper>

+ 196 - 192
java110-db/src/main/resources/mapper/hardwareAdapation/MachineServiceDaoImplMapper.xml

@@ -5,7 +5,7 @@
 <mapper namespace="machineServiceDaoImpl">
 
     <!-- 保存设备信息 add by wuxw 2018-07-03 -->
-       <insert id="saveBusinessMachineInfo" parameterType="Map">
+    <insert id="saveBusinessMachineInfo" parameterType="Map">
            insert into business_machine(
 machine_mac,machine_id,machine_code,auth_code,operate,machine_version,community_id,b_id,machine_name,machine_type_cd,machine_ip
 ) values (
@@ -14,218 +14,222 @@ machine_mac,machine_id,machine_code,auth_code,operate,machine_version,community_
        </insert>
 
 
-       <!-- 查询设备信息(Business) add by wuxw 2018-07-03 -->
-       <select id="getBusinessMachineInfo" parameterType="Map" resultType="Map">
-           select  t.machine_mac,t.machine_mac machineMac,t.machine_id,t.machine_id machineId,t.machine_code,t.machine_code machineCode,t.auth_code,t.auth_code authCode,t.operate,t.machine_version,t.machine_version machineVersion,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.machine_name,t.machine_name machineName,t.machine_type_cd,t.machine_type_cd machineTypeCd,t.machine_ip,t.machine_ip machineIp 
-from business_machine t 
-where 1 =1 
-<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="machineCode !=null and machineCode != ''">
-   and t.machine_code= #{machineCode}
-</if> 
-<if test="authCode !=null and authCode != ''">
-   and t.auth_code= #{authCode}
-</if> 
-<if test="operate !=null and operate != ''">
-   and t.operate= #{operate}
-</if> 
-<if test="machineVersion !=null and machineVersion != ''">
-   and t.machine_version= #{machineVersion}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="bId !=null and bId != ''">
-   and t.b_id= #{bId}
-</if> 
-<if test="machineName !=null and machineName != ''">
-   and t.machine_name= #{machineName}
-</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> 
-
-       </select>
-
-
+    <!-- 查询设备信息(Business) add by wuxw 2018-07-03 -->
+    <select id="getBusinessMachineInfo" parameterType="Map" resultType="Map">
+        select t.machine_mac,t.machine_mac machineMac,t.machine_id,t.machine_id machineId,t.machine_code,t.machine_code
+        machineCode,t.auth_code,t.auth_code authCode,t.operate,t.machine_version,t.machine_version
+        machineVersion,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.machine_name,t.machine_name
+        machineName,t.machine_type_cd,t.machine_type_cd machineTypeCd,t.machine_ip,t.machine_ip machineIp
+        from business_machine t
+        where 1 =1
+        <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="machineCode !=null and machineCode != ''">
+            and t.machine_code= #{machineCode}
+        </if>
+        <if test="authCode !=null and authCode != ''">
+            and t.auth_code= #{authCode}
+        </if>
+        <if test="operate !=null and operate != ''">
+            and t.operate= #{operate}
+        </if>
+        <if test="machineVersion !=null and machineVersion != ''">
+            and t.machine_version= #{machineVersion}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="bId !=null and bId != ''">
+            and t.b_id= #{bId}
+        </if>
+        <if test="machineName !=null and machineName != ''">
+            and t.machine_name= #{machineName}
+        </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>
 
+    </select>
 
 
     <!-- 保存设备信息至 instance表中 add by wuxw 2018-07-03 -->
     <insert id="saveMachineInfoInstance" parameterType="Map">
         insert into machine(
-machine_mac,machine_id,machine_code,auth_code,machine_version,status_cd,community_id,b_id,machine_name,machine_type_cd,machine_ip
-) select t.machine_mac,t.machine_id,t.machine_code,t.auth_code,t.machine_version,'0',t.community_id,t.b_id,t.machine_name,t.machine_type_cd,t.machine_ip from business_machine t where 1=1
-<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="machineCode !=null and machineCode != ''">
-   and t.machine_code= #{machineCode}
-</if> 
-<if test="authCode !=null and authCode != ''">
-   and t.auth_code= #{authCode}
-</if> 
-   and t.operate= 'ADD'
-<if test="machineVersion !=null and machineVersion != ''">
-   and t.machine_version= #{machineVersion}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="bId !=null and bId != ''">
-   and t.b_id= #{bId}
-</if> 
-<if test="machineName !=null and machineName != ''">
-   and t.machine_name= #{machineName}
-</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> 
+        machine_mac,machine_id,machine_code,auth_code,machine_version,status_cd,community_id,b_id,machine_name,machine_type_cd,machine_ip
+        ) select
+        t.machine_mac,t.machine_id,t.machine_code,t.auth_code,t.machine_version,'0',t.community_id,t.b_id,t.machine_name,t.machine_type_cd,t.machine_ip
+        from business_machine t where 1=1
+        <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="machineCode !=null and machineCode != ''">
+            and t.machine_code= #{machineCode}
+        </if>
+        <if test="authCode !=null and authCode != ''">
+            and t.auth_code= #{authCode}
+        </if>
+        and t.operate= 'ADD'
+        <if test="machineVersion !=null and machineVersion != ''">
+            and t.machine_version= #{machineVersion}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="bId !=null and bId != ''">
+            and t.b_id= #{bId}
+        </if>
+        <if test="machineName !=null and machineName != ''">
+            and t.machine_name= #{machineName}
+        </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>
 
     </insert>
 
 
-
     <!-- 查询设备信息 add by wuxw 2018-07-03 -->
     <select id="getMachineInfo" parameterType="Map" resultType="Map">
-        select  t.machine_mac,t.machine_mac machineMac,t.machine_id,t.machine_id machineId,t.machine_code,t.machine_code machineCode,t.auth_code,t.auth_code authCode,t.machine_version,t.machine_version machineVersion,t.status_cd,t.status_cd statusCd,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.machine_name,t.machine_name machineName,t.machine_type_cd,t.machine_type_cd machineTypeCd,t.machine_ip,t.machine_ip machineIp 
-from machine t 
-where 1 =1 
-<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="machineCode !=null and machineCode != ''">
-   and t.machine_code= #{machineCode}
-</if> 
-<if test="authCode !=null and authCode != ''">
-   and t.auth_code= #{authCode}
-</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="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="bId !=null and bId != ''">
-   and t.b_id= #{bId}
-</if> 
-<if test="machineName !=null and machineName != ''">
-   and t.machine_name= #{machineName}
-</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="page != -1 and page != null ">
-   limit #{page}, #{row}
-</if> 
+        select t.machine_mac,t.machine_mac machineMac,t.machine_id,t.machine_id machineId,t.machine_code,t.machine_code
+        machineCode,t.auth_code,t.auth_code authCode,t.machine_version,t.machine_version
+        machineVersion,t.status_cd,t.status_cd statusCd,t.community_id,t.community_id communityId,t.b_id,t.b_id
+        bId,t.machine_name,t.machine_name machineName,t.machine_type_cd,t.machine_type_cd
+        machineTypeCd,t.machine_ip,t.machine_ip machineIp
+        from machine t
+        where 1 =1
+        <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="machineCode !=null and machineCode != ''">
+            and t.machine_code= #{machineCode}
+        </if>
+        <if test="authCode !=null and authCode != ''">
+            and t.auth_code= #{authCode}
+        </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="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="bId !=null and bId != ''">
+            and t.b_id= #{bId}
+        </if>
+        <if test="machineName !=null and machineName != ''">
+            and t.machine_name= #{machineName}
+        </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="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
 
     </select>
 
 
-
-
     <!-- 修改设备信息 add by wuxw 2018-07-03 -->
     <update id="updateMachineInfoInstance" parameterType="Map">
-        update  machine t set t.status_cd = #{statusCd}
-<if test="newBId != null and newBId != ''">
-,t.b_id = #{newBId}
-</if> 
-<if test="machineMac !=null and machineMac != ''">
-, t.machine_mac= #{machineMac}
-</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="machineVersion !=null and machineVersion != ''">
-, t.machine_version= #{machineVersion}
-</if> 
-<if test="communityId !=null and communityId != ''">
-, t.community_id= #{communityId}
-</if> 
-<if test="machineName !=null and machineName != ''">
-, t.machine_name= #{machineName}
-</if> 
-<if test="machineTypeCd !=null and machineTypeCd != ''">
-, t.machine_type_cd= #{machineTypeCd}
-</if> 
-<if test="machineIp !=null and machineIp != ''">
-, t.machine_ip= #{machineIp}
-</if> 
- where 1=1 <if test="machineId !=null and machineId != ''">
-and t.machine_id= #{machineId}
-</if> 
-<if test="bId !=null and bId != ''">
-and t.b_id= #{bId}
-</if> 
+        update machine t set t.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,t.b_id = #{newBId}
+        </if>
+        <if test="machineMac !=null and machineMac != ''">
+            , t.machine_mac= #{machineMac}
+        </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="machineVersion !=null and machineVersion != ''">
+            , t.machine_version= #{machineVersion}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            , t.community_id= #{communityId}
+        </if>
+        <if test="machineName !=null and machineName != ''">
+            , t.machine_name= #{machineName}
+        </if>
+        <if test="machineTypeCd !=null and machineTypeCd != ''">
+            , t.machine_type_cd= #{machineTypeCd}
+        </if>
+        <if test="machineIp !=null and machineIp != ''">
+            , t.machine_ip= #{machineIp}
+        </if>
+        where 1=1
+        <if test="machineId !=null and machineId != ''">
+            and t.machine_id= #{machineId}
+        </if>
+        <if test="bId !=null and bId != ''">
+            and t.b_id= #{bId}
+        </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="machineMac !=null and machineMac != ''">
-   and t.machine_mac= #{machineMac}
-</if> 
-<if test="machineId !=null and machineId != ''">
-   and t.machine_id= #{machineId}
-</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="machineVersion !=null and machineVersion != ''">
-   and t.machine_version= #{machineVersion}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="bId !=null and bId != ''">
-   and t.b_id= #{bId}
-</if> 
-<if test="machineName !=null and machineName != ''">
-   and t.machine_name= #{machineName}
-</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> 
-
-
-     </select>
+    <select id="queryMachinesCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from machine t
+        where 1 =1
+        <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="machineCode !=null and machineCode != ''">
+            and t.machine_code= #{machineCode}
+        </if>
+        <if test="authCode !=null and authCode != ''">
+            and t.auth_code= #{authCode}
+        </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="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="bId !=null and bId != ''">
+            and t.b_id= #{bId}
+        </if>
+        <if test="machineName !=null and machineName != ''">
+            and t.machine_name= #{machineName}
+        </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>
+
+
+    </select>
 
 </mapper>

+ 28 - 0
java110-db/src/main/resources/mapper/hardwareAdapation/MachineTranslateServiceDaoImplMapper.xml

@@ -4,6 +4,34 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="machineTranslateServiceDaoImpl">
 
+
+    <!-- 保存设备同步信息 add by wuxw 2018-07-03 -->
+    <insert id="saveMachineTranslate" parameterType="Map">
+    insert into machine_translate(
+    machine_id,machine_code,status_cd,type_cd,machine_translate_id,obj_id,obj_name,state,community_id,b_id
+    ) values (
+    #{machineId},#{machineCode},'0',#{typeCd},#{machineTranslateId},#{objId},#{objName},#{state},#{communityId},#{bId}
+    )
+ </insert>
+    <update id="updateMachineTranslate" parameterType="Map">
+        update machine_translate t set
+        <if test="statusCd !=null and statusCd != ''">
+             t.status_cd= #{statusCd},
+        </if>
+        <if test="state !=null and state != ''">
+             t.state= #{state}
+        </if>
+        where 1=1
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="objId !=null and objId != ''">
+            and t.obj_id= #{objId}
+        </if>
+        <if test="machineId !=null and machineId != ''">
+            and t.machine_id= #{machineId}
+        </if>
+    </update>
     <!-- 保存设备同步信息 add by wuxw 2018-07-03 -->
     <insert id="saveBusinessMachineTranslateInfo" parameterType="Map">
            insert into business_machine_translate(