hym 4 年之前
父节点
当前提交
a42ad8a6d1
共有 23 个文件被更改,包括 589 次插入42 次删除
  1. 1 1
      src/main/java/com/zoniot/ccrc/controller/GridManagementController.java
  2. 3 2
      src/main/java/com/zoniot/ccrc/controller/system/CommunityManagerController.java
  3. 65 0
      src/main/java/com/zoniot/ccrc/controller/system/OperationLogController.java
  4. 4 4
      src/main/java/com/zoniot/ccrc/controller/system/OrganController.java
  5. 1 1
      src/main/java/com/zoniot/ccrc/dao/CommunityMapper.java
  6. 2 1
      src/main/java/com/zoniot/ccrc/dao/GridManagementMapper.java
  7. 21 0
      src/main/java/com/zoniot/ccrc/dao/OperationLogMapper.java
  8. 2 1
      src/main/java/com/zoniot/ccrc/dao/SiteMapper.java
  9. 59 0
      src/main/java/com/zoniot/ccrc/entity/OperationLog.java
  10. 5 0
      src/main/java/com/zoniot/ccrc/entity/Organization.java
  11. 48 0
      src/main/java/com/zoniot/ccrc/entity/ProgramItem.java
  12. 1 1
      src/main/java/com/zoniot/ccrc/service/CommunityService.java
  13. 27 0
      src/main/java/com/zoniot/ccrc/service/OperationLogService.java
  14. 2 5
      src/main/java/com/zoniot/ccrc/service/impl/CommunityServiceImpl.java
  15. 2 1
      src/main/java/com/zoniot/ccrc/service/impl/GridManagementServiceImpl.java
  16. 127 0
      src/main/java/com/zoniot/ccrc/service/impl/OperationLogServiceImpl.java
  17. 9 3
      src/main/java/com/zoniot/ccrc/service/impl/OrganizationServiceImpl.java
  18. 6 3
      src/main/java/com/zoniot/ccrc/service/impl/SiteServiceImpl.java
  19. 1 0
      src/main/resources/mapper/CommunityMapper.xml
  20. 7 1
      src/main/resources/mapper/GridManagementMapper.xml
  21. 166 0
      src/main/resources/mapper/OperationLogMapper.xml
  22. 10 5
      src/main/resources/mapper/OrganizationMapper.xml
  23. 20 13
      src/main/resources/mapper/SiteMapper.xml

+ 1 - 1
src/main/java/com/zoniot/ccrc/controller/GridManagementController.java

