|  |  |  | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.ComSwDangerReportVO; | 
|---|
|  |  |  | import com.panzhihua.common.model.vos.community.ComSwSafetyWorkRecordVO; | 
|---|
|  |  |  | import com.panzhihua.common.service.user.UserService; | 
|---|
|  |  |  | import com.panzhihua.common.utlis.DateUtils; | 
|---|
|  |  |  | import com.panzhihua.common.utlis.StringUtils; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComSwDangerReportDAO; | 
|---|
|  |  |  | import com.panzhihua.service_community.dao.ComSwPatrolRecordDAO; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  | import java.text.SimpleDateFormat; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Arrays; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @auther txb | 
|---|
|  |  |  | 
|---|
|  |  |  | IPage<ComSwDangerReportVO> iPage = comSwDangerReportDAO.pageDangerReport(page, comSwPatrolRecordPageDTO); | 
|---|
|  |  |  | if (!iPage.getRecords().isEmpty()) { | 
|---|
|  |  |  | iPage.getRecords().forEach(comSwDangerReportVO -> { | 
|---|
|  |  |  | if (StringUtils.isNotEmpty(comSwDangerReportVO.getAssignPerson())) { | 
|---|
|  |  |  | comSwDangerReportVO.setIsAssign(ComSwDangerReportVO.isOk.no); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | if (StringUtils.isNotEmpty(comSwDangerReportVO.getStatus()) && "2".equals(comSwDangerReportVO.getStatus())) { | 
|---|
|  |  |  | comSwDangerReportVO.setIsAssign(ComSwDangerReportVO.isOk.yes); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | comSwDangerReportVO.setIsAssign(ComSwDangerReportVO.isOk.no); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | StringBuilder patrolNameString = new StringBuilder(); | 
|---|
|  |  |  | StringBuilder patrolPhoneString = new StringBuilder(); | 
|---|
|  |  |  | //巡查人员id查询巡查人员的名字和电话 | 
|---|
|  |  |  | if(StringUtils.isNotEmpty(comSwDangerReportVO.getPatrolPerson())){ | 
|---|
|  |  |  | String[] patrolIds = comSwDangerReportVO.getPatrolPerson().split(","); | 
|---|
|  |  |  | for (int i = 0; i < patrolIds.length ; i++) { | 
|---|
|  |  |  | Map<String,String> leader = comSwPatrolRecordDAO.getPbServiceTeamById(patrolIds[i]); | 
|---|
|  |  |  | if(leader != null){ | 
|---|
|  |  |  | if(i != 0){ | 
|---|
|  |  |  | patrolNameString.append(","); | 
|---|
|  |  |  | patrolPhoneString.append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | patrolNameString.append(leader.get("name")); | 
|---|
|  |  |  | patrolPhoneString.append(leader.get("phone")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | comSwDangerReportVO.setPPersonName(patrolNameString.toString()); | 
|---|
|  |  |  | comSwDangerReportVO.setPPersonPhone(patrolPhoneString.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //整改人员id查询整改人员的名字和电话 | 
|---|
|  |  |  | StringBuilder dangerNameString = new StringBuilder(); | 
|---|
|  |  |  | StringBuilder dangerPhoneString = new StringBuilder(); | 
|---|
|  |  |  | if(StringUtils.isNotEmpty(comSwDangerReportVO.getRectifyPerson())){ | 
|---|
|  |  |  | String[] dangerIds = comSwDangerReportVO.getRectifyPerson().split(","); | 
|---|
|  |  |  | for (int i = 0; i < dangerIds.length ; i++) { | 
|---|
|  |  |  | Map<String,String> person = comSwPatrolRecordDAO.getPbServiceTeamById(dangerIds[i]); | 
|---|
|  |  |  | if(person != null){ | 
|---|
|  |  |  | if(i != 0){ | 
|---|
|  |  |  | dangerNameString.append(","); | 
|---|
|  |  |  | dangerPhoneString.append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | dangerNameString.append(person.get("name")); | 
|---|
|  |  |  | dangerPhoneString.append(person.get("phone")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | comSwDangerReportVO.setDPersonName(dangerNameString.toString()); | 
|---|
|  |  |  | comSwDangerReportVO.setDPersonPhone(dangerPhoneString.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | comSwDangerReportVO.setPatrolType(sb.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询人员信息 | 
|---|
|  |  |  | //查询整改人员信息 | 
|---|
|  |  |  | if(StringUtils.isNotEmpty(comSwDangerReportVO.getRectifyPerson())){ | 
|---|
|  |  |  | StringBuilder sb = new StringBuilder(); | 
|---|
|  |  |  | String personIds[] = comSwDangerReportVO.getRectifyPerson().split(","); | 
|---|
|  |  |  | 
|---|
|  |  |  | comSwDangerReportVO.setAssignPersonName(sb.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询巡查人员 | 
|---|
|  |  |  | Map<String,String> map = comSwPatrolRecordDAO.getPatrolPersonName(comSwDangerReportVO.getId()); | 
|---|
|  |  |  | if(map != null){ | 
|---|
|  |  |  | comSwDangerReportVO.setPatrolName(map.get("person_name")); | 
|---|
|  |  |  | StringBuilder patrolNameString = new StringBuilder(); | 
|---|
|  |  |  | StringBuilder patrolPhoneString = new StringBuilder(); | 
|---|
|  |  |  | //巡查人员id查询巡查人员的名字和电话 | 
|---|
|  |  |  | if(StringUtils.isNotEmpty(comSwDangerReportVO.getPatrolPerson())){ | 
|---|
|  |  |  | String[] patrolIds = comSwDangerReportVO.getPatrolPerson().split(","); | 
|---|
|  |  |  | for (int i = 0; i < patrolIds.length ; i++) { | 
|---|
|  |  |  | Map<String,String> leader = comSwPatrolRecordDAO.getPbServiceTeamById(patrolIds[i]); | 
|---|
|  |  |  | if(leader != null){ | 
|---|
|  |  |  | if(i != 0){ | 
|---|
|  |  |  | patrolNameString.append(","); | 
|---|
|  |  |  | patrolPhoneString.append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | patrolNameString.append(leader.get("name")); | 
|---|
|  |  |  | patrolPhoneString.append(leader.get("phone")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | comSwDangerReportVO.setPPersonName(patrolNameString.toString()); | 
|---|
|  |  |  | comSwDangerReportVO.setPPersonPhone(patrolPhoneString.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //整改人员id查询整改人员的名字和电话 | 
|---|
|  |  |  | StringBuilder dangerNameString = new StringBuilder(); | 
|---|
|  |  |  | StringBuilder dangerPhoneString = new StringBuilder(); | 
|---|
|  |  |  | if(StringUtils.isNotEmpty(comSwDangerReportVO.getRectifyPerson())){ | 
|---|
|  |  |  | String[] dangerIds = comSwDangerReportVO.getRectifyPerson().split(","); | 
|---|
|  |  |  | for (int i = 0; i < dangerIds.length ; i++) { | 
|---|
|  |  |  | Map<String,String> person = comSwPatrolRecordDAO.getPbServiceTeamById(dangerIds[i]); | 
|---|
|  |  |  | if(person != null){ | 
|---|
|  |  |  | if(i != 0){ | 
|---|
|  |  |  | dangerNameString.append(","); | 
|---|
|  |  |  | dangerPhoneString.append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | dangerNameString.append(person.get("name")); | 
|---|
|  |  |  | dangerPhoneString.append(person.get("phone")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | comSwDangerReportVO.setDPersonName(dangerNameString.toString()); | 
|---|
|  |  |  | comSwDangerReportVO.setDPersonPhone(dangerPhoneString.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok(comSwDangerReportVO); | 
|---|
|  |  |  | 
|---|
|  |  |  | BeanUtils.copyProperties(comSwDangerReportDO, comSwDangerReportVO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BeanUtils.copyProperties(comSwPatrolRecordDO, comSwDangerReportVO); | 
|---|
|  |  |  | StringBuilder patrolNameString = new StringBuilder(); | 
|---|
|  |  |  | StringBuilder patrolPhoneString = new StringBuilder(); | 
|---|
|  |  |  | //巡查人员id查询巡查人员的名字和电话 | 
|---|
|  |  |  | if(StringUtils.isNotEmpty(comSwDangerReportVO.getPatrolPerson())){ | 
|---|
|  |  |  | String[] patrolIds = comSwDangerReportVO.getPatrolPerson().split(","); | 
|---|
|  |  |  | for (int i = 0; i < patrolIds.length ; i++) { | 
|---|
|  |  |  | Map<String,String> leader = comSwPatrolRecordDAO.getPbServiceTeamById(patrolIds[i]); | 
|---|
|  |  |  | if(leader != null){ | 
|---|
|  |  |  | if(i != 0){ | 
|---|
|  |  |  | patrolNameString.append(","); | 
|---|
|  |  |  | patrolPhoneString.append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | patrolNameString.append(leader.get("name")); | 
|---|
|  |  |  | patrolPhoneString.append(leader.get("phone")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | comSwDangerReportVO.setPPersonName(patrolNameString.toString()); | 
|---|
|  |  |  | comSwDangerReportVO.setPPersonPhone(patrolPhoneString.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //整改人员id查询整改人员的名字和电话 | 
|---|
|  |  |  | StringBuilder dangerNameString = new StringBuilder(); | 
|---|
|  |  |  | StringBuilder dangerPhoneString = new StringBuilder(); | 
|---|
|  |  |  | if(StringUtils.isNotEmpty(comSwDangerReportVO.getRectifyPerson())){ | 
|---|
|  |  |  | String[] dangerIds = comSwDangerReportVO.getRectifyPerson().split(","); | 
|---|
|  |  |  | for (int i = 0; i < dangerIds.length ; i++) { | 
|---|
|  |  |  | Map<String,String> person = comSwPatrolRecordDAO.getPbServiceTeamById(dangerIds[i]); | 
|---|
|  |  |  | if(person != null){ | 
|---|
|  |  |  | if(i != 0){ | 
|---|
|  |  |  | dangerNameString.append(","); | 
|---|
|  |  |  | dangerPhoneString.append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | dangerNameString.append(person.get("name")); | 
|---|
|  |  |  | dangerPhoneString.append(person.get("phone")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | comSwDangerReportVO.setDPersonName(dangerNameString.toString()); | 
|---|
|  |  |  | comSwDangerReportVO.setDPersonPhone(dangerPhoneString.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(comSwDangerReportVO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BeanUtils.copyProperties(comSwDangerReportHandleDTO, comSwDangerReportDO); | 
|---|
|  |  |  | comSwDangerReportDO.setStatus(String.valueOf(SafeWordStatusEnum.YCL.getCode())); | 
|---|
|  |  |  | ComSwDangerReportDO comSwDangerReportDO1 = comSwDangerReportDAO.selectById(comSwDangerReportHandleDTO.getDangerReportId()); | 
|---|
|  |  |  | if (!comSwDangerReportDO1.getStatus().equals(String.valueOf(SafeWordStatusEnum.DCL.getCode()))) { | 
|---|
|  |  |  | return R.fail("该隐患报告已处理,请勿重复操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int update = comSwDangerReportDAO.updateById(comSwDangerReportDO); | 
|---|
|  |  |  | if (update > 0) { | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BeanUtils.copyProperties(comSwDangerReportRectifyDTO, comSwDangerReportDO); | 
|---|
|  |  |  | comSwDangerReportDO.setStatus(String.valueOf(SafeWordStatusEnum.YZG.getCode())); | 
|---|
|  |  |  | comSwDangerReportDO.setRectifyTime(DateUtils.getCurrentDateStr()); | 
|---|
|  |  |  | ComSwDangerReportDO comSwDangerReportDO1 = comSwDangerReportDAO.selectById(comSwDangerReportRectifyDTO.getDangerReportId()); | 
|---|
|  |  |  | if (comSwDangerReportDO1.getStatus().equals(String.valueOf(SafeWordStatusEnum.YZG.getCode()))) { | 
|---|
|  |  |  | return R.fail("该隐患报告已整改,请勿重复操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int update = comSwDangerReportDAO.updateById(comSwDangerReportDO); | 
|---|
|  |  |  | if (update > 0) { | 
|---|
|  |  |  | return R.ok(); | 
|---|