@@ -3,6 +3,9 @@ package com.hz.pm.api.external.model.enumeration; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Getter; | |||
import java.util.Arrays; | |||
import java.util.Optional; | |||
/** | |||
* <p> | |||
* MhUnitStripEnum | |||
@@ -15,12 +18,22 @@ import lombok.Getter; | |||
@AllArgsConstructor | |||
public enum MhUnitStripEnum { | |||
GOV_COMPANY("国有企业"), | |||
GOV_COMPANY("国有企业", 1), | |||
PARTY_GOV("党政领域", 2), | |||
INDUSTRY("重点行业", 3); | |||
private final String val; | |||
private final Integer code; | |||
PARTY_GOV("党政领域"), | |||
public static Optional<MhUnitStripEnum> get(Integer code) { | |||
return Arrays.stream(values()).filter(w -> w.getCode().equals(code)).findFirst(); | |||
} | |||
INDUSTRY("重点行业"); | |||
public boolean eq(Integer code) { | |||
return this.getCode().equals(code); | |||
} | |||
private final String name; | |||
} |
@@ -57,6 +57,9 @@ public class MhProject implements Serializable { | |||
@ApiModelProperty("项目编码") | |||
private String projectCode; | |||
@ApiModelProperty("申报单位领域") | |||
private Integer unitStrip; | |||
private LocalDateTime createTime; | |||
} |
@@ -31,4 +31,10 @@ public class DeclaredProjectListReq extends PagePo { | |||
@ApiModelProperty("创建时间(结束)") | |||
private LocalDate createDateMax; | |||
@ApiModelProperty("申报单位领域") | |||
private Integer unitStrip; | |||
@ApiModelProperty("申报单位ID") | |||
private Long declaredUnitId; | |||
} |
@@ -23,6 +23,12 @@ public class DeclaredProjectListVO { | |||
@ApiModelProperty("申报单位") | |||
private String declaredUnit; | |||
@ApiModelProperty("申报单位领域") | |||
private Integer unitStrip; | |||
@ApiModelProperty("申报单位领域") | |||
private String unitStripName; | |||
@ApiModelProperty("项目申报金额(万元)") | |||
private BigDecimal declaredAmount; | |||
@@ -1,5 +1,6 @@ | |||
package com.hz.pm.api.user.controller; | |||
import com.hz.pm.api.external.model.enumeration.MhUnitStripEnum; | |||
import com.hz.pm.api.user.manage.MhUnitManage; | |||
import com.hz.pm.api.user.model.dto.MhUnitTreeDTO; | |||
import com.hz.pm.api.user.model.dto.MhUnitUserTreeDTO; | |||
@@ -38,6 +39,12 @@ public class MhUnitController { | |||
return mhUnitManage.getMhUnitTree(); | |||
} | |||
@GetMapping("/treeByStrip") | |||
@ApiOperation("按照领域查询单位树") | |||
public List<MhUnitTreeDTO> getMhUnitTreeByStrip(Integer unitStrip) { | |||
return mhUnitManage.getMhUnitTreeByStrip(unitStrip); | |||
} | |||
@GetMapping("/page") | |||
@ApiOperation("单位列表") | |||
public PageVo<MhUnitListVO> page(MhUnitListReq req) { | |||
@@ -50,4 +57,5 @@ public class MhUnitController { | |||
return mhUnitManage.getUserTree(req); | |||
} | |||
} |
@@ -1,7 +1,7 @@ | |||
package com.hz.pm.api.user.manage; | |||
import cn.hutool.core.bean.BeanUtil; | |||
import com.baomidou.mybatisplus.core.conditions.Wrapper; | |||
import cn.hutool.core.lang.Assert; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
@@ -51,12 +51,26 @@ public class MhUnitManage { | |||
List<UnitDTO> allUnits = mhUnitCache.all(); | |||
List<MhUnitTreeDTO> nodes = allUnits.stream().map(w -> { | |||
MhUnitTreeDTO node = BeanUtil.copyProperties(w, MhUnitTreeDTO.class); | |||
node.setStrip(node.getStrip()); | |||
node.setStrip(node.getType().getStrip()); | |||
return node; | |||
}).collect(Collectors.toList()); | |||
return TreeUtil.convertToTree(nodes, 0L); | |||
} | |||
public List<MhUnitTreeDTO> getMhUnitTreeByStrip(Integer unitStrip) { | |||
Assert.notNull(unitStrip, "领域不能为空"); | |||
List<UnitDTO> allUnits = mhUnitCache.all(); | |||
List<MhUnitTreeDTO> nodes = allUnits.stream() | |||
.filter(w -> w.getType() != null && w.getType().getStrip().eq(unitStrip)) | |||
.map(w -> { | |||
MhUnitTreeDTO node = BeanUtil.copyProperties(w, MhUnitTreeDTO.class); | |||
node.setStrip(node.getStrip()); | |||
return node; | |||
}).collect(Collectors.toList()); | |||
return convertToTree(nodes); | |||
} | |||
public PageVo<MhUnitListVO> page(MhUnitListReq req) { | |||
LambdaQueryWrapper<MhUnit> query = Wrappers.lambdaQuery(MhUnit.class) | |||
.like(StrUtils.isNotBlank(req.getName()), MhUnit::getName, req.getName()); | |||
@@ -70,7 +84,7 @@ public class MhUnitManage { | |||
unit.setType(type); | |||
unit.setStrip(type.getStrip()); | |||
unit.setTypeName(type.getVal()); | |||
unit.setStripName(type.getStrip().getName()); | |||
unit.setStripName(type.getStrip().getVal()); | |||
}); | |||
return unit; | |||
}).collect(Collectors.toList()); | |||
@@ -146,4 +160,27 @@ public class MhUnitManage { | |||
return node; | |||
} | |||
public static List<MhUnitTreeDTO> convertToTree(List<MhUnitTreeDTO> units) { | |||
List<Long> ids = CollUtils.fieldList(units, MhUnitTreeDTO::getId); | |||
List<MhUnitTreeDTO> roots = new ArrayList<>(); | |||
for (MhUnitTreeDTO node : units) { | |||
if (!ids.contains(node.getParentId())) { | |||
roots.add(node); | |||
} else { | |||
for (MhUnitTreeDTO parent : units) { | |||
if (parent.getId().equals(node.getParentId())) { | |||
List<MhUnitTreeDTO> children = parent.getChildren(); | |||
if (children == null) { | |||
children = new ArrayList<>(); | |||
parent.setChildren(children); | |||
} | |||
children.add(node); | |||
break; | |||
} | |||
} | |||
} | |||
} | |||
return roots; | |||
} | |||
} |
@@ -24,6 +24,8 @@ import com.hz.pm.api.projectlib.model.entity.MhProject; | |||
import com.hz.pm.api.projectlib.model.entity.MhProjectSchemaTargetData; | |||
import com.hz.pm.api.projectlib.service.IMhProjectSchemaTargetDataService; | |||
import com.hz.pm.api.projectlib.service.IMhProjectService; | |||
import com.hz.pm.api.user.helper.MhUnitCache; | |||
import com.hz.pm.api.user.model.dto.UnitDTO; | |||
import com.hz.pm.api.user.model.entity.MhCompany; | |||
import com.hz.pm.api.user.model.entity.MhUnit; | |||
import com.hz.pm.api.user.model.entity.UserInfo; | |||
@@ -69,6 +71,7 @@ public class SyncMhUserOrgManage { | |||
private final IExpertDictionaryService expertDictionaryService; | |||
private final IMhProjectService mhProjectService; | |||
private final IMhProjectSchemaTargetDataService mhProjectSchemaTargetDataService; | |||
private final MhUnitCache unitCache; | |||
@Transactional(rollbackFor = Exception.class) | |||
public void syncMhProjects() { | |||
@@ -89,6 +92,10 @@ public class SyncMhUserOrgManage { | |||
} else { | |||
preProject = BeanUtil.copyProperties(v, MhProject.class); | |||
} | |||
UnitDTO unit = unitCache.getById(preProject.getUnitId()); | |||
if (unit != null && unit.getType() != null) { | |||
preProject.setUnitStrip(unit.getType().getStrip().getCode()); | |||
} | |||
mhProjectService.saveOrUpdate(preProject); | |||
if (v.getSchemeTargetData() != null) { | |||
MhProjectSchemaTargetData schemaTargetData = new MhProjectSchemaTargetData(); | |||
@@ -1,7 +1,12 @@ | |||
package com.hz.pm.api.todocenter; | |||
import cn.hutool.core.io.FileUtil; | |||
import cn.hutool.json.JSONUtil; | |||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.hz.pm.api.external.model.dto.MhUnitDTO; | |||
import com.hz.pm.api.user.model.entity.MhUnit; | |||
import com.hz.pm.api.user.service.IMhUnitService; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.hz.pm.api.AppTests; | |||
import com.wflow.bean.entity.WflowCcTasks; | |||
@@ -309,4 +314,20 @@ public class FlowableTest extends AppTests { | |||
} | |||
@Autowired | |||
private IMhUnitService mhUnitService; | |||
@Test | |||
public void test(){ | |||
String s = FileUtil.readUtf8String("/Users/wendy/Desktop/response.json"); | |||
List<MhUnitDTO> units = JSONUtil.parseObj(s).getBeanList("data", MhUnitDTO.class); | |||
for (MhUnitDTO unit : units) { | |||
LambdaUpdateWrapper<MhUnit> set = Wrappers.lambdaUpdate(MhUnit.class) | |||
.eq(MhUnit::getId, unit.getUnitId()) | |||
.set(MhUnit::getUnifiedSocialCreditCode,unit.getUnifiedSocialCreditCode()) | |||
.set(MhUnit::getType, unit.getType()); | |||
mhUnitService.update(set); | |||
} | |||
} | |||
} |