@@ -164,7 +164,7 @@ public class GridManagementController {
      * @return Response对象
      */
     @RequestMapping(value = "deleteGridDevice", method = RequestMethod.POST)
-    @ApiOperation(value = "查询建筑信息")
+    @ApiOperation(value = "删除网格设备")
     public AjaxMessage deleteGridDevice(Integer id) {
 
         gridManagementService.deleteGridDevice(id);

+ 3 - 2
src/main/java/com/zoniot/ccrc/controller/system/CommunityManagerController.java

@@ -110,9 +110,10 @@ public class CommunityManagerController {
 	@ApiOperation(value = "获取机构小区")
 
 	public AjaxMessage getOrgCommunity(
-			@ApiParam(value = "小区Id") @RequestParam(required = false) Integer orgId
+			@ApiParam(value = "小区Id") @RequestParam(required = false) Integer orgId,
+			@ApiParam(value = "区域Id") @RequestParam(required = false) Integer areaId
 	) {
-		List<Community>communities=communityService.getOrgCommunity(orgId);
+		List<Community>communities=communityService.getOrgCommunity(orgId,areaId);
 		return new AjaxMessage(ResultStatus.OK,communities);
 	}
 }

+ 65 - 0
src/main/java/com/zoniot/ccrc/controller/system/OperationLogController.java

@@ -0,0 +1,65 @@
+package com.zoniot.ccrc.controller.system;
+
+
+import com.zoniot.ccrc.commom.model.AjaxMessage;
+import com.zoniot.ccrc.commom.model.Pagination;
+import com.zoniot.ccrc.commom.model.ResultStatus;
+import com.zoniot.ccrc.entity.OperationLog;
+import com.zoniot.ccrc.service.OperationLogService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.time.LocalDateTime;
+
+@Controller
+@RequestMapping("system/operationLog")
+@Api(tags = "操作日志")
+public class OperationLogController {
+    @Autowired
+    private OperationLogService operationLogService;
+
+    @ResponseBody
+    @GetMapping("getPage")
+    @ApiOperation(value = "查询操作日志分页")
+    public AjaxMessage<Pagination<OperationLog>> getPage(
+            @ApiParam(value = "用户名", required = false) @RequestParam(required = false) String username,
+            @ApiParam(value = "操作内容", required = false) @RequestParam(required = false) String content,
+            @ApiParam(value = "手机号", required = false) @RequestParam(required = false) String mobilephone,
+            @ApiParam(value = "开始时间 格式:yyyyMMddHHmmss", required = false) @RequestParam(required = false) @DateTimeFormat(pattern = "yyyyMMddHHmmss") LocalDateTime startDate,
+            @ApiParam(value = "开始时间 格式:yyyyMMddHHmmss", required = false) @RequestParam(required = false) @DateTimeFormat(pattern = "yyyyMMddHHmmss") LocalDateTime endDate,
+            @ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") int pageNum,
+            @ApiParam(value = "条数,非必传,默认15条", required = false, defaultValue = "15") @RequestParam(required = false, defaultValue = "15") int pageSize
+    ){
+        Pagination<OperationLog> pageInfo = operationLogService.getPage(username,content, startDate, endDate, pageNum, pageSize,mobilephone);
+        return new AjaxMessage<>(ResultStatus.OK, pageInfo);
+    }
+
+    @ResponseBody
+    @PostMapping("add")
+    @ApiOperation(value = "添加操作日志")
+    public AjaxMessage add(
+            @ApiParam(value = "操作日志", required = true) @RequestBody(required = true)  OperationLog operationLog
+    ) {
+        operationLogService.add(operationLog);
+        return new AjaxMessage(ResultStatus.OK);
+    }
+
+    @GetMapping("/getExcel")
+    @ApiOperation(value = "操作日志导出excel")
+    public void getExcel(
+            @ApiParam(value = "用户名", required = false) @RequestParam(required = false) String username,
+            @ApiParam(value = "操作内容", required = false) @RequestParam(required = false) String content,
+            @ApiParam(value = "手机号码", required = false) @RequestParam(required = false) String mobilephone,
+            @ApiParam(value = "开始时间 格式:yyyyMMddHHmmss", required = false) @RequestParam(required = false) @DateTimeFormat(pattern = "yyyyMMddHHmmss") LocalDateTime startDate,
+            @ApiParam(value = "开始时间 格式:yyyyMMddHHmmss", required = false) @RequestParam(required = false) @DateTimeFormat(pattern = "yyyyMMddHHmmss") LocalDateTime endDate,
+            HttpServletResponse httpServletResponse
+    ) {
+        operationLogService.getExcel(username,content, startDate, endDate, mobilephone, httpServletResponse);
+    }
+}

+ 4 - 4
src/main/java/com/zoniot/ccrc/controller/system/OrganController.java

@@ -65,16 +65,16 @@ public class OrganController {
         return new AjaxMessage(ResultStatus.OK);
     }
 
-    @GetMapping("deleteQuery")
+   /* @GetMapping("deleteQuery")
     @ApiOperation(value = "删除查询", notes = "删除查询,返回用户个数个子类个数")
     public AjaxMessage deleteQuery(
             @ApiParam(value = "机构id", required = true) @RequestParam(required = true) Integer id
     ) {
         Map<String,Integer> map =  organizationService.deleteQuery(id);
         return new AjaxMessage<>(ResultStatus.OK, map);
-    }
+    }*/
 
-    @GetMapping("getOrganTreeForCustomer")
+   /* @GetMapping("getOrganTreeForCustomer")
     @ApiOperation(value = "获取机构树(数据权限)", notes = "权限:sys:organ:query")
     //@PreAuthorize("hasAuthority('sys:organ:query')")
     public AjaxMessage<List<OrganizationDto>> getOrganTreeForCustomer(
@@ -82,5 +82,5 @@ public class OrganController {
 
         List<OrganizationDto> list = organizationService.findListByCustomer();
         return new AjaxMessage<>(ResultStatus.OK, list);
-    }
+    }*/
 }

+ 1 - 1
src/main/java/com/zoniot/ccrc/dao/CommunityMapper.java

@@ -47,5 +47,5 @@ public interface CommunityMapper {
 
     List<CommunityDto> getListByCustomerIds(@Param("siteId") Integer siteId, @Param("customerIds") List<Integer> customerIds, @Param("communityName") String communityName, @Param("province") Integer province, @Param("city") Integer city, @Param("region") Integer region);
 
-    List<Community> getOrgCommunity(@Param("orgId") Integer orgId);
+    List<Community> getOrgCommunity(@Param("orgId") Integer orgId,@Param("areaId") Integer areaId);
 }

+ 2 - 1
src/main/java/com/zoniot/ccrc/dao/GridManagementMapper.java

@@ -85,7 +85,8 @@ public interface GridManagementMapper {
     List<GridUser> selectGirdUserInfo(@Param("username") String username,
                                       @Param("orgId") Integer orgId,
                                       @Param("siteId") Integer siteId,
-                                      @Param("userId") Integer userId);
+                                      @Param("userId") Integer userId,
+                                      @Param("type") Integer type);
 
     List<Community> getCommutityByOrg(@Param("ids") List<Integer> orgId);
 

+ 21 - 0
src/main/java/com/zoniot/ccrc/dao/OperationLogMapper.java

@@ -0,0 +1,21 @@
+package com.zoniot.ccrc.dao;
+
+
+import com.zoniot.ccrc.entity.OperationLog;
+import com.zoniot.ccrc.entity.ProgramItem;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Mapper
+public interface OperationLogMapper {
+    int insertSelective(OperationLog record);
+
+    int updateByPrimaryKeySelective(OperationLog record);
+
+    List<OperationLog> getList(@Param("siteId") Integer siteId, @Param("programItems") List<ProgramItem> programItems,
+                               @Param("username") String username, @Param("content") String content,
+                               @Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate, @Param("mobilephone") String mobilephone);
+}

+ 2 - 1
src/main/java/com/zoniot/ccrc/dao/SiteMapper.java

@@ -31,8 +31,9 @@ public interface SiteMapper {
     List<Integer> getSiteCustomerIds();
     List<Customer> getCustomerList();
 
-    void updateCustomerSiteId(@Param("id") Integer id, @Param("customerId") Integer customerId);
+    void updateCustomerSiteId(@Param("id") Integer id, @Param("customerIds")  List<Integer>customerIds);
 
     void deleteCustomerRelations(@Param("id") Integer id);
 
+    List<Integer> getAllCustomerIds(@Param("id")Integer id, @Param("customerId") Integer customerId);
 }

+ 59 - 0
src/main/java/com/zoniot/ccrc/entity/OperationLog.java

@@ -0,0 +1,59 @@
+package com.zoniot.ccrc.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+@ApiModel(value="com-bz-smart_city-entity-OperationLog")
+public class OperationLog {
+
+    @ApiModelProperty(value="id")
+    private Integer id;
+
+    @ApiModelProperty(value="站点id",hidden = true)
+    private Integer siteId;
+
+    @ApiModelProperty(value="设备id")
+    private Long deviceId;
+
+    @ApiModelProperty(value="操作名称")
+    private String operationName;
+
+    @ApiModelProperty(value="用户")
+    private String username;
+
+    @ApiModelProperty(value="旧数据")
+    private String oldData;
+
+    @ApiModelProperty(value="新数据")
+    private String newData;
+
+    @JsonIgnore
+    @ApiModelProperty(value="状态",hidden = true)
+    private Integer status;
+
+    @ApiModelProperty(value="手机号")
+    private String mobilePhone;
+
+    @JsonIgnore
+    @ApiModelProperty(value="创建人",hidden = true)
+    private String createBy;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value="创建时间")
+    private LocalDateTime createDate;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新人",hidden = true)
+    private String updateBy;
+
+    @JsonIgnore
+    @ApiModelProperty(value="更新时间",hidden = true)
+    private LocalDateTime updateDate;
+
+}

