Commit 0681b859 authored by KeYong's avatar KeYong

Merge remote-tracking branch 'origin/dev_upgrade' into dev_upgrade

parents 1b136b63 cad29b4e
package com.yeejoin.amos.fas.business.controller;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.fas.business.feign.JcsFeign;
import com.yeejoin.amos.fas.business.service.intfc.IDictService;
import com.yeejoin.amos.fas.business.service.intfc.IEmergencyTaskService;
import com.yeejoin.amos.fas.business.vo.EmergencyRelationVo;
import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.dao.entity.Dict;
import com.yeejoin.amos.fas.dao.entity.EmergencyRelation;
import com.yeejoin.amos.fas.dao.entity.EmergencyRelationTree;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Page;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
......@@ -15,6 +19,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
......@@ -29,6 +34,8 @@ import java.util.stream.Collectors;
public class EmergencyTaskController extends BaseController{
@Autowired
JcsFeign jcsFeign;
@Autowired
IEmergencyTaskService iEmergencyTaskService;
@Autowired
private IDictService dictService;
......@@ -50,7 +57,13 @@ public class EmergencyTaskController extends BaseController{
tree.setChildren(treeNodes.stream().filter(t->t.getObligationId().equals(e.getId())).collect(Collectors.toList()));
list.add(tree);
});
return CommonResponseUtil.success(list);
EmergencyRelationTree tree = new EmergencyRelationTree();
tree.setId(0);
tree.setName("全部");
tree.setType("3");
tree.setCode("0");
tree.setChildren(list);
return CommonResponseUtil.success(tree);
}
......@@ -61,6 +74,9 @@ public class EmergencyTaskController extends BaseController{
if (pageNumber >=1 ){
pageNumber = pageNumber -1 ;
}
if(obligationId == 0){
obligationId = null;
}
CommonPageable commonPageable = new CommonPageable(pageNumber, pageSize);
Page<EmergencyTaskContent> list = iEmergencyTaskService.list(obligationId,commonPageable);
return CommonResponseUtil.success(list);
......@@ -77,12 +93,58 @@ public class EmergencyTaskController extends BaseController{
@ApiOperation(httpMethod = "POST",value = "新增树人员节点", notes = "新增树人员节点")
@PostMapping(value = "/savePerson", produces = "application/json;charset=UTF-8")
public CommonResponse savePerson(@RequestBody EmergencyRelation emergencyRelation){
public CommonResponse savePerson(@RequestBody EmergencyRelationVo vo){
List<Long> personIds = vo.getPersonIds();
List<Object> objects = jcsFeign.listCompanyByIds(personIds);
objects.forEach(e->
{
String json = JSONObject.toJSONString(e);
JSONObject jsonObject = JSONObject.parseObject(json);
EmergencyRelation emergencyRelation = new EmergencyRelation();
emergencyRelation.setObligationId(vo.getObligationId());
emergencyRelation.setPersonId(Long.valueOf(jsonObject.get("sequenceNbr").toString()));
emergencyRelation.setPersonName(jsonObject.get("bizOrgName").toString());
emergencyRelation.setAmosOrgId(Long.valueOf(jsonObject.get("amosOrgId").toString()));
emergencyRelation.setCreateDate(new Date());
iEmergencyTaskService.save(emergencyRelation);
}
);
return CommonResponseUtil.success();
}
@ApiOperation(httpMethod = "POST",value = "编辑树人员节点", notes = "编辑树人员节点")
@PostMapping(value = "/editPerson", produces = "application/json;charset=UTF-8")
public CommonResponse editPerson(@RequestBody EmergencyRelationVo vo){
this.deleteTreeNode(vo.getObligationId(), null);
List<Long> personIds = vo.getPersonIds();
List<Object> objects = jcsFeign.listCompanyByIds(personIds);
objects.forEach(e->
{
String json = JSONObject.toJSONString(e);
JSONObject jsonObject = JSONObject.parseObject(json);
EmergencyRelation emergencyRelation = new EmergencyRelation();
emergencyRelation.setObligationId(vo.getObligationId());
emergencyRelation.setPersonId(Long.valueOf(jsonObject.get("sequenceNbr").toString()));
emergencyRelation.setPersonName(jsonObject.get("bizOrgName").toString());
emergencyRelation.setAmosOrgId(Long.valueOf(jsonObject.get("amosOrgId").toString()));
emergencyRelation.setCreateDate(new Date());
iEmergencyTaskService.save(emergencyRelation);
}
);
return CommonResponseUtil.success();
}
@ApiOperation(httpMethod = "GET",value = "获取当前节点绑定人员", notes = "获取当前节点绑定人员")
@RequestMapping(value = "/getPersons", method = RequestMethod.GET)
public CommonResponse getPersons(@RequestParam Long obligationId){
EmergencyRelationVo emergencyRelationVo = new EmergencyRelationVo();
emergencyRelationVo.setPersonIds(iEmergencyTaskService.getPersonIds(obligationId));
return CommonResponseUtil.success(emergencyRelationVo);
}
}
......@@ -18,5 +18,8 @@ public interface EmergencyTaskMapper extends BaseMapper {
List<String> roleCodes(String amosOrgId);
List<Long> getPersonIds(Long obligationId);
List<String> roleNames(String amosOrgId);
}
......@@ -6,6 +6,8 @@ import com.yeejoin.amos.fas.core.util.ResponseModel;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 消息推送
......@@ -35,4 +37,7 @@ public interface JcsFeign {
@RequestMapping(value = "/jcs/common/duty-person/person/on_duty/list", method = RequestMethod.GET,consumes = "application/json")
ResponseModel dutyPersonList();
@RequestMapping(value = "/jcs//org-person/listCompanyByIds", method = RequestMethod.GET,consumes = "application/json")
List<Object> listCompanyByIds(@RequestParam List<Long> ids);
}
......@@ -58,4 +58,10 @@ public class EmergencyTaskServiceImpl implements IEmergencyTaskService {
String roleNames = String.join(",", list);
return roleNames;
}
@Override
public List<Long> getPersonIds(Long obligationId) {
return emergencyTaskMapper.getPersonIds(obligationId);
}
}
......@@ -21,6 +21,8 @@ public interface IEmergencyTaskService {
String getRolesByUserId(String userId);
List<Long> getPersonIds(Long obligationId);
String getRolesNameByUserId(String userId);
}
package com.yeejoin.amos.fas.business.vo;
import lombok.Data;
import java.util.List;
@Data
public class EmergencyRelationVo {
//职责id
private Long obligationId;
//人员id
private List<Long> personIds;
}
......@@ -13,7 +13,7 @@
FROM
c_emergency_task_content
<where>
<if test="_parameter != null ">
<if test="obligationId != null ">
obligation_id = #{obligationId}
</if>
</where>
......@@ -57,7 +57,6 @@
cer.amos_id = #{amosOrgId}
</if>
</where>
</select>
<select id="roleNames" resultType="string">
......@@ -70,17 +69,38 @@
cer.amos_id = #{amosOrgId}
</if>
</where>
</select>
<select id="getPersonIds" resultType="long">
SELECT
cer.person_id AS persons
FROM
c_emergency_relation cer
<where>
<if test="_parameter != null ">
cer.obligationId = #{obligationId}
</if>
</where>
</select>
<delete id="deleteTreeNode">
delete from c_emergency_relation where obligationId = #{obligationId} and person_id = #{personId}
delete from c_emergency_relation cer
<where>
<if test="obligationId != null ">
cer.obligationId = #{obligationId}
</if>
<if test="personId != null ">
and cer.person_id = #{personId}
</if>
</where>
</delete>
<insert id="save" parameterType="com.yeejoin.amos.fas.dao.entity.EmergencyRelation">
INSERT INTO `c_emergency_relation`(id, `obligationId`, `person_id`, `amos_id`, `person_name`)
VALUES (#{id}, #{obligationId}, #{personId}, #{amosOrgId}, #{personName});
INSERT INTO `c_emergency_relation`(id, `obligationId`, `person_id`, `amos_id`, `person_name`, `create_date`)
VALUES (#{id}, #{obligationId}, #{personId}, #{amosOrgId}, #{personName},#{createDate});
</insert>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment