From d72e81a9145387ad786a269ff0d2d5e829d7f504 Mon Sep 17 00:00:00 2001 From: ljf Date: Thu, 21 Dec 2023 17:20:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/kms/config/WaterPortal.java | 59 ++-- .../java/com/kms/config/WaterRequestUtil.java | 33 +- ...UserScheduled.java => WaterScheduled.java} | 34 +- .../kms/config/singleDomain/SingleOrg.java | 327 ++++++++++++++++++ .../src/main/resources/application-test.yml | 3 + pom.xml | 1 + 6 files changed, 409 insertions(+), 48 deletions(-) rename jwtech-admin/src/main/java/com/kms/config/scheduled/{UserScheduled.java => WaterScheduled.java} (78%) diff --git a/jwtech-admin/src/main/java/com/kms/config/WaterPortal.java b/jwtech-admin/src/main/java/com/kms/config/WaterPortal.java index c5f46992..3a6f009d 100644 --- a/jwtech-admin/src/main/java/com/kms/config/WaterPortal.java +++ b/jwtech-admin/src/main/java/com/kms/config/WaterPortal.java @@ -10,15 +10,6 @@ import com.jwtech.util.HttpUtil; import com.kms.common.http.utils.HttpClientUtils; import com.kms.config.singleDomain.SingleOrg; import lombok.Data; -import org.apache.http.HttpEntity; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.HttpClientBuilder; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - import java.io.IOException; import java.util.Date; import java.util.HashMap; @@ -55,17 +46,17 @@ public class WaterPortal { String signature = timestamp + paasToken + nonce + timestamp; signature = SHACoder.encodeSHA256Hex(signature).toUpperCase(); -// HttpResponse httpGet = HttpRequest.get(loginUrl) -// .header("x-tsp-target",paasId) -// .header("x-tsp-uid-type","id") -// .header("x-tsp-uid","20231207000003") -// .header("x-tsp-paasid",paasId) -// .header("x-tsp-signature",signature) -// .header("x-tsp-timestamp",timestamp) -// .header("x-tsp-serviceid","DGSP_1606192265703567361") -// .header("x-tsp-nonce", nonce) -// .header("x-tsp-appsecret","92c8749c5a424758ba550f3cc79cf882") -// .execute(); + HttpResponse httpGet = HttpRequest.get(loginUrl) + .header("x-tsp-target",paasId) + .header("x-tsp-uid-type","id") + .header("x-tsp-uid","20231207000003") + .header("x-tsp-paasid",paasId) + .header("x-tsp-signature",signature) + .header("x-tsp-timestamp",timestamp) + .header("x-tsp-serviceid","DGSP_1606192265703567361") + .header("x-tsp-nonce", nonce) + .header("x-tsp-appsecret","92c8749c5a424758ba550f3cc79cf882") + .execute(); //获取用户 // HashMap hashMap = new HashMap<>(); @@ -84,28 +75,26 @@ public class WaterPortal { //获取部门信息 - HashMap hashMap = new HashMap<>(); - hashMap.put("page",1); - hashMap.put("size",100); - hashMap.put("systemCode","sgc-jg"); - HttpResponse httpGet = HttpRequest.post(orgUrl) - .header("x-tsp-paasid","1732703111547482114") - .header("x-tsp-signature",signature) - .header("x-tsp-timestamp",timestamp) - .header("x-tsp-serviceid","DGSP_1606192265703567361") - .header("x-tsp-nonce", nonce) - .header("x-tsp-appsecret","92c8749c5a424758ba550f3cc79cf882") - .body(JSONObject.toJSONString(hashMap)) - .execute(); +// HashMap hashMap = new HashMap<>(); +// hashMap.put("page",1); +// hashMap.put("size",100); +// hashMap.put("systemCode","sgc-jg"); +// HttpResponse httpGet = HttpRequest.post(orgUrl) +// .header("x-tsp-paasid","1732703111547482114") +// .header("x-tsp-signature",signature) +// .header("x-tsp-timestamp",timestamp) +// .header("x-tsp-serviceid","DGSP_1606192265703567361") +// .header("x-tsp-nonce", nonce) +// .header("x-tsp-appsecret","92c8749c5a424758ba550f3cc79cf882") +// .body(JSONObject.toJSONString(hashMap)) +// .execute(); String body = httpGet.body(); JSONObject jsonObject = JSONObject.parseObject(body); String records = jsonObject.getJSONObject("data").getString("records"); List singleOrgs = JSONObject.parseArray(records, SingleOrg.class); - System.out.println(body); - } } diff --git a/jwtech-admin/src/main/java/com/kms/config/WaterRequestUtil.java b/jwtech-admin/src/main/java/com/kms/config/WaterRequestUtil.java index 0e61f5d7..7164e494 100644 --- a/jwtech-admin/src/main/java/com/kms/config/WaterRequestUtil.java +++ b/jwtech-admin/src/main/java/com/kms/config/WaterRequestUtil.java @@ -6,6 +6,9 @@ import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSONObject; import com.jianwei.common.core.domain.AjaxResult; import com.jianwei.common.exception.CustomException; +import com.kms.config.scheduled.WaterScheduled; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; @@ -18,6 +21,8 @@ import java.util.HashMap; @Component public class WaterRequestUtil { + private static final Logger log = LoggerFactory.getLogger(WaterRequestUtil.class); + @Value("${water.paasToken}") public String paasToken; @Value("${water.paasId}") @@ -54,6 +59,14 @@ public class WaterRequestUtil { public String orgAppsecret; + //业务角色 + @Value("${water.roleUrl}") + public String roleUrl; + @Value("${water.roleServiceId}") + public String roleServiceId; + @Value("${water.roleAppsecret}") + public String roleAppsecret; + /** * 设置 * @param httpRequest @@ -111,6 +124,8 @@ public class WaterRequestUtil { * @return */ public WaterResult authUser(String authorization){ + log.info("--------请求统一门户用户验证,请求地址为:"+userUrl); + System.out.println("--------请求统一门户用户验证,请求地址为:"+userUrl); HttpRequest get = createGet(userUrl,authUserServiceId,authUserAppsecret); HttpResponse response = get.header("Authorization", authorization) .execute(); @@ -122,11 +137,12 @@ public class WaterRequestUtil { public WaterResult getOrgPage(){ + log.info("--------请求获取门户组织信息,请求地址为:"+orgUrl); HashMap hashMap = new HashMap<>(); hashMap.put("page",1); hashMap.put("size",100); hashMap.put("systemCode",systemCode); - HttpRequest get = createPost(userUrl,authUserServiceId,authUserAppsecret); + HttpRequest get = createPost(orgUrl,orgServiceId,orgAppsecret); HttpResponse response = get.body(JSONObject.toJSONString(hashMap)) .execute(); String body = response.body(); @@ -136,6 +152,21 @@ public class WaterRequestUtil { } + public WaterResult getRolePage(){ + log.info("--------请求获取门户角色信息,请求地址为:"+roleUrl); + HashMap hashMap = new HashMap<>(); + hashMap.put("page",1); + hashMap.put("size",100); + hashMap.put("systemCode",systemCode); + HttpRequest get = createPost(roleUrl,roleServiceId,roleAppsecret); + HttpResponse response = get.body(JSONObject.toJSONString(hashMap)) + .execute(); + String body = response.body(); + WaterResult waterResult = JSONObject.parseObject(body, WaterResult.class); + isSuccess(waterResult); + return waterResult; + } + diff --git a/jwtech-admin/src/main/java/com/kms/config/scheduled/UserScheduled.java b/jwtech-admin/src/main/java/com/kms/config/scheduled/WaterScheduled.java similarity index 78% rename from jwtech-admin/src/main/java/com/kms/config/scheduled/UserScheduled.java rename to jwtech-admin/src/main/java/com/kms/config/scheduled/WaterScheduled.java index 8393f404..e0a6af74 100644 --- a/jwtech-admin/src/main/java/com/kms/config/scheduled/UserScheduled.java +++ b/jwtech-admin/src/main/java/com/kms/config/scheduled/WaterScheduled.java @@ -1,9 +1,7 @@ package com.kms.config.scheduled; -import cn.hutool.core.bean.BeanUtil; import com.alibaba.fastjson.JSONObject; import com.jianwei.common.constant.UserConstants; -import com.jianwei.common.core.domain.AjaxResult; import com.jianwei.common.core.domain.entity.SysDept; import com.kms.common.utils.BaseEntityUtils; import com.kms.config.WaterRequestUtil; @@ -11,21 +9,20 @@ import com.kms.config.WaterResult; import com.kms.config.singleDomain.SingleOrg; import com.kms.system.service.SysDeptService; import com.kms.system.service.SysUserService; -import lombok.extern.log4j.Log4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.parsing.BeanEntry; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.Scheduled; +import java.util.Date; import java.util.List; @Configuration -public class UserScheduled { +public class WaterScheduled { - private static final Logger log = LoggerFactory.getLogger(UserScheduled.class); + private static final Logger log = LoggerFactory.getLogger(WaterScheduled.class); @Autowired WaterRequestUtil waterRequestUtil; @@ -43,8 +40,10 @@ public class UserScheduled { // // } - -// @Scheduled + /** + * + */ +// @Scheduled(cron = "0 0 0 ? * ? ") public void orgScheduled(){ WaterResult waterResult = waterRequestUtil.getOrgPage(); String data = waterResult.getData(); @@ -52,8 +51,7 @@ public class UserScheduled { List singleOrgs = JSONObject.parseArray(records, SingleOrg.class); for (SingleOrg singleOrg : singleOrgs) { SysDept dept = new SysDept(); - BaseEntityUtils.preInsert(dept); - BeanUtils.copyProperties(dept,singleOrg); + BeanUtils.copyProperties(singleOrg,dept); dept.setXzqhId(singleOrg.getArea()); dept.setXzqhName(singleOrg.getAreaText()); dept.setSingleCode(singleOrg.getCode()); @@ -67,16 +65,28 @@ public class UserScheduled { dept.setLeader(singleOrg.getDutyPerson()); dept.setName(singleOrg.getName()); dept.setAdminName(singleOrg.getName()); - if(singleOrg.getStatus().equals("1")){ + dept.setCreateTime(new Date()); + dept.setUpdateTime(new Date()); + if(singleOrg.getStatus()==null||singleOrg.getStatus().equals("1")){ dept.setStatus("0"); + }else { + dept.setStatus("1"); } if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { log.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); } // dept.setParentId("100"); - int i = deptService.insertDept(dept); + deptService.saveOrUpdate(dept); } } + + public void roeScheduled(){ + WaterResult rolePage = waterRequestUtil.getRolePage(); + + + + } + } diff --git a/jwtech-admin/src/main/java/com/kms/config/singleDomain/SingleOrg.java b/jwtech-admin/src/main/java/com/kms/config/singleDomain/SingleOrg.java index e1730938..375c822b 100644 --- a/jwtech-admin/src/main/java/com/kms/config/singleDomain/SingleOrg.java +++ b/jwtech-admin/src/main/java/com/kms/config/singleDomain/SingleOrg.java @@ -1,10 +1,13 @@ package com.kms.config.singleDomain; + import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; @Data @AllArgsConstructor +@NoArgsConstructor public class SingleOrg { private String address; //机构地址 @@ -54,7 +57,331 @@ public class SingleOrg { private String id; private String status; + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getAreaText() { + return areaText; + } + + public void setAreaText(String areaText) { + this.areaText = areaText; + } + + public String getBusinessScope() { + return businessScope; + } + + public void setBusinessScope(String businessScope) { + this.businessScope = businessScope; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getCategoryText() { + return categoryText; + } + + public void setCategoryText(String categoryText) { + this.categoryText = categoryText; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getParent() { + return parent; + } + + public void setParent(String parent) { + this.parent = parent; + } + + public String getCrossParent() { + return crossParent; + } + + public void setCrossParent(String crossParent) { + this.crossParent = crossParent; + } + + public String getDonaQualif() { + return donaQualif; + } + + public void setDonaQualif(String donaQualif) { + this.donaQualif = donaQualif; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getNature() { + return nature; + } + + public void setNature(String nature) { + this.nature = nature; + } + + public String getNatureText() { + return natureText; + } + + public void setNatureText(String natureText) { + this.natureText = natureText; + } + + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } + + public String getLevelText() { + return levelText; + } + + public void setLevelText(String levelText) { + this.levelText = levelText; + } + + public String getRecord() { + return record; + } + + public void setRecord(String record) { + this.record = record; + } + + public String getDutyPerson() { + return dutyPerson; + } + + public void setDutyPerson(String dutyPerson) { + this.dutyPerson = dutyPerson; + } + + public String getFoundDate() { + return foundDate; + } + + public void setFoundDate(String foundDate) { + this.foundDate = foundDate; + } + + public String getRegisterDate() { + return registerDate; + } + + public void setRegisterDate(String registerDate) { + this.registerDate = registerDate; + } + + public String getManageOrg() { + return manageOrg; + } + + public void setManageOrg(String manageOrg) { + this.manageOrg = manageOrg; + } + + public String getDutyPersonPhone() { + return dutyPersonPhone; + } + + public void setDutyPersonPhone(String dutyPersonPhone) { + this.dutyPersonPhone = dutyPersonPhone; + } + + public String getExpiryDate() { + return expiryDate; + } + + public void setExpiryDate(String expiryDate) { + this.expiryDate = expiryDate; + } + + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + + public String getPromoter() { + return promoter; + } + + public void setPromoter(String promoter) { + this.promoter = promoter; + } + + public String getPromoterPhone() { + return promoterPhone; + } + + public void setPromoterPhone(String promoterPhone) { + this.promoterPhone = promoterPhone; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getVolunteerNum() { + return volunteerNum; + } + + public void setVolunteerNum(String volunteerNum) { + this.volunteerNum = volunteerNum; + } + + public String getTel() { + return tel; + } + + public void setTel(String tel) { + this.tel = tel; + } + + public String getBusinessTime() { + return businessTime; + } + + public void setBusinessTime(String businessTime) { + this.businessTime = businessTime; + } + + public String getMap() { + return map; + } + + public void setMap(String map) { + this.map = map; + } + + public String getTifld() { + return tifld; + } + + public void setTifld(String tifld) { + this.tifld = tifld; + } + + public String getUscc() { + return uscc; + } + + public void setUscc(String uscc) { + this.uscc = uscc; + } + + public String getGovOrgId() { + return govOrgId; + } + + public void setGovOrgId(String govOrgId) { + this.govOrgId = govOrgId; + } + + public String getGovOrgName() { + return govOrgName; + } + + public void setGovOrgName(String govOrgName) { + this.govOrgName = govOrgName; + } + + public String getLegalPerson() { + return legalPerson; + } + + public void setLegalPerson(String legalPerson) { + this.legalPerson = legalPerson; + } + + public String getLegalPersonNo() { + return legalPersonNo; + } + + public void setLegalPersonNo(String legalPersonNo) { + this.legalPersonNo = legalPersonNo; + } + + public String getLegalPersonPhone() { + return legalPersonPhone; + } + + public void setLegalPersonPhone(String legalPersonPhone) { + this.legalPersonPhone = legalPersonPhone; + } + + public String getSeq() { + return seq; + } + + public void setSeq(String seq) { + this.seq = seq; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getStatus() { + return status; + } + public void setStatus(String status) { + this.status = status; + } } diff --git a/jwtech-admin/src/main/resources/application-test.yml b/jwtech-admin/src/main/resources/application-test.yml index eb535c9a..6d5a0603 100644 --- a/jwtech-admin/src/main/resources/application-test.yml +++ b/jwtech-admin/src/main/resources/application-test.yml @@ -272,3 +272,6 @@ water: orgUrl: ${water.url}/usrc/open-api/org/orgPage orgServiceId: DGSP_1606197217079439362 orgAppsecret: 7ac7d77ddaa14ad1b653a0263906c0f8 + roleUrl: ${water.url}/usrc/open-api/role/page + roleServiceId: DGSP_1731517609955848193 + roleAppsecret: e49e175c07fd4bbe90b3c928772fa58f diff --git a/pom.xml b/pom.xml index 3955ef64..887677e1 100644 --- a/pom.xml +++ b/pom.xml @@ -24,6 +24,7 @@ jwtech-system jwtech-generator jwtech-framework + jwtech-quartz pom