+ 5 - 0
src/main/java/com/zoniot/ccrc/entity/Organization.java

@@ -57,4 +57,9 @@ public class Organization {
     private String updateBy;
     @ApiModelProperty(value = "小区id", position = 54)
     private List<Integer>communityId;
+    /**
+     * 区域id
+     */
+    @ApiModelProperty(value = "区域id",position = 55)
+    private String areaId;
 }

+ 48 - 0
src/main/java/com/zoniot/ccrc/entity/ProgramItem.java

@@ -0,0 +1,48 @@
+package com.zoniot.ccrc.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+@ApiModel(value="com.bz.smart_city.entity.ProgramItem")
+@Data
+public class ProgramItem implements Serializable {
+
+    private static final long serialVersionUID = 3770821337946751269L;
+
+    @ApiModelProperty(value="主键")
+    private Integer id;
+
+    @ApiModelProperty(value="数据项id")
+    private Integer programId;
+
+    @ApiModelProperty(value="维度id")
+    private Integer dimensionId;
+
+    @ApiModelProperty(value="维度编码")
+    private String dimensionCode;
+
+    @ApiModelProperty(value="维度值")
+    private String dimensionValue;
+
+    @ApiModelProperty(value="备注")
+    private String remark;
+
+    @ApiModelProperty(value="状态")
+    private Integer status;
+
+    @ApiModelProperty(value="创建时间")
+    private LocalDateTime dateCreate;
+
+    @ApiModelProperty(value="更新时间")
+    private LocalDateTime dateUpdate;
+
+    @ApiModelProperty(value="创建人")
+    private String createBy;
+
+    @ApiModelProperty(value="更新人")
+    private String updateBy;
+}

