|
@@ -2,17 +2,21 @@ package com.qunzhixinxi.hnqz.admin.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.constant.UpmsLevel;
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.UpmsType;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysAreaEntity;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysAreaEntity;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.SysDeptCsm;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDeptRelation;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDeptRelation;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmDaDrugEnt;
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.WmDaDrugEnt;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskType;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.entity.WmTaskTypeEntRef;
|
|
import com.qunzhixinxi.hnqz.admin.mapper.WmDaDrugEntMapper;
|
|
import com.qunzhixinxi.hnqz.admin.mapper.WmDaDrugEntMapper;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysAreaEntityService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysAreaEntityService;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysDeptCsmService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDeptRelationService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDeptRelationService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysEnterpriseAreaService;
|
|
import com.qunzhixinxi.hnqz.admin.service.SysEnterpriseAreaService;
|
|
@@ -20,9 +24,15 @@ import com.qunzhixinxi.hnqz.admin.service.SysUserAreaService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmDaDrugEntService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmDaDrugEntService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskSubmissionPercentRuleService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskSubmissionPercentRuleService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskSubmissionRuleService;
|
|
import com.qunzhixinxi.hnqz.admin.service.WmTaskSubmissionRuleService;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeEntRefService;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmTaskTypeService;
|
|
|
|
+import com.qunzhixinxi.hnqz.common.core.constant.CommonConstants;
|
|
|
|
+import com.qunzhixinxi.hnqz.common.core.util.IDUtils;
|
|
import com.qunzhixinxi.hnqz.common.data.datascope.DataScope;
|
|
import com.qunzhixinxi.hnqz.common.data.datascope.DataScope;
|
|
|
|
+import com.qunzhixinxi.hnqz.common.security.service.HnqzUser;
|
|
import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
|
|
import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -39,6 +49,7 @@ import java.util.stream.Collectors;
|
|
* @author gaoyanng
|
|
* @author gaoyanng
|
|
* @date 2020-06-25 23:35:42
|
|
* @date 2020-06-25 23:35:42
|
|
*/
|
|
*/
|
|
|
|
+@Slf4j
|
|
@Service
|
|
@Service
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
public class WmDaDrugEntServiceImpl extends ServiceImpl<WmDaDrugEntMapper, WmDaDrugEnt> implements WmDaDrugEntService {
|
|
public class WmDaDrugEntServiceImpl extends ServiceImpl<WmDaDrugEntMapper, WmDaDrugEnt> implements WmDaDrugEntService {
|
|
@@ -51,56 +62,10 @@ public class WmDaDrugEntServiceImpl extends ServiceImpl<WmDaDrugEntMapper, WmDaD
|
|
private final WmTaskSubmissionPercentRuleService taskSubmissionPercentRuleService;
|
|
private final WmTaskSubmissionPercentRuleService taskSubmissionPercentRuleService;
|
|
private final SysUserAreaService sysUserAreaService;
|
|
private final SysUserAreaService sysUserAreaService;
|
|
private final SysAreaEntityService areaEntityService;
|
|
private final SysAreaEntityService areaEntityService;
|
|
|
|
+ private final WmTaskTypeService taskTypeService;
|
|
|
|
+ private final WmTaskTypeEntRefService taskTypeEntRefService;
|
|
|
|
+ private final SysDeptCsmService deptCsmService;
|
|
|
|
|
|
- @Override
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
- public boolean saveDrugEnt(WmDaDrugEnt entity) {
|
|
|
|
- Integer deptId = Integer.parseInt(System.currentTimeMillis() / 1000 + "");
|
|
|
|
- entity.setDeptId(deptId);
|
|
|
|
- entity.setCreateTime(LocalDateTime.now());
|
|
|
|
- boolean isSave = super.save(entity);
|
|
|
|
- if (isSave) {
|
|
|
|
- SysDept sysDept = new SysDept();
|
|
|
|
- sysDept.setDeptId(deptId);
|
|
|
|
- sysDept.setName(entity.getEntname());
|
|
|
|
- sysDept.setLevel(2);
|
|
|
|
- sysDept.setLevel1Id(entity.getId());
|
|
|
|
- sysDept.setLevel1Name(entity.getEntname());
|
|
|
|
- sysDept.setTaxCode(entity.getEntcode());
|
|
|
|
- sysDept.setFinancialReviewType(entity.getFinancialReviewType());
|
|
|
|
- sysDept.setDeptPermissions(entity.getDeptPermissions());
|
|
|
|
- /**
|
|
|
|
- * @Modify: start
|
|
|
|
- * @Author: ryz
|
|
|
|
- * @Date: 2021/4/19
|
|
|
|
- */
|
|
|
|
- if (sysDeptService.saveDept(sysDept) > 0) {
|
|
|
|
-
|
|
|
|
-// Map<String, Integer> subjectTypeAndChannel = entity.getSubjectTypeAndChannel();
|
|
|
|
-// if (CollUtil.isNotEmpty(subjectTypeAndChannel)) {
|
|
|
|
-// for (Map.Entry<String, Integer> entry : subjectTypeAndChannel.entrySet()) {
|
|
|
|
-// SysDeptSub deptSub = new SysDeptSub();
|
|
|
|
-// deptSub.setDeptId(sysDept.getDeptId());
|
|
|
|
-// deptSub.setSubjectChannel(entry.getValue());
|
|
|
|
-// deptSub.setSubjectType(entry.getKey());
|
|
|
|
-// deptSub.setEnableFlag(SubjectTypeEnum.ENABLE_FLAG_TRUE.getCode());
|
|
|
|
-// deptSub.setUpdateTime(sysDept.getCreateTime());
|
|
|
|
-// sysDeptSubMapper.insert(deptSub);
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @Modify: end
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
-// return sysDeptService.saveDept(sysDept) > 0 ? true : false;
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<WmDaDrugEnt> selectByScope(Wrapper<WmDaDrugEnt> queryWrapper) {
|
|
public List<WmDaDrugEnt> selectByScope(Wrapper<WmDaDrugEnt> queryWrapper) {
|
|
@@ -108,44 +73,133 @@ public class WmDaDrugEntServiceImpl extends ServiceImpl<WmDaDrugEntMapper, WmDaD
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 保存药企
|
|
|
|
+ *
|
|
|
|
+ * @param entity 药企信息
|
|
|
|
+ * @param operator 操作人
|
|
|
|
+ * @return 保存结果
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
- public boolean saveDrugEnts(WmDaDrugEnt entity) {
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public Boolean saveDrugEnt(WmDaDrugEnt entity, HnqzUser operator) {
|
|
|
|
|
|
|
|
+ // 保存药企信息
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
- Integer deptId = (int) System.currentTimeMillis() / 1000;
|
|
|
|
|
|
+ Integer userId = operator.getId();
|
|
|
|
+ Integer ancestorId = operator.getDeptId();
|
|
|
|
+ Integer deptId = IDUtils.getId();
|
|
entity.setDeptId(deptId);
|
|
entity.setDeptId(deptId);
|
|
entity.setCreateTime(now);
|
|
entity.setCreateTime(now);
|
|
- entity.setCreateUser(SecurityUtils.getUser().getId());
|
|
|
|
-
|
|
|
|
- if (super.save(entity)) {
|
|
|
|
- SysDept sysDept = new SysDept();
|
|
|
|
- sysDept.setDeptId(deptId);
|
|
|
|
- sysDept.setName(entity.getEntname());
|
|
|
|
- sysDept.setLevel(2);
|
|
|
|
- sysDept.setDeptPermissions(entity.getDeptPermissions());
|
|
|
|
- sysDept.setFinancialReviewType(entity.getFinancialReviewType());
|
|
|
|
- sysDept.setExpiryDate(now.plusYears(1L).toLocalDate());
|
|
|
|
- sysDeptService.save(sysDept);
|
|
|
|
-
|
|
|
|
- List<SysDeptRelation> newList = new ArrayList<>(2);
|
|
|
|
- SysDeptRelation sysDeptRelation = new SysDeptRelation();
|
|
|
|
- sysDeptRelation.setAncestor(SecurityUtils.getUser().getDeptId());
|
|
|
|
- sysDeptRelation.setDescendant(deptId);
|
|
|
|
- newList.add(sysDeptRelation);
|
|
|
|
- SysDeptRelation sysDeptRelation1 = new SysDeptRelation();
|
|
|
|
- sysDeptRelation1.setAncestor(deptId);
|
|
|
|
- sysDeptRelation1.setDescendant(deptId);
|
|
|
|
- newList.add(sysDeptRelation1);
|
|
|
|
- sysDeptRelationService.saveBatch(newList);
|
|
|
|
-
|
|
|
|
- // 初始化任务规则
|
|
|
|
- taskSubmissionRuleService.initDeptTaskSubmissionRule(Collections.singleton(deptId));
|
|
|
|
- // 初始化企业的任务类型配置的信息
|
|
|
|
- taskSubmissionPercentRuleService.initTaskTypeConfigRule(Collections.singleton(deptId));
|
|
|
|
-
|
|
|
|
- return true;
|
|
|
|
|
|
+ entity.setManagement("1");
|
|
|
|
+ entity.setPgqx("1");
|
|
|
|
+ entity.setCreateTime(now);
|
|
|
|
+ entity.setUpdateTime(now);
|
|
|
|
+ entity.setCreateUser(userId);
|
|
|
|
+ entity.setUpdateUser(userId);
|
|
|
|
+
|
|
|
|
+ this.save(entity);
|
|
|
|
+
|
|
|
|
+ // 映射部门表
|
|
|
|
+ SysDept sysDept = new SysDept();
|
|
|
|
+ sysDept.setDeptId(deptId);
|
|
|
|
+ sysDept.setName(entity.getEntname());
|
|
|
|
+ sysDept.setLevel(UpmsLevel.DeptLevel.L2.getLevel());
|
|
|
|
+ sysDept.setDeptPermissions(entity.getDeptPermissions());
|
|
|
|
+ sysDept.setFinancialReviewType(entity.getFinancialReviewType());
|
|
|
|
+ sysDept.setIssueDate(now.toLocalDate());
|
|
|
|
+ sysDept.setExpiryDate(now.plusYears(99L).toLocalDate());
|
|
|
|
+ sysDept.setCreateTime(now);
|
|
|
|
+ sysDept.setUpdateTime(now);
|
|
|
|
+ sysDeptService.save(sysDept);
|
|
|
|
+
|
|
|
|
+ // 构建部门关联
|
|
|
|
+ List<SysDeptRelation> rels = new ArrayList<>(2);
|
|
|
|
+ SysDeptRelation r1 = new SysDeptRelation();
|
|
|
|
+ r1.setAncestor(ancestorId);
|
|
|
|
+ r1.setDescendant(deptId);
|
|
|
|
+ rels.add(r1);
|
|
|
|
+ SysDeptRelation r2 = new SysDeptRelation();
|
|
|
|
+ r2.setAncestor(deptId);
|
|
|
|
+ r2.setDescendant(deptId);
|
|
|
|
+ rels.add(r2);
|
|
|
|
+ sysDeptRelationService.saveBatch(rels);
|
|
|
|
+
|
|
|
|
+ // 初始化任务规则
|
|
|
|
+ taskSubmissionRuleService.initDeptTaskSubmissionRule(Collections.singleton(deptId));
|
|
|
|
+ // 初始化企业的任务类型配置的信息
|
|
|
|
+ taskSubmissionPercentRuleService.initTaskTypeConfigRule(Collections.singleton(deptId));
|
|
|
|
+
|
|
|
|
+ // 企业关联任务类型
|
|
|
|
+ List<WmTaskType> taskTypes = taskTypeService.list(Wrappers.<WmTaskType>lambdaQuery()
|
|
|
|
+ .eq(WmTaskType::getDelFlag, CommonConstants.STATUS_NORMAL)
|
|
|
|
+ .eq(WmTaskType::getDurgentId, entity.getId()));
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(taskTypes)) {
|
|
|
|
+ log.info("企业{}, 积分规则已经分配", entity.getId());
|
|
}
|
|
}
|
|
- return false;
|
|
|
|
|
|
+
|
|
|
|
+ WmTaskTypeEntRef wmTaskTypeEntRef = new WmTaskTypeEntRef();
|
|
|
|
+ wmTaskTypeEntRef.setDrugentId(entity.getId());
|
|
|
|
+ wmTaskTypeEntRef.setAgentId(entity.getId());
|
|
|
|
+ wmTaskTypeEntRef.setDeptId(deptId.toString());
|
|
|
|
+ wmTaskTypeEntRef.setCreateTime(now);
|
|
|
|
+ wmTaskTypeEntRef.setUpdateTime(now);
|
|
|
|
+ wmTaskTypeEntRef.setCreateUser(userId);
|
|
|
|
+ wmTaskTypeEntRef.setUpdateUser(userId);
|
|
|
|
+ wmTaskTypeEntRef.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
|
+ wmTaskTypeEntRef.setEnableFlag(CommonConstants.STATUS_NORMAL);
|
|
|
|
+ wmTaskTypeEntRef.setTenantId(operator.getTenantId());
|
|
|
|
+ taskTypeEntRefService.save(wmTaskTypeEntRef);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<WmTaskType> types = taskTypeService.list(Wrappers.<WmTaskType>lambdaQuery()
|
|
|
|
+ .eq(WmTaskType::getDelFlag, CommonConstants.STATUS_NORMAL)
|
|
|
|
+ .eq(WmTaskType::getStatus, CommonConstants.STATUS_NORMAL)
|
|
|
|
+ .eq(WmTaskType::getTaskTypeLevel, "1")).stream()
|
|
|
|
+ .map(tt -> {
|
|
|
|
+ WmTaskType t = new WmTaskType();
|
|
|
|
+ t.setTaskTypeName(tt.getTaskTypeName());
|
|
|
|
+ t.setTaskTypeLevel("2");
|
|
|
|
+ t.setStatus(CommonConstants.STATUS_NORMAL);
|
|
|
|
+ t.setDurgentId(entity.getId());
|
|
|
|
+ t.setLevel1Id(tt.getLevel1Id());
|
|
|
|
+ t.setTaskEntId(entity.getId());
|
|
|
|
+ t.setScore(tt.getScore());
|
|
|
|
+ t.setTaskScoreStart(tt.getTaskScoreStart());
|
|
|
|
+ t.setTaskScoreEnd(tt.getTaskScoreEnd());
|
|
|
|
+ t.setDeptId(deptId);
|
|
|
|
+ t.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
|
+ t.setEnableFlag(CommonConstants.STATUS_NORMAL);
|
|
|
|
+ t.setTenantId(tt.getTenantId());
|
|
|
|
+ t.setCreateTime(now);
|
|
|
|
+ t.setCreateUser(userId);
|
|
|
|
+ t.setUpdateTime(now);
|
|
|
|
+ t.setUpdateUser(userId);
|
|
|
|
+ t.setBaseId(tt.getId());
|
|
|
|
+ t.setRealFlag(tt.getRealFlag());
|
|
|
|
+ t.setRuleId(entity.getId().toString());
|
|
|
|
+ t.setParentId(tt.getParentId());
|
|
|
|
+ t.setTaskReceiverType(tt.getTaskReceiverType());
|
|
|
|
+ t.setTaskRemark(tt.getTaskRemark());
|
|
|
|
+ return t;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ taskTypeService.saveBatch(types);
|
|
|
|
+
|
|
|
|
+ // CSM创建的企业,负责人默认是该CSM
|
|
|
|
+ SysDeptCsm insert = new SysDeptCsm();
|
|
|
|
+ insert.setDeptId(deptId);
|
|
|
|
+ insert.setUserId(userId);
|
|
|
|
+ insert.setCsmName(operator.getRealName());
|
|
|
|
+ deptCsmService.save(insert);
|
|
|
|
+
|
|
|
|
+ // 区域
|
|
|
|
+ enterpriseAreaService.saveRelation(Long.valueOf(deptId), entity.getAreaCodes());
|
|
|
|
+
|
|
|
|
+ return Boolean.TRUE;
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -182,7 +236,7 @@ public class WmDaDrugEntServiceImpl extends ServiceImpl<WmDaDrugEntMapper, WmDaD
|
|
areas = wmDaDrugEnt.getAreaCodes();
|
|
areas = wmDaDrugEnt.getAreaCodes();
|
|
} else {
|
|
} else {
|
|
areas = sysUserAreaService.listUserAreas(Long.valueOf(SecurityUtils.getUser().getId()));
|
|
areas = sysUserAreaService.listUserAreas(Long.valueOf(SecurityUtils.getUser().getId()));
|
|
- if (CollUtil.isNotEmpty(areas)){
|
|
|
|
|
|
+ if (CollUtil.isNotEmpty(areas)) {
|
|
areas = areaEntityService.list(Wrappers.<SysAreaEntity>lambdaQuery()
|
|
areas = areaEntityService.list(Wrappers.<SysAreaEntity>lambdaQuery()
|
|
.in(SysAreaEntity::getAreaId, areas)
|
|
.in(SysAreaEntity::getAreaId, areas)
|
|
.eq(SysAreaEntity::getAreaStatus, Boolean.TRUE)
|
|
.eq(SysAreaEntity::getAreaStatus, Boolean.TRUE)
|