package com.sooka.sponest.mobile.comprehensive.personBasicInfoController; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.core.constant.HttpStatus; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.page.PageDomain; import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.core.web.page.TableSupport; import com.ruoyi.common.security.utils.DictUtils; import com.sooka.sponest.comprehensive.api.comprehensivePersonBasicInfo.domain.OtherPersonInfo; import com.sooka.sponest.comprehensive.api.comprehensivePersonBasicInfo.domain.PersonBasicInfo; import com.sooka.sponest.comprehensive.api.comprehensivePersonBasicInfo.service.RemotePersonBasicInfoService; import com.ruoyi.common.core.domain.DictKeys; import com.sooka.sponest.data.api.digitalenvironment.domain.EnvironmentBiggas; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.*; /** * @Author LG * @Date 2023/9/8 - 9:38 */ @RestController @RequestMapping("/AppPersonBasicInfoController") public class AppPersonBasicInfoController { @Resource private RemotePersonBasicInfoService personBasicInfoService; /** * 查询大气监测点/水质监测点/污染源监测点管理列表 */ @GetMapping("/PersonBasicInfo/list") public AjaxResult list(PersonBasicInfo info) { PageDomain pageDomain = TableSupport.buildPageRequest(); Integer pageNum = pageDomain.getPageNum(); Integer pageSize = pageDomain.getPageSize(); Integer delFlag = info.getDelFlag(); return AjaxResult.success(personBasicInfoService.getList(pageNum, pageSize, delFlag).getRows()); } /** * 获取重点企业详细信息 */ @GetMapping("/PersonBasicInfo/edit") public AjaxResult getInfo(EnvironmentBiggas biggas) { AjaxResult ajaxResult = personBasicInfoService.getEdit(biggas.getId()); if ("200".equals(ajaxResult.get("code").toString())) { Map data = (Map) ajaxResult.get("data"); HashMap basicInfo = (HashMap) data.get("basicInfo"); setPersonBasicInfo(basicInfo); List> userBinds = (List>) basicInfo.get("userBinds"); ArrayList> otherInfo = (ArrayList>) data.get("otherInfo"); Map result = new HashMap<>(); result.put("basicInfo",data.get("basicInfo")); userBinds.forEach(bind -> { otherInfo.stream() .filter(info -> info.get("id").equals(bind.get("otherPersonId"))) .findFirst() .ifPresent(info -> setLabel(info, (Integer) bind.get("otherPersonType"))); }); otherInfo.forEach(bind ->{ switch(String.valueOf(bind.get("otherPersonType"))){ case "1": result.put("registeredPopulation", bind); break; case "2": result.put("floatingPopulation", bind); break; case "3": result.put("leftBehindPerson", bind); break; case "4": result.put("campusAroundPerson", bind); break; case "5": result.put("prisonReleased", bind); break; case "6": result.put("communityCorrectionStaff", bind); break; case "7": result.put("psychosisPopulation", bind); break; case "8": result.put("drugAddict", bind); break; case "9": result.put("aidsRisk", bind); break; case "10": result.put("keyYouth", bind); break; } }); return AjaxResult.success(result); } else { return ajaxResult; } } private void setLabel(HashMap json, Integer type) { switch (type) { case 1: setRegisteredPopulation(json); break; case 2: setFloatingPopulation(json); break; case 3: setLeftBehindPerson(json); break; case 4: setCampusAroundPerson(json); break; case 5: setPrisonReleased(json); break; case 6: setCommunityCorrectionStaff(json); break; case 7: setPsychosisPopulation(json); break; case 8: setDrugAddict(json); break; case 9: setAidsRisk(json); break; case 10: setKeyYouth(json); break; } json.put("otherPersonType", type); } /** * 新增重点企业 */ @PostMapping("/PersonBasicInfo") public AjaxResult add(@RequestBody String json) { return personBasicInfoService.add(dataToList(json)); } /** * 修改重点企业 */ @PostMapping("/PersonBasicInfo/put") public AjaxResult edit(@RequestBody String json) { return personBasicInfoService.edit(dataToList(json)); } private String dataToList(String json){ JSONObject jsonObject = JSONObject.parseObject(json); Set strings = jsonObject.keySet(); JSONArray list = new JSONArray(); list.add(jsonObject.getJSONObject("basicInfo")); strings.remove("basicInfo"); for (String string : strings) { list.add(jsonObject.getJSONObject(string)); } return JSONArray.toJSONString(list); } /** * 删除重点企业 */ @GetMapping("/PersonBasicInfo/del") public AjaxResult remove(@RequestParam("id") List id) { return personBasicInfoService.del(id.toArray(new String[0])); } // private void setPersonBasicInfo(JSONObject basicInfo){ private void setPersonBasicInfo(HashMap basicInfo) {//0 basicInfo.put("genderLabel", getDictData("comprehensive_sex", String.valueOf(basicInfo.get("gender"))));//性别字典值 basicInfo.put("nationLabel", getDictData("comprehensive_nation", String.valueOf(basicInfo.get("nation"))));//民族字典值 basicInfo.put("maritalStatusLabel", getDictData("comprehensive_marital_status", String.valueOf(basicInfo.get("maritalStatus"))));//婚姻状况字典值 basicInfo.put("educationLabel", getDictData("comprehensive_educational_background", String.valueOf(basicInfo.get("education"))));//学历字典值 basicInfo.put("religiousBeliefLabel", null == basicInfo.get("religiousBelief") ? null : getDictData("comprehensive_religious_belief", String.valueOf(basicInfo.get("religiousBelief"))));//宗教信仰字典值 basicInfo.put("politicalOutlookLabel", getDictData("comprehensive_political_status", String.valueOf(basicInfo.get("politicalOutlook"))));//政治面貌字典值 basicInfo.put("occupationalCategoryLabel", getDictData("comprehensive_occupational_category", String.valueOf(basicInfo.get("occupationalCategory"))));//职业类别字典值 } private void setRegisteredPopulation(HashMap json) {//1 json.put("entryIdentityLabel", getDictData(DictKeys.COMPREHENSIVE_HOUSEHOLDS_IDENTIFICATION, String.valueOf(json.get("entryIdentity"))));//人户一致标识 json.put("accountRelationshipLabel", getDictData("comprehensive_relation", String.valueOf(json.get("accountRelationship"))));//与户主关系 } private void setFloatingPopulation(HashMap json) {//2 json.put("inflowCauselabel", getDictData("comprehensive_inflow_reason", String.valueOf(json.get("inflowCause"))));//流入原因 json.put("focusPeopleLabel", "1".equals(json.get("focusPeople")) ? "是" : "否");//是否重点关注人员 json.put("certificationTypeLabel", null == json.get("certificationType") ? null : getDictData(DictKeys.COMPREHENSIVE_CERTIFICATION_TYPE, String.valueOf(json.get("certificationType"))));//办证类型 json.put("domicileTypeLabel", getDictData(DictKeys.COMPREHENSIVE_RESIDENCE_TYPE, String.valueOf(json.get("domicileType"))));//住所类型 } private void setLeftBehindPerson(HashMap json) {//3 json.put("entryIdentityLabel", getDictData(DictKeys.COMPREHENSIVE_HOUSEHOLDS_IDENTIFICATION, String.valueOf(json.get("entryIdentity"))));//人户一致标识 json.put("leftBehindTypeLabel", getDictData(DictKeys.COMPREHENSIVE_LEFT_BEHIND_PERSONNEL_TYPE, String.valueOf(json.get("leftBehindType"))));//留守人员类型 json.put("healthStatusLabel", null == json.get("healthStatus") ? null : getDictData(DictKeys.COMPREHENSIVE_HEALTH_STATUS, String.valueOf(json.get("healthStatus"))));//健康状况 json.put("leftBehindRelationshipLabel", getDictData("comprehensive_relation", String.valueOf(json.get("leftBehindRelationship"))));//与留守人员关系 json.put("keyFamilyHealthStatusLabel", null == json.get("keyFamilyHealthStatus") ? null : getDictData(DictKeys.COMPREHENSIVE_HEALTH_STATUS, String.valueOf(json.get("keyFamilyHealthStatus"))));//家庭主要成员健康状况 } private void setCampusAroundPerson(HashMap json) {//4 json.put("harmLevelLabel", getDictData(DictKeys.COMPREHENSIVE_DEGREE_OF_HARM, String.valueOf(json.get("harmLevel"))));//危害程度 json.put("focusPeopleLabel", "1".equals(json.get("focusPeople")) ? "是" : "否");//是否关注 } private void setPrisonReleased(HashMap json) {//5 json.put("originalChargeLabel", getDictData(DictKeys.COMPREHENSIVE_OFFENCES_CLASSIFICATION, String.valueOf(json.get("originalCharge"))));//原罪名 json.put("recidivismLabel", "1".equals(json.get("recidivism")) ? "是" : "否");//是否累犯 json.put("riskAssessmentTypeLabel", getDictData(DictKeys.COMPREHENSIVE_HAZARD_ASSESSMENT_TYPE, String.valueOf(json.get("riskAssessmentType"))));//危险性评估类型 json.put("linkUpStatusLabel", getDictData(DictKeys.COMPREHENSIVE_CONNECTION, String.valueOf(json.get("linkUpStatus"))));//衔接情况 json.put("placementStatusLabel", getDictData(DictKeys.COMPREHENSIVE_PLACEMENT, String.valueOf(json.get("placementStatus"))));//安置情况 json.put("reoffendLabel", "1".equals(json.get("reoffend")) ? "是" : "否");//是否重新犯罪 } private void setCommunityCorrectionStaff(HashMap json) {//6 json.put("caseCategoryLabel", getDictData("comprehensive_case_category", String.valueOf(json.get("caseCategory"))));//案件类别 json.put("correctiveReleaseTypeLabel", null == json.get("correctiveReleaseType") ? null : getDictData(DictKeys.COMPREHENSIVE_CORRECTIVE_RELEASE_TYPE, String.valueOf(json.get("correctiveReleaseType"))));//矫正解除(终止)类型 json.put("receivingModeLabel", getDictData(DictKeys.COMPREHENSIVE_RECEIVING_METHOD, String.valueOf(json.get("receivingMode"))));//接收方式 json.put("correctionClassLabel", getDictData(DictKeys.COMPREHENSIVE_CORRECTIVE_CATEGORY, String.valueOf(json.get("correctionClass"))));//矫正类别 json.put("tubeLabel", "1".equals(json.get("tube")) ? "是" : "否");//是否有脱管 json.put("leakingPipesLabel", "1".equals(json.get("leakingPipes")) ? "是" : "否");//是否有漏管 json.put("recidivismLabel", null == json.get("recidivism") ? null : "1".equals(json.get("recidivism")) ? "是" : "否");//是否累惯犯 json.put("establishCorrectionTeamLabel", "1".equals(json.get("establishCorrectionTeam")) ? "是" : "否");//是否建立矫正小组 json.put("reoffendLabel", "1".equals(json.get("reoffend")) ? "是" : "否");//是否重新犯罪 json.put("fourHistoriesListLabel", getDictDataList(DictKeys.COMPREHENSIVE_THREE_INVOLVED_SITUATION, (List) json.get("fourHistoriesList")));//“四史”情况 json.put("threeStepListLabel", getDictDataList("comprehensive_three_involved_situation", (List) json.get("threeStepList")));//“三涉”情况 json.put("correctionTeamCompositionListLabel", getDictDataList(DictKeys.COMPREHENSIVE_CORRECTIONS_TEAM_COMPOSITION_TYPE, (List) json.get("correctionTeamCompositionList")));//矫正小组人员组成情况 } private void setPsychosisPopulation(HashMap json) {//7 json.put("familyEconomicSituationLabel", null == json.get("familyEconomicSituationLabel") ? null : getDictData(DictKeys.COMPREHENSIVE_HOUSEHOLDS_FINANCIAL_SITUATION, String.valueOf(json.get("familyEconomicSituationLabel"))));//家庭经济状况 json.put("subsistenceAllowanceLabel", "1".equals(json.get("subsistenceAllowance")) ? "是" : "否");//是否纳入低保 json.put("diagnosisTypeLabel", getDictData(DictKeys.COMPREHENSIVE_CURRENT_DIAGNOSTIC, String.valueOf(json.get("diagnosisType"))));//目前诊断类型 json.put("historyCausingAccidentsLabel", "1".equals(json.get("historyCausingAccidents")) ? "有" : "无");//有无肇事肇祸史 json.put("riskAssessmentLevelLabel", getDictData(DictKeys.COMPREHENSIVE_HAZARD_ASSESSMENT, String.valueOf(json.get("riskAssessmentLevel"))));//目前危险性评估等级 json.put("treatmentSituationLabel", getDictData(DictKeys.COMPREHENSIVE_TREATMENT_CONDITIONS, String.valueOf(json.get("treatmentSituation"))));//治疗情况 json.put("reasonsHospitalizationListLabel", getDictDataList(DictKeys.COMPREHENSIVE_HOSPITALIZATION_REASONS, (List) json.get("reasonsHospitalizationList")));//实施住院治疗原因 json.put("participatingManagersListLabel", getDictDataList(DictKeys.COMPREHENSIVE_MANAGERS, (List) json.get("participatingManagersList")));//参与管理人员 json.put("assistanceSituationListLabel", getDictDataList(DictKeys.COMPREHENSIVE_HELP_SITUATION, (List) json.get("assistanceSituationList")));//帮扶情况 } private void setDrugAddict(HashMap json) {//8 json.put("controlSituationLabel", getDictData(DictKeys.COMPREHENSIVE_GOVERNANCE, String.valueOf(json.get("controlSituation"))));//管控情况 json.put("criminalHistoryLabel", null == json.get("criminalHistory") ? null : "1".equals(json.get("criminalHistory")) ? "有" : "无");//有无犯罪史 json.put("drugUseLabel", getDictData("comprehensive_case_consequence", String.valueOf(json.get("drugUse"))));//吸毒原因 json.put("drugAbuseLabel", null == json.get("drugAbuse") ? null : getDictData("comprehensive_case_consequence", String.valueOf(json.get("drugAbuse"))));//吸毒后果 } private void setAidsRisk(HashMap json) {//9 json.put("routeInfectionLabel", getDictData(DictKeys.COMPREHENSIVE_ROUTE_OF_INFECTION, String.valueOf(json.get("routeInfection"))));//感染途径 json.put("criminalHistoryLabel", "1".equals(json.get("criminalHistory")) ? "是" : "否");//是否有违法犯罪史 json.put("caseCategoryLabel", null == json.get("caseCategory") ? null : getDictData("comprehensive_case_category", String.valueOf(json.get("caseCategory"))));//案件类别 json.put("concernTypeLabel", getDictData(DictKeys.COMPREHENSIVE_TYPE_OF_CONCERN, String.valueOf(json.get("concernType"))));//关注类型 json.put("admissionSituationLabel", null == json.get("admissionSituation") ? null : getDictData(DictKeys.COMPREHENSIVE_ADMISSION_TO_INERTIA, String.valueOf(json.get("admissionSituation"))));//收治情况 } private void setKeyYouth(HashMap json) {//10 json.put("personTypeLabel", null == json.get("personType") ? null : getDictData(DictKeys.COMPREHENSIVE_TYPE_OF_PERSON, String.valueOf(json.get("personType"))));//人员类型 json.put("familySituationLabel", getDictData(DictKeys.COMPREHENSIVE_FAMILY_INERTIA, String.valueOf(json.get("familySituation"))));//家庭情况 json.put("guardianRelationLabel", getDictData("comprehensive_relation", String.valueOf(json.get("guardianRelation"))));//与监护人关系 json.put("reoffendLabel", "1".equals(json.get("reoffend")) ? "是" : "否");//是否违法犯罪 json.put("meansAssistanceLabel", getDictData(DictKeys.COMPREHENSIVE_MEANS_OF_HELP, String.valueOf(json.get("meansAssistance"))));//帮扶手段 } private String getDictData(String dictKey, String value) { return DictUtils.getDictDataByValue(dictKey, value); } private List getDictDataList(String dictKey, List values) { return DictUtils.getDictDataListByValue(dictKey, values); } @GetMapping("/PersonBasicInfo/getOtherList") public AjaxResult getOtherList(PersonBasicInfo personBasicInfo){ PageDomain pageDomain = TableSupport.buildPageRequest(); Integer pageNum = pageDomain.getPageNum(); Integer pageSize = pageDomain.getPageSize(); Integer delFlag = personBasicInfo.getDelFlag(); Integer personType = personBasicInfo.getPersonType(); TableDataInfo list = personBasicInfoService.getOtherList(pageNum, pageSize, delFlag, personType); if(HttpStatus.SUCCESS == list.getCode()){ return AjaxResult.success(list.getRows()); }else{ return AjaxResult.error(list.getCode(),list.getMsg()); } } @GetMapping("/PersonBasicInfo/getOtherEdit") public AjaxResult getOtherEdit(OtherPersonInfo otherPersonInfo){ return personBasicInfoService.getOtherEdit(otherPersonInfo.getBasicId(), otherPersonInfo.getPersonType()); } @GetMapping("/PersonBasicInfo/getAllUserInfo") public AjaxResult getAllUserInfo(PersonBasicInfo personBasicInfo){ return personBasicInfoService.getAllUserInfo(personBasicInfo.getName()); } }