+ 1 - 1
src/main/java/com/zoniot/ccrc/service/CommunityService.java

@@ -56,7 +56,7 @@ public interface CommunityService {
     Community findCacheByName(Integer siteId, String communityName);
 
 
-    List<Community> getOrgCommunity(Integer orgId);
+    List<Community> getOrgCommunity(Integer orgId, Integer areaId);
 
     void syncCommunity(CommunityData communityData);
 }

+ 27 - 0
src/main/java/com/zoniot/ccrc/service/OperationLogService.java

@@ -0,0 +1,27 @@
+package com.zoniot.ccrc.service;
+
+
+
+import com.zoniot.ccrc.commom.model.Pagination;
+import com.zoniot.ccrc.entity.OperationLog;
+
+import javax.servlet.http.HttpServletResponse;
+import java.time.LocalDateTime;
+
+public interface OperationLogService {
+
+
+    int insertSelective(OperationLog record);
+
+    int updateByPrimaryKeySelective(OperationLog record);
+
+    Pagination<OperationLog> getPage(String username, String content, LocalDateTime startDate,
+                                     LocalDateTime endDate, int pageNum, int pageSize, String mobilephone);
+
+    void add(OperationLog operationLog);
+
+    void getExcel(String username, String content, LocalDateTime startDate, LocalDateTime endDate, String mobilephone, HttpServletResponse httpServletResponse);
+
+    void addMobileOperationLog(OperationLog operationLog);
+}
+

+ 2 - 5
src/main/java/com/zoniot/ccrc/service/impl/CommunityServiceImpl.java

@@ -19,12 +19,9 @@ import com.zoniot.ccrc.entity.Area;
 import com.zoniot.ccrc.entity.Community;
 import com.zoniot.ccrc.service.CommunityService;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.time.LocalDateTime;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -284,9 +281,9 @@ public class CommunityServiceImpl implements CommunityService {
     }
 
     @Override
