|
@@ -1,29 +1,32 @@
|
|
|
package cn.com.qmth.print.manage.service.impl;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
import cn.com.qmth.print.manage.dao.OrgDao;
|
|
|
import cn.com.qmth.print.manage.entity.OrgEntity;
|
|
|
import cn.com.qmth.print.manage.service.OrgService;
|
|
|
import cn.com.qmth.print.manage.service.query.OrgQuery;
|
|
|
-import cn.com.qmth.print.manage.utils.SolarUtils;
|
|
|
+
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
-
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import com.qmth.boot.core.solar.model.OrgInfo;
|
|
|
+import com.qmth.boot.core.solar.service.SolarService;
|
|
|
|
|
|
@Service
|
|
|
public class OrgServiceImpl extends ServiceImpl<OrgDao, OrgEntity> implements OrgService {
|
|
|
|
|
|
- @Autowired
|
|
|
- private SolarUtils solarUtils;
|
|
|
+ @Resource
|
|
|
+ private SolarService solarService;
|
|
|
|
|
|
@Override
|
|
|
public IPage<OrgEntity> pageQuery(OrgQuery query) {
|
|
@@ -49,7 +52,7 @@ public class OrgServiceImpl extends ServiceImpl<OrgDao, OrgEntity> implements Or
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void pull() {
|
|
|
- List<Map> mapList = solarUtils.pullSchool();
|
|
|
+ List<OrgInfo> orglist = solarService.getOrgList();
|
|
|
List<OrgEntity> orgEntities = this.list();
|
|
|
// 不在中心的学校,本地全部禁用
|
|
|
if (!CollectionUtils.isEmpty(orgEntities)) {
|
|
@@ -58,32 +61,26 @@ public class OrgServiceImpl extends ServiceImpl<OrgDao, OrgEntity> implements Or
|
|
|
this.updateById(orgEntity);
|
|
|
}
|
|
|
}
|
|
|
- if (!CollectionUtils.isEmpty(mapList)) {
|
|
|
- for (Map map : mapList) {
|
|
|
- Long orgId = Long.valueOf(String.valueOf(map.get("id"))); // 机构中心的id
|
|
|
- String code = String.valueOf(map.get("code"));
|
|
|
- String name = String.valueOf(map.get("name"));
|
|
|
- String logo = String.valueOf(map.get("logo"));
|
|
|
- String accessKey = String.valueOf(map.get("accessKey"));
|
|
|
- String accessSecret = String.valueOf(map.get("accessSecret"));
|
|
|
-
|
|
|
+ if (!orglist.isEmpty()) {
|
|
|
+ for (OrgInfo org : orglist) {
|
|
|
OrgEntity entity = null;
|
|
|
if (!CollectionUtils.isEmpty(orgEntities)) {
|
|
|
- entity = orgEntities.stream().filter(m -> m.getCode().equals(code)).findFirst().orElse(null);
|
|
|
+ entity = orgEntities.stream().filter(m -> m.getCode().equals(org.getCode())).findFirst()
|
|
|
+ .orElse(null);
|
|
|
}
|
|
|
if (entity == null) {
|
|
|
entity = new OrgEntity();
|
|
|
// 中心的学校ID被占用,则使用自增ID
|
|
|
- OrgEntity orgById = this.getById(orgId);
|
|
|
+ OrgEntity orgById = this.getById(org.getId());
|
|
|
if (orgById == null) {
|
|
|
- entity.setId(orgId);
|
|
|
+ entity.setId(org.getId());
|
|
|
}
|
|
|
}
|
|
|
- entity.setCode(code);
|
|
|
- entity.setName(name);
|
|
|
- entity.setAccessKey(accessKey);
|
|
|
- entity.setAccessSecret(accessSecret);
|
|
|
- entity.setLogoUrl(logo);
|
|
|
+ entity.setCode(org.getCode());
|
|
|
+ entity.setName(org.getName());
|
|
|
+ entity.setAccessKey(org.getAccessKey());
|
|
|
+ entity.setAccessSecret(org.getAccessSecret());
|
|
|
+ entity.setLogoUrl(org.getLogoUrl());
|
|
|
entity.setEnable(true);
|
|
|
entity.setCreateTime(new Date());
|
|
|
entity.setUpdateTime(new Date());
|