调整用户企业关联列表的SQL和解除绑定方式

This commit is contained in:
wenc000 2020-05-05 13:12:00 +08:00
parent 4cc01f64e9
commit 29b694dcc8
8 changed files with 176 additions and 13 deletions

View File

@ -67,6 +67,17 @@ public class EnterpriseOfGridOperatorController extends AbstractController {
return enterpriseOfGridOperatorService.deleteEnterpriseOfGridOperator(ids);
}
@ApiOperation(value = "删除网格员的企业(通过企业ID和用户ID物理)", notes = "删除网格员的企业(通过企业ID和用户ID物理)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "enterpriseId", value = "企业ID", paramType = "path"),
@ApiImplicitParam(name = "userId", value = "用户ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@DeleteMapping("deleteenterpriseofgridoperator/{enterpriseId}/{userId}")
public SuccessResult deleteEnterpriseOfGridOperatorById(@PathVariable("enterpriseId") String enterpriseId, @PathVariable("userId") String userId) throws RemoveException {
return enterpriseOfGridOperatorService.deleteEnterpriseOfGridOperatorByEnterpriseIdAndUserId(enterpriseId, userId);
}
@ApiOperation(value = "修改网格员的企业", notes = "修改网格员的企业接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "enterpriseOfGridOperatorId", value = "网格员的企业ID", paramType = "path")

View File

@ -2,6 +2,7 @@ package com.cm.inspection.controller.app.apis.enterpriseofgridoperator;
import com.cm.common.annotation.CheckRequestBodyAnnotation;
import com.cm.common.base.AbstractController;
import com.cm.common.component.SecurityComponent;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.exception.RemoveException;
import com.cm.common.exception.SearchException;
@ -10,6 +11,7 @@ import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList;
import com.cm.common.token.app.entity.AppToken;
import com.cm.inspection.pojo.dtos.enterpriseofgridoperator.EnterpriseOfGridOperatorDTO;
import com.cm.inspection.pojo.vos.enterpriseofgridoperator.EnterpriseOfGridOperatorVO;
import com.cm.inspection.service.enterpriseofgridoperator.IEnterpriseOfGridOperatorService;
@ -61,12 +63,12 @@ public class EnterpriseOfGridOperatorAppController extends AbstractController {
@ApiOperation(value = "删除网格员的企业(通过id物理)", notes = "删除网格员的企业(通过id物理)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3")
@ApiImplicitParam(name = "enterpriseId", value = "企业ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@DeleteMapping("deleteenterpriseofgridoperator/{ids}")
public SuccessResult deleteEnterpriseOfGridOperatorById(@RequestHeader("token") String token, @PathVariable("ids") String ids) throws RemoveException {
return enterpriseOfGridOperatorService.deleteEnterpriseOfGridOperator(ids);
@DeleteMapping("deleteenterpriseofgridoperator/{enterpriseId}")
public SuccessResult deleteEnterpriseOfGridOperatorById(@RequestHeader("token") String token, @PathVariable("enterpriseId") String enterpriseId) throws RemoveException {
return enterpriseOfGridOperatorService.deleteEnterpriseOfGridOperatorByTokenAndEnterpriseId(token, enterpriseId);
}
@ApiOperation(value = "修改网格员的企业", notes = "修改网格员的企业接口")

View File

@ -77,6 +77,8 @@ public class EnterpriseOfGridOperatorDTO {
private String natureDictionaryName;
@ApiModelProperty(name = "isLogOffByEnterpriseId", value = "是否注销")
private Integer isLogOffByEnterpriseId;
@ApiModelProperty(name = "userCount", value = "绑定用户数")
private Integer userCount;
public String getEnterpriseOfGridOperatorId() {
return enterpriseOfGridOperatorId == null ? "" : enterpriseOfGridOperatorId;
@ -334,6 +336,14 @@ public class EnterpriseOfGridOperatorDTO {
this.isLogOffByEnterpriseId = isLogOffByEnterpriseId;
}
public Integer getUserCount() {
return userCount;
}
public void setUserCount(Integer userCount) {
this.userCount = userCount;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("{");
@ -401,6 +411,8 @@ public class EnterpriseOfGridOperatorDTO {
.append(natureDictionaryName).append('\"');
sb.append(",\"isLogOffByEnterpriseId\":")
.append(isLogOffByEnterpriseId);
sb.append(",\"userCount\":")
.append(userCount);
sb.append('}');
return sb.toString();
}

View File

@ -145,7 +145,7 @@ public class EnterpriseServiceImpl extends BaseService implements IEnterpriseSer
if (enterpriseDTO == null) {
throw new ParamsException("企业不存在");
}
if (StringUtils.isBlank(enterpriseDTO.getNature())) {
if (!StringUtils.isBlank(enterpriseDTO.getNature())) {
throw new ParamsException("企业已经绑定场所性质");
}
DataDictionaryDTO dataDictionaryDTO = dataDictionaryService.getDictionaryById(enterpriseNatureVO.getNatureId());

View File

@ -59,6 +59,26 @@ public interface IEnterpriseOfGridOperatorService {
*/
SuccessResult deleteEnterpriseOfGridOperator(String ids) throws RemoveException;
/**
* 删除网格员的企业(通过token, 企业ID物理)
*
* @param token
* @param enterpriseId
* @return
* @throws RemoveException
*/
SuccessResult deleteEnterpriseOfGridOperatorByTokenAndEnterpriseId(String token, String enterpriseId) throws RemoveException;
/**
* 删除网格员的企业(通过企业ID和用户ID物理)
*
* @param enterpriseId
* @param userId
* @return
* @throws RemoveException
*/
SuccessResult deleteEnterpriseOfGridOperatorByEnterpriseIdAndUserId(String enterpriseId, String userId) throws RemoveException;
/**
* 删除网格员的企业(APP)
*
@ -169,4 +189,5 @@ public interface IEnterpriseOfGridOperatorService {
* @throws SearchException
*/
List<GridPersonnelDTO> listGridPersonnel(Map<String, Object> params) throws SearchException;
}

View File

@ -10,6 +10,7 @@ import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList;
import com.cm.common.token.app.AppTokenManager;
import com.cm.common.token.app.entity.AppToken;
import com.cm.common.utils.HashMapUtil;
import com.cm.common.utils.UUIDUtil;
import com.cm.inspection.dao.enterpriseofgridoperator.IEnterpriseOfGridOperatorDao;
@ -90,6 +91,20 @@ public class EnterpriseOfGridOperatorServiceImpl extends BaseService implements
return new SuccessResult();
}
@Override
public SuccessResult deleteEnterpriseOfGridOperatorByTokenAndEnterpriseId(String token, String enterpriseId) throws RemoveException {
return deleteEnterpriseOfGridOperatorByEnterpriseIdAndUserId(enterpriseId, AppTokenManager.getInstance().getToken(token).getAppTokenUser().getId());
}
@Override
public SuccessResult deleteEnterpriseOfGridOperatorByEnterpriseIdAndUserId(String enterpriseId, String userId) throws RemoveException {
Map<String, Object> params = getHashMap(1);
params.put("enterpriseId", enterpriseId);
params.put("userId", userId);
enterpriseOfGridOperatorDao.deleteEnterpriseOfGridOperator(params);
return new SuccessResult();
}
@Override
public SuccessResult removeEnterpriseOfGridOperatorByToken(String token, String ids) throws RemoveException {
removeEnterpriseOfGridOperatorInfo(token, ids);

View File

@ -5,6 +5,7 @@
<resultMap id="enterpriseOfGridOperatorDTO" type="com.cm.inspection.pojo.dtos.enterpriseofgridoperator.EnterpriseOfGridOperatorDTO">
<id column="enterprise_of_grid_operator_id" property="enterpriseOfGridOperatorId"/>
<result column="user_id" property="userId"/>
<result column="user_count" property="userCount"/>
<result column="enterprise_id" property="enterpriseId"/>
<result column="name_join_by_enterprise_id" property="nameJoinByEnterpriseId"/>
<result column="type_join_by_enterprise_id" property="typeJoinByEnterpriseId"/>
@ -108,10 +109,17 @@
DELETE FROM
gen_enterprise_of_grid_operator
WHERE
<if test="enterpriseOfGridOperatorIds != null and enterpriseOfGridOperatorIds.size > 0">
enterprise_of_grid_operator_id IN
<foreach collection="enterpriseOfGridOperatorIds" index="index" open="(" separator="," close=")">
#{enterpriseOfGridOperatorIds[${index}]}
</foreach>
<foreach collection="enterpriseOfGridOperatorIds" index="index" open="(" separator="," close=")">
#{enterpriseOfGridOperatorIds[${index}]}
</foreach>
</if>
<if test="enterpriseId != null and enterpriseId != '' and userId != null and userId != ''">
enterprise_id = #{enterpriseId}
AND
user_id = #{userId}
</if>
</delete>
<!-- 修改网格员的企业 -->
@ -235,8 +243,8 @@
</if>
</select>
<!-- 网格员的企业列表通过用户ID -->
<select id="listEnterpriseOfGridOperatorByUserId" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
<!-- 网格员的企业列表通过用户ID,性能问题废弃 -->
<select id="listEnterpriseOfGridOperatorByUserIdDiscard" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
SELECT
t1.enterprise_id,
t1.name name_join_by_enterprise_id,
@ -313,6 +321,100 @@
</if>
</select>
<!-- 网格员的企业列表通过用户ID -->
<select id="listEnterpriseOfGridOperatorByUserId" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
SELECT
t1.enterprise_id,
t1.name name_join_by_enterprise_id,
t1.type type_join_by_enterprise_id,
t1.type_dictionary_name,
t1.area1 area1_join_by_enterprise_id,
t1.area1_dictionary_name,
t1.area2 area2_join_by_enterprise_id,
t1.area2_dictionary_name,
t1.area3 area3_join_by_enterprise_id,
t1.area3_dictionary_name,
t1.area4 area4_join_by_enterprise_id,
t1.area4_dictionary_name,
t1.area5 area5_join_by_enterprise_id,
t1.area5_dictionary_name,
t1.address address_join_by_enterprise_id,
t1.industry_type industry_type_join_by_enterprise_id,
t1.industry_type_dictionary_name,
t1.industry industry_join_by_enterprise_id,
t1.industry_dictionary_name,
t1.engaged_count engaged_count_join_by_enterprise_id,
t1.risk_operation risk_operation_join_by_enterprise_id,
t1.risk_operation_dictionary_name,
t1.legal_person,
t1.master master_join_by_enterprise_id,
t1.phone phone_join_by_enterprise_id,
t1.classify classify_by_enterprise_id,
t1.classify_dictionary_name,
t1.nature nature_by_enterprise_id,
t1.nature_dictionary_name,
t1.is_log_off is_log_off_by_enterprise_id,
(
SELECT
COUNT(*)
FROM
gen_enterprise_of_grid_operator st1
WHERE
st1.user_id = #{userId}
AND
t1.enterprise_id = st1.enterprise_id
) user_count
FROM
gen_enterprise t1
WHERE
t1.is_delete = 0
AND (
t1.enterprise_id IN (
SELECT
wt1.enterprise_id
FROM
gen_enterprise_of_grid_operator wt1
WHERE
wt1.user_id = #{userId}
) OR t1.enterprise_id NOT IN (
SELECT
wt2.enterprise_id
FROM
gen_enterprise_of_grid_operator wt2
GROUP BY
wt2.enterprise_id
)
)
<if test="area1 != null and area1 != ''">
AND
t1.area1 = #{area1}
</if>
<if test="area2 != null and area2 != ''">
AND
t1.area2 = #{area2}
</if>
<if test="area3 != null and area3 != ''">
AND
t1.area3 = #{area3}
</if>
<if test="area4 != null and area4 != ''">
AND
t1.area4 = #{area4}
</if>
<if test="area5 != null and area5 != ''">
AND
t1.area5 = #{area5}
</if>
<if test="keywords != null and keywords != ''">
AND
t1.name LIKE CONCAT('%', #{keywords}, '%')
</if>
<if test="type != null and type != ''">
AND
t1.type = #{type}
</if>
</select>
<!-- 网格员的企业列表通过用户ID和企业ID -->
<select id="listEnterpriseOfGridOperatorByUserIdAndEnterpriseId" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
SELECT

View File

@ -325,8 +325,8 @@
},
{field: 'operation', width: 100, title: '操作', fixed: 'right', align: 'center',
templet: function(row) {
var userId = row.userId;
if(typeof(userId) === 'undefined' || userId == null || userId == '') {
var userCount = row.userCount;
if(typeof(userCount) === 'undefined' || userCount == null || userCount == 0) {
return '<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="claimEvent">认领企业</button>';
}
return '<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="relieveEvent">解除认领</button>';
@ -388,7 +388,7 @@
top.dialog.msg(data.msg);
});
} else if(layEvent === 'relieveEvent') {
top.restAjax.delete(top.restAjax.path('api/enterpriseofgridoperator/deleteenterpriseofgridoperator/{id}', [data.enterpriseOfGridOperatorId]), {}, null, function (code, data) {
top.restAjax.delete(top.restAjax.path('api/enterpriseofgridoperator/deleteenterpriseofgridoperator/{enterpriseId}/{userId}', [data.enterpriseId, userId]), {}, null, function (code, data) {
top.dialog.msg('解除成功', {time: 1000});
reloadTable();
}, function (code, data) {