-    public List<Community> getOrgCommunity(Integer orgId) {
+    public List<Community> getOrgCommunity(Integer orgId, Integer areaId) {
 
-        return communityMapper.getOrgCommunity(orgId);
+        return communityMapper.getOrgCommunity(orgId,areaId);
     }
 
     @Override

+ 2 - 1
src/main/java/com/zoniot/ccrc/service/impl/GridManagementServiceImpl.java

@@ -147,7 +147,8 @@ public class GridManagementServiceImpl implements GridManagementService {
 
         Integer siteId=currentUser.getSiteId();
         Integer userId=currentUser.getId();
-        List<GridUser> users=gridManagementMapper.selectGirdUserInfo(name,orgId,siteId,userId);
+        Integer type =currentUser.getType();
+        List<GridUser> users=gridManagementMapper.selectGirdUserInfo(name,orgId,siteId,userId,type);
         return users;
     }
 

+ 127 - 0
src/main/java/com/zoniot/ccrc/service/impl/OperationLogServiceImpl.java

@@ -0,0 +1,127 @@
+package com.zoniot.ccrc.service.impl;
+
+import com.alibaba.fastjson.JSON;
+
+import com.github.pagehelper.PageHelper;
+import com.zoniot.ccrc.commom.model.Pagination;
+import com.zoniot.ccrc.commom.utils.UserUtil;
+import com.zoniot.ccrc.dao.DeviceMapper;
+import com.zoniot.ccrc.dao.OperationLogMapper;
+import com.zoniot.ccrc.dto.LoginUser;
+import com.zoniot.ccrc.entity.Device;
+import com.zoniot.ccrc.entity.OperationLog;
+import com.zoniot.ccrc.service.OperationLogService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+
+import static com.google.common.collect.Lists.newArrayList;
+
+@Slf4j
+@Service
+public class OperationLogServiceImpl implements OperationLogService {
+
+    @Resource
+    private OperationLogMapper operationLogMapper;
+    @Resource
+    private DeviceMapper deviceMapper;
+
+    @Override
+    public int insertSelective(OperationLog record) {
+        return operationLogMapper.insertSelective(record);
+    }
+
+    @Override
+    public int updateByPrimaryKeySelective(OperationLog record) {
+        return operationLogMapper.updateByPrimaryKeySelective(record);
+    }
+
+    @Override
+    public Pagination<OperationLog> getPage(String username, String content,
+                                            LocalDateTime startDate, LocalDateTime endDate, int pageNum, int pageSize, String mobilephone) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        PageHelper.startPage(pageNum, pageSize);
+        List<OperationLog> list = operationLogMapper.getList(loginUser.getSiteId(), null, username,
+                 content, startDate, endDate,mobilephone);
+        return new Pagination<>(list);
+    }
+
+    @Override
+    public void add(OperationLog operationLog) {
+        log.info("begin add operationLog={}", JSON.toJSON(operationLog));
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        operationLog.setSiteId(loginUser.getSiteId());
+        operationLog.setUsername(loginUser.getUsername());
+        //新增手机号码
+        operationLog.setMobilePhone(loginUser.getMobilePhone());
+        operationLog.setStatus(1);
+        operationLog.setCreateBy(loginUser.getUsername());
+        operationLog.setCreateDate(LocalDateTime.now());
+        operationLog.setUpdateBy(loginUser.getUsername());
+        operationLog.setUpdateDate(LocalDateTime.now());
+        this.insertSelective(operationLog);
+        log.info("end add operationLog");
+    }
+
+    @Override
+    public void addMobileOperationLog(OperationLog operationLog) {
+      /*  log.info("begin add addMobileOperationLog={}", JSON.toJSON(operationLog));
+        LoginAssistantUser loginAssistantUser = AssistantUserUtil.getCurrentUser();
+        Device device = deviceMapper.findByDeviceIdIgnore(operationLog.getDeviceId());
+        operationLog.setSiteId(device.getSiteId());
+        operationLog.setUsername(loginAssistantUser.getUserName() != null ? loginAssistantUser.getUserName() : loginAssistantUser.getPhoneNumber());
+        operationLog.setStatus(1);
+        operationLog.setCreateBy(loginAssistantUser.getPhoneNumber()==null?loginAssistantUser.getId().toString():loginAssistantUser.getPhoneNumber());
+        operationLog.setCreateDate(LocalDateTime.now());
+        operationLog.setUpdateBy(loginAssistantUser.getPhoneNumber()==null?loginAssistantUser.getId().toString():loginAssistantUser.getPhoneNumber());
+        operationLog.setUpdateDate(LocalDateTime.now());
+        //新增手机号码
+        operationLog.setMobilePhone(loginAssistantUser.getPhoneNumber()==null?
+                (operationLog.getMobilePhone()  != null ? operationLog.getMobilePhone() : loginAssistantUser.getId().toString())
+                :loginAssistantUser.getPhoneNumber());
+        this.insertSelective(operationLog);
+        log.info("end add addMobileOperationLog");*/
+    }
+
+    @Override
+    public void getExcel(String username,  String content, LocalDateTime startDate, LocalDateTime endDate,String mobilephone, HttpServletResponse httpServletResponse) {
+      /*  LoginUser loginUser = UserUtil.getCurrentUser();
+        List<OperationLog> list = operationLogMapper.getList(loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), username, content, startDate, endDate,mobilephone);
+        String title = "操作日志";
+        String[] rowsName;
+        if(loginUser.getSiteType() != null && loginUser.getSiteType() == 2){
+            rowsName = new String[]{"序号", "操作时间", "用户名","手机号", "操作内容"};
+        }else{
+            rowsName= new String[]{"序号", "时间", "用户名","手机号", "操作", "操作前", "操作后"};
+        }
+        List<Object[]> dataList = newArrayList();
+        Object[] objs = null;
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        for (int i = 0; i < list.size(); i++) {
+            OperationLog operationLog = list.get(i);
+            objs = new Object[rowsName.length];
+            objs[0] = (i + 1);
+            objs[1] = operationLog.getCreateDate().format(df);
+            objs[2] = operationLog.getUsername();
+            objs[3] = operationLog.getMobilePhone();
+            objs[4] = operationLog.getOperationName();
+            if(loginUser.getSiteType() == null || loginUser.getSiteType() != 2) {
+                objs[5] = operationLog.getOldData().replaceAll("&", ",\r\n");
+                objs[6] = operationLog.getNewData().replaceAll("&", ",\r\n");
+            }
+            dataList.add(objs);
+        }
+        ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
+        try {
+            excelUtil.export(httpServletResponse);
+        } catch (Exception e) {
+            throw new ServiceException(-900, "导出异常");
+        }*/
+    }
+}
+

+ 9 - 3
src/main/java/com/zoniot/ccrc/service/impl/OrganizationServiceImpl.java

@@ -91,11 +91,17 @@ public class OrganizationServiceImpl implements OrganizationService {
         }
 
         int result = this.insert(organization);
-        organizationMapper.updateCommutity(organization.getCommunityId(),organization.getId());
+
+        updateOrgCommunity(organization);
         log.info("end add Organization result:" + result);
 
     }
-
+    private void updateOrgCommunity(Organization organization){
+        List<Integer>communityIds=organization.getCommunityId();
+        if(communityIds!=null&&communityIds.size()>0){
+            organizationMapper.updateCommutity(organization.getCommunityId(),organization.getId());
+        }
+    }
     @Override
     public void edit(Organization organization) {
         log.info("begin edit Organization organization:" + JSON.toJSONString(organization));
@@ -105,7 +111,7 @@ public class OrganizationServiceImpl implements OrganizationService {
             throw new ServiceException(-900, "机构名称已存在");
         }
         organizationMapper.deleteCommutityRations(organization.getId());
-        organizationMapper.updateCommutity(organization.getCommunityId(),organization.getId());
+        updateOrgCommunity(organization);
 
         int result = this.updateByPrimaryKeySelective(organization);
         log.info("end edit Organization result:" + result);

+ 6 - 3
src/main/java/com/zoniot/ccrc/service/impl/SiteServiceImpl.java

@@ -169,10 +169,13 @@ public class SiteServiceImpl implements SiteService {
 
         }
 
-        siteMapper.updateCustomerSiteId(siteDto.getId(),siteDto.getCustomerId());
+        updateCustomerId(siteDto.getId(),siteDto.getCustomerId());
         log.info("end add site");
     }
-
+    private void updateCustomerId(Integer id,Integer customerId){
+        List<Integer>customerIds=siteMapper.getAllCustomerIds(id,customerId);
+        siteMapper.updateCustomerSiteId(id,customerIds);
+    }
     @Override
     @Transactional
     public void edit(SiteDto siteDto) {
@@ -260,7 +263,7 @@ public class SiteServiceImpl implements SiteService {
 
         }
         siteMapper.deleteCustomerRelations(siteDto.getId());
-        siteMapper.updateCustomerSiteId(siteDto.getId(),siteDto.getCustomerId());
+        updateCustomerId(siteDto.getId(),siteDto.getCustomerId());
         log.info("end edit site");
     }
 

+ 1 - 0
src/main/resources/mapper/CommunityMapper.xml

@@ -486,6 +486,7 @@
             </if>
             <if test="orgId==null">
                 and org_id is null
+                and region=#{areaId}
             </if>
         </where>
     </select>

+ 7 - 1
src/main/resources/mapper/GridManagementMapper.xml

@@ -193,7 +193,13 @@
          left join (select count(*)peoples,user_id from sc_grid_management group by user_id)c
          on a.id=c.user_id
         <where>
-                a.status=1 and ((ssu.type !=4) or(ssu.type=4 and a.id=#{userId}))
+            <if test="type == 4 ">
+                and a.id=#{userId}
+            </if>
+            <if test="type != 4 ">
+                and ssu.type=4
+            </if>
+                a.status=1
             <if test="username != null and username!='' ">
                 and username LIKE concat('%',#{username},'%')
             </if>

+ 166 - 0
src/main/resources/mapper/OperationLogMapper.xml

@@ -0,0 +1,166 @@
+<?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="com.zoniot.ccrc.dao.OperationLogMapper">
+  <resultMap id="BaseResultMap" type="com.zoniot.ccrc.entity.OperationLog">
+    <!--@mbg.generated-->
+    <!--@Table sc_operation_log-->
+    <id column="id" property="id" />
+    <result column="site_id" property="siteId" />
+    <result column="device_id" property="deviceId" />
+    <result column="operation_name" property="operationName" />
+    <result column="username" property="username" />
+    <result column="old_data" property="oldData" />
+    <result column="new_data" property="newData" />
+    <result column="status" property="status" />
+    <result column="create_by" property="createBy" />
+    <result column="create_date" property="createDate" />
+    <result column="update_by" property="updateBy" />
+    <result column="update_date" property="updateDate" />
+    <result column="mobilephone" property="mobilePhone" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, site_id, device_id, operation_name, username, old_data, new_data, `status`, create_by, 
+    create_date, update_by, update_date,mobilephone
+  </sql>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.zoniot.ccrc.entity.OperationLog" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_operation_log
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="siteId != null">
+        site_id,
+      </if>
+      <if test="deviceId != null">
+        device_id,
+      </if>
+      <if test="operationName != null">
+        operation_name,
+      </if>
+      <if test="username != null">
+        username,
+      </if>
+      <if test="oldData != null">
+        old_data,
+      </if>
+      <if test="newData != null">
+        new_data,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="createBy != null">
+        create_by,
+      </if>
+      <if test="createDate != null">
+        create_date,
+      </if>
+      <if test="updateBy != null">
+        update_by,
+      </if>
+      <if test="updateDate != null">
+        update_date,
+      </if>
+      <if test="mobilePhone != null">
+        mobilephone,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="siteId != null">
+        #{siteId},
+      </if>
+      <if test="deviceId != null">
+        #{deviceId},
+      </if>
+      <if test="operationName != null">
+        #{operationName},
+      </if>
+      <if test="username != null">
+        #{username},
+      </if>
+      <if test="oldData != null">
+        #{oldData},
+      </if>
+      <if test="newData != null">
+        #{newData},
+      </if>
+      <if test="status != null">
+        #{status},
+      </if>
+      <if test="createBy != null">
+        #{createBy},
+      </if>
+      <if test="createDate != null">
+        #{createDate},
+      </if>
+      <if test="updateBy != null">
+        #{updateBy},
+      </if>
+      <if test="updateDate != null">
+        #{updateDate},
+      </if>
+      <if test="mobilePhone != null">
+        #{mobilePhone},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.zoniot.ccrc.entity.OperationLog">
+    <!--@mbg.generated-->
+    update sc_operation_log
+    <set>
+      <if test="siteId != null">
+        site_id = #{siteId},
+      </if>
+      <if test="deviceId != null">
+        device_id = #{deviceId},
+      </if>
+      <if test="operationName != null">
+        operation_name = #{operationName},
+      </if>
+      <if test="username != null">
+        username = #{username},
+      </if>
+      <if test="oldData != null">
+        old_data = #{oldData},
+      </if>
+      <if test="newData != null">
+        new_data = #{newData},
+      </if>
+      <if test="status != null">
+        `status` = #{status},
+      </if>
+      <if test="createBy != null">
+        create_by = #{createBy},
+      </if>
+      <if test="createDate != null">
+        create_date = #{createDate},
+      </if>
+      <if test="updateBy != null">
+        update_by = #{updateBy},
+      </if>
+      <if test="updateDate != null">
+        update_date = #{updateDate},
+      </if>
+    </set>
+    where id = #{id}
+  </update>
+    <select id="getList" resultMap="BaseResultMap">
+        select sol.* from sc_operation_log sol
+        <if test="programItems != null and programItems.size() != 0">
+        left join sc_device_dimension sdd on (sdd.device_id = sol.device_id and sdd.status = 1)
+        </if>
+        where sol.status = 1
+        <if test="siteId != null"> and sol.site_id = #{siteId}</if>
+        <if test="programItems != null and programItems.size() != 0"> and
+          <foreach close=")" collection="programItems" item="item" open="(" separator=" or ">
+            sdd.${item.dimensionCode} = #{item.dimensionValue}
+          </foreach>
+        </if>
+        <if test="username != null and username != ''"> AND sol.username LIKE concat('%',#{username},'%')</if>
+        <if test="content != null and content != ''"> AND (sol.operation_name LIKE concat('%',#{content},'%')
+         or (sol.old_data LIKE concat('%',#{content},'%') or sol.new_data LIKE concat('%',#{content},'%')))</if>
+        <if test="startDate != null"> and sol.create_date <![CDATA[ >= ]]> #{startDate}</if>
+        <if test="endDate != null"> and sol.create_date <![CDATA[ <= ]]> #{endDate}</if>
+         <if test="mobilephone != null and mobilephone != ''">AND sol.mobilephone LIKE concat('%',#{mobilephone},'%')</if>
+        order by sol.create_date desc
+    </select>
+</mapper>

+ 10 - 5
src/main/resources/mapper/OrganizationMapper.xml

@@ -15,6 +15,7 @@
         <result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
         <result column="site_id" property="siteId" jdbcType="INTEGER"/>
         <result column="collections" property="collections" jdbcType="VARCHAR"/>
+        <result column="area_id" property="areaId" jdbcType="VARCHAR"/>
     </resultMap>
 
 
@@ -31,7 +32,7 @@
         update_date,
         update_by,
 		site_id,
-		collections
+		collections,area_id
 	</sql>
 
     <sql id="Base_Column_List_Org">
@@ -46,7 +47,8 @@
         org.update_date,
         org.update_by,
 		org.site_id,
-		org.collections
+		org.collections,
+        org.area_id
 	</sql>
 
     <!--auto generated Code-->
@@ -64,7 +66,8 @@
             update_by,
             site_id,
             collections,
-            customer_id
+            customer_id,
+            area_id
         ) VALUES (
             #{organization.id,jdbcType=INTEGER},
             #{organization.parentId,jdbcType=INTEGER},
@@ -78,7 +81,8 @@
             #{organization.updateBy,jdbcType=VARCHAR},
             #{organization.siteId,jdbcType=INTEGER},
             #{organization.collections,jdbcType=VARCHAR},
-            #{organization.customerId,jdbcType=BIGINT}
+            #{organization.customerId,jdbcType=BIGINT},
+                #{organization.areaId,jdbcType=VARCHAR}
         )
 </insert>
 
@@ -165,7 +169,8 @@
                 <if test="organization.updateDate != null"> update_date = #{organization.updateDate,jdbcType=TIMESTAMP},</if>
                 <if test="organization.updateBy != null"> update_by = #{organization.updateBy,jdbcType=VARCHAR},</if>
                 <if test="organization.siteId != null"> site_id = #{organization.siteId,jdbcType=INTEGER},</if>
-                <if test="organization.collections != null"> collections = #{organization.collections,jdbcType=VARCHAR}</if>
+                <if test="organization.collections != null"> collections = #{organization.collections,jdbcType=VARCHAR},</if>
+            <if test="organization.areaId != null"> area_id = #{organization.areaId,jdbcType=VARCHAR}</if>
         </set>
 		WHERE id = #{organization.id,jdbcType=INTEGER}
     </update>

+ 20 - 13
src/main/resources/mapper/SiteMapper.xml

@@ -184,19 +184,11 @@
     </update>
     <update id="updateCustomerSiteId">
         update sc_customer set site_id=#{id}
-        where id in ( SELECT  DATA.id FROM(
-                                              SELECT
-                                                  @ids as _ids,
-                                                  (   SELECT @ids := GROUP_CONCAT(id)
-                                                      FROM sc_customer
-                                                      WHERE FIND_IN_SET(parent_id, @ids)
-                                                  ) as cids,
-                                                  @l := @l+1 as level
-                                              FROM sc_customer,
-                                                   (SELECT @ids :=#{customerId}, @l := 0 ) b
-                                              WHERE @ids IS NOT NULL
-                                          ) id, sc_customer DATA
-                      WHERE FIND_IN_SET(DATA.id, ID._ids))
+        where id in  (
+        <foreach collection="customerIds" item="cid" index="index" open="" close="" separator=",">
+            #{cid}
+        </foreach>
+        )
     </update>
 
 
@@ -221,5 +213,20 @@
     <select id="getCustomerList" resultType="com.zoniot.ccrc.entity.Customer">
         select * from sc_customer where parent_id=0 and status=1
     </select>
+    <select id="getAllCustomerIds" resultType="java.lang.Integer">
+        SELECT  DATA.id FROM(
+                                SELECT
+                                    @ids as _ids,
+                                    (   SELECT @ids := GROUP_CONCAT(id)
+                                        FROM sc_customer
+                                        WHERE FIND_IN_SET(parent_id, @ids)
+                                    ) as cids,
+                                    @l := @l+1 as level
+                                FROM sc_customer,
+                                     (SELECT @ids :=#{customerId}, @l := 0 ) b
+                                WHERE @ids IS NOT NULL
+                            ) id, sc_customer DATA
+        WHERE FIND_IN_SET(DATA.id, ID._ids)
+    </select>
 </mapper>