|
@@ -37,7 +37,6 @@ import com.qunzhixinxi.hnqz.admin.api.constant.enums.DelEnum;
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.enums.EnableEnum;
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.enums.EnableEnum;
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.enums.PackageTypeEnum;
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.enums.PackageTypeEnum;
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.enums.ScorePackageStatusEnum;
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.enums.ScorePackageStatusEnum;
|
|
-import com.qunzhixinxi.hnqz.admin.api.constant.enums.SubjectLocation;
|
|
|
|
import com.qunzhixinxi.hnqz.admin.mapper.*;
|
|
import com.qunzhixinxi.hnqz.admin.mapper.*;
|
|
import com.qunzhixinxi.hnqz.admin.api.feign.SysDeptRecharge;
|
|
import com.qunzhixinxi.hnqz.admin.api.feign.SysDeptRecharge;
|
|
import com.qunzhixinxi.hnqz.admin.api.feign.SysDeptRechargeRecord;
|
|
import com.qunzhixinxi.hnqz.admin.api.feign.SysDeptRechargeRecord;
|
|
@@ -91,385 +90,385 @@ import java.util.stream.Stream;
|
|
@RequestMapping("/wmscorepackage")
|
|
@RequestMapping("/wmscorepackage")
|
|
public class WmScorePackageController {
|
|
public class WmScorePackageController {
|
|
|
|
|
|
- private final WmScorePackageService wmScorePackageService;
|
|
|
|
- private final WmScorePackageStatusService wmScorePackageStatusService;
|
|
|
|
- private final WmDaDrugEntDrugtableService wmDaDrugEntDrugtableService;
|
|
|
|
- private final WmScorePackageMapper wmScorePackageMapper;
|
|
|
|
- private final SysDeptService sysDeptService;
|
|
|
|
- private final WmDaAgentService wmDaAgentService;
|
|
|
|
- private final SysUserService sysUserService;
|
|
|
|
- private final WmTaskService wmTaskService;
|
|
|
|
- private final WmTaskMapper wmTaskMapper;
|
|
|
|
- private final WmTaskRuleService wmTaskRuleService;
|
|
|
|
- private final WmScoreTaskTypeService wmScoreTaskTypeService;
|
|
|
|
- private final WmDaDrugEntService wmDaDrugEntService;
|
|
|
|
- private final WmTaskTypeService wmTaskTypeService;
|
|
|
|
- private final WmScoreTaskTypeMapper wmScoreTaskTypeMapper;
|
|
|
|
- private final WmDaDrugEntMapper wmDaDrugEntMapper;
|
|
|
|
- private final WmDaAgentMapper wmDaAgentMapper;
|
|
|
|
- private final WmTeamService wmTeamService;
|
|
|
|
- private final SysDeptRechargeRecordMapper sysDeptRechargeRecordMapper;
|
|
|
|
- private final SysDeptRechargeMapper sysDeptRechargeMapper;
|
|
|
|
- private final WmBizReminderService wmBizReminderService;
|
|
|
|
- private final StringRedisTemplate redisTemplate;
|
|
|
|
- private final WmPkgQuizRelationService pkgQuizRelationService;
|
|
|
|
- private final SysDictItemService sysDictItemService;
|
|
|
|
- private final Sequence pkgSequence;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @GetMapping(value = "/quiz/relation/list")
|
|
|
|
- public R<?> ListPkgQuizRel(@RequestParam Integer pkgId) {
|
|
|
|
-
|
|
|
|
- List<WmPkgQuizRelation> wmPkgQuizRelations = pkgQuizRelationService.listQuizRelationsByPkgIds(Collections.singletonList(pkgId));
|
|
|
|
- return R.ok(wmPkgQuizRelations);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取积分包号
|
|
|
|
- *
|
|
|
|
- * @return 积分包号
|
|
|
|
- */
|
|
|
|
- @GetMapping(value = "/sn")
|
|
|
|
- public R<String> getPkgSn() {
|
|
|
|
- return R.ok("PKG" + pkgSequence.nextNo());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @PutMapping(value = "/p2p/amount")
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
- public R<?> saveP2pAmount(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
- if (StrUtil.isBlank(wmScorePackage.getId()) || wmScorePackage.getP2pAmount() == null || wmScorePackage.getP2pDraft() == null) {
|
|
|
|
- return R.failed("参数错误");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (wmScorePackage.getP2pServiceAmount() == null) {
|
|
|
|
- wmScorePackage.setP2pServiceAmount(BigDecimal.ZERO);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 如果是草稿,放入缓存
|
|
|
|
- if (wmScorePackage.getP2pDraft()) {
|
|
|
|
- redisTemplate.opsForValue().set(String.format("scorepackage:p2p:amount:%s", wmScorePackage.getId()), wmScorePackage.getP2pAmount().toString(), 180, TimeUnit.DAYS);
|
|
|
|
- redisTemplate.opsForValue().set(String.format("scorepackage:p2p:service-amount:%s", wmScorePackage.getId()), wmScorePackage.getP2pServiceAmount().toString(), 180, TimeUnit.DAYS);
|
|
|
|
- redisTemplate.opsForValue().set(String.format("scorepackage:p2p:desc:%s", wmScorePackage.getId()), wmScorePackage.getDescription(), 180, TimeUnit.DAYS);
|
|
|
|
- return R.ok();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- WmScorePackage sp = new WmScorePackage();
|
|
|
|
- sp.setId(wmScorePackage.getId());
|
|
|
|
- sp.setP2pAmount(wmScorePackage.getP2pAmount());
|
|
|
|
- sp.setDescription(wmScorePackage.getDescription());
|
|
|
|
- sp.setP2pServiceAmount(wmScorePackage.getP2pServiceAmount());
|
|
|
|
- sp.setP2pTime(LocalDateTime.now());
|
|
|
|
- wmScorePackageService.updateById(sp);
|
|
|
|
- return R.ok();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 分页查询
|
|
|
|
- *
|
|
|
|
- * @param page 分页对象
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @GetMapping("/page")
|
|
|
|
- public R<?> getWmScorePackagePage(Page<WmScorePackage> page, WmScorePackage wmScorePackage) {
|
|
|
|
-
|
|
|
|
- OrderItem orderItem = new OrderItem();
|
|
|
|
- orderItem.setColumn("create_time");
|
|
|
|
- orderItem.setAsc(false);
|
|
|
|
- page.addOrder(orderItem);
|
|
|
|
-
|
|
|
|
- wmScorePackage.setDelFlag("0");
|
|
|
|
- wmScorePackage.setEnableFlag("0");
|
|
|
|
- String ruleId = wmScorePackage.getTaskRuleId();
|
|
|
|
- String pakcageName = wmScorePackage.getScoreName();
|
|
|
|
- wmScorePackage.setScoreName(null);
|
|
|
|
- if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
- wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
- } else if (SecurityUtils.getRoles().contains(4)) {
|
|
|
|
- wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
- if ("1".equals(wmScorePackage.getAgentTypeId())) {
|
|
|
|
- wmScorePackage.setDeptId(SecurityUtils.getUser().getDeptId() + "");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- wmScorePackage.setTaskRuleId(null);
|
|
|
|
- QueryWrapper<WmScorePackage> queryWrapper = Wrappers.query(wmScorePackage);
|
|
|
|
-
|
|
|
|
- if (null != pakcageName) {
|
|
|
|
- queryWrapper.like("score_name", pakcageName);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ("4".equals(wmScorePackage.getTypeid())) {
|
|
|
|
- if (null != ruleId) {
|
|
|
|
- WmTaskRule wmTaskRule = new WmTaskRule();
|
|
|
|
-
|
|
|
|
- if (null != wmScorePackage.getDrugEntId()) {
|
|
|
|
- wmTaskRule.setDrugentId(wmScorePackage.getDrugEntId());
|
|
|
|
- wmTaskRule.setRuleMonth(ruleId);
|
|
|
|
- } else {
|
|
|
|
- wmTaskRule.setRuleMonth(ruleId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<WmTaskRule> wmTaskRuleList = wmTaskRuleService.list(Wrappers.query(wmTaskRule));
|
|
|
|
- List<String> stringList = new ArrayList<>();
|
|
|
|
- if (wmTaskRuleList.size() > 0) {
|
|
|
|
- for (WmTaskRule wmt : wmTaskRuleList) {
|
|
|
|
- stringList.add(wmt.getId());
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- stringList.add("-1");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- queryWrapper.in(true, "task_rule_id", stringList);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- wmScorePackageService.page(page, queryWrapper);
|
|
|
|
- page.getRecords().forEach(r -> {
|
|
|
|
- if (r.getP2pAmount() != null) {
|
|
|
|
- r.setP2pDraft(false);
|
|
|
|
- } else {
|
|
|
|
- String s = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:amount:%s", r.getId()));
|
|
|
|
- String s1 = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:service-amount:%s", r.getId()));
|
|
|
|
- String desc = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:desc:%s", r.getId()));
|
|
|
|
- if (StrUtil.isNotBlank(s)) {
|
|
|
|
- r.setP2pAmount(new BigDecimal(s));
|
|
|
|
- r.setP2pServiceAmount(new BigDecimal(s1));
|
|
|
|
- r.setDescription(desc);
|
|
|
|
- }
|
|
|
|
- r.setP2pDraft(true);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- return R.ok(page);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 分页查询
|
|
|
|
- *
|
|
|
|
- * @param page 分页对象
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return 分页结果
|
|
|
|
- */
|
|
|
|
- @GetMapping("/getWmScorePackagePageTask")
|
|
|
|
- public R<?> getWmScorePackagePageTask(Page<WmScorePackage> page, WmScorePackage wmScorePackage) {
|
|
|
|
- OrderItem orderItem = new OrderItem();
|
|
|
|
- orderItem.setColumn("create_time");
|
|
|
|
- orderItem.setAsc(false);
|
|
|
|
- page.addOrder(orderItem);
|
|
|
|
- SysDept sysDept = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
- QueryWrapper<WmScorePackage> queryWrapper = Wrappers.query();
|
|
|
|
- queryWrapper.eq("del_flag", "0");
|
|
|
|
- queryWrapper.eq("enable_flag", "0");
|
|
|
|
- if (!SecurityUtils.getRoles().contains(2)) {
|
|
|
|
- queryWrapper.eq("drug_ent_id", SecurityUtils.getUser().getDrugEntId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (null != wmScorePackage.getPackageFinishStatus()) {
|
|
|
|
- if ("1".equals(wmScorePackage.getPackageFinishStatus())) {
|
|
|
|
- if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
- queryWrapper.eq("package_audit_status", "1");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (SecurityUtils.getRoles().contains(4) || SecurityUtils.getRoles().contains(5)) {
|
|
|
|
- queryWrapper.eq("package_finish_status", "1");
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
- queryWrapper.eq("package_audit_status", "0");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (SecurityUtils.getRoles().contains(4) || SecurityUtils.getRoles().contains(5)) {
|
|
|
|
- queryWrapper.eq("package_finish_status", "0");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (null != wmScorePackage.getScoreId()) {
|
|
|
|
- queryWrapper.like("score_id", wmScorePackage.getScoreId());
|
|
|
|
- }
|
|
|
|
- if (null != wmScorePackage.getTaskRuleId()) {
|
|
|
|
- queryWrapper.eq("task_rule_id", wmScorePackage.getTaskRuleId());
|
|
|
|
- }
|
|
|
|
- if (null != wmScorePackage.getScoreName()) {
|
|
|
|
- queryWrapper.like("score_name", wmScorePackage.getScoreName());
|
|
|
|
- }
|
|
|
|
- if (null != wmScorePackage.getLevel1Id()) {
|
|
|
|
- queryWrapper.eq("level1_id", wmScorePackage.getLevel1Id());
|
|
|
|
- }
|
|
|
|
- List<WmScorePackage> listExt = new ArrayList<>();
|
|
|
|
- WmDaDrugEnt wmDaDrugEnt = new WmDaDrugEnt();
|
|
|
|
- wmDaDrugEnt.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
- WmDaDrugEnt wmDaDrugEnt1 = wmDaDrugEntMapper.selectDeptId(wmDaDrugEnt);
|
|
|
|
- WmDaAgent wmDaAgent = new WmDaAgent();
|
|
|
|
- wmDaAgent.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
- WmDaAgent wmDaAgent1 = wmDaAgentMapper.selectDeptId(wmDaAgent);
|
|
|
|
- if (3 == sysDept.getLevel()) {
|
|
|
|
- if (null != wmScorePackage.getTypeid() && "4".equals(wmScorePackage.getTypeid())) {
|
|
|
|
- queryWrapper.eq("level1_id", wmDaDrugEnt1.getId());
|
|
|
|
- wmScorePackage.setLevel1Id(sysDept.getLevel2Id() + "");
|
|
|
|
- queryWrapper.eq("typeid", 4);
|
|
|
|
- wmScorePackage.setPackageFinishStatus("1");
|
|
|
|
- queryWrapper.eq("package_finish_status", 1);
|
|
|
|
- } else {
|
|
|
|
- queryWrapper.eq("agent_type_id", 1);
|
|
|
|
- queryWrapper.eq("level1_id", sysDept.getLevel2Id());
|
|
|
|
- wmScorePackage.setAgentTypeId("1");
|
|
|
|
- wmScorePackage.setLevel1Id(sysDept.getLevel2Id() + "");
|
|
|
|
- listExt = wmScorePackageService.listWmScorePackageAndTaskExtOld(wmScorePackage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- } else if (4 == sysDept.getLevel()) {
|
|
|
|
- queryWrapper.eq("agent_type_id", 2);
|
|
|
|
- queryWrapper.eq("level2_id", wmDaAgent1.getId());
|
|
|
|
- queryWrapper.ne("typeid", 2);
|
|
|
|
- wmScorePackage.setAgentTypeId("2");
|
|
|
|
- wmScorePackage.setTypeid("2");
|
|
|
|
- listExt = wmScorePackageService.listWmScorePackageAndTaskExt2Old(wmScorePackage);
|
|
|
|
-
|
|
|
|
- } else if (2 == sysDept.getLevel()) {
|
|
|
|
- queryWrapper.eq("agent_type_id", 1);
|
|
|
|
- queryWrapper.eq("typeid", 1);
|
|
|
|
- wmScorePackage.setAgentTypeId("1");
|
|
|
|
- wmScorePackage.setTypeid("1");
|
|
|
|
- listExt = wmScorePackageService.listWmScorePackageAndTaskExtOld(wmScorePackage);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (SecurityUtils.getRoles().contains(2)) {
|
|
|
|
- queryWrapper.eq("agent_type_id", 1);
|
|
|
|
- queryWrapper.eq("typeid", 1);
|
|
|
|
- wmScorePackage.setAgentTypeId("1");
|
|
|
|
- wmScorePackage.setTypeid("1");
|
|
|
|
- listExt = wmScorePackageService.listWmScorePackageAndTaskExtOld(wmScorePackage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- queryWrapper.eq("old_package", 1);
|
|
|
|
- Page<WmScorePackage> pageAnswer = wmScorePackageService.page(page, queryWrapper);
|
|
|
|
- List<WmScorePackage> list = pageAnswer.getRecords();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- for (WmScorePackage wmS :
|
|
|
|
- list) {
|
|
|
|
- for (WmScorePackage ext :
|
|
|
|
- listExt) {
|
|
|
|
- if (wmS.getId().equals(ext.getId())) {
|
|
|
|
- wmS.setYsh(ext.getYsh());
|
|
|
|
- wmS.setYtj(ext.getYtj());
|
|
|
|
- if (2 == sysDept.getLevel()) {
|
|
|
|
- wmS.setDsh(ext.getDsh());
|
|
|
|
- } else {
|
|
|
|
- if (null == ext.getYtj() || null == ext.getScore()) {
|
|
|
|
- wmS.setDsh(0);
|
|
|
|
- } else {
|
|
|
|
- if (ext.getYtj() >= ext.getScore()) {
|
|
|
|
- wmS.setDsh(100);
|
|
|
|
- } else {
|
|
|
|
- wmS.setDsh(new Double(Math.ceil(100.0 * ext.getYtj() / ext.getScore())).intValue());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
- wmS.setPackageFinishStatus("0");
|
|
|
|
- if ("1".equals(wmS.getPackageAuditStatus())) {
|
|
|
|
- wmS.setPackageFinishStatus("1");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 封装报告记录
|
|
|
|
- wmS.setReportMqName(CacheConstants.EXPORT_NBA_HISTORY_REPORT_CACHE);
|
|
|
|
- wmScorePackageService.getReportOpt(wmS);
|
|
|
|
- // 封装excel报告状态
|
|
|
|
- wmScorePackageService.getExcelReportOpt(wmS, CacheConstants.EXCEL_EXPORT_NBA_HISTORY_REPORT_CACHE);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- pageAnswer.setRecords(list);
|
|
|
|
- return R.ok(pageAnswer);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 分页查询
|
|
|
|
- *
|
|
|
|
- * @param page 分页对象
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return 分页结果
|
|
|
|
- */
|
|
|
|
- @GetMapping("/getWmScorePageTask")
|
|
|
|
- public R<?> getWmScorePageTask(Page<WmScorePackage> page, WmScorePackage wmScorePackage) {
|
|
|
|
- OrderItem orderItem = new OrderItem();
|
|
|
|
- orderItem.setColumn("create_time");
|
|
|
|
- orderItem.setAsc(false);
|
|
|
|
- page.addOrder(orderItem);
|
|
|
|
- QueryWrapper<WmScorePackage> queryWrapper = Wrappers.query();
|
|
|
|
- if (null != wmScorePackage.getId()) {
|
|
|
|
- queryWrapper.like("id", wmScorePackage.getId());
|
|
|
|
- }
|
|
|
|
- if (null != wmScorePackage.getSendPackageDeptId()) {
|
|
|
|
- queryWrapper.like("send_package_dept_id", wmScorePackage.getSendPackageDeptId());
|
|
|
|
- }
|
|
|
|
- if (null != wmScorePackage.getPackageStatus()) {
|
|
|
|
- queryWrapper.like("package_status", wmScorePackage.getPackageStatus());
|
|
|
|
- }
|
|
|
|
- SysDept sysDept = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
- queryWrapper.eq("del_flag", "0");
|
|
|
|
- queryWrapper.eq("enable_flag", "0");
|
|
|
|
-
|
|
|
|
- if (null != wmScorePackage.getPackageFinishStatus()) {
|
|
|
|
- if ("1".equals(wmScorePackage.getPackageFinishStatus())) {
|
|
|
|
- if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
- queryWrapper.eq("package_audit_status", "1");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (SecurityUtils.getRoles().contains(4) || SecurityUtils.getRoles().contains(5)) {
|
|
|
|
- queryWrapper.eq("package_finish_status", "1");
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
- queryWrapper.eq("package_audit_status", "0");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (SecurityUtils.getRoles().contains(4) || SecurityUtils.getRoles().contains(5)) {
|
|
|
|
- queryWrapper.eq("package_finish_status", "0");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (3 == sysDept.getLevel()) {
|
|
|
|
- queryWrapper.eq("dept_id", SecurityUtils.getUser().getDeptId());
|
|
|
|
- queryWrapper.eq("typeid", 1);
|
|
|
|
- wmScorePackage.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
- wmScorePackage.setTypeid(String.valueOf(1));
|
|
|
|
- wmScorePackageService.listWmScorePackageAndTaskExt(page, wmScorePackage);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- } else if (4 == sysDept.getLevel()) {
|
|
|
|
- queryWrapper.eq("dept_id", SecurityUtils.getUser().getDeptId());
|
|
|
|
- wmScorePackage.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
- wmScorePackage.setTypeid(String.valueOf(2));
|
|
|
|
- wmScorePackageService.listWmScorePackageAndTaskExt2(page, wmScorePackage);
|
|
|
|
-
|
|
|
|
- } else if (2 == sysDept.getLevel()) {
|
|
|
|
- queryWrapper.eq("typeid", 0);
|
|
|
|
- queryWrapper.eq("dept_id", SecurityUtils.getUser().getDeptId());
|
|
|
|
- wmScorePackage.setTypeid(String.valueOf(0));
|
|
|
|
- wmScorePackage.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
- wmScorePackage.setSendPackageDeptId(wmScorePackage.getSendPackageDeptId());
|
|
|
|
- wmScorePackageService.listWmScorePackageAndTaskExt(page, wmScorePackage);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (SecurityUtils.getRoles().contains(2)) {
|
|
|
|
- queryWrapper.eq("dept_id", SecurityUtils.getUser().getDeptId());
|
|
|
|
- wmScorePackage.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
- wmScorePackage.setSendPackageDeptId(wmScorePackage.getSendPackageDeptId());
|
|
|
|
- wmScorePackageService.listWmScorePackageAndTaskExt(page, wmScorePackage);
|
|
|
|
- }
|
|
|
|
|
|
+ private final WmScorePackageService wmScorePackageService;
|
|
|
|
+ private final WmScorePackageStatusService wmScorePackageStatusService;
|
|
|
|
+ private final WmDaDrugEntDrugtableService wmDaDrugEntDrugtableService;
|
|
|
|
+ private final WmScorePackageMapper wmScorePackageMapper;
|
|
|
|
+ private final SysDeptService sysDeptService;
|
|
|
|
+ private final WmDaAgentService wmDaAgentService;
|
|
|
|
+ private final SysUserService sysUserService;
|
|
|
|
+ private final WmTaskService wmTaskService;
|
|
|
|
+ private final WmTaskMapper wmTaskMapper;
|
|
|
|
+ private final WmTaskRuleService wmTaskRuleService;
|
|
|
|
+ private final WmScoreTaskTypeService wmScoreTaskTypeService;
|
|
|
|
+ private final WmDaDrugEntService wmDaDrugEntService;
|
|
|
|
+ private final WmTaskTypeService wmTaskTypeService;
|
|
|
|
+ private final WmScoreTaskTypeMapper wmScoreTaskTypeMapper;
|
|
|
|
+ private final WmDaDrugEntMapper wmDaDrugEntMapper;
|
|
|
|
+ private final WmDaAgentMapper wmDaAgentMapper;
|
|
|
|
+ private final WmTeamService wmTeamService;
|
|
|
|
+ private final SysDeptRechargeRecordMapper sysDeptRechargeRecordMapper;
|
|
|
|
+ private final SysDeptRechargeMapper sysDeptRechargeMapper;
|
|
|
|
+ private final WmBizReminderService wmBizReminderService;
|
|
|
|
+ private final StringRedisTemplate redisTemplate;
|
|
|
|
+ private final WmPkgQuizRelationService pkgQuizRelationService;
|
|
|
|
+ private final SysDictItemService sysDictItemService;
|
|
|
|
+ private final Sequence pkgSequence;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/quiz/relation/list")
|
|
|
|
+ public R<?> ListPkgQuizRel(@RequestParam Integer pkgId) {
|
|
|
|
+
|
|
|
|
+ List<WmPkgQuizRelation> wmPkgQuizRelations = pkgQuizRelationService.listQuizRelationsByPkgIds(Collections.singletonList(pkgId));
|
|
|
|
+ return R.ok(wmPkgQuizRelations);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取积分包号
|
|
|
|
+ *
|
|
|
|
+ * @return 积分包号
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/sn")
|
|
|
|
+ public R<String> getPkgSn() {
|
|
|
|
+ return R.ok("PKG" + pkgSequence.nextNo());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @PutMapping(value = "/p2p/amount")
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public R<?> saveP2pAmount(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
+ if (StrUtil.isBlank(wmScorePackage.getId()) || wmScorePackage.getP2pAmount() == null || wmScorePackage.getP2pDraft() == null) {
|
|
|
|
+ return R.failed("参数错误");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (wmScorePackage.getP2pServiceAmount() == null) {
|
|
|
|
+ wmScorePackage.setP2pServiceAmount(BigDecimal.ZERO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 如果是草稿,放入缓存
|
|
|
|
+ if (wmScorePackage.getP2pDraft()) {
|
|
|
|
+ redisTemplate.opsForValue().set(String.format("scorepackage:p2p:amount:%s", wmScorePackage.getId()), wmScorePackage.getP2pAmount().toString(), 180, TimeUnit.DAYS);
|
|
|
|
+ redisTemplate.opsForValue().set(String.format("scorepackage:p2p:service-amount:%s", wmScorePackage.getId()), wmScorePackage.getP2pServiceAmount().toString(), 180, TimeUnit.DAYS);
|
|
|
|
+ redisTemplate.opsForValue().set(String.format("scorepackage:p2p:desc:%s", wmScorePackage.getId()), wmScorePackage.getDescription(), 180, TimeUnit.DAYS);
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ WmScorePackage sp = new WmScorePackage();
|
|
|
|
+ sp.setId(wmScorePackage.getId());
|
|
|
|
+ sp.setP2pAmount(wmScorePackage.getP2pAmount());
|
|
|
|
+ sp.setDescription(wmScorePackage.getDescription());
|
|
|
|
+ sp.setP2pServiceAmount(wmScorePackage.getP2pServiceAmount());
|
|
|
|
+ sp.setP2pTime(LocalDateTime.now());
|
|
|
|
+ wmScorePackageService.updateById(sp);
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页查询
|
|
|
|
+ *
|
|
|
|
+ * @param page 分页对象
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/page")
|
|
|
|
+ public R<?> getWmScorePackagePage(Page<WmScorePackage> page, WmScorePackage wmScorePackage) {
|
|
|
|
+
|
|
|
|
+ OrderItem orderItem = new OrderItem();
|
|
|
|
+ orderItem.setColumn("create_time");
|
|
|
|
+ orderItem.setAsc(false);
|
|
|
|
+ page.addOrder(orderItem);
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setDelFlag("0");
|
|
|
|
+ wmScorePackage.setEnableFlag("0");
|
|
|
|
+ String ruleId = wmScorePackage.getTaskRuleId();
|
|
|
|
+ String pakcageName = wmScorePackage.getScoreName();
|
|
|
|
+ wmScorePackage.setScoreName(null);
|
|
|
|
+ if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
+ wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
+ } else if (SecurityUtils.getRoles().contains(4)) {
|
|
|
|
+ wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
+ if ("1".equals(wmScorePackage.getAgentTypeId())) {
|
|
|
|
+ wmScorePackage.setDeptId(SecurityUtils.getUser().getDeptId() + "");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ wmScorePackage.setTaskRuleId(null);
|
|
|
|
+ QueryWrapper<WmScorePackage> queryWrapper = Wrappers.query(wmScorePackage);
|
|
|
|
+
|
|
|
|
+ if (null != pakcageName) {
|
|
|
|
+ queryWrapper.like("score_name", pakcageName);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ("4".equals(wmScorePackage.getTypeid())) {
|
|
|
|
+ if (null != ruleId) {
|
|
|
|
+ WmTaskRule wmTaskRule = new WmTaskRule();
|
|
|
|
+
|
|
|
|
+ if (null != wmScorePackage.getDrugEntId()) {
|
|
|
|
+ wmTaskRule.setDrugentId(wmScorePackage.getDrugEntId());
|
|
|
|
+ wmTaskRule.setRuleMonth(ruleId);
|
|
|
|
+ } else {
|
|
|
|
+ wmTaskRule.setRuleMonth(ruleId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<WmTaskRule> wmTaskRuleList = wmTaskRuleService.list(Wrappers.query(wmTaskRule));
|
|
|
|
+ List<String> stringList = new ArrayList<>();
|
|
|
|
+ if (wmTaskRuleList.size() > 0) {
|
|
|
|
+ for (WmTaskRule wmt : wmTaskRuleList) {
|
|
|
|
+ stringList.add(wmt.getId());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ stringList.add("-1");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ queryWrapper.in(true, "task_rule_id", stringList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wmScorePackageService.page(page, queryWrapper);
|
|
|
|
+ page.getRecords().forEach(r -> {
|
|
|
|
+ if (r.getP2pAmount() != null) {
|
|
|
|
+ r.setP2pDraft(false);
|
|
|
|
+ } else {
|
|
|
|
+ String s = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:amount:%s", r.getId()));
|
|
|
|
+ String s1 = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:service-amount:%s", r.getId()));
|
|
|
|
+ String desc = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:desc:%s", r.getId()));
|
|
|
|
+ if (StrUtil.isNotBlank(s)) {
|
|
|
|
+ r.setP2pAmount(new BigDecimal(s));
|
|
|
|
+ r.setP2pServiceAmount(new BigDecimal(s1));
|
|
|
|
+ r.setDescription(desc);
|
|
|
|
+ }
|
|
|
|
+ r.setP2pDraft(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return R.ok(page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页查询
|
|
|
|
+ *
|
|
|
|
+ * @param page 分页对象
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return 分页结果
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getWmScorePackagePageTask")
|
|
|
|
+ public R<?> getWmScorePackagePageTask(Page<WmScorePackage> page, WmScorePackage wmScorePackage) {
|
|
|
|
+ OrderItem orderItem = new OrderItem();
|
|
|
|
+ orderItem.setColumn("create_time");
|
|
|
|
+ orderItem.setAsc(false);
|
|
|
|
+ page.addOrder(orderItem);
|
|
|
|
+ SysDept sysDept = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
+ QueryWrapper<WmScorePackage> queryWrapper = Wrappers.query();
|
|
|
|
+ queryWrapper.eq("del_flag", "0");
|
|
|
|
+ queryWrapper.eq("enable_flag", "0");
|
|
|
|
+ if (!SecurityUtils.getRoles().contains(2)) {
|
|
|
|
+ queryWrapper.eq("drug_ent_id", SecurityUtils.getUser().getDrugEntId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null != wmScorePackage.getPackageFinishStatus()) {
|
|
|
|
+ if ("1".equals(wmScorePackage.getPackageFinishStatus())) {
|
|
|
|
+ if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
+ queryWrapper.eq("package_audit_status", "1");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (SecurityUtils.getRoles().contains(4) || SecurityUtils.getRoles().contains(5)) {
|
|
|
|
+ queryWrapper.eq("package_finish_status", "1");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
+ queryWrapper.eq("package_audit_status", "0");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (SecurityUtils.getRoles().contains(4) || SecurityUtils.getRoles().contains(5)) {
|
|
|
|
+ queryWrapper.eq("package_finish_status", "0");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (null != wmScorePackage.getScoreId()) {
|
|
|
|
+ queryWrapper.like("score_id", wmScorePackage.getScoreId());
|
|
|
|
+ }
|
|
|
|
+ if (null != wmScorePackage.getTaskRuleId()) {
|
|
|
|
+ queryWrapper.eq("task_rule_id", wmScorePackage.getTaskRuleId());
|
|
|
|
+ }
|
|
|
|
+ if (null != wmScorePackage.getScoreName()) {
|
|
|
|
+ queryWrapper.like("score_name", wmScorePackage.getScoreName());
|
|
|
|
+ }
|
|
|
|
+ if (null != wmScorePackage.getLevel1Id()) {
|
|
|
|
+ queryWrapper.eq("level1_id", wmScorePackage.getLevel1Id());
|
|
|
|
+ }
|
|
|
|
+ List<WmScorePackage> listExt = new ArrayList<>();
|
|
|
|
+ WmDaDrugEnt wmDaDrugEnt = new WmDaDrugEnt();
|
|
|
|
+ wmDaDrugEnt.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
+ WmDaDrugEnt wmDaDrugEnt1 = wmDaDrugEntMapper.selectDeptId(wmDaDrugEnt);
|
|
|
|
+ WmDaAgent wmDaAgent = new WmDaAgent();
|
|
|
|
+ wmDaAgent.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
+ WmDaAgent wmDaAgent1 = wmDaAgentMapper.selectDeptId(wmDaAgent);
|
|
|
|
+ if (3 == sysDept.getLevel()) {
|
|
|
|
+ if (null != wmScorePackage.getTypeid() && "4".equals(wmScorePackage.getTypeid())) {
|
|
|
|
+ queryWrapper.eq("level1_id", wmDaDrugEnt1.getId());
|
|
|
|
+ wmScorePackage.setLevel1Id(sysDept.getLevel2Id());
|
|
|
|
+ queryWrapper.eq("typeid", 4);
|
|
|
|
+ wmScorePackage.setPackageFinishStatus("1");
|
|
|
|
+ queryWrapper.eq("package_finish_status", 1);
|
|
|
|
+ } else {
|
|
|
|
+ queryWrapper.eq("agent_type_id", 1);
|
|
|
|
+ queryWrapper.eq("level1_id", sysDept.getLevel2Id());
|
|
|
|
+ wmScorePackage.setAgentTypeId("1");
|
|
|
|
+ wmScorePackage.setLevel1Id(sysDept.getLevel2Id());
|
|
|
|
+ listExt = wmScorePackageService.listWmScorePackageAndTaskExtOld(wmScorePackage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ } else if (4 == sysDept.getLevel()) {
|
|
|
|
+ queryWrapper.eq("agent_type_id", 2);
|
|
|
|
+ queryWrapper.eq("level2_id", wmDaAgent1.getId());
|
|
|
|
+ queryWrapper.ne("typeid", 2);
|
|
|
|
+ wmScorePackage.setAgentTypeId("2");
|
|
|
|
+ wmScorePackage.setTypeid("2");
|
|
|
|
+ listExt = wmScorePackageService.listWmScorePackageAndTaskExt2Old(wmScorePackage);
|
|
|
|
+
|
|
|
|
+ } else if (2 == sysDept.getLevel()) {
|
|
|
|
+ queryWrapper.eq("agent_type_id", 1);
|
|
|
|
+ queryWrapper.eq("typeid", 1);
|
|
|
|
+ wmScorePackage.setAgentTypeId("1");
|
|
|
|
+ wmScorePackage.setTypeid("1");
|
|
|
|
+ listExt = wmScorePackageService.listWmScorePackageAndTaskExtOld(wmScorePackage);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (SecurityUtils.getRoles().contains(2)) {
|
|
|
|
+ queryWrapper.eq("agent_type_id", 1);
|
|
|
|
+ queryWrapper.eq("typeid", 1);
|
|
|
|
+ wmScorePackage.setAgentTypeId("1");
|
|
|
|
+ wmScorePackage.setTypeid("1");
|
|
|
|
+ listExt = wmScorePackageService.listWmScorePackageAndTaskExtOld(wmScorePackage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ queryWrapper.eq("old_package", 1);
|
|
|
|
+ Page<WmScorePackage> pageAnswer = wmScorePackageService.page(page, queryWrapper);
|
|
|
|
+ List<WmScorePackage> list = pageAnswer.getRecords();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for (WmScorePackage wmS :
|
|
|
|
+ list) {
|
|
|
|
+ for (WmScorePackage ext :
|
|
|
|
+ listExt) {
|
|
|
|
+ if (wmS.getId().equals(ext.getId())) {
|
|
|
|
+ wmS.setYsh(ext.getYsh());
|
|
|
|
+ wmS.setYtj(ext.getYtj());
|
|
|
|
+ if (2 == sysDept.getLevel()) {
|
|
|
|
+ wmS.setDsh(ext.getDsh());
|
|
|
|
+ } else {
|
|
|
|
+ if (null == ext.getYtj() || null == ext.getScore()) {
|
|
|
|
+ wmS.setDsh(0);
|
|
|
|
+ } else {
|
|
|
|
+ if (ext.getYtj() >= ext.getScore()) {
|
|
|
|
+ wmS.setDsh(100);
|
|
|
|
+ } else {
|
|
|
|
+ wmS.setDsh(new Double(Math.ceil(100.0 * ext.getYtj() / ext.getScore())).intValue());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
+ wmS.setPackageFinishStatus("0");
|
|
|
|
+ if ("1".equals(wmS.getPackageAuditStatus())) {
|
|
|
|
+ wmS.setPackageFinishStatus("1");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 封装报告记录
|
|
|
|
+ wmS.setReportMqName(CacheConstants.EXPORT_NBA_HISTORY_REPORT_CACHE);
|
|
|
|
+ wmScorePackageService.getReportOpt(wmS);
|
|
|
|
+ // 封装excel报告状态
|
|
|
|
+ wmScorePackageService.getExcelReportOpt(wmS, CacheConstants.EXCEL_EXPORT_NBA_HISTORY_REPORT_CACHE);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ pageAnswer.setRecords(list);
|
|
|
|
+ return R.ok(pageAnswer);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页查询
|
|
|
|
+ *
|
|
|
|
+ * @param page 分页对象
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return 分页结果
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getWmScorePageTask")
|
|
|
|
+ public R<?> getWmScorePageTask(Page<WmScorePackage> page, WmScorePackage wmScorePackage) {
|
|
|
|
+ OrderItem orderItem = new OrderItem();
|
|
|
|
+ orderItem.setColumn("create_time");
|
|
|
|
+ orderItem.setAsc(false);
|
|
|
|
+ page.addOrder(orderItem);
|
|
|
|
+ QueryWrapper<WmScorePackage> queryWrapper = Wrappers.query();
|
|
|
|
+ if (null != wmScorePackage.getId()) {
|
|
|
|
+ queryWrapper.like("id", wmScorePackage.getId());
|
|
|
|
+ }
|
|
|
|
+ if (null != wmScorePackage.getSendPackageDeptId()) {
|
|
|
|
+ queryWrapper.like("send_package_dept_id", wmScorePackage.getSendPackageDeptId());
|
|
|
|
+ }
|
|
|
|
+ if (null != wmScorePackage.getPackageStatus()) {
|
|
|
|
+ queryWrapper.like("package_status", wmScorePackage.getPackageStatus());
|
|
|
|
+ }
|
|
|
|
+ SysDept sysDept = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
+ queryWrapper.eq("del_flag", "0");
|
|
|
|
+ queryWrapper.eq("enable_flag", "0");
|
|
|
|
+
|
|
|
|
+ if (null != wmScorePackage.getPackageFinishStatus()) {
|
|
|
|
+ if ("1".equals(wmScorePackage.getPackageFinishStatus())) {
|
|
|
|
+ if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
+ queryWrapper.eq("package_audit_status", "1");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (SecurityUtils.getRoles().contains(4) || SecurityUtils.getRoles().contains(5)) {
|
|
|
|
+ queryWrapper.eq("package_finish_status", "1");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
+ queryWrapper.eq("package_audit_status", "0");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (SecurityUtils.getRoles().contains(4) || SecurityUtils.getRoles().contains(5)) {
|
|
|
|
+ queryWrapper.eq("package_finish_status", "0");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (3 == sysDept.getLevel()) {
|
|
|
|
+ queryWrapper.eq("dept_id", SecurityUtils.getUser().getDeptId());
|
|
|
|
+ queryWrapper.eq("typeid", 1);
|
|
|
|
+ wmScorePackage.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
+ wmScorePackage.setTypeid(String.valueOf(1));
|
|
|
|
+ wmScorePackageService.listWmScorePackageAndTaskExt(page, wmScorePackage);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ } else if (4 == sysDept.getLevel()) {
|
|
|
|
+ queryWrapper.eq("dept_id", SecurityUtils.getUser().getDeptId());
|
|
|
|
+ wmScorePackage.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
+ wmScorePackage.setTypeid(String.valueOf(2));
|
|
|
|
+ wmScorePackageService.listWmScorePackageAndTaskExt2(page, wmScorePackage);
|
|
|
|
+
|
|
|
|
+ } else if (2 == sysDept.getLevel()) {
|
|
|
|
+ queryWrapper.eq("typeid", 0);
|
|
|
|
+ queryWrapper.eq("dept_id", SecurityUtils.getUser().getDeptId());
|
|
|
|
+ wmScorePackage.setTypeid(String.valueOf(0));
|
|
|
|
+ wmScorePackage.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
+ wmScorePackage.setSendPackageDeptId(wmScorePackage.getSendPackageDeptId());
|
|
|
|
+ wmScorePackageService.listWmScorePackageAndTaskExt(page, wmScorePackage);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (SecurityUtils.getRoles().contains(2)) {
|
|
|
|
+ queryWrapper.eq("dept_id", SecurityUtils.getUser().getDeptId());
|
|
|
|
+ wmScorePackage.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
+ wmScorePackage.setSendPackageDeptId(wmScorePackage.getSendPackageDeptId());
|
|
|
|
+ wmScorePackageService.listWmScorePackageAndTaskExt(page, wmScorePackage);
|
|
|
|
+ }
|
|
|
|
|
|
// for (WmScorePackage ext : page.getRecords()) {
|
|
// for (WmScorePackage ext : page.getRecords()) {
|
|
// List<WmScoreTaskType> taskTypelist = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(ext.getId());
|
|
// List<WmScoreTaskType> taskTypelist = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(ext.getId());
|
|
@@ -704,3354 +703,3354 @@ public class WmScorePackageController {
|
|
//
|
|
//
|
|
// });
|
|
// });
|
|
|
|
|
|
- List<WmScorePackage> wmList = page.getRecords();
|
|
|
|
- List<Future<WmScorePackage>> futureList = new ArrayList<>(wmList.size());
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- for (WmScorePackage wmS : wmList) {
|
|
|
|
- Future<WmScorePackage> future = wmScorePackageService.finishRate(wmS);
|
|
|
|
- futureList.add(future);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- List<WmScorePackage> finalRecords = new ArrayList<>(wmList.size());
|
|
|
|
- try {
|
|
|
|
- for (Future<WmScorePackage> future : futureList) {
|
|
|
|
- WmScorePackage sPackage = future.get();
|
|
|
|
-
|
|
|
|
- if (sPackage.getP2pAmount() != null) {
|
|
|
|
- sPackage.setP2pDraft(false);
|
|
|
|
- } else {
|
|
|
|
- String s = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:amount:%s", sPackage.getId()));
|
|
|
|
- String s1 = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:service-amount:%s", sPackage.getId()));
|
|
|
|
- String desc = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:desc:%s", sPackage.getId()));
|
|
|
|
- if (StrUtil.isNotBlank(s)) {
|
|
|
|
- sPackage.setP2pAmount(new BigDecimal(s));
|
|
|
|
- sPackage.setP2pServiceAmount(new BigDecimal(s1));
|
|
|
|
- sPackage.setDescription(desc);
|
|
|
|
- }
|
|
|
|
- sPackage.setP2pDraft(true);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- finalRecords.add(sPackage);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- } catch (ExecutionException | InterruptedException e) {
|
|
|
|
- log.error("获取分页信息失败", e);
|
|
|
|
- return R.failed("获取分页信息失败");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok(page);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 分页查询
|
|
|
|
- *
|
|
|
|
- * @param page 分页对象
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return 分页结果
|
|
|
|
- */
|
|
|
|
- @GetMapping("/getWmScorePackageTask")
|
|
|
|
- public R<?> getWmScorePackageTask(Page<?> page, WmScorePackage wmScorePackage) {
|
|
|
|
-
|
|
|
|
- OrderItem orderItem = new OrderItem();
|
|
|
|
- orderItem.setColumn("create_time");
|
|
|
|
- orderItem.setAsc(false);
|
|
|
|
- page.addOrder(orderItem);
|
|
|
|
-
|
|
|
|
- if (!SecurityUtils.getRoles().contains(2) && !SecurityUtils.getRoles().contains(1)) {
|
|
|
|
- wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
- }
|
|
|
|
- wmScorePackage.setDelFlag("0");
|
|
|
|
- wmScorePackage.setEnableFlag("0");
|
|
|
|
- if (SecurityUtils.getRoles().contains(4)) {
|
|
|
|
- SysDept sysDept1 = new SysDept();
|
|
|
|
- sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
- SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
- wmScorePackage.setLevel1Id(sysDept.getLevel2Id() + "");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<WmScorePackage> listExt = new ArrayList<>();
|
|
|
|
- SysDept sysDept1 = new SysDept();
|
|
|
|
- sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
- SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
- if (sysDept.getLevel() == 3) {
|
|
|
|
- wmScorePackage.setAgentTypeId("1");
|
|
|
|
- wmScorePackage.setLevel1Id(sysDept.getLevel2Id() + "");
|
|
|
|
-
|
|
|
|
- listExt = wmScorePackageService.listWmScorePackageAndTaskExt(wmScorePackage);
|
|
|
|
- } else if (sysDept.getLevel() == 4) {
|
|
|
|
- wmScorePackage.setAgentTypeId("2");
|
|
|
|
- wmScorePackage.setLevel2Id(sysDept.getLevel3Id() + "");
|
|
|
|
- wmScorePackage.setTypeid("2");
|
|
|
|
- listExt = wmScorePackageService.listWmScorePackageAndTaskExt2(wmScorePackage);
|
|
|
|
- } else if (sysDept.getLevel() == 2) {
|
|
|
|
- wmScorePackage.setAgentTypeId("1");
|
|
|
|
- wmScorePackage.setTypeid("1");
|
|
|
|
- listExt = wmScorePackageService.listWmScorePackageAndTaskExt(wmScorePackage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (SecurityUtils.getRoles().contains(2) || SecurityUtils.getRoles().contains(1)) {
|
|
|
|
- wmScorePackage.setAgentTypeId("1");
|
|
|
|
- wmScorePackage.setTypeid("1");
|
|
|
|
- listExt = wmScorePackageService.listWmScorePackageAndTaskExt(wmScorePackage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- int ytj = 0;
|
|
|
|
- int ywc = 0;
|
|
|
|
- int dqf = 0;
|
|
|
|
- for (WmScorePackage wmS :
|
|
|
|
- listExt) {
|
|
|
|
- ywc += wmS.getScore();
|
|
|
|
-
|
|
|
|
- if (null != wmS.getYsh()) {
|
|
|
|
- //TODO
|
|
|
|
- //dqf+=wmS.getYsh();
|
|
|
|
- if (wmS.getYtj() > wmS.getScore()) {
|
|
|
|
- dqf += wmS.getScore();
|
|
|
|
- } else {
|
|
|
|
- dqf += wmS.getYtj();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (null != wmS.getYtj()) {
|
|
|
|
- if (wmS.getYtj() > wmS.getScore()) {
|
|
|
|
- ytj += wmS.getScore();
|
|
|
|
- } else {
|
|
|
|
- ytj += wmS.getYtj();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("ytj", ytj);
|
|
|
|
- map.put("ywc", ywc);
|
|
|
|
- map.put("dqf", dqf);
|
|
|
|
-
|
|
|
|
- return R.ok(map);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 分页查询
|
|
|
|
- *
|
|
|
|
- * @param page 分页对象
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return 分页结果
|
|
|
|
- */
|
|
|
|
- @GetMapping("/getListRule")
|
|
|
|
- public R<?> getListRule(Page<WmScorePackage> page, WmScorePackage wmScorePackage) {
|
|
|
|
- OrderItem orderItem = new OrderItem();
|
|
|
|
- orderItem.setColumn("create_time");
|
|
|
|
- orderItem.setAsc(false);
|
|
|
|
- page.addOrder(orderItem);
|
|
|
|
-
|
|
|
|
- wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
- wmScorePackage.setDelFlag("0");
|
|
|
|
- wmScorePackage.setEnableFlag("0");
|
|
|
|
- if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
- wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
- wmScorePackage.setAgentTypeId("1");
|
|
|
|
- } else if (SecurityUtils.getRoles().contains(4)) {
|
|
|
|
- wmScorePackage.setAgentTypeId("2");
|
|
|
|
- SysDept sysDept1 = new SysDept();
|
|
|
|
- sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
- SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
- if (null != sysDept) {
|
|
|
|
- if (3 == sysDept.getLevel()) {
|
|
|
|
- WmDaAgent wmDaAgent = wmDaAgentService.getById(sysDept.getLevel2Id());
|
|
|
|
-
|
|
|
|
- wmScorePackage.setLevel1Id(wmDaAgent.getId());
|
|
|
|
-
|
|
|
|
- List<Integer> list = new ArrayList<>();
|
|
|
|
- list.add(2);
|
|
|
|
- list.add(3);
|
|
|
|
- list.add(4);
|
|
|
|
- wmScorePackage.setSendPackageDeptId(SecurityUtils.getUser().getDeptId() + "");
|
|
|
|
- Page<WmScorePackage> pageAnswer = wmScorePackageService.page(page, Wrappers.query(wmScorePackage)
|
|
|
|
- .lambda()
|
|
|
|
- .in(WmScorePackage::getTypeid, list));
|
|
|
|
- List<WmScorePackage> listExt = wmScorePackageService.listWmScorePackageAndTaskLevel3(wmScorePackage);
|
|
|
|
- List<WmScorePackage> listWmScorePackage = pageAnswer.getRecords();
|
|
|
|
-
|
|
|
|
- for (WmScorePackage wmS :
|
|
|
|
- listWmScorePackage) {
|
|
|
|
- for (WmScorePackage ext :
|
|
|
|
- listExt) {
|
|
|
|
- if (wmS.getId().equals(ext.getId())) {
|
|
|
|
- wmS.setYsh(ext.getYsh());
|
|
|
|
- wmS.setYtj(ext.getYtj());
|
|
|
|
- wmS.setDsh(ext.getDsh());
|
|
|
|
-
|
|
|
|
- if (2 == sysDept.getLevel()) {
|
|
|
|
- wmS.setDsh(ext.getDsh());
|
|
|
|
- } else {
|
|
|
|
- if (null == ext.getYtj() || null == ext.getScore()) {
|
|
|
|
- wmS.setYwctt(0);
|
|
|
|
- } else {
|
|
|
|
- if (ext.getYtj() >= ext.getScore()) {
|
|
|
|
- wmS.setYwctt(100);
|
|
|
|
- } else {
|
|
|
|
- wmS.setYwctt(new Double(Math.ceil(100.0 * ext.getYtj() / ext.getScore())).intValue());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- pageAnswer.setRecords(listWmScorePackage);
|
|
|
|
- return R.ok(pageAnswer);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (4 == sysDept.getLevel()) {
|
|
|
|
- WmDaAgent wmDaAgent = wmDaAgentService.getById(sysDept.getLevel3Id());
|
|
|
|
- wmScorePackage.setLevel2Id(wmDaAgent.getId());
|
|
|
|
- List<Integer> list = new ArrayList<>();
|
|
|
|
- list.add(3);
|
|
|
|
- list.add(4);
|
|
|
|
-
|
|
|
|
- wmScorePackage.setSendPackageDeptId(SecurityUtils.getUser().getDeptId() + "");
|
|
|
|
- Page<WmScorePackage> pageAnswer = wmScorePackageService.page(page, Wrappers.query(wmScorePackage)
|
|
|
|
- .lambda()
|
|
|
|
- .in(WmScorePackage::getTypeid, list));
|
|
|
|
- List<WmScorePackage> listExt = wmScorePackageService.listWmScorePackageAndTaskLevel1(wmScorePackage);
|
|
|
|
- List<WmScorePackage> listWmScorePackage = pageAnswer.getRecords();
|
|
|
|
-
|
|
|
|
- for (WmScorePackage wmS :
|
|
|
|
- listWmScorePackage) {
|
|
|
|
- for (WmScorePackage ext :
|
|
|
|
- listExt) {
|
|
|
|
- if (wmS.getId().equals(ext.getId())) {
|
|
|
|
- wmS.setYsh(ext.getYsh());
|
|
|
|
- wmS.setYtj(ext.getYtj());
|
|
|
|
- if (2 == sysDept.getLevel()) {
|
|
|
|
- wmS.setYwctt(ext.getDsh());
|
|
|
|
- } else {
|
|
|
|
- if (null == ext.getYtj() || null == ext.getScore()) {
|
|
|
|
- wmS.setYwctt(0);
|
|
|
|
- } else {
|
|
|
|
- if (!(ext.getYtj() > ext.getScore())) {
|
|
|
|
- wmS.setYwctt(new Double(Math.ceil(100.0 * ext.getYtj() / ext.getScore())).intValue());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- pageAnswer.setRecords(listWmScorePackage);
|
|
|
|
- return R.ok(pageAnswer);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- sysDept.setDeptId(sysDept.getDeptId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- return R.ok(wmScorePackageService.page(page, Wrappers.query(wmScorePackage)));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 分页查询
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @GetMapping("/getTotalData")
|
|
|
|
- public R<?> getTotalData(WmScorePackage wmScorePackage) {
|
|
|
|
- wmScorePackage.setDelFlag("0");
|
|
|
|
- wmScorePackage.setEnableFlag("0");
|
|
|
|
- if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
- wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
- } else if (SecurityUtils.getRoles().contains(4)) {
|
|
|
|
- wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
- SysDept sysDept1 = new SysDept();
|
|
|
|
- sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
- SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
- if (null != sysDept) {
|
|
|
|
- if (3 == sysDept.getLevel()) {
|
|
|
|
- WmDaAgent wmDaAgent = wmDaAgentService.getById(sysDept.getLevel2Id());
|
|
|
|
-
|
|
|
|
- wmScorePackage.setLevel1Id(wmDaAgent.getId());
|
|
|
|
- List<WmScorePackage> list = wmScorePackageService.list(Wrappers.query(wmScorePackage).lambda());
|
|
|
|
- List<WmScorePackage> newList = new ArrayList<>();
|
|
|
|
- for (WmScorePackage wmS : list) {
|
|
|
|
- if ("2".equals(wmS.getTypeid()) || "3".equals(wmS.getTypeid()) || "4".equals(wmS.getTypeid())) {
|
|
|
|
- if (SecurityUtils.getUser().getDeptId().toString().equals(wmS.getDeptId())) {
|
|
|
|
- newList.add(wmS);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- newList.add(wmS);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- return R.ok(newList);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (4 == sysDept.getLevel()) {
|
|
|
|
- WmDaAgent wmDaAgent = wmDaAgentService.getById(sysDept.getLevel3Id());
|
|
|
|
-
|
|
|
|
- wmScorePackage.setLevel2Id(wmDaAgent.getId());
|
|
|
|
- List<Integer> list = new ArrayList<>();
|
|
|
|
- list.add(2);
|
|
|
|
- list.add(3);
|
|
|
|
- list.add(4);
|
|
|
|
-
|
|
|
|
- return R.ok(wmScorePackageService.list(Wrappers.query(wmScorePackage)
|
|
|
|
- .lambda()
|
|
|
|
- .in(WmScorePackage::getTypeid, list)));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- return R.ok(wmScorePackageService.pageList(Wrappers.query(wmScorePackage)));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 通过id查询积分包
|
|
|
|
- *
|
|
|
|
- * @param id id
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @GetMapping("/{id}")
|
|
|
|
- public R<?> getById(@PathVariable("id") Integer id) {
|
|
|
|
- return R.ok(wmScorePackageService.getById(id));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 新增积分包
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @SysLog("新增积分包")
|
|
|
|
- @PostMapping
|
|
|
|
- public R<?> save(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
-
|
|
|
|
- if (wmScorePackage.getScore() <= 0) {
|
|
|
|
- return R.failed("积分包分值必须大于0");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (null != wmScorePackage.getScoreId() && !"".equals(wmScorePackage.getScoreId())) {
|
|
|
|
- WmScorePackage wmScorePackage1 = new WmScorePackage();
|
|
|
|
- wmScorePackage1.setDelFlag("0");
|
|
|
|
- wmScorePackage1.setScoreId(wmScorePackage.getScoreId());
|
|
|
|
- List<WmScorePackage> wmScorePackageList = wmScorePackageService.list(Wrappers.query(wmScorePackage1));
|
|
|
|
- if (wmScorePackageList.size() > 0) {
|
|
|
|
- return R.failed("积分包ID已存在");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- wmScorePackage.setDelFlag("0");
|
|
|
|
- wmScorePackage.setEnableFlag("0");
|
|
|
|
- wmScorePackage.setIsConduct("0");
|
|
|
|
- wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
- if ("1".equals(wmScorePackage.getTypeid())) {
|
|
|
|
- if (null != wmScorePackage.getLevel1Id()) {
|
|
|
|
- WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getLevel1Id());
|
|
|
|
- wmScorePackage.setDeptId(wmDaAgent.getDeptId() + "");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else if ("2".equals(wmScorePackage.getTypeid())) {
|
|
|
|
- SysDept sysDept1 = new SysDept();
|
|
|
|
- sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
- SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
- if (sysDept.getLevel() == 3) {
|
|
|
|
- if (null != wmScorePackage.getLevel2Id()) {
|
|
|
|
- WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getLevel2Id());
|
|
|
|
- wmScorePackage.setDeptId(wmDaAgent.getDeptId() + "");
|
|
|
|
-
|
|
|
|
- WmDaAgent wmDaAgent1 = wmDaAgentService.getById(sysDept.getLevel2Id());
|
|
|
|
- wmScorePackage.setLevel1Id(wmDaAgent1.getId());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- } else if ("3".equals(wmScorePackage.getTypeid())) {
|
|
|
|
- if (null != wmScorePackage.getXxdbId()) {
|
|
|
|
- SysUser sysUser = sysUserService.getById(wmScorePackage.getXxdbId());
|
|
|
|
- if (null != sysUser.getDeptId()) {
|
|
|
|
- wmScorePackage.setDeptId(sysUser.getDeptId() + "");
|
|
|
|
- SysDept sysDept1 = new SysDept();
|
|
|
|
- sysDept1.setDeptId(sysUser.getDeptId());
|
|
|
|
- SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
- wmScorePackage.setLevel1Id(sysDept.getLevel2Id() == null || sysDept.getLevel2Id() == 0 ? null : sysDept
|
|
|
|
- .getLevel2Id() + "");
|
|
|
|
- wmScorePackage.setLevel2Id(sysDept.getLevel3Id() == null || sysDept.getLevel3Id() == 0 ? null : sysDept
|
|
|
|
- .getLevel3Id() + "");
|
|
|
|
- wmScorePackage.setPackageStatus("2");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else if ("4".equals(wmScorePackage.getTypeid())) {
|
|
|
|
- wmScorePackage.setDeptId(SecurityUtils.getUser().getDeptId() + "");
|
|
|
|
- SysDept sysDept1 = new SysDept();
|
|
|
|
- sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
- SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
- wmScorePackage.setLevel1Id(sysDept.getLevel2Id() == null || sysDept.getLevel2Id() == 0 ? null : sysDept.getLevel2Id() + "");
|
|
|
|
- wmScorePackage.setLevel2Id(sysDept.getLevel3Id() == null || sysDept.getLevel3Id() == 0 ? null : sysDept.getLevel3Id() + "");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (null != wmScorePackage.getScoreName() && !"".equals(wmScorePackage.getScoreName())) {
|
|
|
|
- WmScorePackage wmScorePackage1 = new WmScorePackage();
|
|
|
|
- wmScorePackage1.setDelFlag("0");
|
|
|
|
- wmScorePackage1.setScoreName(wmScorePackage.getScoreName());
|
|
|
|
- wmScorePackage1.setDeptId(wmScorePackage.getDeptId());
|
|
|
|
- List<WmScorePackage> wmScorePackageList = wmScorePackageService.list(Wrappers.query(wmScorePackage1));
|
|
|
|
- if (wmScorePackageList.size() > 0) {
|
|
|
|
- return R.failed("积分包名称已存在");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- wmScorePackage.setCreateTime(LocalDateTime.now());
|
|
|
|
- wmScorePackage.setPackageFinishStatus("0");
|
|
|
|
- wmScorePackage.setPackageAuditStatus("0");
|
|
|
|
- wmScorePackage.setSendPackageDeptId(SecurityUtils.getUser().getDeptId() + "");
|
|
|
|
- boolean isAnswer = wmScorePackageService.save(wmScorePackage);
|
|
|
|
- if (isAnswer) {
|
|
|
|
- if (SecurityUtils.getRoles().contains(4)) {
|
|
|
|
- WmScorePackage queryWm = new WmScorePackage();
|
|
|
|
- SysDept sysDept1 = new SysDept();
|
|
|
|
- sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
- SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
- if (sysDept.getLevel() == 3) {
|
|
|
|
- queryWm.setAgentTypeId("1");
|
|
|
|
- queryWm.setTypeid("1");
|
|
|
|
- queryWm.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
- queryWm.setLevel1Id(sysDept.getLevel2Id() + "");
|
|
|
|
- queryWm.setTaskRuleId(wmScorePackage.getTaskRuleId());
|
|
|
|
- queryWm.setDeptId(SecurityUtils.getUser().getDeptId() + "");
|
|
|
|
- } else if (sysDept.getLevel() == 4) {
|
|
|
|
- queryWm.setAgentTypeId("2");
|
|
|
|
- queryWm.setTypeid("2");
|
|
|
|
- queryWm.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
- queryWm.setLevel1Id(sysDept.getLevel2Id() + "");
|
|
|
|
- queryWm.setTaskRuleId(wmScorePackage.getTaskRuleId());
|
|
|
|
- } else {
|
|
|
|
- queryWm.setId("-1");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<WmScorePackage> wmScorePackageList = wmScorePackageService.list(Wrappers.query(queryWm));
|
|
|
|
- if (wmScorePackageList.size() > 0) {
|
|
|
|
- for (WmScorePackage wms : wmScorePackageList) {
|
|
|
|
- wms.setIsConduct("1");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- wmScorePackageService.updateBatchById(wmScorePackageList);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return R.ok();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 修改积分包
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @SysLog("修改积分包")
|
|
|
|
- @PutMapping
|
|
|
|
- public R<?> updateById(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
- if (wmScorePackage.getScore() <= 0) {
|
|
|
|
- return R.failed("积分包分值必须大于0");
|
|
|
|
- }
|
|
|
|
- WmScorePackage oldData = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
- if (StringUtils.isNotEmpty(wmScorePackage.getScorePackageName())
|
|
|
|
- && !oldData.getScorePackageName().equals(wmScorePackage.getScorePackageName())) {
|
|
|
|
- WmScorePackage wmScorePackage1 = new WmScorePackage();
|
|
|
|
- wmScorePackage1.setDelFlag("0");
|
|
|
|
- wmScorePackage1.setScorePackageName(wmScorePackage.getScorePackageName());
|
|
|
|
- wmScorePackage1.setDeptId(wmScorePackage.getDeptId());
|
|
|
|
- List<WmScorePackage> wmScorePackageList = wmScorePackageService.listWmScorePackages(wmScorePackage1);
|
|
|
|
- if (wmScorePackageList.size() > 0) {
|
|
|
|
- return R.failed("积分包名称已存在");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (null != wmScorePackage.getScoreId() && !"".equals(wmScorePackage.getScoreId())) {
|
|
|
|
- WmScorePackage wmScorePackage1 = new WmScorePackage();
|
|
|
|
- wmScorePackage1.setDelFlag("0");
|
|
|
|
- wmScorePackage1.setScoreId(wmScorePackage.getScoreId());
|
|
|
|
- List<WmScorePackage> wmScorePackageList = wmScorePackageService.list(Wrappers.query(wmScorePackage1));
|
|
|
|
- if (wmScorePackageList.size() > 1) {
|
|
|
|
- return R.failed("积分包ID已存在");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ("4".equals(wmScorePackage.getPackageStatus())) {
|
|
|
|
- WmTask wmTask = new WmTask();
|
|
|
|
- wmTask.setScorePackageId(wmScorePackage.getId());
|
|
|
|
- List<WmTask> wmTaskList = wmTaskService.list(Wrappers.query(wmTask));
|
|
|
|
-
|
|
|
|
- for (WmTask wmt : wmTaskList) {
|
|
|
|
- wmt.setEnableFlag("1");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- wmTaskService.updateBatchById(wmTaskList);
|
|
|
|
- }
|
|
|
|
- return R.ok(wmScorePackageService.updateById(wmScorePackage));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 修改积分包
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackageVO 积分包
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @SysLog("修改积分包折扣和实际结算金额")
|
|
|
|
- @PostMapping(value = "/updateByIdWithType")
|
|
|
|
- public R<?> updateByIdWithType(@RequestBody @Valid WmScorePackageVO wmScorePackageVO) {
|
|
|
|
- return wmScorePackageService.updateByIdWithType(wmScorePackageVO);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 通过id删除积分包
|
|
|
|
- *
|
|
|
|
- * @param id id
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @SysLog("通过id删除积分包")
|
|
|
|
- @DeleteMapping("/{id}")
|
|
|
|
- public R<?> removeById(@PathVariable Integer id) {
|
|
|
|
- return R.ok(wmScorePackageService.removeById(id));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取药企列表
|
|
|
|
- *
|
|
|
|
- * @return 角色列表
|
|
|
|
- */
|
|
|
|
- @GetMapping("/list")
|
|
|
|
- public R<?> listWmScorePackage(WmScorePackage wmScorePackage) {
|
|
|
|
- wmScorePackage.setDelFlag("0");
|
|
|
|
- wmScorePackage.setEnableFlag("0");
|
|
|
|
-
|
|
|
|
- List<WmScorePackage> list = wmScorePackageService.list(Wrappers.query(wmScorePackage));
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
|
- if (list.size() > 0) {
|
|
|
|
- for (WmScorePackage sysUser : list) {
|
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
|
- map.put("id", sysUser.getId() + "");
|
|
|
|
- if (null == sysUser.getScoreId() || "".equals(sysUser.getScoreId().trim())) {
|
|
|
|
- map.put("scoreId", "-");
|
|
|
|
- } else {
|
|
|
|
- map.put("scoreId", sysUser.getScoreId());
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- if (null == sysUser.getScoreName() || "".equals(sysUser.getScoreName().trim())) {
|
|
|
|
- map.put("scoreName", "-");
|
|
|
|
- } else {
|
|
|
|
- map.put("scoreName", sysUser.getScoreName() + "");
|
|
|
|
- }
|
|
|
|
- answerList.add(map);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- return R.ok(answerList);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取药企列表
|
|
|
|
- *
|
|
|
|
- * @return 角色列表
|
|
|
|
- */
|
|
|
|
- @GetMapping("/listWmScorePackageAndTask")
|
|
|
|
- public R<?> listWmScorePackageAndTask(WmScorePackage wmScorePackage) {
|
|
|
|
- wmScorePackage.setDelFlag("0");
|
|
|
|
- wmScorePackage.setEnableFlag("0");
|
|
|
|
- if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
- wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
- } else if (SecurityUtils.getRoles().contains(4)) {
|
|
|
|
- wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
- }
|
|
|
|
- return R.ok(wmScorePackageService.listWmScorePackageAndTask(wmScorePackage));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取药企列表
|
|
|
|
- *
|
|
|
|
- * @return 角色列表
|
|
|
|
- */
|
|
|
|
- @GetMapping("/packageIsZZ")
|
|
|
|
- public R<?> packageIsZZ(WmScorePackage wmScorePackage) {
|
|
|
|
- wmScorePackage.setDelFlag("0");
|
|
|
|
- wmScorePackage.setEnableFlag("0");
|
|
|
|
-
|
|
|
|
- return R.ok(wmScorePackageService.listWmScorePackageAndTask(wmScorePackage));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 分页查询
|
|
|
|
- *
|
|
|
|
- * @param page 分页对象
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return 分页结果
|
|
|
|
- */
|
|
|
|
- @GetMapping("/getPlatTotalData")
|
|
|
|
- public R<?> getPlatTotalData(Page<?> page, WmScorePackage wmScorePackage, String[] dates) {
|
|
|
|
-
|
|
|
|
- if (null != dates && dates.length > 0) {
|
|
|
|
- // 将时间戳转为当前时间
|
|
|
|
-
|
|
|
|
- wmScorePackage.setDelFlag(dates[0].substring(0, 10));
|
|
|
|
- wmScorePackage.setEnableFlag(dates[1].substring(0, 10));
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- return R.ok(wmScorePackageService.getPlatTotalData(page, wmScorePackage));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取药企列表
|
|
|
|
- *
|
|
|
|
- * @return 角色列表
|
|
|
|
- */
|
|
|
|
- @GetMapping("/listNoDel")
|
|
|
|
- public R<?> listWmScorePackageNoDel(WmScorePackage wmScorePackage) {
|
|
|
|
-
|
|
|
|
- List<WmScorePackage> list = wmScorePackageService.list(Wrappers.query(wmScorePackage));
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
|
- if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
- for (WmScorePackage scorePackage : list) {
|
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
|
- map.put("id", scorePackage.getId() + "");
|
|
|
|
- if (StringUtils.isEmpty(scorePackage.getScoreId())) {
|
|
|
|
- map.put("scoreId", "-");
|
|
|
|
- } else {
|
|
|
|
- map.put("scoreId", scorePackage.getScoreId());
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isEmpty(scorePackage.getScorePackageName())) {
|
|
|
|
- map.put("scoreName", "-");
|
|
|
|
- } else {
|
|
|
|
- map.put("scoreName", scorePackage.getScorePackageName());
|
|
|
|
- }
|
|
|
|
- answerList.add(map);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- return R.ok(answerList);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 分页查询
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return 积分包列表
|
|
|
|
- */
|
|
|
|
- @GetMapping("/selectLists")
|
|
|
|
- public R<?> selectLists(WmScorePackage wmScorePackage) {
|
|
|
|
- wmScorePackage.getRelationScoreId();
|
|
|
|
- return R.ok(wmScorePackageService.selectLists(wmScorePackage));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 查看分配积分信息 二期 业务平台
|
|
|
|
- */
|
|
|
|
- @PostMapping("/selectWmScorePackage")
|
|
|
|
- public R<?> selectWmScorePackage(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
- try {
|
|
|
|
- return R.ok(wmScorePackageService.selectWmScorePackage(wmScorePackage));
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return R.failed();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取企业大包详细信息
|
|
|
|
- *
|
|
|
|
- * @param id 积分包id
|
|
|
|
- * @return {@link R}<{@link ?}> 积分包详情
|
|
|
|
- */
|
|
|
|
- @GetMapping("/get-big-package-detail")
|
|
|
|
- public R<?> getBigPackageDetail(String id) {
|
|
|
|
- WmScorePackage wmScorePackage = wmScorePackageMapper.selectById(id);
|
|
|
|
-
|
|
|
|
- // 关联积分包
|
|
|
|
- if (StrUtil.isBlank(wmScorePackage.getRelationScoreId())) {
|
|
|
|
- wmScorePackage.setRelationScoreId("-1");
|
|
|
|
- wmScorePackage.setRelationScoreName("无");
|
|
|
|
- } else {
|
|
|
|
- WmScorePackage relationPackage = wmScorePackageMapper.selectById(wmScorePackage.getRelationScoreId());
|
|
|
|
- if (relationPackage != null) {
|
|
|
|
- wmScorePackage.setRelationScoreName(relationPackage.getScorePackageName());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 关联服务企业
|
|
|
|
- if (StrUtil.isNotBlank(wmScorePackage.getRelatedService())) {
|
|
|
|
- SysDept serviceDept = sysDeptService.getById(wmScorePackage.getRelatedService());
|
|
|
|
- if (serviceDept != null) {
|
|
|
|
- wmScorePackage.setRelatedServiceName(serviceDept.getName());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 接包对象
|
|
|
|
- if (StrUtil.isNotBlank(wmScorePackage.getAcceptSug())) {
|
|
|
|
- // 此处暂认为drugEnt和agent不会出现相同的id
|
|
|
|
- WmDaAgent daAgent = wmDaAgentMapper.selectById(wmScorePackage.getAcceptSug());
|
|
|
|
- if (daAgent == null) {
|
|
|
|
- WmDaDrugEnt daDrugEnt = wmDaDrugEntMapper.selectById(wmScorePackage.getAcceptSug());
|
|
|
|
- if (daDrugEnt != null) {
|
|
|
|
- wmScorePackage.setAcceptSug(daDrugEnt.getEntname());
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- wmScorePackage.setAcceptSugName(daAgent.getGsmc());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 可分配积分值
|
|
|
|
- List<WmScorePackage> scorePackagekfpjf =
|
|
|
|
- wmScorePackageService.getScorePackagekfpjf(
|
|
|
|
- null,
|
|
|
|
- null,
|
|
|
|
- new String[]{"0", "1", "2"},
|
|
|
|
- new String[]{id});
|
|
|
|
- if (CollUtil.isNotEmpty(scorePackagekfpjf)) {
|
|
|
|
- wmScorePackage.setKfpjf(scorePackagekfpjf.get(0).getKfpjf());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 推广药品
|
|
|
|
- if (ArrayUtil.isNotEmpty(wmScorePackage.getDrugtable())) {
|
|
|
|
- List<WmDaDrugEntDrugtable> drugtables = wmDaDrugEntDrugtableService.listByIds(Stream.of(wmScorePackage.getDrugtable()).collect(Collectors.toSet()));
|
|
|
|
- if (CollUtil.isNotEmpty(drugtables)) {
|
|
|
|
- String[] drugtableNames = drugtables.stream().map(WmDaDrugEntDrugtable::getDrugname).toArray(String[]::new);
|
|
|
|
- wmScorePackage.setDrugtableName(drugtableNames);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 积分包关联的有效任务类型
|
|
|
|
- WmScoreTaskType wmScoreTaskType = new WmScoreTaskType();
|
|
|
|
- wmScoreTaskType.setScoreId("-1".equals(wmScorePackage.getRelationScoreId()) ? wmScorePackage.getId() : wmScorePackage.getRelationScoreId());
|
|
|
|
- List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.listWmScoreTaskType(wmScoreTaskType);
|
|
|
|
- Set<String> taskTypeSet = taskTypeList.stream().map(WmScoreTaskType::getTaskTypeId).collect(Collectors.toSet());
|
|
|
|
- wmScorePackage.setTaskTypeSet(taskTypeSet);
|
|
|
|
-
|
|
|
|
- // 查询关联的试卷
|
|
|
|
- List<WmPkgQuizRelation> quizRelations = pkgQuizRelationService.listQuizRelationsByPkgIds(Collections.singletonList(Integer.parseInt(id)));
|
|
|
|
-
|
|
|
|
- if (CollUtil.isNotEmpty(quizRelations)){
|
|
|
|
- List<Integer> quizIds = quizRelations.stream().map(WmPkgQuizRelation::getQuizId).collect(Collectors.toList());
|
|
|
|
- List<Integer> relIds = quizRelations.stream().map(WmPkgQuizRelation::getRelationId).collect(Collectors.toList());
|
|
|
|
- wmScorePackage.setQuizIds(quizIds);
|
|
|
|
- wmScorePackage.setQuizRelationIds(relIds);
|
|
|
|
- wmScorePackage.setQuizNames(quizRelations.stream().map(WmPkgQuizRelation::getTitle).collect(Collectors.toList()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- wmScorePackage.setQuizRelations(quizRelations);
|
|
|
|
-
|
|
|
|
- return R.ok(wmScorePackage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * BC-企业承接任务
|
|
|
|
- *
|
|
|
|
- * @param current 当前页
|
|
|
|
- * @param size 每页大小
|
|
|
|
- * @param deptId 部门ID
|
|
|
|
- * @param scorePackageName 积分包名称
|
|
|
|
- * @param acceptSug 接包对象
|
|
|
|
- * @param allocationDate 分配日期
|
|
|
|
- * @param endLabelDate 结束标签日期
|
|
|
|
- * @return {@link R}<{@link ?}> 结果
|
|
|
|
- */
|
|
|
|
- @GetMapping("/selectWmScorePackageListsForBC")
|
|
|
|
- public R<?> selectWmScorePackageListForBC(@RequestParam(value = "current") Integer current,
|
|
|
|
- @RequestParam(value = "size") Integer size,
|
|
|
|
- @RequestParam(value = "deptId") Integer deptId,
|
|
|
|
- @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
- @RequestParam(value = "acceptSug", required = false) String acceptSug,
|
|
|
|
- @RequestParam(value = "allocationDate", required = false) LocalDate allocationDate,
|
|
|
|
- @RequestParam(value = "endLabelDate", required = false) LocalDate endLabelDate) {
|
|
|
|
-
|
|
|
|
- Page<WmScorePackage> pageAnswer = wmScorePackageService.selectWmScorePackageLists(new Page<>(current, size), deptId,
|
|
|
|
- scorePackageName, acceptSug, allocationDate, endLabelDate);
|
|
|
|
-
|
|
|
|
- //根据积分包id查询计算完成积分值 已付积分值
|
|
|
|
- List<WmScorePackage> wmList = pageAnswer.getRecords();
|
|
|
|
-
|
|
|
|
- List<Future<WmScorePackage>> futureList = new ArrayList<>(wmList.size());
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- for (WmScorePackage wmS : wmList) {
|
|
|
|
- Future<WmScorePackage> future = wmScorePackageService.finishRate(wmS);
|
|
|
|
- futureList.add(future);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- List<WmScorePackage> finalRecords = new ArrayList<>(wmList.size());
|
|
|
|
- try {
|
|
|
|
- for (Future<WmScorePackage> future : futureList) {
|
|
|
|
- WmScorePackage wmScorePackage = future.get();
|
|
|
|
-
|
|
|
|
- if (wmScorePackage.getP2pAmount() != null) {
|
|
|
|
- wmScorePackage.setP2pDraft(false);
|
|
|
|
- } else {
|
|
|
|
- String s = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:amount:%s", wmScorePackage.getId()));
|
|
|
|
- String s1 = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:service-amount:%s", wmScorePackage.getId()));
|
|
|
|
- String desc = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:desc:%s", wmScorePackage.getId()));
|
|
|
|
- if (StrUtil.isNotBlank(s)) {
|
|
|
|
- wmScorePackage.setP2pAmount(new BigDecimal(s));
|
|
|
|
- wmScorePackage.setP2pServiceAmount(new BigDecimal(s1));
|
|
|
|
- wmScorePackage.setDescription(desc);
|
|
|
|
- }
|
|
|
|
- wmScorePackage.setP2pDraft(true);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- finalRecords.add(wmScorePackage);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- pageAnswer.setRecords(finalRecords);
|
|
|
|
- } catch (ExecutionException | InterruptedException e) {
|
|
|
|
- log.error("获取分页信息失败", e);
|
|
|
|
- return R.failed("获取分页信息失败");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok(pageAnswer);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 分页查询积分管理信息 二期 业务平台
|
|
|
|
- */
|
|
|
|
- @GetMapping("/selectWmScorePackageLists")
|
|
|
|
- public R<?> selectWmScorePackageList(@RequestParam(value = "current") Integer current,
|
|
|
|
- @RequestParam(value = "size") Integer size,
|
|
|
|
- @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
- @RequestParam(value = "acceptSug", required = false) String acceptSug,
|
|
|
|
- @RequestParam(value = "allocationDate", required = false) LocalDate allocationDate,
|
|
|
|
- @RequestParam(value = "endLabelDate", required = false) LocalDate endLabelDate) {
|
|
|
|
- Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
-
|
|
|
|
- return this.selectWmScorePackageListForBC(current, size, deptId, scorePackageName, acceptSug, allocationDate, endLabelDate);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取关联积分包名称 二期 业务平台
|
|
|
|
- *
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @GetMapping("/lists")
|
|
|
|
- public R<?> listWmScorePackages(WmScorePackage wmScorePackage) {
|
|
|
|
- // 当前企业deptId
|
|
|
|
- String deptId = wmScorePackage.getDeptId();
|
|
|
|
- if (StrUtil.isBlank(deptId)) {
|
|
|
|
- deptId = String.valueOf(SecurityUtils.getUser().getDeptId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- wmScorePackage.setDelFlag("0");
|
|
|
|
- wmScorePackage.setEnableFlag("0");
|
|
|
|
- wmScorePackage.setDeptId(deptId);
|
|
|
|
- List<WmScorePackage> list = wmScorePackageService.list(Wrappers.query(wmScorePackage));
|
|
|
|
-
|
|
|
|
- SysDept dept = sysDeptService.getById(deptId);
|
|
|
|
-
|
|
|
|
- List<Map<String, Object>> answerList = new ArrayList<>();
|
|
|
|
- if (dept.getLevel() == 3) {
|
|
|
|
- for (WmScorePackage wmScorePackage1 : list) {
|
|
|
|
- Map<String, Object> map1 = new HashMap<>();
|
|
|
|
- map1.put("relationScoreId", wmScorePackage1.getId());
|
|
|
|
- map1.put("scorePackageName", wmScorePackage1.getScorePackageName());
|
|
|
|
- answerList.add(map1);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- return R.ok(answerList);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 根据上级药企获取关联积分包 二期 业务平台(企业承接新增积分包的)
|
|
|
|
- *
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @GetMapping("/selectRelationScoreId")
|
|
|
|
- public R<?> selectRelationScoreId(WmScorePackage wmScorePackage) {
|
|
|
|
-
|
|
|
|
- SysDept selfId = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
-
|
|
|
|
- SysDept sysDept = sysDeptService.getById(wmScorePackage.getRelatedService());
|
|
|
|
-
|
|
|
|
- List<Map<String, Object>> answerList = new ArrayList<>();
|
|
|
|
-
|
|
|
|
- //获取关联积分包
|
|
|
|
- if (sysDept.getLevel() == 2 && selfId.getLevel() != 2) {
|
|
|
|
- wmScorePackage.setSendPackageDeptId(wmScorePackage.getRelatedService());
|
|
|
|
- wmScorePackage.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
- List<WmScorePackage> list = wmScorePackageService.selectByReRelatedService(wmScorePackage);
|
|
|
|
- if (list.size() > 0) {
|
|
|
|
- for (WmScorePackage wmScorePackage1 : list) {
|
|
|
|
- if (wmScorePackage1.getKfpjf() == null || wmScorePackage1.getKfpjf() <= 0) {
|
|
|
|
- // 过滤掉可分配积分值为0的积分包
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- Map<String, Object> map1 = new HashMap<>();
|
|
|
|
- map1.put("relationScoreName", wmScorePackage1.getScorePackageName());
|
|
|
|
- map1.put("drugProducerList", wmScorePackage1.getDrugProducerList());
|
|
|
|
- map1.put("drugtable", wmScorePackage1.getDrugtable());
|
|
|
|
- map1.put("id", wmScorePackage1.getId());
|
|
|
|
- answerList.add(map1);
|
|
|
|
- }
|
|
|
|
- } else if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
- Map<String, Object> map2 = new HashMap<>();
|
|
|
|
- map2.put("id", "-1");
|
|
|
|
- map2.put("relationScoreName", "无");
|
|
|
|
- answerList.add(map2);
|
|
|
|
- }
|
|
|
|
- } else if (sysDept.getLevel() == 3) {
|
|
|
|
- wmScorePackage.setSendPackageDeptId(wmScorePackage.getRelatedService());
|
|
|
|
- wmScorePackage.setDeptId(wmScorePackage.getRelatedService());
|
|
|
|
- List<WmScorePackage> list = wmScorePackageService.selectByReRelatedService(wmScorePackage);
|
|
|
|
- for (WmScorePackage wmScorePackage1 : list) {
|
|
|
|
- if (wmScorePackage1.getKfpjf() == null || wmScorePackage1.getKfpjf() <= 0) {
|
|
|
|
- // 过滤掉可分配积分值为0的积分包
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- Map<String, Object> map3 = new HashMap<>();
|
|
|
|
- map3.put("id", wmScorePackage1.getId());
|
|
|
|
- map3.put("drugProducerList", wmScorePackage1.getDrugProducerList());
|
|
|
|
- map3.put("drugtable", wmScorePackage1.getDrugtable());
|
|
|
|
- map3.put("relationScoreName", wmScorePackage1.getScorePackageName());
|
|
|
|
- answerList.add(map3);
|
|
|
|
- }
|
|
|
|
- Map<String, Object> map4 = new HashMap<>();
|
|
|
|
- map4.put("id", "-1");
|
|
|
|
- map4.put("relationScoreName", "无");
|
|
|
|
- answerList.add(map4);
|
|
|
|
- } else if (selfId.getLevel() == 2) {
|
|
|
|
- Map<String, Object> map5 = new HashMap<>();
|
|
|
|
- map5.put("id", "-1");
|
|
|
|
- map5.put("relationScoreName", "无");
|
|
|
|
- answerList.add(map5);
|
|
|
|
- }
|
|
|
|
- return R.ok(answerList);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取可分配积分 二期 业务平台
|
|
|
|
- *
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @GetMapping("/selectKfpjf")
|
|
|
|
- public R<?> selectKfpjf(WmScorePackage wmScorePackage) {
|
|
|
|
-
|
|
|
|
- SysDept wmId = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
- WmDaAgent anId = wmDaAgentService.selectByDeptId(wmId.getDeptId());
|
|
|
|
- List<Map<String, Object>> answerList = new ArrayList<>();
|
|
|
|
- Map<String, Object> map2 = new HashMap<>();
|
|
|
|
-
|
|
|
|
- //获取接包对象和可分配积分
|
|
|
|
- List wmDaDrugEnts = new ArrayList();
|
|
|
|
- if ("-1".equals(wmScorePackage.getId()) && wmId.getLevel() == 3) {
|
|
|
|
- map2.put("kfpjf", "");
|
|
|
|
- List<WmDaAgent> list = wmDaAgentService.listAgentByDeptRelation(Integer.parseInt(anId.getDeptId()));
|
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
|
- if (Integer.parseInt(list.get(i).getEnableFlag()) == 0) {
|
|
|
|
- wmDaDrugEnts.add(list.get(i));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else if ("-1".equals(wmScorePackage.getId()) && wmId.getDeptId()
|
|
|
|
- .equals(SecurityUtils.getUser().getDeptId())) {
|
|
|
|
- WmDaDrugEnt wmDaDrugEnt = wmDaDrugEntService.selectByDeptId(wmId.getDeptId());
|
|
|
|
- List<WmDaAgent> list = wmDaAgentService.selectWmDaAgentByDeptId(wmDaDrugEnt.getDeptId());
|
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
|
- if (Integer.parseInt(list.get(i).getEnableFlag()) == 0) {
|
|
|
|
- wmDaDrugEnts.add(list.get(i));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- List<WmDaAgent> list = wmDaAgentService.selectWmDaAgentByRelationIds(wmId.getDeptId());
|
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
|
- if (Integer.parseInt(list.get(i).getEnableFlag()) == 0) {
|
|
|
|
- wmDaDrugEnts.add(list.get(i));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- wmScorePackage.setDelFlag("0");
|
|
|
|
- wmScorePackage.setEnableFlag("0");
|
|
|
|
- List<WmScorePackage> list = wmScorePackageService.list(Wrappers.query(wmScorePackage));
|
|
|
|
- map2.put("acceptSug", wmDaDrugEnts);
|
|
|
|
- for (WmScorePackage wmScorePackage1 : list) {
|
|
|
|
- if (SecurityUtils.getUser().getDeptId().equals(Integer.valueOf(wmScorePackage1.getDeptId()))) {
|
|
|
|
- WmScoreTaskType wmScoreTaskType = new WmScoreTaskType();
|
|
|
|
- wmScoreTaskType.setScoreId(wmScorePackage1.getId());
|
|
|
|
- wmScorePackage1.setWmScoreTaskTypeList(wmScoreTaskTypeService.listWmScoreTaskTypes(wmScoreTaskType));
|
|
|
|
- map2.put("kfpjf", wmScorePackage1.getKfpjf());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- answerList.add(map2);
|
|
|
|
- //获取数据
|
|
|
|
- if (wmId.getLevel() == 3) {
|
|
|
|
- for (WmScorePackage wmScorePackage1 : list) {
|
|
|
|
- Map<String, Object> map1 = new HashMap<>();
|
|
|
|
- List<String> stringList = new ArrayList<>();
|
|
|
|
- if (SecurityUtils.getUser().getDeptId().equals(Integer.valueOf(wmScorePackage1.getDeptId()))) {
|
|
|
|
- WmScoreTaskType wmScoreTaskType = new WmScoreTaskType();
|
|
|
|
- wmScoreTaskType.setScoreId(wmScorePackage1.getId());
|
|
|
|
- List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.listWmScoreTaskType(wmScoreTaskType);
|
|
|
|
- Set<String> taskTypeSet = taskTypeList.stream()
|
|
|
|
- .map(WmScoreTaskType::getTaskTypeId)
|
|
|
|
- .collect(Collectors.toSet());
|
|
|
|
- wmScorePackage.setTaskTypeSet(taskTypeSet);
|
|
|
|
- map1.put("scoreId", wmScorePackage1.getScoreId());
|
|
|
|
- map1.put("id", wmScorePackage1.getId());
|
|
|
|
- map1.put("kfpjf", wmScorePackage1.getKfpjf());
|
|
|
|
- map1.put("belongDate", wmScorePackage1.getBelongDate());
|
|
|
|
- map1.put("packsgeType1", wmScorePackage1.getPackageType1());
|
|
|
|
- map1.put("wmScoreTaskTypeList", wmScorePackage.getTaskTypeSet());
|
|
|
|
- map1.put("wmScoreTaskTypeList1", wmScorePackage1.getWmScoreTaskTypeList());
|
|
|
|
- stringList.add(wmScorePackage1.getScoreId());
|
|
|
|
- answerList.add(map1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- return R.ok(answerList);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 新增积分包(大包)
|
|
|
|
- * <p>
|
|
|
|
- * 满足以下任一条件,则可以发包
|
|
|
|
- * 1.存在积分充值配置,并且 发包积分 < 积分充值分配的积分
|
|
|
|
- * 2.关联了上级积分包
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 积分包信息
|
|
|
|
- * @return 新增结果
|
|
|
|
- */
|
|
|
|
- @SysLog("新增积分包(大包)")
|
|
|
|
- @PostMapping("/saves")
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
- public R<?> saves(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
-
|
|
|
|
- log.info("新增积分包(大包)入参:{}", wmScorePackage);
|
|
|
|
-
|
|
|
|
- HnqzUser operator = SecurityUtils.getUser();
|
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
|
- List<Integer> roles = SecurityUtils.getRoles();
|
|
|
|
- Integer deptId = operator.getDeptId();
|
|
|
|
- Integer userId = operator.getId();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- String relPkgId = wmScorePackage.getRelationScoreId();
|
|
|
|
- boolean relatedScoreId = StrUtil.isNotBlank(relPkgId) && Integer.parseInt(relPkgId) > 0;
|
|
|
|
- SysDeptRecharge deptRecharge = null;
|
|
|
|
-
|
|
|
|
- // 校验积分值
|
|
|
|
- if (wmScorePackage.getScore() <= 0) {
|
|
|
|
- return R.failed("积分包分值必须大于0");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 校验积分包名称是否存在
|
|
|
|
- if (StrUtil.isNotBlank(wmScorePackage.getScorePackageName())) {
|
|
|
|
-
|
|
|
|
- int existed = wmScorePackageService.count(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
- .eq(WmScorePackage::getDelFlag, "0")
|
|
|
|
- .eq(WmScorePackage::getScorePackageName, wmScorePackage.getScorePackageName())
|
|
|
|
- .eq(WmScorePackage::getDeptId, wmScorePackage.getDeptId()));
|
|
|
|
-
|
|
|
|
- if (existed != 0) {
|
|
|
|
- return R.failed("积分包名称已存在");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 校验积分值
|
|
|
|
- if (!relatedScoreId) {
|
|
|
|
- // 校验 发包积分 < 积分充值分配的积分 则可以发包
|
|
|
|
- deptRecharge = sysDeptRechargeMapper.selectOne(Wrappers.<SysDeptRecharge>lambdaQuery().eq(SysDeptRecharge::getDeptId, deptId));
|
|
|
|
- if (deptRecharge == null) {
|
|
|
|
- log.error("未配置积分充值信息");
|
|
|
|
- throw new BizException("积分余额:0,积分不足");
|
|
|
|
- }
|
|
|
|
- int limitScore = deptRecharge.getScore() + deptRecharge.getOverdrawScore();
|
|
|
|
- if (wmScorePackage.getScore() > limitScore) {
|
|
|
|
- log.error("已分配积分不足,发包积分={},剩余积分={},透支额度={}", wmScorePackage.getScore(), deptRecharge.getScore(), limitScore);
|
|
|
|
- throw new BizException(String.format("积分余额:%s,积分不足", deptRecharge.getScore()));
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- // 校验上级可分配积分值
|
|
|
|
- List<WmScorePackage> scorePackagekfpjf =
|
|
|
|
- wmScorePackageService.getScorePackagekfpjf(
|
|
|
|
- null,
|
|
|
|
- null,
|
|
|
|
- new String[]{"0", "1", "2"},
|
|
|
|
- new String[]{wmScorePackage.getRelationScoreId()});
|
|
|
|
-
|
|
|
|
- if (CollUtil.isNotEmpty(scorePackagekfpjf)) {
|
|
|
|
- int kfpjf = scorePackagekfpjf.get(0).getKfpjf();
|
|
|
|
- if (wmScorePackage.getScore() > kfpjf) {
|
|
|
|
- log.error("可分配积分值不足");
|
|
|
|
- throw new BizException("可分配积分值不足");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- wmScorePackage.setPackageType1("1");
|
|
|
|
- wmScorePackage.setDelFlag("0");
|
|
|
|
- wmScorePackage.setEnableFlag("0");
|
|
|
|
- wmScorePackage.setPackageIsConduct("0");
|
|
|
|
- wmScorePackage.setDrugEntId("");
|
|
|
|
- wmScorePackage.setCreateUser(userId);
|
|
|
|
- wmScorePackage.setCreateTime(now);
|
|
|
|
- wmScorePackage.setUpdateTime(now);
|
|
|
|
- wmScorePackage.setPackageFinishStatus("0");
|
|
|
|
- wmScorePackage.setPackageAuditStatus("0");
|
|
|
|
- wmScorePackage.setSendPackageDeptId(deptId.toString());
|
|
|
|
- wmScorePackage.setAllocationDate(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN).format(now));
|
|
|
|
- if (wmScorePackage.getEndTime() == null) {
|
|
|
|
- // 默认截止日期为一年后
|
|
|
|
- wmScorePackage.setEndTime(now.plusYears(1).toLocalDate());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 关联上级推广药品企业(兼容历史)
|
|
|
|
- if (StringUtils.isEmpty(relPkgId)) {
|
|
|
|
- wmScorePackage.setDrugProducerList(null);
|
|
|
|
- } else if (StringUtils.isNotEmpty(relPkgId) && ArrayUtils.isEmpty(wmScorePackage.getDrugtable())) {
|
|
|
|
- // 关联上级推广药品
|
|
|
|
- WmScorePackage relateSp = wmScorePackageService.getById(relPkgId);
|
|
|
|
- if (relateSp != null) {
|
|
|
|
- wmScorePackage.setDrugtable(relateSp.getDrugtable());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- SysDept sysDeptRelatedService = sysDeptService.getById(Integer.valueOf(wmScorePackage.getRelatedService()));
|
|
|
|
- if (StrUtil.isBlank(wmScorePackage.getTypeid())) {
|
|
|
|
- WmDaDrugEnt wmDaDrugEnt = wmDaDrugEntService.selectByDeptId(deptId);
|
|
|
|
- if (wmDaDrugEnt != null) {
|
|
|
|
- if (null != wmScorePackage.getAcceptSug() && !wmScorePackage.getAcceptSug().equals(wmDaDrugEnt.getId())) {
|
|
|
|
- WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getAcceptSug());
|
|
|
|
- SysDept sysDepts = sysDeptService.getById(Integer.valueOf(wmDaAgent.getDeptId()));
|
|
|
|
- if (sysDepts.getLevel() == 3) {
|
|
|
|
- wmScorePackage.setLevel1Id(wmDaAgent.getId());
|
|
|
|
- } else if (sysDepts.getLevel() == 4) {
|
|
|
|
- wmScorePackage.setLevel2Id(wmDaAgent.getId());
|
|
|
|
- }
|
|
|
|
- wmScorePackage.setDeptId(wmDaAgent.getDeptId());
|
|
|
|
- wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
- } else if (wmDaDrugEnt.getId().equals(wmScorePackage.getAcceptSug())) {
|
|
|
|
- wmScorePackage.setDeptId(deptId.toString());
|
|
|
|
- wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if (sysDeptRelatedService.getLevel() == 2) {
|
|
|
|
- WmDaDrugEnt wmDaDrugEnts = wmDaDrugEntService.selectByDeptId(Integer.valueOf(wmScorePackage.getRelatedService()));
|
|
|
|
- if (null != wmScorePackage.getAcceptSug() && !wmScorePackage.getAcceptSug().equals(wmDaDrugEnts.getId())) {
|
|
|
|
- WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getAcceptSug());
|
|
|
|
- SysDept sysDepts = sysDeptService.getById(Integer.valueOf(wmDaAgent.getDeptId()));
|
|
|
|
-
|
|
|
|
- if (sysDepts.getLevel() == 3) {
|
|
|
|
- wmScorePackage.setLevel1Id(wmDaAgent.getId());
|
|
|
|
- } else if (sysDepts.getLevel() == 4) {
|
|
|
|
- wmScorePackage.setLevel2Id(wmDaAgent.getId());
|
|
|
|
- }
|
|
|
|
- wmScorePackage.setDeptId(wmDaAgent.getDeptId());
|
|
|
|
- wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
- } else if (wmScorePackage.getAcceptSug().equals(wmDaDrugEnt.getId())) {
|
|
|
|
- wmScorePackage.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
- wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
- }
|
|
|
|
- } else if (sysDeptRelatedService.getLevel() == 3) {
|
|
|
|
- WmDaAgent wmDaAgent1 = wmDaAgentService.selectByDeptId(Integer.valueOf(wmScorePackage.getRelatedService()));
|
|
|
|
- if (null != wmScorePackage.getAcceptSug() && !wmScorePackage.getAcceptSug().equals(wmDaAgent1.getId())) {
|
|
|
|
- WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getAcceptSug());
|
|
|
|
- SysDept sysDepts = sysDeptService.getById(Integer.valueOf(wmDaAgent.getDeptId()));
|
|
|
|
- if (sysDepts.getLevel() == 3) {
|
|
|
|
- wmScorePackage.setLevel1Id(wmDaAgent.getId());
|
|
|
|
- } else if (sysDepts.getLevel() == 4) {
|
|
|
|
- wmScorePackage.setLevel2Id(wmDaAgent.getId());
|
|
|
|
- }
|
|
|
|
- wmScorePackage.setDeptId(wmDaAgent.getDeptId());
|
|
|
|
- wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
- } else if (wmDaAgent1.getId().equals(wmScorePackage.getAcceptSug())) {
|
|
|
|
- wmScorePackage.setDeptId(deptId.toString());
|
|
|
|
- wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //药企规则ID
|
|
|
|
- SysDept sysDeptRuleId = sysDeptService.getById(deptId);
|
|
|
|
- Integer deptLevel = sysDeptRuleId.getLevel();
|
|
|
|
-
|
|
|
|
- if (deptLevel == 2) {
|
|
|
|
- WmDaDrugEnt wmDaDrugEnt = wmDaDrugEntService.selectByDeptId(sysDeptRuleId.getDeptId());
|
|
|
|
- if (wmScorePackage.getAcceptSug().equals(wmDaDrugEnt.getId())) {
|
|
|
|
- wmScorePackage.setRuleId(wmScorePackage.getAcceptSug());
|
|
|
|
- wmScorePackage.setDrugEntId(wmDaDrugEnt.getId());
|
|
|
|
- } else if (!wmScorePackage.getAcceptSug().equals(wmDaDrugEnt.getId())) {
|
|
|
|
- WmTaskType wmTaskType = new WmTaskType();
|
|
|
|
- wmTaskType.setRuleId(wmDaDrugEnt.getId() + wmScorePackage.getAcceptSug());
|
|
|
|
- List<WmTaskType> wmTaskTypeList = wmTaskTypeService.selectByRuleId(wmTaskType);
|
|
|
|
- if (CollUtil.isNotEmpty(wmTaskTypeList)) {
|
|
|
|
- wmScorePackage.setRuleId(wmDaDrugEnt.getId() + wmScorePackage.getAcceptSug());
|
|
|
|
- wmScorePackage.setDrugEntId(wmDaDrugEnt.getId());
|
|
|
|
- } else {
|
|
|
|
- log.error("请药企给下级cso分配积分规则");
|
|
|
|
- return R.failed("请药企给下级cso分配积分规则");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- } else if (deptLevel == 3) {
|
|
|
|
- //一级cso规则ID
|
|
|
|
- WmDaAgent daAgent = wmDaAgentService.getOne(Wrappers.<WmDaAgent>lambdaQuery()
|
|
|
|
- .eq(WmDaAgent::getEnableFlag, EnableEnum.ENABLE.val())
|
|
|
|
- .eq(WmDaAgent::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
|
- .eq(WmDaAgent::getDeptId, String.valueOf(sysDeptRuleId.getDeptId())));
|
|
|
|
- if (StringUtils.isNotBlank(wmScorePackage.getRelationScoreId())) {
|
|
|
|
- // 关联了积分包的情况
|
|
|
|
- WmScorePackage relationScorePackage = wmScorePackageService.getById(wmScorePackage.getRelationScoreId());
|
|
|
|
- if (relationScorePackage != null) {
|
|
|
|
- wmScorePackage.setRuleId(relationScorePackage.getRuleId());
|
|
|
|
- wmScorePackage.setDrugEntId(relationScorePackage.getDrugEntId());
|
|
|
|
- } else {
|
|
|
|
- log.error("cso没有分配积分规则");
|
|
|
|
- return R.failed("cso没有分配积分规则");
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- // 没有关联积分包的情况
|
|
|
|
- List<WmTaskType> taskTypeList = wmTaskTypeService.list(Wrappers.<WmTaskType>lambdaQuery()
|
|
|
|
- .eq(WmTaskType::getRuleId, daAgent.getId()));
|
|
|
|
- if (CollectionUtil.isNotEmpty(taskTypeList)) {
|
|
|
|
- wmScorePackage.setRuleId(daAgent.getId());
|
|
|
|
- wmScorePackage.setDrugEntId("");
|
|
|
|
- } else {
|
|
|
|
- log.error("cso没有分配积分规则");
|
|
|
|
- return R.failed("cso没有分配积分规则");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 保存积分包
|
|
|
|
- String typeId = "";
|
|
|
|
- if (roles.contains(4) || roles.contains(3)) {
|
|
|
|
- if (deptLevel == 2) {
|
|
|
|
- typeId = wmScorePackage.getDeptId().equals(deptId.toString()) ? "0" : "1";
|
|
|
|
- } else if (deptLevel == 3) {
|
|
|
|
- typeId = wmScorePackage.getDeptId().equals(deptId.toString()) ? "1" : "2";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- wmScorePackage.setTypeid(typeId);
|
|
|
|
- boolean isAnswer = wmScorePackageService.save(wmScorePackage);
|
|
|
|
-
|
|
|
|
- // 发包成功 更新 上级包
|
|
|
|
- if (isAnswer) {
|
|
|
|
- if ((roles.contains(4) || roles.contains(3)) && deptLevel == 3) {
|
|
|
|
- WmScorePackage relPkg = wmScorePackageService.getById(relPkgId);
|
|
|
|
- // 是当前操作人所在企业的的关联包
|
|
|
|
- if (relPkg != null && deptId.toString().equals(relPkg.getDeptId())) {
|
|
|
|
- relPkg.setKfpjf((int) Math.ceil(relPkg.getKfpjf() - wmScorePackage.getScore()));
|
|
|
|
- // 判断积分包是否被发放 (原有外包业务逻辑,不知道为什么)
|
|
|
|
- int count = wmScorePackageService.count(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
- .ne(WmScorePackage::getId, wmScorePackage.getId())
|
|
|
|
- .eq(WmScorePackage::getId, relPkgId)
|
|
|
|
- .eq(WmScorePackage::getEnableFlag, "0")
|
|
|
|
- .notIn(WmScorePackage::getTypeid, 3, 4));
|
|
|
|
-
|
|
|
|
- relPkg.setPackageIsConduct(count == 0 ? "0" : "1");
|
|
|
|
- wmScorePackageService.updateById(relPkg);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // 失败了
|
|
|
|
- else {
|
|
|
|
- return R.failed("下发积分包失败");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<WmScoreTaskType> taskTypeList = wmScorePackage.getWmScoreTaskTypeList();
|
|
|
|
- if (CollUtil.isNotEmpty(taskTypeList)) {
|
|
|
|
-
|
|
|
|
- if (StrUtil.isBlank(relPkgId) || (StrUtil.isNotBlank(relPkgId) && deptLevel == 3)) {
|
|
|
|
- List<WmScoreTaskType> scoreTaskTypes = taskTypeList.stream().map(taskType -> {
|
|
|
|
- WmScoreTaskType wmScoreTaskType = new WmScoreTaskType();
|
|
|
|
- wmScoreTaskType.setScoreId(wmScorePackage.getId());
|
|
|
|
- wmScoreTaskType.setType("1");
|
|
|
|
- wmScoreTaskType.setTaskTypeId(taskType.getTaskTypeId());
|
|
|
|
-
|
|
|
|
- return wmScoreTaskType;
|
|
|
|
- }).collect(Collectors.toList());
|
|
|
|
- wmScoreTaskTypeService.deleteByScoreId(wmScorePackage.getId());
|
|
|
|
- wmScoreTaskTypeService.batchInsertType(scoreTaskTypes);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (!relatedScoreId) {
|
|
|
|
- // 更新积分充值信息
|
|
|
|
- int currentScore = deptRecharge.getScore() - wmScorePackage.getScore();
|
|
|
|
- int updateRecharge = sysDeptRechargeMapper.update(null, Wrappers.<SysDeptRecharge>lambdaUpdate()
|
|
|
|
- .eq(SysDeptRecharge::getId, deptRecharge.getId())
|
|
|
|
- .eq(SysDeptRecharge::getVersion, deptRecharge.getVersion())
|
|
|
|
- .set(SysDeptRecharge::getScore, currentScore)
|
|
|
|
- .set(SysDeptRecharge::getVersion, deptRecharge.getVersion() + 1)
|
|
|
|
- .set(SysDeptRecharge::getUpdateTime, now)
|
|
|
|
- .set(SysDeptRecharge::getUpdateUser, userId));
|
|
|
|
- if (updateRecharge <= 0) {
|
|
|
|
- log.warn("更新积分充值信息失败");
|
|
|
|
- throw new RuntimeException("操作失败,请重试");
|
|
|
|
- }
|
|
|
|
- // 更新积分充值记录
|
|
|
|
- SysDeptRechargeRecord rechargeRecord = new SysDeptRechargeRecord();
|
|
|
|
- rechargeRecord.setDeptId(deptId);
|
|
|
|
- rechargeRecord.setChangeScore(-wmScorePackage.getScore());
|
|
|
|
- rechargeRecord.setRechargeId(deptRecharge.getId());
|
|
|
|
- rechargeRecord.setPackageId(wmScorePackage.getId());
|
|
|
|
- rechargeRecord.setPackageType(RechargeRecordPackageType.TO_ENTERPRISE);
|
|
|
|
- rechargeRecord.setType(RechargeRecordType.SEND_PACKAGE_DEPT);
|
|
|
|
- rechargeRecord.setCurrentScore(currentScore);
|
|
|
|
- rechargeRecord.setCreateUser(userId);
|
|
|
|
- rechargeRecord.setCreateTime(now);
|
|
|
|
- sysDeptRechargeRecordMapper.insert(rechargeRecord);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 保存关联的试卷
|
|
|
|
- if (CollUtil.isNotEmpty(wmScorePackage.getQuizIds())) {
|
|
|
|
- pkgQuizRelationService.createPkgQuizzes(wmScorePackage.getQuizIds(), Integer.parseInt(wmScorePackage.getId()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 判断是否有关联关系
|
|
|
|
- if (CollUtil.isNotEmpty(wmScorePackage.getQuizRelationIds())) {
|
|
|
|
- pkgQuizRelationService.copyQuizRelations(wmScorePackage.getQuizRelationIds(), Integer.parseInt(wmScorePackage.getId()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 终止积分包(大包)
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 积分包信息
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @SysLog("终止积分包(大包)")
|
|
|
|
- @PostMapping("/stopWmScorePackage")
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
-
|
|
|
|
- public R<?> stopWmScorePackage(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
- log.info("终止积分包(大包)入参:{}", wmScorePackage);
|
|
|
|
- if (StrUtil.isBlank(wmScorePackage.getId()) || !StrUtil.equalsAny(wmScorePackage.getEnableType(), "1", "2")) {
|
|
|
|
- return R.failed("参数错误");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- String cacheKey = CacheConstants.TERMINATE_PACKAGE_KEY + wmScorePackage.getId();
|
|
|
|
- Boolean absent = redisTemplate.opsForValue().setIfAbsent(cacheKey, JSONUtil.toJsonStr(wmScorePackage), 3L, TimeUnit.SECONDS);
|
|
|
|
- if (Boolean.FALSE.equals(absent)) {
|
|
|
|
- return R.failed("正在处理");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok(wmScorePackageService.terminatePackageForDept(wmScorePackage.getId(),
|
|
|
|
- UpmsType.TerminatePackageType.getByEnableType(wmScorePackage.getEnableType())));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 终止积分包 new 终止 二期 业务平台
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @SysLog("终止积分包")
|
|
|
|
- @PostMapping("/updateStatusByIds")
|
|
|
|
- public R<?> updateStatusByIds(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
- if (wmScorePackage.getScore() <= 0) {
|
|
|
|
- return R.failed("积分包分值必须大于0");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- wmScorePackage.setUpdateUser(SecurityUtils.getUser().getId());
|
|
|
|
- wmScorePackage.setUpdateTime(LocalDateTime.now());
|
|
|
|
- if (null != wmScorePackage.getRelationScoreId() && !"".equals(wmScorePackage.getRelationScoreId())) {
|
|
|
|
- WmScorePackage wmScorePackage1 = new WmScorePackage();
|
|
|
|
- wmScorePackage1.setDelFlag("0");
|
|
|
|
- wmScorePackage1.setRelationScoreId(wmScorePackage.getRelationScoreId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (null != wmScorePackage.getScorePackageName() && !"".equals(wmScorePackage.getScorePackageName())) {
|
|
|
|
- WmScorePackage wmScorePackage1 = new WmScorePackage();
|
|
|
|
- wmScorePackage1.setEnableFlag("0");
|
|
|
|
- List<WmScorePackage> wmScorePackageList = wmScorePackageService.list(Wrappers.query(wmScorePackage1));
|
|
|
|
- WmScorePackage wmId = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
- if (wmScorePackageList.size() > 0) {
|
|
|
|
- for (WmScorePackage wms : wmScorePackageList) {
|
|
|
|
- if (wmId.getId().equals(wms.getRelationScoreId())) {
|
|
|
|
- return R.failed("积分包已被分派,请联系下属CSO终止关联积分包");
|
|
|
|
- } else if (null != wms.getRelationScoreId() && "".equals(wms.getRelationScoreId())) {
|
|
|
|
- wmScorePackage.setEnableFlag("1");
|
|
|
|
- wmScorePackage.setPackageFinishStatus("2");
|
|
|
|
- List<WmScorePackage> wmScorePackages = wmScorePackageService.selectRelationScoreId(wmId.getId());
|
|
|
|
- if (wmScorePackages.size() > 0) {
|
|
|
|
- for (WmScorePackage wmScorePackage3 : wmScorePackages) {
|
|
|
|
- if (wmId.getRelationScoreId().equals(wmScorePackage3.getRelationScoreId())) {
|
|
|
|
- wms.setPackageIsConduct("1");
|
|
|
|
- break;
|
|
|
|
- } else {
|
|
|
|
- wms.setPackageIsConduct("0");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- wmScorePackage.setPackageIsConduct("0");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (SecurityUtils.getRoles().contains(4) || SecurityUtils.getRoles().contains(3)) {
|
|
|
|
- WmScorePackage queryWm = new WmScorePackage();
|
|
|
|
-
|
|
|
|
- SysDept sysDept = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
-
|
|
|
|
- if (sysDept.getLevel() == 3) {
|
|
|
|
- queryWm.setEnableFlag("0");
|
|
|
|
- } else {
|
|
|
|
- queryWm.setId("-1");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<WmScorePackage> wmScorePackageList = wmScorePackageService.list(Wrappers.query(queryWm));
|
|
|
|
- WmScorePackage wmId = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
- if (wmScorePackageList.size() > 0) {
|
|
|
|
- for (WmScorePackage wmScorePackage2 : wmScorePackageList) {
|
|
|
|
- if (wmId.getId().equals(wmScorePackage2.getRelationScoreId())) {
|
|
|
|
- return R.failed("积分包已被分派,请联系下属CSO终止关联积分包");
|
|
|
|
- } else if (wmScorePackage2.getId().equals(wmId.getRelationScoreId())) {
|
|
|
|
- List<WmScorePackage> wmScorePackages = wmScorePackageService.selectRelationScoreId(wmId.getId());
|
|
|
|
- if (wmScorePackages.size() > 0) {
|
|
|
|
- for (WmScorePackage wmScorePackage1 : wmScorePackages) {
|
|
|
|
- if (wmId.getRelationScoreId().equals(wmScorePackage1.getRelationScoreId())) {
|
|
|
|
- wmScorePackage2.setPackageIsConduct("1");
|
|
|
|
- break;
|
|
|
|
- } else {
|
|
|
|
- wmScorePackage2.setPackageIsConduct("0");
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- wmScorePackage.setEnableFlag("1");
|
|
|
|
- wmScorePackage.setPackageFinishStatus("2");
|
|
|
|
- wmScorePackage2.setKfpjf(new Double(Math.ceil(wmScorePackage2.getKfpjf() + wmId.getScore())).intValue());
|
|
|
|
-
|
|
|
|
- wmScorePackage.setPackageIsConduct("0");
|
|
|
|
-
|
|
|
|
- } else if (null == wmScorePackage.getRelationScoreId() || "".equals(wmScorePackage.getRelationScoreId())) {
|
|
|
|
- wmScorePackage.setEnableFlag("1");
|
|
|
|
- wmScorePackage.setPackageFinishStatus("2");
|
|
|
|
- List<WmScorePackage> wmScorePackages = wmScorePackageService.selectRelationScoreId(wmId.getId());
|
|
|
|
- if (wmScorePackages.size() > 0) {
|
|
|
|
- for (WmScorePackage wmScorePackage1 : wmScorePackages) {
|
|
|
|
- if (wmId.getRelationScoreId().equals(wmScorePackage1.getRelationScoreId())) {
|
|
|
|
- wmScorePackage2.setPackageIsConduct("1");
|
|
|
|
- break;
|
|
|
|
- } else {
|
|
|
|
- wmScorePackage2.setPackageIsConduct("0");
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- wmScorePackage.setPackageIsConduct("0");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- wmScorePackageService.updateBatchById(wmScorePackageList);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok(wmScorePackageService.updateById(wmScorePackage));
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 修改积分包(二期)
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return 更新结果
|
|
|
|
- */
|
|
|
|
- @SysLog("修改积分包(大包)")
|
|
|
|
- @PostMapping("/updateByIds")
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
- public R<?> updateByIds(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
-
|
|
|
|
- log.info("修改积分包(大包)入参:{}", wmScorePackage);
|
|
|
|
-
|
|
|
|
- if (wmScorePackage.getScore() <= 0) {
|
|
|
|
- return R.failed("积分包分值必须大于0");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 校验修改后的积分包值 不能小于 已下发的下级包积分包值
|
|
|
|
- List<WmScorePackage> subPackages = wmScorePackageService.list(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
- .eq(WmScorePackage::getRelationScoreId, wmScorePackage.getId())
|
|
|
|
- .ne(WmScorePackage::getScorePackageStatus, ScorePackageStatusEnum.TERMINATED.val()));
|
|
|
|
- if (CollUtil.isNotEmpty(subPackages)) {
|
|
|
|
- int subPackgesScore = subPackages.stream().mapToInt(WmScorePackage::getScore).sum();
|
|
|
|
- if (wmScorePackage.getScore() < subPackgesScore) {
|
|
|
|
- return R.failed(String.format("该积分包已分配%s积分,修改后积分包值需大于该值", subPackgesScore));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- wmScorePackage.setPackageType1("1");
|
|
|
|
- wmScorePackage.setUpdateUser(SecurityUtils.getUser().getId());
|
|
|
|
- wmScorePackage.setUpdateTime(LocalDateTime.now());
|
|
|
|
- WmScorePackage oldData = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
- if (StringUtils.isNotEmpty(wmScorePackage.getScorePackageName())
|
|
|
|
- && !oldData.getScorePackageName().equals(wmScorePackage.getScorePackageName())) {
|
|
|
|
- WmScorePackage wmScorePackage1 = new WmScorePackage();
|
|
|
|
- wmScorePackage1.setDelFlag("0");
|
|
|
|
- wmScorePackage1.setScorePackageName(wmScorePackage.getScorePackageName());
|
|
|
|
- wmScorePackage1.setDeptId(wmScorePackage.getDeptId());
|
|
|
|
- List<WmScorePackage> wmScorePackageList = wmScorePackageService.listWmScorePackages(wmScorePackage1);
|
|
|
|
- if (wmScorePackageList.size() > 0) {
|
|
|
|
- return R.failed("积分包名称已存在");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- SysDept sysDeptDrugEntId = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
-
|
|
|
|
- WmDaDrugEnt wmDaDrugEnt = wmDaDrugEntService.selectByDeptId(sysDeptDrugEntId.getDeptId());
|
|
|
|
-
|
|
|
|
- if (null != wmDaDrugEnt) {
|
|
|
|
- if (null != wmScorePackage.getAcceptSug() && !wmScorePackage.getAcceptSug().equals(wmDaDrugEnt.getId())) {
|
|
|
|
- WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getAcceptSug());
|
|
|
|
-
|
|
|
|
- SysDept sysDepts = sysDeptService.getById(Integer.valueOf(wmDaAgent.getDeptId()));
|
|
|
|
-
|
|
|
|
- if (sysDepts.getLevel() == 3) {
|
|
|
|
- wmScorePackage.setLevel2Id("");
|
|
|
|
- wmScorePackage.setLevel1Id(wmScorePackage.getAcceptSug());
|
|
|
|
- } else if (sysDepts.getLevel() == 4) {
|
|
|
|
- wmScorePackage.setLevel1Id("");
|
|
|
|
- wmScorePackage.setLevel2Id(wmScorePackage.getAcceptSug());
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- wmScorePackage.setLevel1Id("");
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getAcceptSug());
|
|
|
|
-
|
|
|
|
- if (null != wmScorePackage.getAcceptSug() && !wmScorePackage.getAcceptSug().equals(wmDaAgent.getId())) {
|
|
|
|
-
|
|
|
|
- SysDept sysDepts = sysDeptService.getById(Integer.valueOf(wmDaAgent.getDeptId()));
|
|
|
|
- if (sysDepts.getLevel() == 3) {
|
|
|
|
- wmScorePackage.setLevel2Id("");
|
|
|
|
- wmScorePackage.setLevel1Id(wmScorePackage.getAcceptSug());
|
|
|
|
- } else if (sysDepts.getLevel() == 4) {
|
|
|
|
- wmScorePackage.setLevel1Id("");
|
|
|
|
- wmScorePackage.setLevel2Id(wmScorePackage.getAcceptSug());
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- wmScorePackage.setLevel1Id("");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- if (SecurityUtils.getRoles().contains(3) || SecurityUtils.getRoles().contains(4)) {
|
|
|
|
-
|
|
|
|
- //药企规则ID
|
|
|
|
- SysDept sysDeptRuleId = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
-
|
|
|
|
- if (sysDeptRuleId.getLevel() == 2) {
|
|
|
|
- WmDaDrugEnt wmDaDrugEntRuleId = wmDaDrugEntService.selectByDeptId(sysDeptRuleId.getDeptId());
|
|
|
|
- if (wmScorePackage.getAcceptSug().equals(wmDaDrugEntRuleId.getId())) {
|
|
|
|
- wmScorePackage.setRuleId(wmScorePackage.getAcceptSug());
|
|
|
|
- wmScorePackage.setDrugEntId(wmDaDrugEntRuleId.getId());
|
|
|
|
- } else if (!wmScorePackage.getAcceptSug().equals(wmDaDrugEntRuleId.getId())) {
|
|
|
|
- wmScorePackage.setRuleId(wmDaDrugEntRuleId.getId() + wmScorePackage.getAcceptSug());
|
|
|
|
- wmScorePackage.setDrugEntId(wmDaDrugEntRuleId.getId());
|
|
|
|
- }
|
|
|
|
- } else if (sysDeptRuleId.getLevel() == 3) {
|
|
|
|
- //一级cso规则ID
|
|
|
|
- WmDaAgent daAgent = wmDaAgentService.getOne(Wrappers.<WmDaAgent>lambdaQuery()
|
|
|
|
- .eq(WmDaAgent::getEnableFlag, EnableEnum.ENABLE.val())
|
|
|
|
- .eq(WmDaAgent::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
|
- .eq(WmDaAgent::getDeptId, String.valueOf(sysDeptRuleId.getDeptId())));
|
|
|
|
- if (StringUtils.isNotBlank(wmScorePackage.getRelationScoreId())) {
|
|
|
|
- // 关联了积分包的情况
|
|
|
|
- WmScorePackage relationScorePackage = wmScorePackageService.getById(wmScorePackage.getRelationScoreId());
|
|
|
|
- if (relationScorePackage != null) {
|
|
|
|
- wmScorePackage.setRuleId(relationScorePackage.getRuleId());
|
|
|
|
- wmScorePackage.setDrugEntId(relationScorePackage.getDrugEntId());
|
|
|
|
- } else {
|
|
|
|
- return R.failed("cso没有分配积分规则");
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- // 没有关联积分包的情况
|
|
|
|
- List<WmTaskType> taskTypeList = wmTaskTypeService.list(Wrappers.<WmTaskType>lambdaQuery()
|
|
|
|
- .eq(WmTaskType::getRuleId, daAgent.getId()));
|
|
|
|
- if (CollectionUtil.isNotEmpty(taskTypeList)) {
|
|
|
|
- wmScorePackage.setRuleId(wmScorePackage.getAcceptSug());
|
|
|
|
- wmScorePackage.setDrugEntId("");
|
|
|
|
- } else {
|
|
|
|
- return R.failed("cso没有分配积分规则");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- WmScorePackage queryWm = new WmScorePackage();
|
|
|
|
- SysDept sysDept = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
-
|
|
|
|
- if (sysDept.getLevel() == 3) {//判断是cso
|
|
|
|
- queryWm.setEnableFlag("0");
|
|
|
|
- } else if (sysDept.getLevel() == 2) {//判断是药企
|
|
|
|
- WmScorePackage wmId = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
- queryWm.setScorePackageName(wmId.getScorePackageName());//获取当前包的scoreId
|
|
|
|
- } else {
|
|
|
|
- queryWm.setId("-1");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- WmScorePackage wmIds = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
- if (wmDaDrugEnt != null) {
|
|
|
|
- if (null != wmScorePackage.getAcceptSug() && !wmScorePackage.getAcceptSug()
|
|
|
|
- .equals(wmDaDrugEnt.getId())) {
|
|
|
|
- WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getAcceptSug());
|
|
|
|
- wmScorePackage.setDeptId(wmDaAgent.getDeptId() + "");
|
|
|
|
- wmScorePackage.setKfpjf(wmScorePackage.getScore() - wmIds.getScore() + wmIds.getKfpjf());
|
|
|
|
- } else if (wmScorePackage.getAcceptSug().equals(wmDaDrugEnt.getId())) {
|
|
|
|
- wmScorePackage.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
- wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getAcceptSug());
|
|
|
|
- if (null != wmScorePackage.getAcceptSug() && !wmScorePackage.getAcceptSug().equals(wmDaAgent.getId())) {
|
|
|
|
- wmScorePackage.setDeptId(wmDaAgent.getDeptId() + "");
|
|
|
|
- wmScorePackage.setKfpjf(wmScorePackage.getScore() - wmIds.getScore() + wmIds.getKfpjf());
|
|
|
|
- } else if (wmScorePackage.getAcceptSug().equals(wmDaAgent.getId())) {
|
|
|
|
- wmScorePackage.setDeptId(String.valueOf(wmDaAgent.getDeptId()));
|
|
|
|
- wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- SysDept sysDept5 = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
- SysDept sysDept6 = sysDeptService.getById(Integer.valueOf(wmScorePackage.getDeptId()));
|
|
|
|
-
|
|
|
|
- if (sysDept5.getLevel() == 2 && sysDept6.getLevel() == 2 && wmScorePackage.getDeptId()
|
|
|
|
- .equals(String.valueOf(sysDept5.getDeptId()))) {
|
|
|
|
- wmScorePackage.setTypeid("0");
|
|
|
|
- } else if (sysDept5.getLevel() == 2) {
|
|
|
|
- wmScorePackage.setTypeid("1");
|
|
|
|
- } else if (sysDept5.getLevel() == 3 && sysDept6.getLevel() == 3 && wmScorePackage.getDeptId()
|
|
|
|
- .equals(String.valueOf(sysDept5.getDeptId()))) {
|
|
|
|
- wmScorePackage.setTypeid("1");
|
|
|
|
- } else if (sysDept5.getLevel() == 3) {
|
|
|
|
- wmScorePackage.setTypeid("2");
|
|
|
|
- }
|
|
|
|
- List<WmScorePackage> wmScorePackageList = wmScorePackageService.list(Wrappers.query(queryWm));
|
|
|
|
- WmScorePackage wmId = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
- if (wmScorePackageList.size() > 0) {
|
|
|
|
- for (WmScorePackage wms : wmScorePackageList) {
|
|
|
|
- if (wmScorePackageList.size() > 0) {
|
|
|
|
- if (wms.getId().equals(wmScorePackage.getRelationScoreId())) {//判断是否有scoreId与当前关联积分包匹配
|
|
|
|
- List<WmScorePackage> wmScorePackagess = wmScorePackageService.selectRelationScoreId(wmId.getId());
|
|
|
|
- if (wmScorePackagess.size() > 0) {
|
|
|
|
- for (WmScorePackage wmScorePackage13 : wmScorePackagess) {
|
|
|
|
- if (wmScorePackage.getRelationScoreId().equals(wmScorePackage13.getId())) {
|
|
|
|
- wms.setPackageIsConduct("1");
|
|
|
|
- break;
|
|
|
|
- } else {
|
|
|
|
- wms.setPackageIsConduct("0");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (!wmScorePackage.getRelationScoreId().equals(wmId.getRelationScoreId())) {
|
|
|
|
- if (wmScorePackage.getScore() < wms.getKfpjf() + wmId.getScore()) {
|
|
|
|
- wms.setKfpjf(new Double(Math.ceil(wms.getKfpjf() - wmScorePackage.getScore())).intValue());
|
|
|
|
- } else {
|
|
|
|
- wms.setKfpjf(new Double(Math.ceil(wms.getKfpjf() - wmScorePackage.getScore())).intValue());
|
|
|
|
- }
|
|
|
|
- } else if (wmScorePackage.getScore() > wms.getKfpjf() + wmId.getScore()) {
|
|
|
|
- return R.failed("可分配积分不足");
|
|
|
|
- } else if (wmScorePackage.getScore() < wms.getKfpjf() + wmId.getScore()) {
|
|
|
|
- wms.setKfpjf(new Double(Math.ceil(wms.getKfpjf() + wmId.getScore() - wmScorePackage.getScore()))
|
|
|
|
- .intValue());
|
|
|
|
- wmId.setScore(wmScorePackage.getScore());
|
|
|
|
- } else {
|
|
|
|
- wms.setKfpjf(new Double(Math.ceil(wms.getKfpjf() + wmId.getScore() - wmScorePackage.getScore()))
|
|
|
|
- .intValue());
|
|
|
|
- wmId.setScore(wmScorePackage.getScore());
|
|
|
|
- }
|
|
|
|
- } else if (wms.getKfpjf() != null && !wmScorePackage.getRelationScoreId()
|
|
|
|
- .equals("") && wmScorePackage.getScore() > wms.getKfpjf() + wmId.getScore()) {
|
|
|
|
- return R.failed("可分配积分不足");
|
|
|
|
- } else if ("".equals(wmScorePackage.getRelationScoreId()) && wms.getId()
|
|
|
|
- .equals(wmId.getRelationScoreId())) {//判断关联积分包是否为无
|
|
|
|
- wms.setKfpjf(wmId.getScore() + wms.getKfpjf());
|
|
|
|
- } else if (wms.getId().equals(wmId.getRelationScoreId())) {
|
|
|
|
- wms.setKfpjf(new Double(Math.ceil(wms.getKfpjf() + wmId.getScore())).intValue());
|
|
|
|
- //判断是否进行中
|
|
|
|
- List<WmScorePackage> wmScorePackages = wmScorePackageService.selectRelationScoreId(wmId.getId());
|
|
|
|
- if (wmScorePackages.size() > 0) {
|
|
|
|
- for (WmScorePackage wmScorePackage1 : wmScorePackages) {
|
|
|
|
- if (null != wmScorePackage1.getRelationScoreId() && wmScorePackage1.getRelationScoreId()
|
|
|
|
- .equals(wmId.getRelationScoreId())) {
|
|
|
|
- wms.setPackageIsConduct("1");
|
|
|
|
- break;
|
|
|
|
- } else {
|
|
|
|
- wms.setPackageIsConduct("0");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- wmScorePackageService.updateBatchById(wmScorePackageList);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (CollUtil.isNotEmpty(wmScorePackage.getWmScoreTaskTypeList())) {
|
|
|
|
- // 如果存在taskTypeId=39 则同时增加应收账款回款-A类、B类、C类任务类型(39/40/41)
|
|
|
|
- if (wmScorePackage.getWmScoreTaskTypeList().stream().anyMatch(wmTaskTypeTree -> "39".equals(wmTaskTypeTree.getTaskTypeId()))) {
|
|
|
|
- WmScoreTaskType addTaskType40 = new WmScoreTaskType();
|
|
|
|
- addTaskType40.setScoreId(wmScorePackage.getId());
|
|
|
|
- addTaskType40.setType("1");
|
|
|
|
- addTaskType40.setTaskTypeId("40");
|
|
|
|
- WmScoreTaskType addTaskType41 = new WmScoreTaskType();
|
|
|
|
- addTaskType41.setScoreId(wmScorePackage.getId());
|
|
|
|
- addTaskType41.setType("1");
|
|
|
|
- addTaskType41.setTaskTypeId("41");
|
|
|
|
- wmScorePackage.getWmScoreTaskTypeList().add(addTaskType40);
|
|
|
|
- wmScorePackage.getWmScoreTaskTypeList().add(addTaskType41);
|
|
|
|
- }
|
|
|
|
- // 如果存在taskTypeId=42 则同时增加手术跟台-一级/手术跟台-二级/手术跟台-三级任务类型(42/43/44)
|
|
|
|
- if (wmScorePackage.getWmScoreTaskTypeList().stream().anyMatch(wmTaskTypeTree -> "42".equals(wmTaskTypeTree.getTaskTypeId()))) {
|
|
|
|
- WmScoreTaskType addTaskType43 = new WmScoreTaskType();
|
|
|
|
- addTaskType43.setScoreId(wmScorePackage.getId());
|
|
|
|
- addTaskType43.setType("1");
|
|
|
|
- addTaskType43.setTaskTypeId("43");
|
|
|
|
- WmScoreTaskType addTaskType44 = new WmScoreTaskType();
|
|
|
|
- addTaskType44.setScoreId(wmScorePackage.getId());
|
|
|
|
- addTaskType44.setType("1");
|
|
|
|
- addTaskType44.setTaskTypeId("44");
|
|
|
|
- wmScorePackage.getWmScoreTaskTypeList().add(addTaskType43);
|
|
|
|
- wmScorePackage.getWmScoreTaskTypeList().add(addTaskType44);
|
|
|
|
- }
|
|
|
|
- // 如果存在taskTypeId=47 47,库存调研 48,竞品调研 49,培训 50,使用情况调查
|
|
|
|
- if (wmScorePackage.getWmScoreTaskTypeList().stream().anyMatch(wmTaskTypeTree -> "47".equals(wmTaskTypeTree.getTaskTypeId()))) {
|
|
|
|
- WmScoreTaskType addTaskTypeTree48 = new WmScoreTaskType();
|
|
|
|
- addTaskTypeTree48.setTaskTypeId("48");
|
|
|
|
- addTaskTypeTree48.setType("1");
|
|
|
|
- WmScoreTaskType addTaskTypeTree49 = new WmScoreTaskType();
|
|
|
|
- addTaskTypeTree49.setTaskTypeId("49");
|
|
|
|
- addTaskTypeTree49.setType("1");
|
|
|
|
- WmScoreTaskType addTaskTypeTree50 = new WmScoreTaskType();
|
|
|
|
- addTaskTypeTree50.setTaskTypeId("50");
|
|
|
|
- addTaskTypeTree50.setType("1");
|
|
|
|
- wmScorePackage.getWmScoreTaskTypeList().add(addTaskTypeTree48);
|
|
|
|
- wmScorePackage.getWmScoreTaskTypeList().add(addTaskTypeTree49);
|
|
|
|
- wmScorePackage.getWmScoreTaskTypeList().add(addTaskTypeTree50);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<WmScoreTaskType> wmScoreTaskTypess = new ArrayList<>();
|
|
|
|
- for (WmScoreTaskType wmScoreTaskTypes : wmScorePackage.getWmScoreTaskTypeList()) {
|
|
|
|
- WmScoreTaskType wmScoreTaskType = new WmScoreTaskType();
|
|
|
|
- //将积分表id和前端传的tasktypeId赋值给wmScoreTaskTypess
|
|
|
|
- if ("".equals(wmScorePackage.getRelationScoreId())) {
|
|
|
|
- wmScoreTaskType.setScoreId(wmScorePackage.getId());
|
|
|
|
- wmScoreTaskType.setType("1");
|
|
|
|
- wmScoreTaskType.setTaskTypeId(wmScoreTaskTypes.getTaskTypeId());
|
|
|
|
- wmScoreTaskTypess.add(wmScoreTaskType);
|
|
|
|
- } else {
|
|
|
|
- wmScoreTaskType.setScoreId(wmScorePackage.getId());
|
|
|
|
- wmScoreTaskType.setType("1");
|
|
|
|
- wmScoreTaskType.setTaskTypeId(wmScoreTaskTypes.getTaskTypeId());
|
|
|
|
- wmScoreTaskTypess.add(wmScoreTaskType);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- wmScoreTaskTypeService.deleteByScoreId(wmScorePackage.getId());
|
|
|
|
- wmScoreTaskTypeService.batchInsertType(wmScoreTaskTypess);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 查询原积分包值
|
|
|
|
- int oldPackageScore = wmScorePackageService.getById(wmScorePackage.getId()).getScore();
|
|
|
|
-
|
|
|
|
- // 屏蔽推广药品企业
|
|
|
|
- wmScorePackage.setDrugProducerList(null);
|
|
|
|
-
|
|
|
|
- wmScorePackageService.updateById(wmScorePackage);
|
|
|
|
-
|
|
|
|
- Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
- Integer userId = SecurityUtils.getUser().getId();
|
|
|
|
- // 如果是通过积分充值的积分发的包,则回收积分
|
|
|
|
- SysDeptRechargeRecord rechargeRecord = sysDeptRechargeRecordMapper.selectOne(Wrappers.<SysDeptRechargeRecord>lambdaQuery()
|
|
|
|
- .eq(SysDeptRechargeRecord::getPackageId, wmScorePackage.getId())
|
|
|
|
- .in(SysDeptRechargeRecord::getType, RechargeRecordType.SEND_PACKAGE_DEPT, RechargeRecordType.SEND_PACKAGE_PERSONAL));
|
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
|
-
|
|
|
|
- boolean relatedScoreId = StrUtil.isNotBlank(wmScorePackage.getRelationScoreId()) && Integer.parseInt(wmScorePackage.getRelationScoreId()) > 0;
|
|
|
|
-
|
|
|
|
- // 积分值相比修改前的变动(相对于积分余额,增加则为负-消耗,减少则为正-回收)
|
|
|
|
- int changeScore = oldPackageScore - wmScorePackage.getScore();
|
|
|
|
-
|
|
|
|
- if (!relatedScoreId) {
|
|
|
|
- // 没有关联上级包的情况
|
|
|
|
- log.info("修改积分包,更新积分配置信息");
|
|
|
|
- // 校验 发包积分 < 积分充值分配的积分 则可以发包
|
|
|
|
- SysDeptRecharge deptRecharge = sysDeptRechargeMapper.selectOne(Wrappers.<SysDeptRecharge>lambdaQuery()
|
|
|
|
- .eq(SysDeptRecharge::getDeptId, deptId));
|
|
|
|
- if (deptRecharge == null) {
|
|
|
|
- log.warn("未配置积分充值信息");
|
|
|
|
- throw new RuntimeException("积分余额:0。积分不足");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- int currentScore = deptRecharge.getScore() + changeScore;
|
|
|
|
-
|
|
|
|
- int limitScore = deptRecharge.getScore() + deptRecharge.getOverdrawScore();
|
|
|
|
- if (changeScore < 0 && Math.abs(changeScore) > limitScore) {
|
|
|
|
- log.warn("已分配积分不足,修改积分={},剩余积分={},透支额度={}",
|
|
|
|
- changeScore, deptRecharge.getScore(), deptRecharge.getOverdrawScore());
|
|
|
|
- throw new RuntimeException(String.format("积分余额:%s。积分不足", deptRecharge.getScore()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 更新积分充值信息
|
|
|
|
- int updateRecharge = sysDeptRechargeMapper.update(null, Wrappers.<SysDeptRecharge>lambdaUpdate()
|
|
|
|
- .eq(SysDeptRecharge::getId, deptRecharge.getId())
|
|
|
|
- .eq(SysDeptRecharge::getVersion, deptRecharge.getVersion())
|
|
|
|
- .set(SysDeptRecharge::getScore, currentScore)
|
|
|
|
- .set(SysDeptRecharge::getVersion, deptRecharge.getVersion() + 1)
|
|
|
|
- .set(SysDeptRecharge::getUpdateTime, now)
|
|
|
|
- .set(SysDeptRecharge::getUpdateUser, userId));
|
|
|
|
- if (updateRecharge <= 0) {
|
|
|
|
- log.warn("更新大包积分充值信息失败");
|
|
|
|
- throw new RuntimeException("操作失败,请重试");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 更新积分充值记录
|
|
|
|
- SysDeptRechargeRecord newRechargeRecord = new SysDeptRechargeRecord();
|
|
|
|
- newRechargeRecord.setRechargeId(deptRecharge.getId());
|
|
|
|
- newRechargeRecord.setChangeScore(changeScore);
|
|
|
|
- newRechargeRecord.setCurrentScore(currentScore);
|
|
|
|
- newRechargeRecord.setType(RechargeRecordType.RECOVERY);
|
|
|
|
- newRechargeRecord.setDeptId(deptRecharge.getDeptId());
|
|
|
|
- newRechargeRecord.setRelationDeptId(rechargeRecord != null ? rechargeRecord.getRelationDeptId() : null);
|
|
|
|
- newRechargeRecord.setPackageType(RechargeRecordPackageType.TO_ENTERPRISE);
|
|
|
|
- newRechargeRecord.setPackageId(wmScorePackage.getId());
|
|
|
|
- newRechargeRecord.setCreateUser(userId);
|
|
|
|
- sysDeptRechargeRecordMapper.insert(newRechargeRecord);
|
|
|
|
- } else {
|
|
|
|
- // 关联了上级包的情况
|
|
|
|
- if (changeScore < 0) {
|
|
|
|
- // 变动积分后比原先多,则校验上级可分配积分值
|
|
|
|
- List<WmScorePackage> scorePackagekfpjf = wmScorePackageService.getScorePackagekfpjf(null, null, new String[]{"0", "1", "2"},
|
|
|
|
- new String[]{wmScorePackage.getRelationScoreId()});
|
|
|
|
-
|
|
|
|
- if (CollUtil.isNotEmpty(scorePackagekfpjf)) {
|
|
|
|
- int kfpjf = scorePackagekfpjf.get(0).getKfpjf();
|
|
|
|
- if (Math.abs(changeScore) > kfpjf) {
|
|
|
|
- throw new RuntimeException("可分配积分值不足");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok(Boolean.TRUE);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 查询关联积分包列表
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 积分包信息
|
|
|
|
- * @return 列表
|
|
|
|
- */
|
|
|
|
- @GetMapping("/getRelationScoreList")
|
|
|
|
- public R<?> getRelationScoreList(WmScorePackage wmScorePackage) {
|
|
|
|
- return wmScorePackageService.getRelationScoreList(wmScorePackage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 查询接单对象范围
|
|
|
|
- *
|
|
|
|
- * @return {@link R}<{@link ?}>
|
|
|
|
- */
|
|
|
|
- @GetMapping("/list-package-user-scope")
|
|
|
|
- public R<?> listPackageUserScope() {
|
|
|
|
- Integer sendDeptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
-
|
|
|
|
- QueryWrapper<WmScorePackage> queryWrapper = Wrappers.<WmScorePackage>query()
|
|
|
|
- .select("package_user_scope")
|
|
|
|
- .and(wrapper ->
|
|
|
|
- wrapper.eq("package_type1", PackageTypeEnum.TYPE1_SCOTE_PACKAGE.val())
|
|
|
|
- .eq("package_type2", PackageTypeEnum.TYPE2_TASK_PACKAGE.val())
|
|
|
|
- .or(wrapper2 -> wrapper2.eq("package_type1", PackageTypeEnum.TYPE1_SCORE_AND_TASK_PACKAGE.val())
|
|
|
|
- .eq("package_type2", PackageTypeEnum.TYPE2_SETTLE_PACKAGE.val())))
|
|
|
|
- .eq("send_package_dept_id", sendDeptId)
|
|
|
|
- .in("typeid", "3", "4", "5");
|
|
|
|
- List<WmScorePackage> packages = wmScorePackageService.list(queryWrapper);
|
|
|
|
- if (CollUtil.isEmpty(packages)) {
|
|
|
|
- return R.ok(Collections.emptyList());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<String> pacakgeUserScores = packages.stream()
|
|
|
|
- .map(WmScorePackage::getPackageUserScope)
|
|
|
|
- .distinct().sorted().collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- List<Map<String, String>> result = new ArrayList<>();
|
|
|
|
- Map<String, String> val1 = new HashMap<>();
|
|
|
|
- val1.put("id", "1");
|
|
|
|
- val1.put("name", "仅内部可见");
|
|
|
|
- Map<String, String> val2 = new HashMap<>();
|
|
|
|
- val2.put("id", "2");
|
|
|
|
- val2.put("name", "全部可见");
|
|
|
|
- result.add(val1);
|
|
|
|
- result.add(val2);
|
|
|
|
- // 查询团队名称
|
|
|
|
- List<WmTeam> teams = wmTeamService.listByIds(pacakgeUserScores);
|
|
|
|
- List<Map<String, String>> teamNameList = teams.stream().map(t -> {
|
|
|
|
- Map<String, String> teamNameMap = new HashMap<>(2);
|
|
|
|
- teamNameMap.put("id", String.valueOf(t.getId()));
|
|
|
|
- teamNameMap.put("name", t.getName());
|
|
|
|
- return teamNameMap;
|
|
|
|
- }).collect(Collectors.toList());
|
|
|
|
- result.addAll(teamNameList);
|
|
|
|
-
|
|
|
|
- return R.ok(result);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 分配积分列表查询--派工平台
|
|
|
|
- *
|
|
|
|
- * @param acceptUser 接单对象,模糊查询
|
|
|
|
- */
|
|
|
|
- @GetMapping("/getScorePackagePageForBC")
|
|
|
|
- public R<?> getScorePackagePageForBC(@RequestParam(value = "current") Integer current,
|
|
|
|
- @RequestParam(value = "size") Integer size,
|
|
|
|
- @RequestParam(value = "deptId") Integer deptId,
|
|
|
|
- Integer userId,
|
|
|
|
- @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
- @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
- @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
- @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
- @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
- @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
- @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
- @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
- @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
- @RequestParam(value = "toApproval", required = false) Boolean toApproval,
|
|
|
|
- @RequestParam(value = "packageUserScope", required = false) String packageUserScope,
|
|
|
|
- String sourceType
|
|
|
|
- ) {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- LocalDateTime start = null;
|
|
|
|
- LocalDateTime end = null;
|
|
|
|
-
|
|
|
|
- if (StrUtil.isNotEmpty(monthStart) && StrUtil.isNotEmpty(monthEnd)) {
|
|
|
|
- start = LocalDateTime.of(LocalDate.parse(monthStart + "-01", DatePattern.NORM_DATE_FORMATTER), LocalTime.MIN);
|
|
|
|
- LocalDate e = LocalDate.parse(monthEnd + "-01", DatePattern.NORM_DATE_FORMATTER);
|
|
|
|
- end = LocalDateTime.of(e.with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- QueryWrapper<WmScorePackage> queryWrapper = Wrappers.<WmScorePackage>query()
|
|
|
|
- .eq("p.package_type1", packageType1)
|
|
|
|
- .eq("p.package_type2", packageType2)
|
|
|
|
- .eq(scorePackageStatus != null, "p.score_package_status", scorePackageStatus)
|
|
|
|
- .eq("p.send_package_dept_id", deptId)
|
|
|
|
- .between(start != null && end != null, "p.create_time", start, end);
|
|
|
|
-
|
|
|
|
- if (StrUtil.isNotBlank(scorePackageName)) {
|
|
|
|
- queryWrapper.and(wrapper -> wrapper.like("p.score_package_name", scorePackageName).or().like("p.pkg_sn", scorePackageName));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (StringUtil.isEmpty(typeId)) {
|
|
|
|
- queryWrapper.in("p.typeid", "3", "4", "5");
|
|
|
|
- } else {
|
|
|
|
- List<String> split = StrUtil.split(typeId, StrUtil.COMMA);
|
|
|
|
- queryWrapper.in("p.typeid", split);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 接单对象范围筛选
|
|
|
|
- if (StrUtil.isNotBlank(packageUserScope)) {
|
|
|
|
- queryWrapper.eq("p.package_user_scope", packageUserScope);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 用于问问的系统来源
|
|
|
|
- if (StrUtil.isNotBlank(sourceType)) {
|
|
|
|
- queryWrapper.eq("p.source_type", sourceType);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (userId != null) {
|
|
|
|
- boolean onePersonScorePackageFlag = PackageTypeEnum.TYPE1_SCOTE_PACKAGE.val().equals(String.valueOf(packageType1))
|
|
|
|
- && PackageTypeEnum.TYPE2_TASK_PACKAGE.val().equals(String.valueOf(packageType2));
|
|
|
|
- boolean multiPersonScorePackageFlag = PackageTypeEnum.TYPE1_SCORE_AND_TASK_PACKAGE.val().equals(String.valueOf(packageType1))
|
|
|
|
- && PackageTypeEnum.TYPE2_SETTLE_PACKAGE.val().equals(String.valueOf(packageType2));
|
|
|
|
- if (onePersonScorePackageFlag || multiPersonScorePackageFlag) {
|
|
|
|
- // 如果是个人承接-按积分值/多人承接-按积分值,判断当前用户是否配置了团队负责人
|
|
|
|
- List<WmTeam> teamList = wmTeamService.list(Wrappers.<WmTeam>lambdaQuery()
|
|
|
|
- .eq(WmTeam::getDeptId, deptId)
|
|
|
|
- .eq(WmTeam::getEnableFlag, EnableEnum.ENABLE.val())
|
|
|
|
- .eq(WmTeam::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
|
- .apply("FIND_IN_SET({0}, leader)", String.valueOf(userId)));
|
|
|
|
- if (CollectionUtil.isNotEmpty(teamList)) {
|
|
|
|
- // 如果配置了,则只查询所在团队下发的积分包
|
|
|
|
- List<String> teamIdList = teamList.stream().map(wmTeam -> String.valueOf(wmTeam.getId())).collect(Collectors.toList());
|
|
|
|
- queryWrapper.in("p.package_user_scope", teamIdList);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Page<WmScorePackage> wmScorePackagePage = wmScorePackageMapper.listScorePackage(new Page<>(current, size),
|
|
|
|
- queryWrapper.orderByDesc("p.create_time"), acceptUser, relationScoreId, toApproval);
|
|
|
|
-
|
|
|
|
- List<WmScorePackage> pageRecords = wmScorePackagePage.getRecords();
|
|
|
|
-
|
|
|
|
- if (CollUtil.isNotEmpty(pageRecords)) {
|
|
|
|
-
|
|
|
|
- Set<String> packageIds = pageRecords.stream().map(WmScorePackage::getId).collect(Collectors.toSet());
|
|
|
|
-
|
|
|
|
- // 任务统计
|
|
|
|
- List<WmTask> taskList = wmTaskMapper.selectList(Wrappers.<WmTask>lambdaQuery()
|
|
|
|
- .eq(WmTask::getRealFlag, "0")
|
|
|
|
- .eq(WmTask::getEnableFlag, "0")
|
|
|
|
- .eq(WmTask::getDelFlag, "0")
|
|
|
|
- .in(WmTask::getScorePackageId, packageIds)
|
|
|
|
- );
|
|
|
|
- Map<String, List<WmTask>> taskGoupMap = taskList.stream().collect(Collectors.groupingBy(WmTask::getScorePackageId));
|
|
|
|
-
|
|
|
|
- // 领取积分包记录
|
|
|
|
- List<WmScorePackageStatus> scorePackageStatusList = wmScorePackageStatusService.list(Wrappers.<WmScorePackageStatus>lambdaQuery()
|
|
|
|
- .in(WmScorePackageStatus::getPackageId, packageIds)
|
|
|
|
- );
|
|
|
|
- Map<String, List<WmScorePackageStatus>> packageStatusGroupMap = scorePackageStatusList.stream()
|
|
|
|
- .collect(Collectors.groupingBy(WmScorePackageStatus::getPackageId));
|
|
|
|
-
|
|
|
|
- //获取上级包
|
|
|
|
- Set<String> parentPackageIds = pageRecords.stream().map(WmScorePackage::getRelationScoreId).collect(Collectors.toSet());
|
|
|
|
- List<WmScorePackage> parentPackages = wmScorePackageMapper.selectList(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
- .in(WmScorePackage::getId, parentPackageIds));
|
|
|
|
- Map<String, WmScorePackage> parentPackageNameMap = parentPackages.stream()
|
|
|
|
- .collect(Collectors.toMap(WmScorePackage::getId, Function.identity()));
|
|
|
|
-
|
|
|
|
- // 类型标签
|
|
|
|
- List<SysDictItem> dictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
- .in(SysDictItem::getType, "package_type1", "package_type2"));
|
|
|
|
- Map<String, List<SysDictItem>> dictItemMap = dictItems.stream().collect(Collectors.groupingBy(SysDictItem::getType));
|
|
|
|
- List<SysDictItem> packageType1List = dictItemMap.get("package_type1");
|
|
|
|
- List<SysDictItem> packageType2List = dictItemMap.get("package_type2");
|
|
|
|
-
|
|
|
|
- // todo
|
|
|
|
- //// 结算记录
|
|
|
|
- //List<WmScorePackageSettleNote> noteList = settleNoteMapper.selectList(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
- // .in(WmScorePackageSettleNote::getPackageId, packageIds));
|
|
|
|
- //Map<String, List<WmScorePackageSettleNote>> noteMap = noteList.stream()
|
|
|
|
- // .collect(Collectors.groupingBy(WmScorePackageSettleNote::getPackageId));
|
|
|
|
-
|
|
|
|
- // 有效任务类型
|
|
|
|
- List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(String.join(",", packageIds));
|
|
|
|
- Map<String, List<WmScoreTaskType>> taskTypeMap = taskTypeList.stream().collect(Collectors.groupingBy(WmScoreTaskType::getScoreId));
|
|
|
|
-
|
|
|
|
- //for (int i = 0; i < pageRecords.size(); i++) {
|
|
|
|
- // WmScorePackage wmScorePackage = pageRecords.get(i);
|
|
|
|
- //
|
|
|
|
- // List<WmTask> tasks = taskGoupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- // List<WmScorePackageStatus> statuses = packageStatusGroupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- // List<WmScorePackageSettleNote> notes = noteMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- // List<WmScoreTaskType> scoreTaskTypes = taskTypeMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- //
|
|
|
|
- // wmScorePackageService.buildScorePackageSync(wmScorePackage, packageType1, packageType2, tasks, statuses,
|
|
|
|
- // packageType1List, packageType2List, parentPackageNameMap, notes, scoreTaskTypes);
|
|
|
|
- //
|
|
|
|
- //}
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok(wmScorePackagePage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 分配积分列表查询--派工平台
|
|
|
|
- *
|
|
|
|
- * @param acceptUser 接单对象,模糊查询
|
|
|
|
- */
|
|
|
|
- @GetMapping("/getScorePackagePage")
|
|
|
|
- public R<?> getScorePackagePage(@RequestParam(value = "current") Integer current,
|
|
|
|
- @RequestParam(value = "size") Integer size,
|
|
|
|
- @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
- @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
- @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
- @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
- @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
- @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
- @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
- @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
- @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
- @RequestParam(value = "toApproval", required = false) Boolean toApproval,
|
|
|
|
- @RequestParam(value = "packageUserScope", required = false) String packageUserScope,
|
|
|
|
- String sourceType
|
|
|
|
- ) {
|
|
|
|
-
|
|
|
|
- Integer sendDeptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
- Integer userId = SecurityUtils.getUser().getId();
|
|
|
|
-
|
|
|
|
- return this.getScorePackagePageForBC(current, size, sendDeptId, userId, packageType1, packageType2, scorePackageName, scorePackageStatus,
|
|
|
|
- typeId, monthStart, monthEnd, acceptUser, relationScoreId, toApproval, packageUserScope, sourceType);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 积分包列表-其他(用于MAH结算:药企查询下级提交的) 用于BC
|
|
|
|
- *
|
|
|
|
- * @param acceptUser 接单对象,模糊查询
|
|
|
|
- */
|
|
|
|
- @GetMapping("/getScorePackagePageForMahForBC")
|
|
|
|
- public R getScorePackagePageForMahForBC(@RequestParam(value = "current") Integer current,
|
|
|
|
- @RequestParam(value = "size") Integer size,
|
|
|
|
- @RequestParam(value = "deptId") Integer deptId,
|
|
|
|
- @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
- @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
- @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
- @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
- @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
- @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
- @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
- @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
- @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
- @RequestParam(value = "toApproval", required = false) Boolean toApproval
|
|
|
|
- ) {
|
|
|
|
-
|
|
|
|
- LocalDateTime start = null;
|
|
|
|
- LocalDateTime end = null;
|
|
|
|
-
|
|
|
|
- if (StrUtil.isNotEmpty(monthStart) && StrUtil.isNotEmpty(monthEnd)) {
|
|
|
|
- start = LocalDateTime.of(LocalDate.parse(monthStart + "-01", DatePattern.NORM_DATE_FORMATTER), LocalTime.MIN);
|
|
|
|
- LocalDate e = LocalDate.parse(monthEnd + "-01", DatePattern.NORM_DATE_FORMATTER);
|
|
|
|
- end = LocalDateTime.of(e.with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- QueryWrapper<WmScorePackage> queryWrapper = Wrappers.<WmScorePackage>query()
|
|
|
|
- .eq("p.package_type1", packageType1)
|
|
|
|
- .eq("p.package_type2", packageType2)
|
|
|
|
- .eq(scorePackageStatus != null, "p.score_package_status", scorePackageStatus)
|
|
|
|
- .eq("p.mah_settle_dept_id", deptId)
|
|
|
|
- .in("p.mah_settle_step", UpmsType.MahSettleStep.BUSINESS.getType(), UpmsType.MahSettleStep.FINANCE.getType())
|
|
|
|
- .between(start != null && end != null, "p.create_time", start, end);
|
|
|
|
-
|
|
|
|
- if (StrUtil.isNotBlank(scorePackageName)) {
|
|
|
|
- queryWrapper.and(wrapper -> wrapper.like("p.score_package_name", scorePackageName).or().like("p.pkg_sn", scorePackageName));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (StringUtil.isEmpty(typeId)) {
|
|
|
|
- queryWrapper.in("p.typeid", "3", "4", "5");
|
|
|
|
- } else {
|
|
|
|
- List<String> split = StrUtil.split(typeId, StrUtil.COMMA);
|
|
|
|
- queryWrapper.in("p.typeid", split);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Page<WmScorePackage> wmScorePackagePage = wmScorePackageMapper.listScorePackage(new Page<>(current, size),
|
|
|
|
- queryWrapper.orderByDesc("p.settlement_date"), acceptUser, relationScoreId, toApproval);
|
|
|
|
-
|
|
|
|
- List<WmScorePackage> pageRecords = wmScorePackagePage.getRecords();
|
|
|
|
-
|
|
|
|
- if (CollUtil.isNotEmpty(pageRecords)) {
|
|
|
|
- Set<String> packageIds = pageRecords.stream().map(WmScorePackage::getId).collect(Collectors.toSet());
|
|
|
|
-
|
|
|
|
- // 任务统计
|
|
|
|
- List<WmTask> taskList = wmTaskMapper.selectList(Wrappers.<WmTask>lambdaQuery()
|
|
|
|
- .eq(WmTask::getRealFlag, "0")
|
|
|
|
- .eq(WmTask::getEnableFlag, "0")
|
|
|
|
- .eq(WmTask::getDelFlag, "0")
|
|
|
|
- .in(WmTask::getScorePackageId, packageIds)
|
|
|
|
- );
|
|
|
|
- Map<String, List<WmTask>> taskGoupMap = taskList.stream().collect(Collectors.groupingBy(WmTask::getScorePackageId));
|
|
|
|
-
|
|
|
|
- // 领取积分包记录
|
|
|
|
- List<WmScorePackageStatus> scorePackageStatusList = wmScorePackageStatusService.list(Wrappers.<WmScorePackageStatus>lambdaQuery()
|
|
|
|
- .in(WmScorePackageStatus::getPackageId, packageIds)
|
|
|
|
- );
|
|
|
|
- Map<String, List<WmScorePackageStatus>> packageStatusGroupMap = scorePackageStatusList.stream()
|
|
|
|
- .collect(Collectors.groupingBy(WmScorePackageStatus::getPackageId));
|
|
|
|
-
|
|
|
|
- //获取上级包
|
|
|
|
- Set<String> parentPackageIds = pageRecords.stream().map(WmScorePackage::getRelationScoreId).collect(Collectors.toSet());
|
|
|
|
- List<WmScorePackage> parentPackages = wmScorePackageMapper.selectList(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
- .in(WmScorePackage::getId, parentPackageIds));
|
|
|
|
- Map<String, WmScorePackage> parentPackageNameMap = parentPackages.stream()
|
|
|
|
- .collect(Collectors.toMap(WmScorePackage::getId, Function.identity()));
|
|
|
|
-
|
|
|
|
- // 类型标签
|
|
|
|
- List<SysDictItem> dictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
- .in(SysDictItem::getType, "package_type1", "package_type2"));
|
|
|
|
- Map<String, List<SysDictItem>> dictItemMap = dictItems.stream().collect(Collectors.groupingBy(SysDictItem::getType));
|
|
|
|
- List<SysDictItem> packageType1List = dictItemMap.get("package_type1");
|
|
|
|
- List<SysDictItem> packageType2List = dictItemMap.get("package_type2");
|
|
|
|
-
|
|
|
|
- // todo
|
|
|
|
- //// 结算记录
|
|
|
|
- //List<WmScorePackageSettleNote> noteList = settleNoteMapper.selectList(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
- // .in(WmScorePackageSettleNote::getPackageId, packageIds));
|
|
|
|
- //Map<String, List<WmScorePackageSettleNote>> noteMap = noteList.stream()
|
|
|
|
- // .collect(Collectors.groupingBy(WmScorePackageSettleNote::getPackageId));
|
|
|
|
-
|
|
|
|
- // 有效任务类型
|
|
|
|
- List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(String.join(",", packageIds));
|
|
|
|
- Map<String, List<WmScoreTaskType>> taskTypeMap = taskTypeList.stream().collect(Collectors.groupingBy(WmScoreTaskType::getScoreId));
|
|
|
|
-
|
|
|
|
- //for (int i = 0; i < pageRecords.size(); i++) {
|
|
|
|
- // WmScorePackage wmScorePackage = pageRecords.get(i);
|
|
|
|
- //
|
|
|
|
- // List<WmTask> tasks = taskGoupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- // List<WmScorePackageStatus> statuses = packageStatusGroupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- // List<WmScorePackageSettleNote> notes = noteMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- // List<WmScoreTaskType> scoreTaskTypes = taskTypeMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- //
|
|
|
|
- // wmScorePackageService.buildScorePackageSync(wmScorePackage, packageType1, packageType2, tasks, statuses,
|
|
|
|
- // packageType1List, packageType2List, parentPackageNameMap, notes, scoreTaskTypes);
|
|
|
|
- //
|
|
|
|
- //}
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 个人承接-其他 标记已读提醒
|
|
|
|
- wmBizReminderService.markRead(UpmsType.BizReminderType.ASSIGN_POINTS_OTHER_REMINDER, deptId);
|
|
|
|
-
|
|
|
|
- return R.ok(wmScorePackagePage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 积分包列表-其他(用于MAH结算:药企查询下级提交的)
|
|
|
|
- *
|
|
|
|
- * @param acceptUser 接单对象,模糊查询
|
|
|
|
- */
|
|
|
|
- @GetMapping("/getScorePackagePageForMah")
|
|
|
|
- public R getScorePackagePageForMah(@RequestParam(value = "current") Integer current,
|
|
|
|
- @RequestParam(value = "size") Integer size,
|
|
|
|
- @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
- @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
- @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
- @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
- @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
- @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
- @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
- @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
- @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
- @RequestParam(value = "toApproval", required = false) Boolean toApproval
|
|
|
|
- ) {
|
|
|
|
-
|
|
|
|
- Integer sendDeptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
-
|
|
|
|
- return this.getScorePackagePageForMahForBC(current, size, sendDeptId, packageType1, packageType2, scorePackageName,
|
|
|
|
- scorePackageStatus, typeId, monthStart, monthEnd, acceptUser, relationScoreId, toApproval);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 个人承接积分值导出-用于BC
|
|
|
|
- *
|
|
|
|
- * @param acceptUser 接单对象,模糊查询
|
|
|
|
- */
|
|
|
|
- @ResponseExcel(name = "exportPackageSettle", sheet = "个人承接积分值导出")
|
|
|
|
- @SysLog("个人承接积分值导出-用于BC")
|
|
|
|
- @GetMapping("/export-score-package-for-bc")
|
|
|
|
- public List<WmScorePackageExcelModel> exportScorePackageForBC(
|
|
|
|
- @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
- @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
- @RequestParam(value = "deptId") Integer deptId,
|
|
|
|
- Integer userId,
|
|
|
|
- @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
- @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
- @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
- @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
- @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
- @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
- @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
- @RequestParam(value = "toApproval", required = false) Boolean toApproval,
|
|
|
|
- @RequestParam(value = "packageUserScope", required = false) String packageUserScope
|
|
|
|
- ) {
|
|
|
|
-
|
|
|
|
- LocalDateTime start = null;
|
|
|
|
- LocalDateTime end = null;
|
|
|
|
-
|
|
|
|
- if (StrUtil.isNotEmpty(monthStart) && StrUtil.isNotEmpty(monthEnd)) {
|
|
|
|
- start = LocalDateTime.of(LocalDate.parse(monthStart + "-01", DatePattern.NORM_DATE_FORMATTER), LocalTime.MIN);
|
|
|
|
- LocalDate e = LocalDate.parse(monthEnd + "-01", DatePattern.NORM_DATE_FORMATTER);
|
|
|
|
- end = LocalDateTime.of(e.with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- QueryWrapper<WmScorePackage> queryWrapper = Wrappers.<WmScorePackage>query()
|
|
|
|
- .eq("p.package_type1", packageType1)
|
|
|
|
- .eq("p.package_type2", packageType2)
|
|
|
|
- .eq(scorePackageStatus != null, "p.score_package_status", scorePackageStatus)
|
|
|
|
- .eq("p.send_package_dept_id", deptId)
|
|
|
|
- .between(start != null && end != null, "p.create_time", start, end);
|
|
|
|
-
|
|
|
|
- if (StrUtil.isNotBlank(scorePackageName)) {
|
|
|
|
- queryWrapper.and(wrapper -> wrapper.like("p.score_package_name", scorePackageName).or().like("p.pkg_sn", scorePackageName));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (StringUtil.isEmpty(typeId)) {
|
|
|
|
- queryWrapper.in("p.typeid", "3", "4", "5");
|
|
|
|
- } else {
|
|
|
|
- List<String> split = StrUtil.split(typeId, StrUtil.COMMA);
|
|
|
|
- queryWrapper.in("p.typeid", split);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 接单对象范围筛选
|
|
|
|
- if (StrUtil.isNotBlank(packageUserScope)) {
|
|
|
|
- queryWrapper.eq("p.package_user_scope", packageUserScope);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (userId != null) {
|
|
|
|
- boolean onePersonScorePackageFlag = PackageTypeEnum.TYPE1_SCOTE_PACKAGE.val().equals(String.valueOf(packageType1))
|
|
|
|
- && PackageTypeEnum.TYPE2_TASK_PACKAGE.val().equals(String.valueOf(packageType2));
|
|
|
|
- boolean multiPersonScorePackageFlag = PackageTypeEnum.TYPE1_SCORE_AND_TASK_PACKAGE.val().equals(String.valueOf(packageType1))
|
|
|
|
- && PackageTypeEnum.TYPE2_SETTLE_PACKAGE.val().equals(String.valueOf(packageType2));
|
|
|
|
- if (onePersonScorePackageFlag || multiPersonScorePackageFlag) {
|
|
|
|
- // 如果是个人承接-按积分值/多人承接-按积分值,判断当前用户是否配置了团队负责人
|
|
|
|
- List<WmTeam> teamList = wmTeamService.list(Wrappers.<WmTeam>lambdaQuery()
|
|
|
|
- .eq(WmTeam::getDeptId, deptId)
|
|
|
|
- .eq(WmTeam::getEnableFlag, EnableEnum.ENABLE.val())
|
|
|
|
- .eq(WmTeam::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
|
- .apply("FIND_IN_SET({0}, leader)", String.valueOf(userId)));
|
|
|
|
- if (CollectionUtil.isNotEmpty(teamList)) {
|
|
|
|
- // 如果配置了,则只查询所在团队下发的积分包
|
|
|
|
- List<String> teamIdList = teamList.stream().map(wmTeam -> String.valueOf(wmTeam.getId())).collect(Collectors.toList());
|
|
|
|
- queryWrapper.in("p.package_user_scope", teamIdList);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- long startMillis = System.currentTimeMillis();
|
|
|
|
- List<WmScorePackage> scorePackageList = wmScorePackageMapper.listScorePackage(
|
|
|
|
- queryWrapper.orderByDesc("p.create_time"), acceptUser, relationScoreId, toApproval);
|
|
|
|
- log.info("积分包列表-不分页sql耗时:{}", System.currentTimeMillis() - startMillis);
|
|
|
|
-
|
|
|
|
- if (CollUtil.isEmpty(scorePackageList)) {
|
|
|
|
- return Collections.emptyList();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- long buildStartMillis = System.currentTimeMillis();
|
|
|
|
-
|
|
|
|
- Set<String> packageIds = scorePackageList.stream().map(WmScorePackage::getId).collect(Collectors.toSet());
|
|
|
|
-
|
|
|
|
- // 任务统计
|
|
|
|
- List<WmTask> taskList = wmTaskMapper.selectList(Wrappers.<WmTask>lambdaQuery()
|
|
|
|
- .eq(WmTask::getRealFlag, "0")
|
|
|
|
- .eq(WmTask::getEnableFlag, "0")
|
|
|
|
- .eq(WmTask::getDelFlag, "0")
|
|
|
|
- .in(WmTask::getScorePackageId, packageIds)
|
|
|
|
- );
|
|
|
|
- Map<String, List<WmTask>> taskGoupMap = taskList.stream().collect(Collectors.groupingBy(WmTask::getScorePackageId));
|
|
|
|
-
|
|
|
|
- // 领取积分包记录
|
|
|
|
- List<WmScorePackageStatus> scorePackageStatusList = wmScorePackageStatusService.list(Wrappers.<WmScorePackageStatus>lambdaQuery()
|
|
|
|
- .in(WmScorePackageStatus::getPackageId, packageIds)
|
|
|
|
- );
|
|
|
|
- Map<String, List<WmScorePackageStatus>> packageStatusGroupMap = scorePackageStatusList.stream()
|
|
|
|
- .collect(Collectors.groupingBy(WmScorePackageStatus::getPackageId));
|
|
|
|
-
|
|
|
|
- //获取上级包
|
|
|
|
- Set<String> parentPackageIds = scorePackageList.stream().map(WmScorePackage::getRelationScoreId).collect(Collectors.toSet());
|
|
|
|
- List<WmScorePackage> parentPackages = wmScorePackageMapper.selectList(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
- .in(WmScorePackage::getId, parentPackageIds));
|
|
|
|
- Map<String, WmScorePackage> parentPackageNameMap = parentPackages.stream()
|
|
|
|
- .collect(Collectors.toMap(WmScorePackage::getId, Function.identity()));
|
|
|
|
-
|
|
|
|
- // 类型标签
|
|
|
|
- List<SysDictItem> dictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
- .in(SysDictItem::getType, "package_type1", "package_type2"));
|
|
|
|
- Map<String, List<SysDictItem>> dictItemMap = dictItems.stream().collect(Collectors.groupingBy(SysDictItem::getType));
|
|
|
|
- List<SysDictItem> packageType1List = dictItemMap.get("package_type1");
|
|
|
|
- List<SysDictItem> packageType2List = dictItemMap.get("package_type2");
|
|
|
|
-
|
|
|
|
- // todo
|
|
|
|
- //// 结算记录
|
|
|
|
- //List<WmScorePackageSettleNote> noteList = settleNoteMapper.selectList(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
- // .in(WmScorePackageSettleNote::getPackageId, packageIds));
|
|
|
|
- //Map<String, List<WmScorePackageSettleNote>> noteMap = noteList.stream()
|
|
|
|
- // .collect(Collectors.groupingBy(WmScorePackageSettleNote::getPackageId));
|
|
|
|
-
|
|
|
|
- // 有效任务类型
|
|
|
|
- List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(String.join(",", packageIds));
|
|
|
|
- Map<String, List<WmScoreTaskType>> taskTypeMap = taskTypeList.stream().collect(Collectors.groupingBy(WmScoreTaskType::getScoreId));
|
|
|
|
-
|
|
|
|
- List<WmScorePackageExcelModel> excelModelList = new ArrayList<>(scorePackageList.size());
|
|
|
|
- for (int i = 0; i < scorePackageList.size(); i++) {
|
|
|
|
- WmScorePackage wmScorePackage = scorePackageList.get(i);
|
|
|
|
- log.info("====> 积分包SN:{}", wmScorePackage.getPackageSn());
|
|
|
|
-
|
|
|
|
- List<WmTask> tasks = taskGoupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- List<WmScorePackageStatus> statuses = packageStatusGroupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- // todo
|
|
|
|
- //List<WmScorePackageSettleNote> notes = noteMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- //List<WmScoreTaskType> scoreTaskTypes = taskTypeMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- //
|
|
|
|
- //wmScorePackageService.buildScorePackageSync(wmScorePackage, packageType1, packageType2, tasks, statuses,
|
|
|
|
- // packageType1List, packageType2List, parentPackageNameMap, notes, scoreTaskTypes);
|
|
|
|
-
|
|
|
|
- WmScorePackageExcelModel excelModel = BeanUtil.copyProperties(wmScorePackage, WmScorePackageExcelModel.class);
|
|
|
|
- if (StrUtil.isNotBlank(wmScorePackage.getScorePackageStatus())) {
|
|
|
|
- excelModel.setScorePackageStatus(Objects.requireNonNull(ScorePackageStatusEnum.getByVal(wmScorePackage.getScorePackageStatus())).getDesc());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (CollUtil.isNotEmpty(wmScorePackage.getUserList())) {
|
|
|
|
- excelModel.setUserNames(String.join(",", wmScorePackage.getUserList()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- String typeid = wmScorePackage.getTypeid();
|
|
|
|
- if (StrUtil.isNotBlank(typeid)) {
|
|
|
|
- excelModel.setTypeidName("3".equals(typeid) ? "全职学术信息沟通专员" :
|
|
|
|
- "4".equals(typeid) ? "兼职学术信息沟通专员" : "5".equals(typeid) ? "招商经理" : typeid);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- excelModel.setNumber(String.valueOf(i+1));
|
|
|
|
- if (wmScorePackage.getYshtt() != null) {
|
|
|
|
- excelModel.setFinishRate(String.valueOf(wmScorePackage.getYshtt()));
|
|
|
|
- }
|
|
|
|
- excelModel.setPayScore(wmScorePackage.getShtg());
|
|
|
|
- if (wmScorePackage.getShtgtt() != null) {
|
|
|
|
- excelModel.setPayRate(String.valueOf(wmScorePackage.getShtgtt()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- excelModelList.add(excelModel);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- log.info("build积分包耗时:{}", System.currentTimeMillis() - buildStartMillis);
|
|
|
|
-
|
|
|
|
- return excelModelList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 个人承接积分值导出
|
|
|
|
- *
|
|
|
|
- * @param acceptUser 接单对象,模糊查询
|
|
|
|
- */
|
|
|
|
- @ResponseExcel(name = "exportPackageSettle", sheet = "个人承接积分值导出")
|
|
|
|
- @SysLog("个人承接积分值导出")
|
|
|
|
- @GetMapping("/export-score-package")
|
|
|
|
- public List<WmScorePackageExcelModel> exportScorePackage(
|
|
|
|
- @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
- @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
- @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
- @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
- @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
- @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
- @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
- @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
- @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
- @RequestParam(value = "toApproval", required = false) Boolean toApproval,
|
|
|
|
- @RequestParam(value = "packageUserScope", required = false) String packageUserScope
|
|
|
|
- ) {
|
|
|
|
-
|
|
|
|
- Integer sendDeptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
- Integer userId = SecurityUtils.getUser().getId();
|
|
|
|
-
|
|
|
|
- return this.exportScorePackageForBC(packageType1, packageType2, sendDeptId, userId, scorePackageName,
|
|
|
|
- scorePackageStatus, typeId, monthStart, monthEnd, acceptUser, relationScoreId, toApproval, packageUserScope);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 个人承接积分值-其他导出-用于BC
|
|
|
|
- *
|
|
|
|
- * @param acceptUser 接单对象,模糊查询
|
|
|
|
- */
|
|
|
|
- @ResponseExcel(name = "exportPackageSettle", sheet = "个人承接积分值-其他导出")
|
|
|
|
- @SysLog("个人承接积分值-其他导出-用于BC")
|
|
|
|
- @GetMapping("/export-score-package-mah-for-bc")
|
|
|
|
- public List<WmScorePackageExcelModel> exportPackageSettleForMahForBC(
|
|
|
|
- @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
- @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
- @RequestParam(value = "deptId") Integer deptId,
|
|
|
|
- @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
- @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
- @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
- @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
- @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
- @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
- @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
- @RequestParam(value = "toApproval", required = false) Boolean toApproval
|
|
|
|
- ) {
|
|
|
|
-
|
|
|
|
- LocalDateTime start = null;
|
|
|
|
- LocalDateTime end = null;
|
|
|
|
-
|
|
|
|
- if (StrUtil.isNotEmpty(monthStart) && StrUtil.isNotEmpty(monthEnd)) {
|
|
|
|
- start = LocalDateTime.of(LocalDate.parse(monthStart + "-01", DatePattern.NORM_DATE_FORMATTER), LocalTime.MIN);
|
|
|
|
- LocalDate e = LocalDate.parse(monthEnd + "-01", DatePattern.NORM_DATE_FORMATTER);
|
|
|
|
- end = LocalDateTime.of(e.with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- QueryWrapper<WmScorePackage> queryWrapper = Wrappers.<WmScorePackage>query()
|
|
|
|
- .eq("p.package_type1", packageType1)
|
|
|
|
- .eq("p.package_type2", packageType2)
|
|
|
|
- .eq(scorePackageStatus != null, "p.score_package_status", scorePackageStatus)
|
|
|
|
- .eq("p.mah_settle_dept_id", deptId)
|
|
|
|
- .in("p.mah_settle_step", UpmsType.MahSettleStep.BUSINESS.getType(), UpmsType.MahSettleStep.FINANCE.getType())
|
|
|
|
- .between(start != null && end != null, "p.create_time", start, end);
|
|
|
|
-
|
|
|
|
- if (StrUtil.isNotBlank(scorePackageName)) {
|
|
|
|
- queryWrapper.and(wrapper -> wrapper.like("p.score_package_name", scorePackageName).or().like("p.pkg_sn", scorePackageName));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (StringUtil.isEmpty(typeId)) {
|
|
|
|
- queryWrapper.in("p.typeid", "3", "4", "5");
|
|
|
|
- } else {
|
|
|
|
- List<String> split = StrUtil.split(typeId, StrUtil.COMMA);
|
|
|
|
- queryWrapper.in("p.typeid", split);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- long startMillis = System.currentTimeMillis();
|
|
|
|
- List<WmScorePackage> scorePackageList = wmScorePackageMapper.listScorePackage(
|
|
|
|
- queryWrapper.orderByDesc("p.settlement_date"), acceptUser, relationScoreId, toApproval);
|
|
|
|
-
|
|
|
|
- log.info("MAH积分包列表sql耗时:{}", System.currentTimeMillis() - startMillis);
|
|
|
|
-
|
|
|
|
- if (CollUtil.isEmpty(scorePackageList)) {
|
|
|
|
- return Collections.emptyList();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- long buildStartMillis = System.currentTimeMillis();
|
|
|
|
-
|
|
|
|
- Set<String> packageIds = scorePackageList.stream().map(WmScorePackage::getId).collect(Collectors.toSet());
|
|
|
|
-
|
|
|
|
- // 任务统计
|
|
|
|
- List<WmTask> taskList = wmTaskMapper.selectList(Wrappers.<WmTask>lambdaQuery()
|
|
|
|
- .eq(WmTask::getRealFlag, "0")
|
|
|
|
- .eq(WmTask::getEnableFlag, "0")
|
|
|
|
- .eq(WmTask::getDelFlag, "0")
|
|
|
|
- .in(WmTask::getScorePackageId, packageIds)
|
|
|
|
- );
|
|
|
|
- Map<String, List<WmTask>> taskGoupMap = taskList.stream().collect(Collectors.groupingBy(WmTask::getScorePackageId));
|
|
|
|
-
|
|
|
|
- // 领取积分包记录
|
|
|
|
- List<WmScorePackageStatus> scorePackageStatusList = wmScorePackageStatusService.list(Wrappers.<WmScorePackageStatus>lambdaQuery()
|
|
|
|
- .in(WmScorePackageStatus::getPackageId, packageIds)
|
|
|
|
- );
|
|
|
|
- Map<String, List<WmScorePackageStatus>> packageStatusGroupMap = scorePackageStatusList.stream()
|
|
|
|
- .collect(Collectors.groupingBy(WmScorePackageStatus::getPackageId));
|
|
|
|
-
|
|
|
|
- //获取上级包
|
|
|
|
- Set<String> parentPackageIds = scorePackageList.stream().map(WmScorePackage::getRelationScoreId).collect(Collectors.toSet());
|
|
|
|
- List<WmScorePackage> parentPackages = wmScorePackageMapper.selectList(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
- .in(WmScorePackage::getId, parentPackageIds));
|
|
|
|
- Map<String, WmScorePackage> parentPackageNameMap = parentPackages.stream()
|
|
|
|
- .collect(Collectors.toMap(WmScorePackage::getId, Function.identity()));
|
|
|
|
-
|
|
|
|
- // 类型标签
|
|
|
|
- List<SysDictItem> dictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
- .in(SysDictItem::getType, "package_type1", "package_type2"));
|
|
|
|
- Map<String, List<SysDictItem>> dictItemMap = dictItems.stream().collect(Collectors.groupingBy(SysDictItem::getType));
|
|
|
|
- List<SysDictItem> packageType1List = dictItemMap.get("package_type1");
|
|
|
|
- List<SysDictItem> packageType2List = dictItemMap.get("package_type2");
|
|
|
|
-
|
|
|
|
- // todo
|
|
|
|
- // 结算记录
|
|
|
|
- //List<WmScorePackageSettleNote> noteList = settleNoteMapper.selectList(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
- // .in(WmScorePackageSettleNote::getPackageId, packageIds));
|
|
|
|
- //Map<String, List<WmScorePackageSettleNote>> noteMap = noteList.stream()
|
|
|
|
- // .collect(Collectors.groupingBy(WmScorePackageSettleNote::getPackageId));
|
|
|
|
-
|
|
|
|
- // 有效任务类型
|
|
|
|
- List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(String.join(",", packageIds));
|
|
|
|
- Map<String, List<WmScoreTaskType>> taskTypeMap = taskTypeList.stream().collect(Collectors.groupingBy(WmScoreTaskType::getScoreId));
|
|
|
|
-
|
|
|
|
- List<WmScorePackageExcelModel> excelModelList = new ArrayList<>(scorePackageList.size());
|
|
|
|
- for (int i = 0; i < scorePackageList.size(); i++) {
|
|
|
|
- WmScorePackage wmScorePackage = scorePackageList.get(i);
|
|
|
|
- log.info("====> 积分包SN:{}", wmScorePackage.getPackageSn());
|
|
|
|
-
|
|
|
|
- List<WmTask> tasks = taskGoupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- List<WmScorePackageStatus> statuses = packageStatusGroupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- // todo
|
|
|
|
- //List<WmScorePackageSettleNote> notes = noteMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- //List<WmScoreTaskType> scoreTaskTypes = taskTypeMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
- //
|
|
|
|
- //wmScorePackageService.buildScorePackageSync(wmScorePackage, packageType1, packageType2, tasks, statuses,
|
|
|
|
- // packageType1List, packageType2List, parentPackageNameMap, notes, scoreTaskTypes);
|
|
|
|
-
|
|
|
|
- WmScorePackageExcelModel excelModel = BeanUtil.copyProperties(wmScorePackage, WmScorePackageExcelModel.class);
|
|
|
|
- if (StrUtil.isNotBlank(wmScorePackage.getScorePackageStatus())) {
|
|
|
|
- excelModel.setScorePackageStatus(Objects.requireNonNull(ScorePackageStatusEnum.getByVal(wmScorePackage.getScorePackageStatus())).getDesc());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (CollUtil.isNotEmpty(wmScorePackage.getUserList())) {
|
|
|
|
- excelModel.setUserNames(String.join(",", wmScorePackage.getUserList()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- String typeid = wmScorePackage.getTypeid();
|
|
|
|
- if (StrUtil.isNotBlank(typeid)) {
|
|
|
|
- excelModel.setTypeidName("3".equals(typeid) ? "全职学术信息沟通专员" :
|
|
|
|
- "4".equals(typeid) ? "兼职学术信息沟通专员" : "5".equals(typeid) ? "招商经理" : typeid);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- excelModel.setNumber(String.valueOf(i+1));
|
|
|
|
- if (wmScorePackage.getYshtt() != null) {
|
|
|
|
- excelModel.setFinishRate(String.valueOf(wmScorePackage.getYshtt()));
|
|
|
|
- }
|
|
|
|
- excelModel.setPayScore(wmScorePackage.getShtg());
|
|
|
|
- if (wmScorePackage.getShtgtt() != null) {
|
|
|
|
- excelModel.setPayRate(String.valueOf(wmScorePackage.getShtgtt()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- excelModelList.add(excelModel);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- log.info("build积分包耗时:{}", System.currentTimeMillis() - buildStartMillis);
|
|
|
|
-
|
|
|
|
- return excelModelList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 个人承接积分值-其他导出
|
|
|
|
- *
|
|
|
|
- * @param acceptUser 接单对象,模糊查询
|
|
|
|
- */
|
|
|
|
- @ResponseExcel(name = "exportPackageSettle", sheet = "个人承接积分值-其他导出")
|
|
|
|
- @SysLog("个人承接积分值-其他导出")
|
|
|
|
- @GetMapping("/export-score-package-mah")
|
|
|
|
- public List<WmScorePackageExcelModel> exportPackageSettleForMah(
|
|
|
|
- @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
- @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
- @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
- @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
- @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
- @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
- @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
- @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
- @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
- @RequestParam(value = "toApproval", required = false) Boolean toApproval
|
|
|
|
- ) {
|
|
|
|
-
|
|
|
|
- Integer sendDeptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
-
|
|
|
|
- return this.exportPackageSettleForMahForBC(packageType1, packageType2, sendDeptId, scorePackageName, scorePackageStatus,
|
|
|
|
- typeId, monthStart, monthEnd, acceptUser, relationScoreId, toApproval);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 积分包列表(结算包管理列表、无团队限制)
|
|
|
|
- *
|
|
|
|
- * @param packageType1 多个逗号分隔
|
|
|
|
- */
|
|
|
|
- @GetMapping("/page-settle-package")
|
|
|
|
- public R<?> pageSettlePackage(@RequestParam(value = "current") Integer current,
|
|
|
|
- @RequestParam(value = "size") Integer size,
|
|
|
|
- @RequestParam(value = "packageType1") String packageType1,
|
|
|
|
- @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
- @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
- @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
- @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
- @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
- @RequestParam(value = "monthEnd", required = false) String monthEnd
|
|
|
|
- ) {
|
|
|
|
-
|
|
|
|
- Integer sendDeptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
- Integer userId = SecurityUtils.getUser().getId();
|
|
|
|
-
|
|
|
|
- LocalDateTime start = null;
|
|
|
|
- LocalDateTime end = null;
|
|
|
|
-
|
|
|
|
- if (StrUtil.isNotEmpty(monthStart) && StrUtil.isNotEmpty(monthEnd)) {
|
|
|
|
- start = LocalDateTime.of(LocalDate.parse(monthStart + "-01", DatePattern.NORM_DATE_FORMATTER), LocalTime.MIN);
|
|
|
|
- LocalDate e = LocalDate.parse(monthEnd + "-01", DatePattern.NORM_DATE_FORMATTER);
|
|
|
|
- end = LocalDateTime.of(e.with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- LambdaQueryWrapper<WmScorePackage> queryWrapper = Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
- .eq(WmScorePackage::getPackageType2, packageType2)
|
|
|
|
- .like(StrUtil.isNotEmpty(scorePackageName), WmScorePackage::getScorePackageName, scorePackageName)
|
|
|
|
- .eq(scorePackageStatus != null, WmScorePackage::getScorePackageStatus, scorePackageStatus)
|
|
|
|
- .eq(WmScorePackage::getSendPackageDeptId, sendDeptId)
|
|
|
|
- .between(start != null && end != null, WmScorePackage::getCreateTime, start, end);
|
|
|
|
-
|
|
|
|
- List<String> packageType1List = StrUtil.split(packageType1, StrUtil.COMMA);
|
|
|
|
- if (StrUtil.contains(packageType1, StrUtil.COMMA)) {
|
|
|
|
- queryWrapper.in(WmScorePackage::getPackageType1, packageType1List);
|
|
|
|
- } else {
|
|
|
|
- queryWrapper.eq(WmScorePackage::getPackageType1, packageType1);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (StringUtil.isEmpty(typeId)) {
|
|
|
|
- queryWrapper.in(WmScorePackage::getTypeid, "3", "4");
|
|
|
|
- } else {
|
|
|
|
- List<String> split = StrUtil.split(typeId, StrUtil.COMMA);
|
|
|
|
- queryWrapper.in(WmScorePackage::getTypeid, split);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- queryWrapper.ne(WmScorePackage::getLocation, SubjectLocation.MAH_SETTLE);
|
|
|
|
-
|
|
|
|
- Page<WmScorePackage> wmScorePackagePage = wmScorePackageMapper.selectPage(new Page<>(current, size), queryWrapper
|
|
|
|
- .orderByDesc(WmScorePackage::getCreateTime));
|
|
|
|
-
|
|
|
|
- List<WmScorePackage> pageRecords = wmScorePackagePage.getRecords();
|
|
|
|
-
|
|
|
|
- if (CollUtil.isNotEmpty(pageRecords)) {
|
|
|
|
|
|
+ List<WmScorePackage> wmList = page.getRecords();
|
|
|
|
+ List<Future<WmScorePackage>> futureList = new ArrayList<>(wmList.size());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for (WmScorePackage wmS : wmList) {
|
|
|
|
+ Future<WmScorePackage> future = wmScorePackageService.finishRate(wmS);
|
|
|
|
+ futureList.add(future);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<WmScorePackage> finalRecords = new ArrayList<>(wmList.size());
|
|
|
|
+ try {
|
|
|
|
+ for (Future<WmScorePackage> future : futureList) {
|
|
|
|
+ WmScorePackage sPackage = future.get();
|
|
|
|
+
|
|
|
|
+ if (sPackage.getP2pAmount() != null) {
|
|
|
|
+ sPackage.setP2pDraft(false);
|
|
|
|
+ } else {
|
|
|
|
+ String s = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:amount:%s", sPackage.getId()));
|
|
|
|
+ String s1 = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:service-amount:%s", sPackage.getId()));
|
|
|
|
+ String desc = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:desc:%s", sPackage.getId()));
|
|
|
|
+ if (StrUtil.isNotBlank(s)) {
|
|
|
|
+ sPackage.setP2pAmount(new BigDecimal(s));
|
|
|
|
+ sPackage.setP2pServiceAmount(new BigDecimal(s1));
|
|
|
|
+ sPackage.setDescription(desc);
|
|
|
|
+ }
|
|
|
|
+ sPackage.setP2pDraft(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ finalRecords.add(sPackage);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ } catch (ExecutionException | InterruptedException e) {
|
|
|
|
+ log.error("获取分页信息失败", e);
|
|
|
|
+ return R.failed("获取分页信息失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.ok(page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页查询
|
|
|
|
+ *
|
|
|
|
+ * @param page 分页对象
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return 分页结果
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getWmScorePackageTask")
|
|
|
|
+ public R<?> getWmScorePackageTask(Page<?> page, WmScorePackage wmScorePackage) {
|
|
|
|
+
|
|
|
|
+ OrderItem orderItem = new OrderItem();
|
|
|
|
+ orderItem.setColumn("create_time");
|
|
|
|
+ orderItem.setAsc(false);
|
|
|
|
+ page.addOrder(orderItem);
|
|
|
|
+
|
|
|
|
+ if (!SecurityUtils.getRoles().contains(2) && !SecurityUtils.getRoles().contains(1)) {
|
|
|
|
+ wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
+ }
|
|
|
|
+ wmScorePackage.setDelFlag("0");
|
|
|
|
+ wmScorePackage.setEnableFlag("0");
|
|
|
|
+ if (SecurityUtils.getRoles().contains(4)) {
|
|
|
|
+ SysDept sysDept1 = new SysDept();
|
|
|
|
+ sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
+ SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
+ wmScorePackage.setLevel1Id(sysDept.getLevel2Id());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<WmScorePackage> listExt = new ArrayList<>();
|
|
|
|
+ SysDept sysDept1 = new SysDept();
|
|
|
|
+ sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
+ SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
+ if (sysDept.getLevel() == 3) {
|
|
|
|
+ wmScorePackage.setAgentTypeId("1");
|
|
|
|
+ wmScorePackage.setLevel1Id(sysDept.getLevel2Id());
|
|
|
|
+
|
|
|
|
+ listExt = wmScorePackageService.listWmScorePackageAndTaskExt(wmScorePackage);
|
|
|
|
+ } else if (sysDept.getLevel() == 4) {
|
|
|
|
+ wmScorePackage.setAgentTypeId("2");
|
|
|
|
+ wmScorePackage.setLevel2Id(sysDept.getLevel3Id());
|
|
|
|
+ wmScorePackage.setTypeid("2");
|
|
|
|
+ listExt = wmScorePackageService.listWmScorePackageAndTaskExt2(wmScorePackage);
|
|
|
|
+ } else if (sysDept.getLevel() == 2) {
|
|
|
|
+ wmScorePackage.setAgentTypeId("1");
|
|
|
|
+ wmScorePackage.setTypeid("1");
|
|
|
|
+ listExt = wmScorePackageService.listWmScorePackageAndTaskExt(wmScorePackage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (SecurityUtils.getRoles().contains(2) || SecurityUtils.getRoles().contains(1)) {
|
|
|
|
+ wmScorePackage.setAgentTypeId("1");
|
|
|
|
+ wmScorePackage.setTypeid("1");
|
|
|
|
+ listExt = wmScorePackageService.listWmScorePackageAndTaskExt(wmScorePackage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ int ytj = 0;
|
|
|
|
+ int ywc = 0;
|
|
|
|
+ int dqf = 0;
|
|
|
|
+ for (WmScorePackage wmS :
|
|
|
|
+ listExt) {
|
|
|
|
+ ywc += wmS.getScore();
|
|
|
|
+
|
|
|
|
+ if (null != wmS.getYsh()) {
|
|
|
|
+ //TODO
|
|
|
|
+ //dqf+=wmS.getYsh();
|
|
|
|
+ if (wmS.getYtj() > wmS.getScore()) {
|
|
|
|
+ dqf += wmS.getScore();
|
|
|
|
+ } else {
|
|
|
|
+ dqf += wmS.getYtj();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null != wmS.getYtj()) {
|
|
|
|
+ if (wmS.getYtj() > wmS.getScore()) {
|
|
|
|
+ ytj += wmS.getScore();
|
|
|
|
+ } else {
|
|
|
|
+ ytj += wmS.getYtj();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("ytj", ytj);
|
|
|
|
+ map.put("ywc", ywc);
|
|
|
|
+ map.put("dqf", dqf);
|
|
|
|
+
|
|
|
|
+ return R.ok(map);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页查询
|
|
|
|
+ *
|
|
|
|
+ * @param page 分页对象
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return 分页结果
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getListRule")
|
|
|
|
+ public R<?> getListRule(Page<WmScorePackage> page, WmScorePackage wmScorePackage) {
|
|
|
|
+ OrderItem orderItem = new OrderItem();
|
|
|
|
+ orderItem.setColumn("create_time");
|
|
|
|
+ orderItem.setAsc(false);
|
|
|
|
+ page.addOrder(orderItem);
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
+ wmScorePackage.setDelFlag("0");
|
|
|
|
+ wmScorePackage.setEnableFlag("0");
|
|
|
|
+ if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
+ wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
+ wmScorePackage.setAgentTypeId("1");
|
|
|
|
+ } else if (SecurityUtils.getRoles().contains(4)) {
|
|
|
|
+ wmScorePackage.setAgentTypeId("2");
|
|
|
|
+ SysDept sysDept1 = new SysDept();
|
|
|
|
+ sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
+ SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
+ if (null != sysDept) {
|
|
|
|
+ if (3 == sysDept.getLevel()) {
|
|
|
|
+ WmDaAgent wmDaAgent = wmDaAgentService.getById(sysDept.getLevel2Id());
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setLevel1Id(wmDaAgent.getId());
|
|
|
|
+
|
|
|
|
+ List<Integer> list = new ArrayList<>();
|
|
|
|
+ list.add(2);
|
|
|
|
+ list.add(3);
|
|
|
|
+ list.add(4);
|
|
|
|
+ wmScorePackage.setSendPackageDeptId(SecurityUtils.getUser().getDeptId() + "");
|
|
|
|
+ Page<WmScorePackage> pageAnswer = wmScorePackageService.page(page, Wrappers.query(wmScorePackage)
|
|
|
|
+ .lambda()
|
|
|
|
+ .in(WmScorePackage::getTypeid, list));
|
|
|
|
+ List<WmScorePackage> listExt = wmScorePackageService.listWmScorePackageAndTaskLevel3(wmScorePackage);
|
|
|
|
+ List<WmScorePackage> listWmScorePackage = pageAnswer.getRecords();
|
|
|
|
+
|
|
|
|
+ for (WmScorePackage wmS :
|
|
|
|
+ listWmScorePackage) {
|
|
|
|
+ for (WmScorePackage ext :
|
|
|
|
+ listExt) {
|
|
|
|
+ if (wmS.getId().equals(ext.getId())) {
|
|
|
|
+ wmS.setYsh(ext.getYsh());
|
|
|
|
+ wmS.setYtj(ext.getYtj());
|
|
|
|
+ wmS.setDsh(ext.getDsh());
|
|
|
|
+
|
|
|
|
+ if (2 == sysDept.getLevel()) {
|
|
|
|
+ wmS.setDsh(ext.getDsh());
|
|
|
|
+ } else {
|
|
|
|
+ if (null == ext.getYtj() || null == ext.getScore()) {
|
|
|
|
+ wmS.setYwctt(0);
|
|
|
|
+ } else {
|
|
|
|
+ if (ext.getYtj() >= ext.getScore()) {
|
|
|
|
+ wmS.setYwctt(100);
|
|
|
|
+ } else {
|
|
|
|
+ wmS.setYwctt(new Double(Math.ceil(100.0 * ext.getYtj() / ext.getScore())).intValue());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ pageAnswer.setRecords(listWmScorePackage);
|
|
|
|
+ return R.ok(pageAnswer);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (4 == sysDept.getLevel()) {
|
|
|
|
+ WmDaAgent wmDaAgent = wmDaAgentService.getById(sysDept.getLevel3Id());
|
|
|
|
+ wmScorePackage.setLevel2Id(wmDaAgent.getId());
|
|
|
|
+ List<Integer> list = new ArrayList<>();
|
|
|
|
+ list.add(3);
|
|
|
|
+ list.add(4);
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setSendPackageDeptId(SecurityUtils.getUser().getDeptId() + "");
|
|
|
|
+ Page<WmScorePackage> pageAnswer = wmScorePackageService.page(page, Wrappers.query(wmScorePackage)
|
|
|
|
+ .lambda()
|
|
|
|
+ .in(WmScorePackage::getTypeid, list));
|
|
|
|
+ List<WmScorePackage> listExt = wmScorePackageService.listWmScorePackageAndTaskLevel1(wmScorePackage);
|
|
|
|
+ List<WmScorePackage> listWmScorePackage = pageAnswer.getRecords();
|
|
|
|
+
|
|
|
|
+ for (WmScorePackage wmS :
|
|
|
|
+ listWmScorePackage) {
|
|
|
|
+ for (WmScorePackage ext :
|
|
|
|
+ listExt) {
|
|
|
|
+ if (wmS.getId().equals(ext.getId())) {
|
|
|
|
+ wmS.setYsh(ext.getYsh());
|
|
|
|
+ wmS.setYtj(ext.getYtj());
|
|
|
|
+ if (2 == sysDept.getLevel()) {
|
|
|
|
+ wmS.setYwctt(ext.getDsh());
|
|
|
|
+ } else {
|
|
|
|
+ if (null == ext.getYtj() || null == ext.getScore()) {
|
|
|
|
+ wmS.setYwctt(0);
|
|
|
|
+ } else {
|
|
|
|
+ if (!(ext.getYtj() > ext.getScore())) {
|
|
|
|
+ wmS.setYwctt(new Double(Math.ceil(100.0 * ext.getYtj() / ext.getScore())).intValue());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ pageAnswer.setRecords(listWmScorePackage);
|
|
|
|
+ return R.ok(pageAnswer);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ sysDept.setDeptId(sysDept.getDeptId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return R.ok(wmScorePackageService.page(page, Wrappers.query(wmScorePackage)));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页查询
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getTotalData")
|
|
|
|
+ public R<?> getTotalData(WmScorePackage wmScorePackage) {
|
|
|
|
+ wmScorePackage.setDelFlag("0");
|
|
|
|
+ wmScorePackage.setEnableFlag("0");
|
|
|
|
+ if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
+ wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
+ } else if (SecurityUtils.getRoles().contains(4)) {
|
|
|
|
+ wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
+ SysDept sysDept1 = new SysDept();
|
|
|
|
+ sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
+ SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
+ if (null != sysDept) {
|
|
|
|
+ if (3 == sysDept.getLevel()) {
|
|
|
|
+ WmDaAgent wmDaAgent = wmDaAgentService.getById(sysDept.getLevel2Id());
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setLevel1Id(wmDaAgent.getId());
|
|
|
|
+ List<WmScorePackage> list = wmScorePackageService.list(Wrappers.query(wmScorePackage).lambda());
|
|
|
|
+ List<WmScorePackage> newList = new ArrayList<>();
|
|
|
|
+ for (WmScorePackage wmS : list) {
|
|
|
|
+ if ("2".equals(wmS.getTypeid()) || "3".equals(wmS.getTypeid()) || "4".equals(wmS.getTypeid())) {
|
|
|
|
+ if (SecurityUtils.getUser().getDeptId().toString().equals(wmS.getDeptId())) {
|
|
|
|
+ newList.add(wmS);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ newList.add(wmS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return R.ok(newList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (4 == sysDept.getLevel()) {
|
|
|
|
+ WmDaAgent wmDaAgent = wmDaAgentService.getById(sysDept.getLevel3Id());
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setLevel2Id(wmDaAgent.getId());
|
|
|
|
+ List<Integer> list = new ArrayList<>();
|
|
|
|
+ list.add(2);
|
|
|
|
+ list.add(3);
|
|
|
|
+ list.add(4);
|
|
|
|
+
|
|
|
|
+ return R.ok(wmScorePackageService.list(Wrappers.query(wmScorePackage)
|
|
|
|
+ .lambda()
|
|
|
|
+ .in(WmScorePackage::getTypeid, list)));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return R.ok(wmScorePackageService.pageList(Wrappers.query(wmScorePackage)));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 通过id查询积分包
|
|
|
|
+ *
|
|
|
|
+ * @param id id
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/{id}")
|
|
|
|
+ public R<?> getById(@PathVariable("id") Integer id) {
|
|
|
|
+ return R.ok(wmScorePackageService.getById(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增积分包
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @SysLog("新增积分包")
|
|
|
|
+ @PostMapping
|
|
|
|
+ public R<?> save(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
+
|
|
|
|
+ if (wmScorePackage.getScore() <= 0) {
|
|
|
|
+ return R.failed("积分包分值必须大于0");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (null != wmScorePackage.getScoreId() && !"".equals(wmScorePackage.getScoreId())) {
|
|
|
|
+ WmScorePackage wmScorePackage1 = new WmScorePackage();
|
|
|
|
+ wmScorePackage1.setDelFlag("0");
|
|
|
|
+ wmScorePackage1.setScoreId(wmScorePackage.getScoreId());
|
|
|
|
+ List<WmScorePackage> wmScorePackageList = wmScorePackageService.list(Wrappers.query(wmScorePackage1));
|
|
|
|
+ if (wmScorePackageList.size() > 0) {
|
|
|
|
+ return R.failed("积分包ID已存在");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setDelFlag("0");
|
|
|
|
+ wmScorePackage.setEnableFlag("0");
|
|
|
|
+ wmScorePackage.setIsConduct("0");
|
|
|
|
+ wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
+ if ("1".equals(wmScorePackage.getTypeid())) {
|
|
|
|
+ if (null != wmScorePackage.getLevel1Id()) {
|
|
|
|
+ WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getLevel1Id());
|
|
|
|
+ wmScorePackage.setDeptId(wmDaAgent.getDeptId() + "");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else if ("2".equals(wmScorePackage.getTypeid())) {
|
|
|
|
+ SysDept sysDept1 = new SysDept();
|
|
|
|
+ sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
+ SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
+ if (sysDept.getLevel() == 3) {
|
|
|
|
+ if (null != wmScorePackage.getLevel2Id()) {
|
|
|
|
+ WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getLevel2Id());
|
|
|
|
+ wmScorePackage.setDeptId(wmDaAgent.getDeptId() + "");
|
|
|
|
+
|
|
|
|
+ WmDaAgent wmDaAgent1 = wmDaAgentService.getById(sysDept.getLevel2Id());
|
|
|
|
+ wmScorePackage.setLevel1Id(wmDaAgent1.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ } else if ("3".equals(wmScorePackage.getTypeid())) {
|
|
|
|
+ if (null != wmScorePackage.getXxdbId()) {
|
|
|
|
+ SysUser sysUser = sysUserService.getById(wmScorePackage.getXxdbId());
|
|
|
|
+ if (null != sysUser.getDeptId()) {
|
|
|
|
+ wmScorePackage.setDeptId(sysUser.getDeptId() + "");
|
|
|
|
+ SysDept sysDept1 = new SysDept();
|
|
|
|
+ sysDept1.setDeptId(sysUser.getDeptId());
|
|
|
|
+ SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
+ wmScorePackage.setLevel1Id(sysDept.getLevel2Id() == null || sysDept.getLevel2Id() == 0 ? null : sysDept
|
|
|
|
+ .getLevel2Id());
|
|
|
|
+ wmScorePackage.setLevel2Id(sysDept.getLevel3Id() == null || sysDept.getLevel3Id() == 0 ? null : sysDept
|
|
|
|
+ .getLevel3Id());
|
|
|
|
+ wmScorePackage.setPackageStatus("2");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else if ("4".equals(wmScorePackage.getTypeid())) {
|
|
|
|
+ wmScorePackage.setDeptId(SecurityUtils.getUser().getDeptId() + "");
|
|
|
|
+ SysDept sysDept1 = new SysDept();
|
|
|
|
+ sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
+ SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
+ wmScorePackage.setLevel1Id(sysDept.getLevel2Id() == null || sysDept.getLevel2Id() == 0 ? null : sysDept.getLevel2Id());
|
|
|
|
+ wmScorePackage.setLevel2Id(sysDept.getLevel3Id() == null || sysDept.getLevel3Id() == 0 ? null : sysDept.getLevel3Id());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null != wmScorePackage.getScoreName() && !"".equals(wmScorePackage.getScoreName())) {
|
|
|
|
+ WmScorePackage wmScorePackage1 = new WmScorePackage();
|
|
|
|
+ wmScorePackage1.setDelFlag("0");
|
|
|
|
+ wmScorePackage1.setScoreName(wmScorePackage.getScoreName());
|
|
|
|
+ wmScorePackage1.setDeptId(wmScorePackage.getDeptId());
|
|
|
|
+ List<WmScorePackage> wmScorePackageList = wmScorePackageService.list(Wrappers.query(wmScorePackage1));
|
|
|
|
+ if (wmScorePackageList.size() > 0) {
|
|
|
|
+ return R.failed("积分包名称已存在");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setCreateTime(LocalDateTime.now());
|
|
|
|
+ wmScorePackage.setPackageFinishStatus("0");
|
|
|
|
+ wmScorePackage.setPackageAuditStatus("0");
|
|
|
|
+ wmScorePackage.setSendPackageDeptId(SecurityUtils.getUser().getDeptId() + "");
|
|
|
|
+ boolean isAnswer = wmScorePackageService.save(wmScorePackage);
|
|
|
|
+ if (isAnswer) {
|
|
|
|
+ if (SecurityUtils.getRoles().contains(4)) {
|
|
|
|
+ WmScorePackage queryWm = new WmScorePackage();
|
|
|
|
+ SysDept sysDept1 = new SysDept();
|
|
|
|
+ sysDept1.setDeptId(SecurityUtils.getUser().getDeptId());
|
|
|
|
+ SysDept sysDept = sysDeptService.selectDeptId(sysDept1);
|
|
|
|
+ if (sysDept.getLevel() == 3) {
|
|
|
|
+ queryWm.setAgentTypeId("1");
|
|
|
|
+ queryWm.setTypeid("1");
|
|
|
|
+ queryWm.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
+ queryWm.setLevel1Id(sysDept.getLevel2Id());
|
|
|
|
+ queryWm.setTaskRuleId(wmScorePackage.getTaskRuleId());
|
|
|
|
+ queryWm.setDeptId(SecurityUtils.getUser().getDeptId() + "");
|
|
|
|
+ } else if (sysDept.getLevel() == 4) {
|
|
|
|
+ queryWm.setAgentTypeId("2");
|
|
|
|
+ queryWm.setTypeid("2");
|
|
|
|
+ queryWm.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
+ queryWm.setLevel1Id(sysDept.getLevel2Id());
|
|
|
|
+ queryWm.setTaskRuleId(wmScorePackage.getTaskRuleId());
|
|
|
|
+ } else {
|
|
|
|
+ queryWm.setId("-1");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<WmScorePackage> wmScorePackageList = wmScorePackageService.list(Wrappers.query(queryWm));
|
|
|
|
+ if (wmScorePackageList.size() > 0) {
|
|
|
|
+ for (WmScorePackage wms : wmScorePackageList) {
|
|
|
|
+ wms.setIsConduct("1");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wmScorePackageService.updateBatchById(wmScorePackageList);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改积分包
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @SysLog("修改积分包")
|
|
|
|
+ @PutMapping
|
|
|
|
+ public R<?> updateById(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
+ if (wmScorePackage.getScore() <= 0) {
|
|
|
|
+ return R.failed("积分包分值必须大于0");
|
|
|
|
+ }
|
|
|
|
+ WmScorePackage oldData = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
+ if (StringUtils.isNotEmpty(wmScorePackage.getScorePackageName())
|
|
|
|
+ && !oldData.getScorePackageName().equals(wmScorePackage.getScorePackageName())) {
|
|
|
|
+ WmScorePackage wmScorePackage1 = new WmScorePackage();
|
|
|
|
+ wmScorePackage1.setDelFlag("0");
|
|
|
|
+ wmScorePackage1.setScorePackageName(wmScorePackage.getScorePackageName());
|
|
|
|
+ wmScorePackage1.setDeptId(wmScorePackage.getDeptId());
|
|
|
|
+ List<WmScorePackage> wmScorePackageList = wmScorePackageService.listWmScorePackages(wmScorePackage1);
|
|
|
|
+ if (wmScorePackageList.size() > 0) {
|
|
|
|
+ return R.failed("积分包名称已存在");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null != wmScorePackage.getScoreId() && !"".equals(wmScorePackage.getScoreId())) {
|
|
|
|
+ WmScorePackage wmScorePackage1 = new WmScorePackage();
|
|
|
|
+ wmScorePackage1.setDelFlag("0");
|
|
|
|
+ wmScorePackage1.setScoreId(wmScorePackage.getScoreId());
|
|
|
|
+ List<WmScorePackage> wmScorePackageList = wmScorePackageService.list(Wrappers.query(wmScorePackage1));
|
|
|
|
+ if (wmScorePackageList.size() > 1) {
|
|
|
|
+ return R.failed("积分包ID已存在");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ("4".equals(wmScorePackage.getPackageStatus())) {
|
|
|
|
+ WmTask wmTask = new WmTask();
|
|
|
|
+ wmTask.setScorePackageId(wmScorePackage.getId());
|
|
|
|
+ List<WmTask> wmTaskList = wmTaskService.list(Wrappers.query(wmTask));
|
|
|
|
+
|
|
|
|
+ for (WmTask wmt : wmTaskList) {
|
|
|
|
+ wmt.setEnableFlag("1");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wmTaskService.updateBatchById(wmTaskList);
|
|
|
|
+ }
|
|
|
|
+ return R.ok(wmScorePackageService.updateById(wmScorePackage));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改积分包
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackageVO 积分包
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @SysLog("修改积分包折扣和实际结算金额")
|
|
|
|
+ @PostMapping(value = "/updateByIdWithType")
|
|
|
|
+ public R<?> updateByIdWithType(@RequestBody @Valid WmScorePackageVO wmScorePackageVO) {
|
|
|
|
+ return wmScorePackageService.updateByIdWithType(wmScorePackageVO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 通过id删除积分包
|
|
|
|
+ *
|
|
|
|
+ * @param id id
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @SysLog("通过id删除积分包")
|
|
|
|
+ @DeleteMapping("/{id}")
|
|
|
|
+ public R<?> removeById(@PathVariable Integer id) {
|
|
|
|
+ return R.ok(wmScorePackageService.removeById(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取药企列表
|
|
|
|
+ *
|
|
|
|
+ * @return 角色列表
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/list")
|
|
|
|
+ public R<?> listWmScorePackage(WmScorePackage wmScorePackage) {
|
|
|
|
+ wmScorePackage.setDelFlag("0");
|
|
|
|
+ wmScorePackage.setEnableFlag("0");
|
|
|
|
+
|
|
|
|
+ List<WmScorePackage> list = wmScorePackageService.list(Wrappers.query(wmScorePackage));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
|
+ if (list.size() > 0) {
|
|
|
|
+ for (WmScorePackage sysUser : list) {
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
+ map.put("id", sysUser.getId() + "");
|
|
|
|
+ if (null == sysUser.getScoreId() || "".equals(sysUser.getScoreId().trim())) {
|
|
|
|
+ map.put("scoreId", "-");
|
|
|
|
+ } else {
|
|
|
|
+ map.put("scoreId", sysUser.getScoreId());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if (null == sysUser.getScoreName() || "".equals(sysUser.getScoreName().trim())) {
|
|
|
|
+ map.put("scoreName", "-");
|
|
|
|
+ } else {
|
|
|
|
+ map.put("scoreName", sysUser.getScoreName() + "");
|
|
|
|
+ }
|
|
|
|
+ answerList.add(map);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return R.ok(answerList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取药企列表
|
|
|
|
+ *
|
|
|
|
+ * @return 角色列表
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/listWmScorePackageAndTask")
|
|
|
|
+ public R<?> listWmScorePackageAndTask(WmScorePackage wmScorePackage) {
|
|
|
|
+ wmScorePackage.setDelFlag("0");
|
|
|
|
+ wmScorePackage.setEnableFlag("0");
|
|
|
|
+ if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
+ wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
+ } else if (SecurityUtils.getRoles().contains(4)) {
|
|
|
|
+ wmScorePackage.setDrugEntId(SecurityUtils.getUser().getDrugEntId());
|
|
|
|
+ }
|
|
|
|
+ return R.ok(wmScorePackageService.listWmScorePackageAndTask(wmScorePackage));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取药企列表
|
|
|
|
+ *
|
|
|
|
+ * @return 角色列表
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/packageIsZZ")
|
|
|
|
+ public R<?> packageIsZZ(WmScorePackage wmScorePackage) {
|
|
|
|
+ wmScorePackage.setDelFlag("0");
|
|
|
|
+ wmScorePackage.setEnableFlag("0");
|
|
|
|
+
|
|
|
|
+ return R.ok(wmScorePackageService.listWmScorePackageAndTask(wmScorePackage));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页查询
|
|
|
|
+ *
|
|
|
|
+ * @param page 分页对象
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return 分页结果
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getPlatTotalData")
|
|
|
|
+ public R<?> getPlatTotalData(Page<?> page, WmScorePackage wmScorePackage, String[] dates) {
|
|
|
|
+
|
|
|
|
+ if (null != dates && dates.length > 0) {
|
|
|
|
+ // 将时间戳转为当前时间
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setDelFlag(dates[0].substring(0, 10));
|
|
|
|
+ wmScorePackage.setEnableFlag(dates[1].substring(0, 10));
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return R.ok(wmScorePackageService.getPlatTotalData(page, wmScorePackage));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取药企列表
|
|
|
|
+ *
|
|
|
|
+ * @return 角色列表
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/listNoDel")
|
|
|
|
+ public R<?> listWmScorePackageNoDel(WmScorePackage wmScorePackage) {
|
|
|
|
+
|
|
|
|
+ List<WmScorePackage> list = wmScorePackageService.list(Wrappers.query(wmScorePackage));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<Map<String, String>> answerList = new ArrayList<>();
|
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
+ for (WmScorePackage scorePackage : list) {
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
|
+ map.put("id", scorePackage.getId() + "");
|
|
|
|
+ if (StringUtils.isEmpty(scorePackage.getScoreId())) {
|
|
|
|
+ map.put("scoreId", "-");
|
|
|
|
+ } else {
|
|
|
|
+ map.put("scoreId", scorePackage.getScoreId());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(scorePackage.getScorePackageName())) {
|
|
|
|
+ map.put("scoreName", "-");
|
|
|
|
+ } else {
|
|
|
|
+ map.put("scoreName", scorePackage.getScorePackageName());
|
|
|
|
+ }
|
|
|
|
+ answerList.add(map);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return R.ok(answerList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页查询
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return 积分包列表
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/selectLists")
|
|
|
|
+ public R<?> selectLists(WmScorePackage wmScorePackage) {
|
|
|
|
+ wmScorePackage.getRelationScoreId();
|
|
|
|
+ return R.ok(wmScorePackageService.selectLists(wmScorePackage));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查看分配积分信息 二期 业务平台
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/selectWmScorePackage")
|
|
|
|
+ public R<?> selectWmScorePackage(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
+ try {
|
|
|
|
+ return R.ok(wmScorePackageService.selectWmScorePackage(wmScorePackage));
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return R.failed();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取企业大包详细信息
|
|
|
|
+ *
|
|
|
|
+ * @param id 积分包id
|
|
|
|
+ * @return {@link R}<{@link ?}> 积分包详情
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/get-big-package-detail")
|
|
|
|
+ public R<?> getBigPackageDetail(String id) {
|
|
|
|
+ WmScorePackage wmScorePackage = wmScorePackageMapper.selectById(id);
|
|
|
|
+
|
|
|
|
+ // 关联积分包
|
|
|
|
+ if (StrUtil.isBlank(wmScorePackage.getRelationScoreId())) {
|
|
|
|
+ wmScorePackage.setRelationScoreId("-1");
|
|
|
|
+ wmScorePackage.setRelationScoreName("无");
|
|
|
|
+ } else {
|
|
|
|
+ WmScorePackage relationPackage = wmScorePackageMapper.selectById(wmScorePackage.getRelationScoreId());
|
|
|
|
+ if (relationPackage != null) {
|
|
|
|
+ wmScorePackage.setRelationScoreName(relationPackage.getScorePackageName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 关联服务企业
|
|
|
|
+ if (StrUtil.isNotBlank(wmScorePackage.getRelatedService())) {
|
|
|
|
+ SysDept serviceDept = sysDeptService.getById(wmScorePackage.getRelatedService());
|
|
|
|
+ if (serviceDept != null) {
|
|
|
|
+ wmScorePackage.setRelatedServiceName(serviceDept.getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 接包对象
|
|
|
|
+ if (StrUtil.isNotBlank(wmScorePackage.getAcceptSug())) {
|
|
|
|
+ // 此处暂认为drugEnt和agent不会出现相同的id
|
|
|
|
+ WmDaAgent daAgent = wmDaAgentMapper.selectById(wmScorePackage.getAcceptSug());
|
|
|
|
+ if (daAgent == null) {
|
|
|
|
+ WmDaDrugEnt daDrugEnt = wmDaDrugEntMapper.selectById(wmScorePackage.getAcceptSug());
|
|
|
|
+ if (daDrugEnt != null) {
|
|
|
|
+ wmScorePackage.setAcceptSug(daDrugEnt.getEntname());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ wmScorePackage.setAcceptSugName(daAgent.getGsmc());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 可分配积分值
|
|
|
|
+ List<WmScorePackage> scorePackagekfpjf =
|
|
|
|
+ wmScorePackageService.getScorePackagekfpjf(
|
|
|
|
+ null,
|
|
|
|
+ null,
|
|
|
|
+ new String[]{"0", "1", "2"},
|
|
|
|
+ new String[]{id});
|
|
|
|
+ if (CollUtil.isNotEmpty(scorePackagekfpjf)) {
|
|
|
|
+ wmScorePackage.setKfpjf(scorePackagekfpjf.get(0).getKfpjf());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 推广药品
|
|
|
|
+ if (ArrayUtil.isNotEmpty(wmScorePackage.getDrugtable())) {
|
|
|
|
+ List<WmDaDrugEntDrugtable> drugtables = wmDaDrugEntDrugtableService.listByIds(Stream.of(wmScorePackage.getDrugtable()).collect(Collectors.toSet()));
|
|
|
|
+ if (CollUtil.isNotEmpty(drugtables)) {
|
|
|
|
+ String[] drugtableNames = drugtables.stream().map(WmDaDrugEntDrugtable::getDrugname).toArray(String[]::new);
|
|
|
|
+ wmScorePackage.setDrugtableName(drugtableNames);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 积分包关联的有效任务类型
|
|
|
|
+ WmScoreTaskType wmScoreTaskType = new WmScoreTaskType();
|
|
|
|
+ wmScoreTaskType.setScoreId("-1".equals(wmScorePackage.getRelationScoreId()) ? wmScorePackage.getId() : wmScorePackage.getRelationScoreId());
|
|
|
|
+ List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.listWmScoreTaskType(wmScoreTaskType);
|
|
|
|
+ Set<String> taskTypeSet = taskTypeList.stream().map(WmScoreTaskType::getTaskTypeId).collect(Collectors.toSet());
|
|
|
|
+ wmScorePackage.setTaskTypeSet(taskTypeSet);
|
|
|
|
+
|
|
|
|
+ // 查询关联的试卷
|
|
|
|
+ List<WmPkgQuizRelation> quizRelations = pkgQuizRelationService.listQuizRelationsByPkgIds(Collections.singletonList(Integer.parseInt(id)));
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(quizRelations)) {
|
|
|
|
+ List<Integer> quizIds = quizRelations.stream().map(WmPkgQuizRelation::getQuizId).collect(Collectors.toList());
|
|
|
|
+ List<Integer> relIds = quizRelations.stream().map(WmPkgQuizRelation::getRelationId).collect(Collectors.toList());
|
|
|
|
+ wmScorePackage.setQuizIds(quizIds);
|
|
|
|
+ wmScorePackage.setQuizRelationIds(relIds);
|
|
|
|
+ wmScorePackage.setQuizNames(quizRelations.stream().map(WmPkgQuizRelation::getTitle).collect(Collectors.toList()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setQuizRelations(quizRelations);
|
|
|
|
+
|
|
|
|
+ return R.ok(wmScorePackage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * BC-企业承接任务
|
|
|
|
+ *
|
|
|
|
+ * @param current 当前页
|
|
|
|
+ * @param size 每页大小
|
|
|
|
+ * @param deptId 部门ID
|
|
|
|
+ * @param scorePackageName 积分包名称
|
|
|
|
+ * @param acceptSug 接包对象
|
|
|
|
+ * @param allocationDate 分配日期
|
|
|
|
+ * @param endLabelDate 结束标签日期
|
|
|
|
+ * @return {@link R}<{@link ?}> 结果
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/selectWmScorePackageListsForBC")
|
|
|
|
+ public R<?> selectWmScorePackageListForBC(@RequestParam(value = "current") Integer current,
|
|
|
|
+ @RequestParam(value = "size") Integer size,
|
|
|
|
+ @RequestParam(value = "deptId") Integer deptId,
|
|
|
|
+ @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
+ @RequestParam(value = "acceptSug", required = false) String acceptSug,
|
|
|
|
+ @RequestParam(value = "allocationDate", required = false) LocalDate allocationDate,
|
|
|
|
+ @RequestParam(value = "endLabelDate", required = false) LocalDate endLabelDate) {
|
|
|
|
+
|
|
|
|
+ Page<WmScorePackage> pageAnswer = wmScorePackageService.selectWmScorePackageLists(new Page<>(current, size), deptId,
|
|
|
|
+ scorePackageName, acceptSug, allocationDate, endLabelDate);
|
|
|
|
+
|
|
|
|
+ //根据积分包id查询计算完成积分值 已付积分值
|
|
|
|
+ List<WmScorePackage> wmList = pageAnswer.getRecords();
|
|
|
|
+
|
|
|
|
+ List<Future<WmScorePackage>> futureList = new ArrayList<>(wmList.size());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for (WmScorePackage wmS : wmList) {
|
|
|
|
+ Future<WmScorePackage> future = wmScorePackageService.finishRate(wmS);
|
|
|
|
+ futureList.add(future);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<WmScorePackage> finalRecords = new ArrayList<>(wmList.size());
|
|
|
|
+ try {
|
|
|
|
+ for (Future<WmScorePackage> future : futureList) {
|
|
|
|
+ WmScorePackage wmScorePackage = future.get();
|
|
|
|
+
|
|
|
|
+ if (wmScorePackage.getP2pAmount() != null) {
|
|
|
|
+ wmScorePackage.setP2pDraft(false);
|
|
|
|
+ } else {
|
|
|
|
+ String s = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:amount:%s", wmScorePackage.getId()));
|
|
|
|
+ String s1 = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:service-amount:%s", wmScorePackage.getId()));
|
|
|
|
+ String desc = redisTemplate.opsForValue().get(String.format("scorepackage:p2p:desc:%s", wmScorePackage.getId()));
|
|
|
|
+ if (StrUtil.isNotBlank(s)) {
|
|
|
|
+ wmScorePackage.setP2pAmount(new BigDecimal(s));
|
|
|
|
+ wmScorePackage.setP2pServiceAmount(new BigDecimal(s1));
|
|
|
|
+ wmScorePackage.setDescription(desc);
|
|
|
|
+ }
|
|
|
|
+ wmScorePackage.setP2pDraft(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ finalRecords.add(wmScorePackage);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ pageAnswer.setRecords(finalRecords);
|
|
|
|
+ } catch (ExecutionException | InterruptedException e) {
|
|
|
|
+ log.error("获取分页信息失败", e);
|
|
|
|
+ return R.failed("获取分页信息失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.ok(pageAnswer);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分页查询积分管理信息 二期 业务平台
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/selectWmScorePackageLists")
|
|
|
|
+ public R<?> selectWmScorePackageList(@RequestParam(value = "current") Integer current,
|
|
|
|
+ @RequestParam(value = "size") Integer size,
|
|
|
|
+ @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
+ @RequestParam(value = "acceptSug", required = false) String acceptSug,
|
|
|
|
+ @RequestParam(value = "allocationDate", required = false) LocalDate allocationDate,
|
|
|
|
+ @RequestParam(value = "endLabelDate", required = false) LocalDate endLabelDate) {
|
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
+
|
|
|
|
+ return this.selectWmScorePackageListForBC(current, size, deptId, scorePackageName, acceptSug, allocationDate, endLabelDate);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取关联积分包名称 二期 业务平台
|
|
|
|
+ *
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/lists")
|
|
|
|
+ public R<?> listWmScorePackages(WmScorePackage wmScorePackage) {
|
|
|
|
+ // 当前企业deptId
|
|
|
|
+ String deptId = wmScorePackage.getDeptId();
|
|
|
|
+ if (StrUtil.isBlank(deptId)) {
|
|
|
|
+ deptId = String.valueOf(SecurityUtils.getUser().getDeptId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setDelFlag("0");
|
|
|
|
+ wmScorePackage.setEnableFlag("0");
|
|
|
|
+ wmScorePackage.setDeptId(deptId);
|
|
|
|
+ List<WmScorePackage> list = wmScorePackageService.list(Wrappers.query(wmScorePackage));
|
|
|
|
+
|
|
|
|
+ SysDept dept = sysDeptService.getById(deptId);
|
|
|
|
+
|
|
|
|
+ List<Map<String, Object>> answerList = new ArrayList<>();
|
|
|
|
+ if (dept.getLevel() == 3) {
|
|
|
|
+ for (WmScorePackage wmScorePackage1 : list) {
|
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
|
+ map1.put("relationScoreId", wmScorePackage1.getId());
|
|
|
|
+ map1.put("scorePackageName", wmScorePackage1.getScorePackageName());
|
|
|
|
+ answerList.add(map1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return R.ok(answerList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据上级药企获取关联积分包 二期 业务平台(企业承接新增积分包的)
|
|
|
|
+ *
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/selectRelationScoreId")
|
|
|
|
+ public R<?> selectRelationScoreId(WmScorePackage wmScorePackage) {
|
|
|
|
+
|
|
|
|
+ SysDept selfId = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
+
|
|
|
|
+ SysDept sysDept = sysDeptService.getById(wmScorePackage.getRelatedService());
|
|
|
|
+
|
|
|
|
+ List<Map<String, Object>> answerList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ //获取关联积分包
|
|
|
|
+ if (sysDept.getLevel() == 2 && selfId.getLevel() != 2) {
|
|
|
|
+ wmScorePackage.setSendPackageDeptId(wmScorePackage.getRelatedService());
|
|
|
|
+ wmScorePackage.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
+ List<WmScorePackage> list = wmScorePackageService.selectByReRelatedService(wmScorePackage);
|
|
|
|
+ if (list.size() > 0) {
|
|
|
|
+ for (WmScorePackage wmScorePackage1 : list) {
|
|
|
|
+ if (wmScorePackage1.getKfpjf() == null || wmScorePackage1.getKfpjf() <= 0) {
|
|
|
|
+ // 过滤掉可分配积分值为0的积分包
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
|
+ map1.put("relationScoreName", wmScorePackage1.getScorePackageName());
|
|
|
|
+ map1.put("drugProducerList", wmScorePackage1.getDrugProducerList());
|
|
|
|
+ map1.put("drugtable", wmScorePackage1.getDrugtable());
|
|
|
|
+ map1.put("id", wmScorePackage1.getId());
|
|
|
|
+ answerList.add(map1);
|
|
|
|
+ }
|
|
|
|
+ } else if (SecurityUtils.getRoles().contains(3)) {
|
|
|
|
+ Map<String, Object> map2 = new HashMap<>();
|
|
|
|
+ map2.put("id", "-1");
|
|
|
|
+ map2.put("relationScoreName", "无");
|
|
|
|
+ answerList.add(map2);
|
|
|
|
+ }
|
|
|
|
+ } else if (sysDept.getLevel() == 3) {
|
|
|
|
+ wmScorePackage.setSendPackageDeptId(wmScorePackage.getRelatedService());
|
|
|
|
+ wmScorePackage.setDeptId(wmScorePackage.getRelatedService());
|
|
|
|
+ List<WmScorePackage> list = wmScorePackageService.selectByReRelatedService(wmScorePackage);
|
|
|
|
+ for (WmScorePackage wmScorePackage1 : list) {
|
|
|
|
+ if (wmScorePackage1.getKfpjf() == null || wmScorePackage1.getKfpjf() <= 0) {
|
|
|
|
+ // 过滤掉可分配积分值为0的积分包
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Map<String, Object> map3 = new HashMap<>();
|
|
|
|
+ map3.put("id", wmScorePackage1.getId());
|
|
|
|
+ map3.put("drugProducerList", wmScorePackage1.getDrugProducerList());
|
|
|
|
+ map3.put("drugtable", wmScorePackage1.getDrugtable());
|
|
|
|
+ map3.put("relationScoreName", wmScorePackage1.getScorePackageName());
|
|
|
|
+ answerList.add(map3);
|
|
|
|
+ }
|
|
|
|
+ Map<String, Object> map4 = new HashMap<>();
|
|
|
|
+ map4.put("id", "-1");
|
|
|
|
+ map4.put("relationScoreName", "无");
|
|
|
|
+ answerList.add(map4);
|
|
|
|
+ } else if (selfId.getLevel() == 2) {
|
|
|
|
+ Map<String, Object> map5 = new HashMap<>();
|
|
|
|
+ map5.put("id", "-1");
|
|
|
|
+ map5.put("relationScoreName", "无");
|
|
|
|
+ answerList.add(map5);
|
|
|
|
+ }
|
|
|
|
+ return R.ok(answerList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取可分配积分 二期 业务平台
|
|
|
|
+ *
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/selectKfpjf")
|
|
|
|
+ public R<?> selectKfpjf(WmScorePackage wmScorePackage) {
|
|
|
|
+
|
|
|
|
+ SysDept wmId = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
+ WmDaAgent anId = wmDaAgentService.selectByDeptId(wmId.getDeptId());
|
|
|
|
+ List<Map<String, Object>> answerList = new ArrayList<>();
|
|
|
|
+ Map<String, Object> map2 = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ //获取接包对象和可分配积分
|
|
|
|
+ List wmDaDrugEnts = new ArrayList();
|
|
|
|
+ if ("-1".equals(wmScorePackage.getId()) && wmId.getLevel() == 3) {
|
|
|
|
+ map2.put("kfpjf", "");
|
|
|
|
+ List<WmDaAgent> list = wmDaAgentService.listAgentByDeptRelation(anId.getDeptId());
|
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
|
+ if (Integer.parseInt(list.get(i).getEnableFlag()) == 0) {
|
|
|
|
+ wmDaDrugEnts.add(list.get(i));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if ("-1".equals(wmScorePackage.getId()) && wmId.getDeptId()
|
|
|
|
+ .equals(SecurityUtils.getUser().getDeptId())) {
|
|
|
|
+ WmDaDrugEnt wmDaDrugEnt = wmDaDrugEntService.selectByDeptId(wmId.getDeptId());
|
|
|
|
+ List<WmDaAgent> list = wmDaAgentService.selectWmDaAgentByDeptId(wmDaDrugEnt.getDeptId().toString());
|
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
|
+ if (Integer.parseInt(list.get(i).getEnableFlag()) == 0) {
|
|
|
|
+ wmDaDrugEnts.add(list.get(i));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ List<WmDaAgent> list = wmDaAgentService.selectWmDaAgentByRelationIds(wmId.getDeptId());
|
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
|
+ if (Integer.parseInt(list.get(i).getEnableFlag()) == 0) {
|
|
|
|
+ wmDaDrugEnts.add(list.get(i));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setDelFlag("0");
|
|
|
|
+ wmScorePackage.setEnableFlag("0");
|
|
|
|
+ List<WmScorePackage> list = wmScorePackageService.list(Wrappers.query(wmScorePackage));
|
|
|
|
+ map2.put("acceptSug", wmDaDrugEnts);
|
|
|
|
+ for (WmScorePackage wmScorePackage1 : list) {
|
|
|
|
+ if (SecurityUtils.getUser().getDeptId().equals(Integer.valueOf(wmScorePackage1.getDeptId()))) {
|
|
|
|
+ WmScoreTaskType wmScoreTaskType = new WmScoreTaskType();
|
|
|
|
+ wmScoreTaskType.setScoreId(wmScorePackage1.getId());
|
|
|
|
+ wmScorePackage1.setWmScoreTaskTypeList(wmScoreTaskTypeService.listWmScoreTaskTypes(wmScoreTaskType));
|
|
|
|
+ map2.put("kfpjf", wmScorePackage1.getKfpjf());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ answerList.add(map2);
|
|
|
|
+ //获取数据
|
|
|
|
+ if (wmId.getLevel() == 3) {
|
|
|
|
+ for (WmScorePackage wmScorePackage1 : list) {
|
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
|
+ List<String> stringList = new ArrayList<>();
|
|
|
|
+ if (SecurityUtils.getUser().getDeptId().equals(Integer.valueOf(wmScorePackage1.getDeptId()))) {
|
|
|
|
+ WmScoreTaskType wmScoreTaskType = new WmScoreTaskType();
|
|
|
|
+ wmScoreTaskType.setScoreId(wmScorePackage1.getId());
|
|
|
|
+ List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.listWmScoreTaskType(wmScoreTaskType);
|
|
|
|
+ Set<String> taskTypeSet = taskTypeList.stream()
|
|
|
|
+ .map(WmScoreTaskType::getTaskTypeId)
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
+ wmScorePackage.setTaskTypeSet(taskTypeSet);
|
|
|
|
+ map1.put("scoreId", wmScorePackage1.getScoreId());
|
|
|
|
+ map1.put("id", wmScorePackage1.getId());
|
|
|
|
+ map1.put("kfpjf", wmScorePackage1.getKfpjf());
|
|
|
|
+ map1.put("belongDate", wmScorePackage1.getBelongDate());
|
|
|
|
+ map1.put("packsgeType1", wmScorePackage1.getPackageType1());
|
|
|
|
+ map1.put("wmScoreTaskTypeList", wmScorePackage.getTaskTypeSet());
|
|
|
|
+ map1.put("wmScoreTaskTypeList1", wmScorePackage1.getWmScoreTaskTypeList());
|
|
|
|
+ stringList.add(wmScorePackage1.getScoreId());
|
|
|
|
+ answerList.add(map1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return R.ok(answerList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增积分包(大包)
|
|
|
|
+ * <p>
|
|
|
|
+ * 满足以下任一条件,则可以发包
|
|
|
|
+ * 1.存在积分充值配置,并且 发包积分 < 积分充值分配的积分
|
|
|
|
+ * 2.关联了上级积分包
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 积分包信息
|
|
|
|
+ * @return 新增结果
|
|
|
|
+ */
|
|
|
|
+ @SysLog("新增积分包(大包)")
|
|
|
|
+ @PostMapping("/saves")
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public R<?> saves(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
+
|
|
|
|
+ log.info("新增积分包(大包)入参:{}", wmScorePackage);
|
|
|
|
+
|
|
|
|
+ HnqzUser operator = SecurityUtils.getUser();
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
+ List<Integer> roles = SecurityUtils.getRoles();
|
|
|
|
+ Integer deptId = operator.getDeptId();
|
|
|
|
+ Integer userId = operator.getId();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String relPkgId = wmScorePackage.getRelationScoreId();
|
|
|
|
+ boolean relatedScoreId = StrUtil.isNotBlank(relPkgId) && Integer.parseInt(relPkgId) > 0;
|
|
|
|
+ SysDeptRecharge deptRecharge = null;
|
|
|
|
+
|
|
|
|
+ // 校验积分值
|
|
|
|
+ if (wmScorePackage.getScore() <= 0) {
|
|
|
|
+ return R.failed("积分包分值必须大于0");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 校验积分包名称是否存在
|
|
|
|
+ if (StrUtil.isNotBlank(wmScorePackage.getScorePackageName())) {
|
|
|
|
+
|
|
|
|
+ int existed = wmScorePackageService.count(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
+ .eq(WmScorePackage::getDelFlag, "0")
|
|
|
|
+ .eq(WmScorePackage::getScorePackageName, wmScorePackage.getScorePackageName())
|
|
|
|
+ .eq(WmScorePackage::getDeptId, wmScorePackage.getDeptId()));
|
|
|
|
+
|
|
|
|
+ if (existed != 0) {
|
|
|
|
+ return R.failed("积分包名称已存在");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 校验积分值
|
|
|
|
+ if (!relatedScoreId) {
|
|
|
|
+ // 校验 发包积分 < 积分充值分配的积分 则可以发包
|
|
|
|
+ deptRecharge = sysDeptRechargeMapper.selectOne(Wrappers.<SysDeptRecharge>lambdaQuery().eq(SysDeptRecharge::getDeptId, deptId));
|
|
|
|
+ if (deptRecharge == null) {
|
|
|
|
+ log.error("未配置积分充值信息");
|
|
|
|
+ throw new BizException("积分余额:0,积分不足");
|
|
|
|
+ }
|
|
|
|
+ int limitScore = deptRecharge.getScore() + deptRecharge.getOverdrawScore();
|
|
|
|
+ if (wmScorePackage.getScore() > limitScore) {
|
|
|
|
+ log.error("已分配积分不足,发包积分={},剩余积分={},透支额度={}", wmScorePackage.getScore(), deptRecharge.getScore(), limitScore);
|
|
|
|
+ throw new BizException(String.format("积分余额:%s,积分不足", deptRecharge.getScore()));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 校验上级可分配积分值
|
|
|
|
+ List<WmScorePackage> scorePackagekfpjf =
|
|
|
|
+ wmScorePackageService.getScorePackagekfpjf(
|
|
|
|
+ null,
|
|
|
|
+ null,
|
|
|
|
+ new String[]{"0", "1", "2"},
|
|
|
|
+ new String[]{wmScorePackage.getRelationScoreId()});
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(scorePackagekfpjf)) {
|
|
|
|
+ int kfpjf = scorePackagekfpjf.get(0).getKfpjf();
|
|
|
|
+ if (wmScorePackage.getScore() > kfpjf) {
|
|
|
|
+ log.error("可分配积分值不足");
|
|
|
|
+ throw new BizException("可分配积分值不足");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setPackageType1("1");
|
|
|
|
+ wmScorePackage.setDelFlag("0");
|
|
|
|
+ wmScorePackage.setEnableFlag("0");
|
|
|
|
+ wmScorePackage.setPackageIsConduct("0");
|
|
|
|
+ wmScorePackage.setDrugEntId(null);
|
|
|
|
+ wmScorePackage.setCreateUser(userId);
|
|
|
|
+ wmScorePackage.setCreateTime(now);
|
|
|
|
+ wmScorePackage.setUpdateTime(now);
|
|
|
|
+ wmScorePackage.setPackageFinishStatus("0");
|
|
|
|
+ wmScorePackage.setPackageAuditStatus("0");
|
|
|
|
+ wmScorePackage.setSendPackageDeptId(deptId.toString());
|
|
|
|
+ wmScorePackage.setAllocationDate(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN).format(now));
|
|
|
|
+ if (wmScorePackage.getEndTime() == null) {
|
|
|
|
+ // 默认截止日期为一年后
|
|
|
|
+ wmScorePackage.setEndTime(now.plusYears(1).toLocalDate());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 关联上级推广药品企业(兼容历史)
|
|
|
|
+ if (StringUtils.isEmpty(relPkgId)) {
|
|
|
|
+ wmScorePackage.setDrugProducerList(null);
|
|
|
|
+ } else if (StringUtils.isNotEmpty(relPkgId) && ArrayUtils.isEmpty(wmScorePackage.getDrugtable())) {
|
|
|
|
+ // 关联上级推广药品
|
|
|
|
+ WmScorePackage relateSp = wmScorePackageService.getById(relPkgId);
|
|
|
|
+ if (relateSp != null) {
|
|
|
|
+ wmScorePackage.setDrugtable(relateSp.getDrugtable());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SysDept sysDeptRelatedService = sysDeptService.getById(Integer.valueOf(wmScorePackage.getRelatedService()));
|
|
|
|
+ if (StrUtil.isBlank(wmScorePackage.getTypeid())) {
|
|
|
|
+ WmDaDrugEnt wmDaDrugEnt = wmDaDrugEntService.selectByDeptId(deptId);
|
|
|
|
+ if (wmDaDrugEnt != null) {
|
|
|
|
+ if (null != wmScorePackage.getAcceptSug() && !wmScorePackage.getAcceptSug().equals(wmDaDrugEnt.getId())) {
|
|
|
|
+ WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getAcceptSug());
|
|
|
|
+ SysDept sysDepts = sysDeptService.getById(Integer.valueOf(wmDaAgent.getDeptId()));
|
|
|
|
+ if (sysDepts.getLevel() == 3) {
|
|
|
|
+ wmScorePackage.setLevel1Id(wmDaAgent.getId());
|
|
|
|
+ } else if (sysDepts.getLevel() == 4) {
|
|
|
|
+ wmScorePackage.setLevel2Id(wmDaAgent.getId());
|
|
|
|
+ }
|
|
|
|
+ wmScorePackage.setDeptId(wmDaAgent.getDeptId().toString());
|
|
|
|
+ wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
+ } else if (wmDaDrugEnt.getId().equals(wmScorePackage.getAcceptSug())) {
|
|
|
|
+ wmScorePackage.setDeptId(deptId.toString());
|
|
|
|
+ wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (sysDeptRelatedService.getLevel() == 2) {
|
|
|
|
+ WmDaDrugEnt wmDaDrugEnts = wmDaDrugEntService.selectByDeptId(Integer.valueOf(wmScorePackage.getRelatedService()));
|
|
|
|
+ if (null != wmScorePackage.getAcceptSug() && !wmScorePackage.getAcceptSug().equals(wmDaDrugEnts.getId())) {
|
|
|
|
+ WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getAcceptSug());
|
|
|
|
+ SysDept sysDepts = sysDeptService.getById(Integer.valueOf(wmDaAgent.getDeptId()));
|
|
|
|
+
|
|
|
|
+ if (sysDepts.getLevel() == 3) {
|
|
|
|
+ wmScorePackage.setLevel1Id(wmDaAgent.getId());
|
|
|
|
+ } else if (sysDepts.getLevel() == 4) {
|
|
|
|
+ wmScorePackage.setLevel2Id(wmDaAgent.getId());
|
|
|
|
+ }
|
|
|
|
+ wmScorePackage.setDeptId(wmDaAgent.getDeptId().toString());
|
|
|
|
+ wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
+ } else if (wmScorePackage.getAcceptSug().equals(wmDaDrugEnt.getId())) {
|
|
|
|
+ wmScorePackage.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
+ wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
+ }
|
|
|
|
+ } else if (sysDeptRelatedService.getLevel() == 3) {
|
|
|
|
+ WmDaAgent wmDaAgent1 = wmDaAgentService.selectByDeptId(Integer.valueOf(wmScorePackage.getRelatedService()));
|
|
|
|
+ if (null != wmScorePackage.getAcceptSug() && !wmScorePackage.getAcceptSug().equals(wmDaAgent1.getId())) {
|
|
|
|
+ WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getAcceptSug());
|
|
|
|
+ SysDept sysDepts = sysDeptService.getById(Integer.valueOf(wmDaAgent.getDeptId()));
|
|
|
|
+ if (sysDepts.getLevel() == 3) {
|
|
|
|
+ wmScorePackage.setLevel1Id(wmDaAgent.getId());
|
|
|
|
+ } else if (sysDepts.getLevel() == 4) {
|
|
|
|
+ wmScorePackage.setLevel2Id(wmDaAgent.getId());
|
|
|
|
+ }
|
|
|
|
+ wmScorePackage.setDeptId(wmDaAgent.getDeptId().toString());
|
|
|
|
+ wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
+ } else if (wmDaAgent1.getId().equals(wmScorePackage.getAcceptSug())) {
|
|
|
|
+ wmScorePackage.setDeptId(deptId.toString());
|
|
|
|
+ wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //药企规则ID
|
|
|
|
+ SysDept sysDeptRuleId = sysDeptService.getById(deptId);
|
|
|
|
+ Integer deptLevel = sysDeptRuleId.getLevel();
|
|
|
|
+
|
|
|
|
+ if (deptLevel == 2) {
|
|
|
|
+ WmDaDrugEnt wmDaDrugEnt = wmDaDrugEntService.selectByDeptId(sysDeptRuleId.getDeptId());
|
|
|
|
+ if (wmScorePackage.getAcceptSug().equals(wmDaDrugEnt.getId())) {
|
|
|
|
+ wmScorePackage.setRuleId(wmScorePackage.getAcceptSug());
|
|
|
|
+ wmScorePackage.setDrugEntId(wmDaDrugEnt.getId());
|
|
|
|
+ } else if (!wmScorePackage.getAcceptSug().equals(wmDaDrugEnt.getId())) {
|
|
|
|
+ WmTaskType wmTaskType = new WmTaskType();
|
|
|
|
+ wmTaskType.setRuleId(wmDaDrugEnt.getId() + wmScorePackage.getAcceptSug());
|
|
|
|
+ List<WmTaskType> wmTaskTypeList = wmTaskTypeService.selectByRuleId(wmTaskType);
|
|
|
|
+ if (CollUtil.isNotEmpty(wmTaskTypeList)) {
|
|
|
|
+ wmScorePackage.setRuleId(wmDaDrugEnt.getId() + wmScorePackage.getAcceptSug());
|
|
|
|
+ wmScorePackage.setDrugEntId(wmDaDrugEnt.getId());
|
|
|
|
+ } else {
|
|
|
|
+ log.error("请药企给下级cso分配积分规则");
|
|
|
|
+ return R.failed("请药企给下级cso分配积分规则");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ } else if (deptLevel == 3) {
|
|
|
|
+ //一级cso规则ID
|
|
|
|
+ WmDaAgent daAgent = wmDaAgentService.getOne(Wrappers.<WmDaAgent>lambdaQuery()
|
|
|
|
+ .eq(WmDaAgent::getEnableFlag, EnableEnum.ENABLE.val())
|
|
|
|
+ .eq(WmDaAgent::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
|
+ .eq(WmDaAgent::getDeptId, String.valueOf(sysDeptRuleId.getDeptId())));
|
|
|
|
+ if (StringUtils.isNotBlank(wmScorePackage.getRelationScoreId())) {
|
|
|
|
+ // 关联了积分包的情况
|
|
|
|
+ WmScorePackage relationScorePackage = wmScorePackageService.getById(wmScorePackage.getRelationScoreId());
|
|
|
|
+ if (relationScorePackage != null) {
|
|
|
|
+ wmScorePackage.setRuleId(relationScorePackage.getRuleId());
|
|
|
|
+ wmScorePackage.setDrugEntId(relationScorePackage.getDrugEntId());
|
|
|
|
+ } else {
|
|
|
|
+ log.error("cso没有分配积分规则");
|
|
|
|
+ return R.failed("cso没有分配积分规则");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 没有关联积分包的情况
|
|
|
|
+ List<WmTaskType> taskTypeList = wmTaskTypeService.list(Wrappers.<WmTaskType>lambdaQuery()
|
|
|
|
+ .eq(WmTaskType::getRuleId, daAgent.getId()));
|
|
|
|
+ if (CollectionUtil.isNotEmpty(taskTypeList)) {
|
|
|
|
+ wmScorePackage.setRuleId(daAgent.getId().toString());
|
|
|
|
+ wmScorePackage.setDrugEntId(null);
|
|
|
|
+ } else {
|
|
|
|
+ log.error("cso没有分配积分规则");
|
|
|
|
+ return R.failed("cso没有分配积分规则");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 保存积分包
|
|
|
|
+ String typeId = "";
|
|
|
|
+ if (roles.contains(4) || roles.contains(3)) {
|
|
|
|
+ if (deptLevel == 2) {
|
|
|
|
+ typeId = wmScorePackage.getDeptId().equals(deptId.toString()) ? "0" : "1";
|
|
|
|
+ } else if (deptLevel == 3) {
|
|
|
|
+ typeId = wmScorePackage.getDeptId().equals(deptId.toString()) ? "1" : "2";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ wmScorePackage.setTypeid(typeId);
|
|
|
|
+ boolean isAnswer = wmScorePackageService.save(wmScorePackage);
|
|
|
|
+
|
|
|
|
+ // 发包成功 更新 上级包
|
|
|
|
+ if (isAnswer) {
|
|
|
|
+ if ((roles.contains(4) || roles.contains(3)) && deptLevel == 3) {
|
|
|
|
+ WmScorePackage relPkg = wmScorePackageService.getById(relPkgId);
|
|
|
|
+ // 是当前操作人所在企业的的关联包
|
|
|
|
+ if (relPkg != null && deptId.toString().equals(relPkg.getDeptId())) {
|
|
|
|
+ relPkg.setKfpjf((int) Math.ceil(relPkg.getKfpjf() - wmScorePackage.getScore()));
|
|
|
|
+ // 判断积分包是否被发放 (原有外包业务逻辑,不知道为什么)
|
|
|
|
+ int count = wmScorePackageService.count(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
+ .ne(WmScorePackage::getId, wmScorePackage.getId())
|
|
|
|
+ .eq(WmScorePackage::getId, relPkgId)
|
|
|
|
+ .eq(WmScorePackage::getEnableFlag, "0")
|
|
|
|
+ .notIn(WmScorePackage::getTypeid, 3, 4));
|
|
|
|
+
|
|
|
|
+ relPkg.setPackageIsConduct(count == 0 ? "0" : "1");
|
|
|
|
+ wmScorePackageService.updateById(relPkg);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 失败了
|
|
|
|
+ else {
|
|
|
|
+ return R.failed("下发积分包失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<WmScoreTaskType> taskTypeList = wmScorePackage.getWmScoreTaskTypeList();
|
|
|
|
+ if (CollUtil.isNotEmpty(taskTypeList)) {
|
|
|
|
+
|
|
|
|
+ if (StrUtil.isBlank(relPkgId) || (StrUtil.isNotBlank(relPkgId) && deptLevel == 3)) {
|
|
|
|
+ List<WmScoreTaskType> scoreTaskTypes = taskTypeList.stream().map(taskType -> {
|
|
|
|
+ WmScoreTaskType wmScoreTaskType = new WmScoreTaskType();
|
|
|
|
+ wmScoreTaskType.setScoreId(wmScorePackage.getId());
|
|
|
|
+ wmScoreTaskType.setType("1");
|
|
|
|
+ wmScoreTaskType.setTaskTypeId(taskType.getTaskTypeId());
|
|
|
|
+
|
|
|
|
+ return wmScoreTaskType;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ wmScoreTaskTypeService.deleteByScoreId(wmScorePackage.getId());
|
|
|
|
+ wmScoreTaskTypeService.batchInsertType(scoreTaskTypes);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (!relatedScoreId) {
|
|
|
|
+ // 更新积分充值信息
|
|
|
|
+ int currentScore = deptRecharge.getScore() - wmScorePackage.getScore();
|
|
|
|
+ int updateRecharge = sysDeptRechargeMapper.update(null, Wrappers.<SysDeptRecharge>lambdaUpdate()
|
|
|
|
+ .eq(SysDeptRecharge::getId, deptRecharge.getId())
|
|
|
|
+ .eq(SysDeptRecharge::getVersion, deptRecharge.getVersion())
|
|
|
|
+ .set(SysDeptRecharge::getScore, currentScore)
|
|
|
|
+ .set(SysDeptRecharge::getVersion, deptRecharge.getVersion() + 1)
|
|
|
|
+ .set(SysDeptRecharge::getUpdateTime, now)
|
|
|
|
+ .set(SysDeptRecharge::getUpdateUser, userId));
|
|
|
|
+ if (updateRecharge <= 0) {
|
|
|
|
+ log.warn("更新积分充值信息失败");
|
|
|
|
+ throw new RuntimeException("操作失败,请重试");
|
|
|
|
+ }
|
|
|
|
+ // 更新积分充值记录
|
|
|
|
+ SysDeptRechargeRecord rechargeRecord = new SysDeptRechargeRecord();
|
|
|
|
+ rechargeRecord.setDeptId(deptId);
|
|
|
|
+ rechargeRecord.setChangeScore(-wmScorePackage.getScore());
|
|
|
|
+ rechargeRecord.setRechargeId(deptRecharge.getId());
|
|
|
|
+ rechargeRecord.setPackageId(wmScorePackage.getId());
|
|
|
|
+ rechargeRecord.setPackageType(RechargeRecordPackageType.TO_ENTERPRISE);
|
|
|
|
+ rechargeRecord.setType(RechargeRecordType.SEND_PACKAGE_DEPT);
|
|
|
|
+ rechargeRecord.setCurrentScore(currentScore);
|
|
|
|
+ rechargeRecord.setCreateUser(userId);
|
|
|
|
+ rechargeRecord.setCreateTime(now);
|
|
|
|
+ sysDeptRechargeRecordMapper.insert(rechargeRecord);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 保存关联的试卷
|
|
|
|
+ if (CollUtil.isNotEmpty(wmScorePackage.getQuizIds())) {
|
|
|
|
+ pkgQuizRelationService.createPkgQuizzes(wmScorePackage.getQuizIds(), Integer.parseInt(wmScorePackage.getId()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 判断是否有关联关系
|
|
|
|
+ if (CollUtil.isNotEmpty(wmScorePackage.getQuizRelationIds())) {
|
|
|
|
+ pkgQuizRelationService.copyQuizRelations(wmScorePackage.getQuizRelationIds(), Integer.parseInt(wmScorePackage.getId()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 终止积分包(大包)
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 积分包信息
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @SysLog("终止积分包(大包)")
|
|
|
|
+ @PostMapping("/stopWmScorePackage")
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+
|
|
|
|
+ public R<?> stopWmScorePackage(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
+ log.info("终止积分包(大包)入参:{}", wmScorePackage);
|
|
|
|
+ if (StrUtil.isBlank(wmScorePackage.getId()) || !StrUtil.equalsAny(wmScorePackage.getEnableType(), "1", "2")) {
|
|
|
|
+ return R.failed("参数错误");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String cacheKey = CacheConstants.TERMINATE_PACKAGE_KEY + wmScorePackage.getId();
|
|
|
|
+ Boolean absent = redisTemplate.opsForValue().setIfAbsent(cacheKey, JSONUtil.toJsonStr(wmScorePackage), 3L, TimeUnit.SECONDS);
|
|
|
|
+ if (Boolean.FALSE.equals(absent)) {
|
|
|
|
+ return R.failed("正在处理");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.ok(wmScorePackageService.terminatePackageForDept(wmScorePackage.getId(),
|
|
|
|
+ UpmsType.TerminatePackageType.getByEnableType(wmScorePackage.getEnableType())));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 终止积分包 new 终止 二期 业务平台
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @SysLog("终止积分包")
|
|
|
|
+ @PostMapping("/updateStatusByIds")
|
|
|
|
+ public R<?> updateStatusByIds(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
+ if (wmScorePackage.getScore() <= 0) {
|
|
|
|
+ return R.failed("积分包分值必须大于0");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setUpdateUser(SecurityUtils.getUser().getId());
|
|
|
|
+ wmScorePackage.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ if (null != wmScorePackage.getRelationScoreId() && !"".equals(wmScorePackage.getRelationScoreId())) {
|
|
|
|
+ WmScorePackage wmScorePackage1 = new WmScorePackage();
|
|
|
|
+ wmScorePackage1.setDelFlag("0");
|
|
|
|
+ wmScorePackage1.setRelationScoreId(wmScorePackage.getRelationScoreId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null != wmScorePackage.getScorePackageName() && !"".equals(wmScorePackage.getScorePackageName())) {
|
|
|
|
+ WmScorePackage wmScorePackage1 = new WmScorePackage();
|
|
|
|
+ wmScorePackage1.setEnableFlag("0");
|
|
|
|
+ List<WmScorePackage> wmScorePackageList = wmScorePackageService.list(Wrappers.query(wmScorePackage1));
|
|
|
|
+ WmScorePackage wmId = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
+ if (wmScorePackageList.size() > 0) {
|
|
|
|
+ for (WmScorePackage wms : wmScorePackageList) {
|
|
|
|
+ if (wmId.getId().equals(wms.getRelationScoreId())) {
|
|
|
|
+ return R.failed("积分包已被分派,请联系下属CSO终止关联积分包");
|
|
|
|
+ } else if (null != wms.getRelationScoreId() && "".equals(wms.getRelationScoreId())) {
|
|
|
|
+ wmScorePackage.setEnableFlag("1");
|
|
|
|
+ wmScorePackage.setPackageFinishStatus("2");
|
|
|
|
+ List<WmScorePackage> wmScorePackages = wmScorePackageService.selectRelationScoreId(wmId.getId());
|
|
|
|
+ if (wmScorePackages.size() > 0) {
|
|
|
|
+ for (WmScorePackage wmScorePackage3 : wmScorePackages) {
|
|
|
|
+ if (wmId.getRelationScoreId().equals(wmScorePackage3.getRelationScoreId())) {
|
|
|
|
+ wms.setPackageIsConduct("1");
|
|
|
|
+ break;
|
|
|
|
+ } else {
|
|
|
|
+ wms.setPackageIsConduct("0");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ wmScorePackage.setPackageIsConduct("0");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (SecurityUtils.getRoles().contains(4) || SecurityUtils.getRoles().contains(3)) {
|
|
|
|
+ WmScorePackage queryWm = new WmScorePackage();
|
|
|
|
+
|
|
|
|
+ SysDept sysDept = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
+
|
|
|
|
+ if (sysDept.getLevel() == 3) {
|
|
|
|
+ queryWm.setEnableFlag("0");
|
|
|
|
+ } else {
|
|
|
|
+ queryWm.setId("-1");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<WmScorePackage> wmScorePackageList = wmScorePackageService.list(Wrappers.query(queryWm));
|
|
|
|
+ WmScorePackage wmId = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
+ if (wmScorePackageList.size() > 0) {
|
|
|
|
+ for (WmScorePackage wmScorePackage2 : wmScorePackageList) {
|
|
|
|
+ if (wmId.getId().equals(wmScorePackage2.getRelationScoreId())) {
|
|
|
|
+ return R.failed("积分包已被分派,请联系下属CSO终止关联积分包");
|
|
|
|
+ } else if (wmScorePackage2.getId().equals(wmId.getRelationScoreId())) {
|
|
|
|
+ List<WmScorePackage> wmScorePackages = wmScorePackageService.selectRelationScoreId(wmId.getId());
|
|
|
|
+ if (wmScorePackages.size() > 0) {
|
|
|
|
+ for (WmScorePackage wmScorePackage1 : wmScorePackages) {
|
|
|
|
+ if (wmId.getRelationScoreId().equals(wmScorePackage1.getRelationScoreId())) {
|
|
|
|
+ wmScorePackage2.setPackageIsConduct("1");
|
|
|
|
+ break;
|
|
|
|
+ } else {
|
|
|
|
+ wmScorePackage2.setPackageIsConduct("0");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ wmScorePackage.setEnableFlag("1");
|
|
|
|
+ wmScorePackage.setPackageFinishStatus("2");
|
|
|
|
+ wmScorePackage2.setKfpjf(new Double(Math.ceil(wmScorePackage2.getKfpjf() + wmId.getScore())).intValue());
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setPackageIsConduct("0");
|
|
|
|
+
|
|
|
|
+ } else if (null == wmScorePackage.getRelationScoreId() || "".equals(wmScorePackage.getRelationScoreId())) {
|
|
|
|
+ wmScorePackage.setEnableFlag("1");
|
|
|
|
+ wmScorePackage.setPackageFinishStatus("2");
|
|
|
|
+ List<WmScorePackage> wmScorePackages = wmScorePackageService.selectRelationScoreId(wmId.getId());
|
|
|
|
+ if (wmScorePackages.size() > 0) {
|
|
|
|
+ for (WmScorePackage wmScorePackage1 : wmScorePackages) {
|
|
|
|
+ if (wmId.getRelationScoreId().equals(wmScorePackage1.getRelationScoreId())) {
|
|
|
|
+ wmScorePackage2.setPackageIsConduct("1");
|
|
|
|
+ break;
|
|
|
|
+ } else {
|
|
|
|
+ wmScorePackage2.setPackageIsConduct("0");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ wmScorePackage.setPackageIsConduct("0");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wmScorePackageService.updateBatchById(wmScorePackageList);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.ok(wmScorePackageService.updateById(wmScorePackage));
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改积分包(二期)
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return 更新结果
|
|
|
|
+ */
|
|
|
|
+ @SysLog("修改积分包(大包)")
|
|
|
|
+ @PostMapping("/updateByIds")
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public R<?> updateByIds(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
+
|
|
|
|
+ log.info("修改积分包(大包)入参:{}", wmScorePackage);
|
|
|
|
+
|
|
|
|
+ if (wmScorePackage.getScore() <= 0) {
|
|
|
|
+ return R.failed("积分包分值必须大于0");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 校验修改后的积分包值 不能小于 已下发的下级包积分包值
|
|
|
|
+ List<WmScorePackage> subPackages = wmScorePackageService.list(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
+ .eq(WmScorePackage::getRelationScoreId, wmScorePackage.getId())
|
|
|
|
+ .ne(WmScorePackage::getScorePackageStatus, ScorePackageStatusEnum.TERMINATED.val()));
|
|
|
|
+ if (CollUtil.isNotEmpty(subPackages)) {
|
|
|
|
+ int subPackgesScore = subPackages.stream().mapToInt(WmScorePackage::getScore).sum();
|
|
|
|
+ if (wmScorePackage.getScore() < subPackgesScore) {
|
|
|
|
+ return R.failed(String.format("该积分包已分配%s积分,修改后积分包值需大于该值", subPackgesScore));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wmScorePackage.setPackageType1("1");
|
|
|
|
+ wmScorePackage.setUpdateUser(SecurityUtils.getUser().getId());
|
|
|
|
+ wmScorePackage.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ WmScorePackage oldData = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
+ if (StringUtils.isNotEmpty(wmScorePackage.getScorePackageName())
|
|
|
|
+ && !oldData.getScorePackageName().equals(wmScorePackage.getScorePackageName())) {
|
|
|
|
+ WmScorePackage wmScorePackage1 = new WmScorePackage();
|
|
|
|
+ wmScorePackage1.setDelFlag("0");
|
|
|
|
+ wmScorePackage1.setScorePackageName(wmScorePackage.getScorePackageName());
|
|
|
|
+ wmScorePackage1.setDeptId(wmScorePackage.getDeptId());
|
|
|
|
+ List<WmScorePackage> wmScorePackageList = wmScorePackageService.listWmScorePackages(wmScorePackage1);
|
|
|
|
+ if (wmScorePackageList.size() > 0) {
|
|
|
|
+ return R.failed("积分包名称已存在");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SysDept sysDeptDrugEntId = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
+
|
|
|
|
+ WmDaDrugEnt wmDaDrugEnt = wmDaDrugEntService.selectByDeptId(sysDeptDrugEntId.getDeptId());
|
|
|
|
+
|
|
|
|
+ if (null != wmDaDrugEnt) {
|
|
|
|
+ if (null != wmScorePackage.getAcceptSug() && !wmScorePackage.getAcceptSug().equals(wmDaDrugEnt.getId())) {
|
|
|
|
+ WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getAcceptSug());
|
|
|
|
+
|
|
|
|
+ SysDept sysDepts = sysDeptService.getById(Integer.valueOf(wmDaAgent.getDeptId()));
|
|
|
|
+
|
|
|
|
+ if (sysDepts.getLevel() == 3) {
|
|
|
|
+ wmScorePackage.setLevel2Id(null);
|
|
|
|
+ wmScorePackage.setLevel1Id(Integer.parseInt(wmScorePackage.getAcceptSug()));
|
|
|
|
+ } else if (sysDepts.getLevel() == 4) {
|
|
|
|
+ wmScorePackage.setLevel1Id(null);
|
|
|
|
+ wmScorePackage.setLevel2Id(Integer.parseInt(wmScorePackage.getAcceptSug()));
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ wmScorePackage.setLevel1Id(null);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getAcceptSug());
|
|
|
|
+
|
|
|
|
+ if (null != wmScorePackage.getAcceptSug() && !wmScorePackage.getAcceptSug().equals(wmDaAgent.getId())) {
|
|
|
|
+
|
|
|
|
+ SysDept sysDepts = sysDeptService.getById(Integer.valueOf(wmDaAgent.getDeptId()));
|
|
|
|
+ if (sysDepts.getLevel() == 3) {
|
|
|
|
+ wmScorePackage.setLevel2Id(null);
|
|
|
|
+ wmScorePackage.setLevel1Id(Integer.parseInt(wmScorePackage.getAcceptSug()));
|
|
|
|
+ } else if (sysDepts.getLevel() == 4) {
|
|
|
|
+ wmScorePackage.setLevel1Id(null);
|
|
|
|
+ wmScorePackage.setLevel2Id(Integer.parseInt(wmScorePackage.getAcceptSug()));
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ wmScorePackage.setLevel1Id(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if (SecurityUtils.getRoles().contains(3) || SecurityUtils.getRoles().contains(4)) {
|
|
|
|
+
|
|
|
|
+ //药企规则ID
|
|
|
|
+ SysDept sysDeptRuleId = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
+
|
|
|
|
+ if (sysDeptRuleId.getLevel() == 2) {
|
|
|
|
+ WmDaDrugEnt wmDaDrugEntRuleId = wmDaDrugEntService.selectByDeptId(sysDeptRuleId.getDeptId());
|
|
|
|
+ if (wmScorePackage.getAcceptSug().equals(wmDaDrugEntRuleId.getId())) {
|
|
|
|
+ wmScorePackage.setRuleId(wmScorePackage.getAcceptSug());
|
|
|
|
+ wmScorePackage.setDrugEntId(wmDaDrugEntRuleId.getId());
|
|
|
|
+ } else if (!wmScorePackage.getAcceptSug().equals(wmDaDrugEntRuleId.getId())) {
|
|
|
|
+ wmScorePackage.setRuleId(wmDaDrugEntRuleId.getId() + wmScorePackage.getAcceptSug());
|
|
|
|
+ wmScorePackage.setDrugEntId(wmDaDrugEntRuleId.getId());
|
|
|
|
+ }
|
|
|
|
+ } else if (sysDeptRuleId.getLevel() == 3) {
|
|
|
|
+ //一级cso规则ID
|
|
|
|
+ WmDaAgent daAgent = wmDaAgentService.getOne(Wrappers.<WmDaAgent>lambdaQuery()
|
|
|
|
+ .eq(WmDaAgent::getEnableFlag, EnableEnum.ENABLE.val())
|
|
|
|
+ .eq(WmDaAgent::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
|
+ .eq(WmDaAgent::getDeptId, String.valueOf(sysDeptRuleId.getDeptId())));
|
|
|
|
+ if (StringUtils.isNotBlank(wmScorePackage.getRelationScoreId())) {
|
|
|
|
+ // 关联了积分包的情况
|
|
|
|
+ WmScorePackage relationScorePackage = wmScorePackageService.getById(wmScorePackage.getRelationScoreId());
|
|
|
|
+ if (relationScorePackage != null) {
|
|
|
|
+ wmScorePackage.setRuleId(relationScorePackage.getRuleId());
|
|
|
|
+ wmScorePackage.setDrugEntId(relationScorePackage.getDrugEntId());
|
|
|
|
+ } else {
|
|
|
|
+ return R.failed("cso没有分配积分规则");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 没有关联积分包的情况
|
|
|
|
+ List<WmTaskType> taskTypeList = wmTaskTypeService.list(Wrappers.<WmTaskType>lambdaQuery()
|
|
|
|
+ .eq(WmTaskType::getRuleId, daAgent.getId()));
|
|
|
|
+ if (CollectionUtil.isNotEmpty(taskTypeList)) {
|
|
|
|
+ wmScorePackage.setRuleId(wmScorePackage.getAcceptSug());
|
|
|
|
+ wmScorePackage.setDrugEntId(null);
|
|
|
|
+ } else {
|
|
|
|
+ return R.failed("cso没有分配积分规则");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ WmScorePackage queryWm = new WmScorePackage();
|
|
|
|
+ SysDept sysDept = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
+
|
|
|
|
+ if (sysDept.getLevel() == 3) {//判断是cso
|
|
|
|
+ queryWm.setEnableFlag("0");
|
|
|
|
+ } else if (sysDept.getLevel() == 2) {//判断是药企
|
|
|
|
+ WmScorePackage wmId = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
+ queryWm.setScorePackageName(wmId.getScorePackageName());//获取当前包的scoreId
|
|
|
|
+ } else {
|
|
|
|
+ queryWm.setId("-1");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ WmScorePackage wmIds = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
+ if (wmDaDrugEnt != null) {
|
|
|
|
+ if (null != wmScorePackage.getAcceptSug() && !wmScorePackage.getAcceptSug()
|
|
|
|
+ .equals(wmDaDrugEnt.getId())) {
|
|
|
|
+ WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getAcceptSug());
|
|
|
|
+ wmScorePackage.setDeptId(wmDaAgent.getDeptId() + "");
|
|
|
|
+ wmScorePackage.setKfpjf(wmScorePackage.getScore() - wmIds.getScore() + wmIds.getKfpjf());
|
|
|
|
+ } else if (wmScorePackage.getAcceptSug().equals(wmDaDrugEnt.getId())) {
|
|
|
|
+ wmScorePackage.setDeptId(String.valueOf(SecurityUtils.getUser().getDeptId()));
|
|
|
|
+ wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ WmDaAgent wmDaAgent = wmDaAgentService.getById(wmScorePackage.getAcceptSug());
|
|
|
|
+ if (null != wmScorePackage.getAcceptSug() && !wmScorePackage.getAcceptSug().equals(wmDaAgent.getId())) {
|
|
|
|
+ wmScorePackage.setDeptId(wmDaAgent.getDeptId() + "");
|
|
|
|
+ wmScorePackage.setKfpjf(wmScorePackage.getScore() - wmIds.getScore() + wmIds.getKfpjf());
|
|
|
|
+ } else if (wmScorePackage.getAcceptSug().equals(wmDaAgent.getId())) {
|
|
|
|
+ wmScorePackage.setDeptId(String.valueOf(wmDaAgent.getDeptId()));
|
|
|
|
+ wmScorePackage.setKfpjf(wmScorePackage.getScore());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SysDept sysDept5 = sysDeptService.getById(SecurityUtils.getUser().getDeptId());
|
|
|
|
+ SysDept sysDept6 = sysDeptService.getById(Integer.valueOf(wmScorePackage.getDeptId()));
|
|
|
|
+
|
|
|
|
+ if (sysDept5.getLevel() == 2 && sysDept6.getLevel() == 2 && wmScorePackage.getDeptId()
|
|
|
|
+ .equals(String.valueOf(sysDept5.getDeptId()))) {
|
|
|
|
+ wmScorePackage.setTypeid("0");
|
|
|
|
+ } else if (sysDept5.getLevel() == 2) {
|
|
|
|
+ wmScorePackage.setTypeid("1");
|
|
|
|
+ } else if (sysDept5.getLevel() == 3 && sysDept6.getLevel() == 3 && wmScorePackage.getDeptId()
|
|
|
|
+ .equals(String.valueOf(sysDept5.getDeptId()))) {
|
|
|
|
+ wmScorePackage.setTypeid("1");
|
|
|
|
+ } else if (sysDept5.getLevel() == 3) {
|
|
|
|
+ wmScorePackage.setTypeid("2");
|
|
|
|
+ }
|
|
|
|
+ List<WmScorePackage> wmScorePackageList = wmScorePackageService.list(Wrappers.query(queryWm));
|
|
|
|
+ WmScorePackage wmId = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
+ if (wmScorePackageList.size() > 0) {
|
|
|
|
+ for (WmScorePackage wms : wmScorePackageList) {
|
|
|
|
+ if (wmScorePackageList.size() > 0) {
|
|
|
|
+ if (wms.getId().equals(wmScorePackage.getRelationScoreId())) {//判断是否有scoreId与当前关联积分包匹配
|
|
|
|
+ List<WmScorePackage> wmScorePackagess = wmScorePackageService.selectRelationScoreId(wmId.getId());
|
|
|
|
+ if (wmScorePackagess.size() > 0) {
|
|
|
|
+ for (WmScorePackage wmScorePackage13 : wmScorePackagess) {
|
|
|
|
+ if (wmScorePackage.getRelationScoreId().equals(wmScorePackage13.getId())) {
|
|
|
|
+ wms.setPackageIsConduct("1");
|
|
|
|
+ break;
|
|
|
|
+ } else {
|
|
|
|
+ wms.setPackageIsConduct("0");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!wmScorePackage.getRelationScoreId().equals(wmId.getRelationScoreId())) {
|
|
|
|
+ if (wmScorePackage.getScore() < wms.getKfpjf() + wmId.getScore()) {
|
|
|
|
+ wms.setKfpjf(new Double(Math.ceil(wms.getKfpjf() - wmScorePackage.getScore())).intValue());
|
|
|
|
+ } else {
|
|
|
|
+ wms.setKfpjf(new Double(Math.ceil(wms.getKfpjf() - wmScorePackage.getScore())).intValue());
|
|
|
|
+ }
|
|
|
|
+ } else if (wmScorePackage.getScore() > wms.getKfpjf() + wmId.getScore()) {
|
|
|
|
+ return R.failed("可分配积分不足");
|
|
|
|
+ } else if (wmScorePackage.getScore() < wms.getKfpjf() + wmId.getScore()) {
|
|
|
|
+ wms.setKfpjf(new Double(Math.ceil(wms.getKfpjf() + wmId.getScore() - wmScorePackage.getScore()))
|
|
|
|
+ .intValue());
|
|
|
|
+ wmId.setScore(wmScorePackage.getScore());
|
|
|
|
+ } else {
|
|
|
|
+ wms.setKfpjf(new Double(Math.ceil(wms.getKfpjf() + wmId.getScore() - wmScorePackage.getScore()))
|
|
|
|
+ .intValue());
|
|
|
|
+ wmId.setScore(wmScorePackage.getScore());
|
|
|
|
+ }
|
|
|
|
+ } else if (wms.getKfpjf() != null && !wmScorePackage.getRelationScoreId()
|
|
|
|
+ .equals("") && wmScorePackage.getScore() > wms.getKfpjf() + wmId.getScore()) {
|
|
|
|
+ return R.failed("可分配积分不足");
|
|
|
|
+ } else if ("".equals(wmScorePackage.getRelationScoreId()) && wms.getId()
|
|
|
|
+ .equals(wmId.getRelationScoreId())) {//判断关联积分包是否为无
|
|
|
|
+ wms.setKfpjf(wmId.getScore() + wms.getKfpjf());
|
|
|
|
+ } else if (wms.getId().equals(wmId.getRelationScoreId())) {
|
|
|
|
+ wms.setKfpjf(new Double(Math.ceil(wms.getKfpjf() + wmId.getScore())).intValue());
|
|
|
|
+ //判断是否进行中
|
|
|
|
+ List<WmScorePackage> wmScorePackages = wmScorePackageService.selectRelationScoreId(wmId.getId());
|
|
|
|
+ if (wmScorePackages.size() > 0) {
|
|
|
|
+ for (WmScorePackage wmScorePackage1 : wmScorePackages) {
|
|
|
|
+ if (null != wmScorePackage1.getRelationScoreId() && wmScorePackage1.getRelationScoreId()
|
|
|
|
+ .equals(wmId.getRelationScoreId())) {
|
|
|
|
+ wms.setPackageIsConduct("1");
|
|
|
|
+ break;
|
|
|
|
+ } else {
|
|
|
|
+ wms.setPackageIsConduct("0");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ wmScorePackageService.updateBatchById(wmScorePackageList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(wmScorePackage.getWmScoreTaskTypeList())) {
|
|
|
|
+ // 如果存在taskTypeId=39 则同时增加应收账款回款-A类、B类、C类任务类型(39/40/41)
|
|
|
|
+ if (wmScorePackage.getWmScoreTaskTypeList().stream().anyMatch(wmTaskTypeTree -> "39".equals(wmTaskTypeTree.getTaskTypeId()))) {
|
|
|
|
+ WmScoreTaskType addTaskType40 = new WmScoreTaskType();
|
|
|
|
+ addTaskType40.setScoreId(wmScorePackage.getId());
|
|
|
|
+ addTaskType40.setType("1");
|
|
|
|
+ addTaskType40.setTaskTypeId("40");
|
|
|
|
+ WmScoreTaskType addTaskType41 = new WmScoreTaskType();
|
|
|
|
+ addTaskType41.setScoreId(wmScorePackage.getId());
|
|
|
|
+ addTaskType41.setType("1");
|
|
|
|
+ addTaskType41.setTaskTypeId("41");
|
|
|
|
+ wmScorePackage.getWmScoreTaskTypeList().add(addTaskType40);
|
|
|
|
+ wmScorePackage.getWmScoreTaskTypeList().add(addTaskType41);
|
|
|
|
+ }
|
|
|
|
+ // 如果存在taskTypeId=42 则同时增加手术跟台-一级/手术跟台-二级/手术跟台-三级任务类型(42/43/44)
|
|
|
|
+ if (wmScorePackage.getWmScoreTaskTypeList().stream().anyMatch(wmTaskTypeTree -> "42".equals(wmTaskTypeTree.getTaskTypeId()))) {
|
|
|
|
+ WmScoreTaskType addTaskType43 = new WmScoreTaskType();
|
|
|
|
+ addTaskType43.setScoreId(wmScorePackage.getId());
|
|
|
|
+ addTaskType43.setType("1");
|
|
|
|
+ addTaskType43.setTaskTypeId("43");
|
|
|
|
+ WmScoreTaskType addTaskType44 = new WmScoreTaskType();
|
|
|
|
+ addTaskType44.setScoreId(wmScorePackage.getId());
|
|
|
|
+ addTaskType44.setType("1");
|
|
|
|
+ addTaskType44.setTaskTypeId("44");
|
|
|
|
+ wmScorePackage.getWmScoreTaskTypeList().add(addTaskType43);
|
|
|
|
+ wmScorePackage.getWmScoreTaskTypeList().add(addTaskType44);
|
|
|
|
+ }
|
|
|
|
+ // 如果存在taskTypeId=47 47,库存调研 48,竞品调研 49,培训 50,使用情况调查
|
|
|
|
+ if (wmScorePackage.getWmScoreTaskTypeList().stream().anyMatch(wmTaskTypeTree -> "47".equals(wmTaskTypeTree.getTaskTypeId()))) {
|
|
|
|
+ WmScoreTaskType addTaskTypeTree48 = new WmScoreTaskType();
|
|
|
|
+ addTaskTypeTree48.setTaskTypeId("48");
|
|
|
|
+ addTaskTypeTree48.setType("1");
|
|
|
|
+ WmScoreTaskType addTaskTypeTree49 = new WmScoreTaskType();
|
|
|
|
+ addTaskTypeTree49.setTaskTypeId("49");
|
|
|
|
+ addTaskTypeTree49.setType("1");
|
|
|
|
+ WmScoreTaskType addTaskTypeTree50 = new WmScoreTaskType();
|
|
|
|
+ addTaskTypeTree50.setTaskTypeId("50");
|
|
|
|
+ addTaskTypeTree50.setType("1");
|
|
|
|
+ wmScorePackage.getWmScoreTaskTypeList().add(addTaskTypeTree48);
|
|
|
|
+ wmScorePackage.getWmScoreTaskTypeList().add(addTaskTypeTree49);
|
|
|
|
+ wmScorePackage.getWmScoreTaskTypeList().add(addTaskTypeTree50);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<WmScoreTaskType> wmScoreTaskTypess = new ArrayList<>();
|
|
|
|
+ for (WmScoreTaskType wmScoreTaskTypes : wmScorePackage.getWmScoreTaskTypeList()) {
|
|
|
|
+ WmScoreTaskType wmScoreTaskType = new WmScoreTaskType();
|
|
|
|
+ //将积分表id和前端传的tasktypeId赋值给wmScoreTaskTypess
|
|
|
|
+ if ("".equals(wmScorePackage.getRelationScoreId())) {
|
|
|
|
+ wmScoreTaskType.setScoreId(wmScorePackage.getId());
|
|
|
|
+ wmScoreTaskType.setType("1");
|
|
|
|
+ wmScoreTaskType.setTaskTypeId(wmScoreTaskTypes.getTaskTypeId());
|
|
|
|
+ wmScoreTaskTypess.add(wmScoreTaskType);
|
|
|
|
+ } else {
|
|
|
|
+ wmScoreTaskType.setScoreId(wmScorePackage.getId());
|
|
|
|
+ wmScoreTaskType.setType("1");
|
|
|
|
+ wmScoreTaskType.setTaskTypeId(wmScoreTaskTypes.getTaskTypeId());
|
|
|
|
+ wmScoreTaskTypess.add(wmScoreTaskType);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ wmScoreTaskTypeService.deleteByScoreId(wmScorePackage.getId());
|
|
|
|
+ wmScoreTaskTypeService.batchInsertType(wmScoreTaskTypess);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 查询原积分包值
|
|
|
|
+ int oldPackageScore = wmScorePackageService.getById(wmScorePackage.getId()).getScore();
|
|
|
|
+
|
|
|
|
+ // 屏蔽推广药品企业
|
|
|
|
+ wmScorePackage.setDrugProducerList(null);
|
|
|
|
+
|
|
|
|
+ wmScorePackageService.updateById(wmScorePackage);
|
|
|
|
+
|
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
+ Integer userId = SecurityUtils.getUser().getId();
|
|
|
|
+ // 如果是通过积分充值的积分发的包,则回收积分
|
|
|
|
+ SysDeptRechargeRecord rechargeRecord = sysDeptRechargeRecordMapper.selectOne(Wrappers.<SysDeptRechargeRecord>lambdaQuery()
|
|
|
|
+ .eq(SysDeptRechargeRecord::getPackageId, wmScorePackage.getId())
|
|
|
|
+ .in(SysDeptRechargeRecord::getType, RechargeRecordType.SEND_PACKAGE_DEPT, RechargeRecordType.SEND_PACKAGE_PERSONAL));
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
+
|
|
|
|
+ boolean relatedScoreId = StrUtil.isNotBlank(wmScorePackage.getRelationScoreId()) && Integer.parseInt(wmScorePackage.getRelationScoreId()) > 0;
|
|
|
|
+
|
|
|
|
+ // 积分值相比修改前的变动(相对于积分余额,增加则为负-消耗,减少则为正-回收)
|
|
|
|
+ int changeScore = oldPackageScore - wmScorePackage.getScore();
|
|
|
|
+
|
|
|
|
+ if (!relatedScoreId) {
|
|
|
|
+ // 没有关联上级包的情况
|
|
|
|
+ log.info("修改积分包,更新积分配置信息");
|
|
|
|
+ // 校验 发包积分 < 积分充值分配的积分 则可以发包
|
|
|
|
+ SysDeptRecharge deptRecharge = sysDeptRechargeMapper.selectOne(Wrappers.<SysDeptRecharge>lambdaQuery()
|
|
|
|
+ .eq(SysDeptRecharge::getDeptId, deptId));
|
|
|
|
+ if (deptRecharge == null) {
|
|
|
|
+ log.warn("未配置积分充值信息");
|
|
|
|
+ throw new RuntimeException("积分余额:0。积分不足");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int currentScore = deptRecharge.getScore() + changeScore;
|
|
|
|
+
|
|
|
|
+ int limitScore = deptRecharge.getScore() + deptRecharge.getOverdrawScore();
|
|
|
|
+ if (changeScore < 0 && Math.abs(changeScore) > limitScore) {
|
|
|
|
+ log.warn("已分配积分不足,修改积分={},剩余积分={},透支额度={}",
|
|
|
|
+ changeScore, deptRecharge.getScore(), deptRecharge.getOverdrawScore());
|
|
|
|
+ throw new RuntimeException(String.format("积分余额:%s。积分不足", deptRecharge.getScore()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 更新积分充值信息
|
|
|
|
+ int updateRecharge = sysDeptRechargeMapper.update(null, Wrappers.<SysDeptRecharge>lambdaUpdate()
|
|
|
|
+ .eq(SysDeptRecharge::getId, deptRecharge.getId())
|
|
|
|
+ .eq(SysDeptRecharge::getVersion, deptRecharge.getVersion())
|
|
|
|
+ .set(SysDeptRecharge::getScore, currentScore)
|
|
|
|
+ .set(SysDeptRecharge::getVersion, deptRecharge.getVersion() + 1)
|
|
|
|
+ .set(SysDeptRecharge::getUpdateTime, now)
|
|
|
|
+ .set(SysDeptRecharge::getUpdateUser, userId));
|
|
|
|
+ if (updateRecharge <= 0) {
|
|
|
|
+ log.warn("更新大包积分充值信息失败");
|
|
|
|
+ throw new RuntimeException("操作失败,请重试");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 更新积分充值记录
|
|
|
|
+ SysDeptRechargeRecord newRechargeRecord = new SysDeptRechargeRecord();
|
|
|
|
+ newRechargeRecord.setRechargeId(deptRecharge.getId());
|
|
|
|
+ newRechargeRecord.setChangeScore(changeScore);
|
|
|
|
+ newRechargeRecord.setCurrentScore(currentScore);
|
|
|
|
+ newRechargeRecord.setType(RechargeRecordType.RECOVERY);
|
|
|
|
+ newRechargeRecord.setDeptId(deptRecharge.getDeptId());
|
|
|
|
+ newRechargeRecord.setRelationDeptId(rechargeRecord != null ? rechargeRecord.getRelationDeptId() : null);
|
|
|
|
+ newRechargeRecord.setPackageType(RechargeRecordPackageType.TO_ENTERPRISE);
|
|
|
|
+ newRechargeRecord.setPackageId(wmScorePackage.getId());
|
|
|
|
+ newRechargeRecord.setCreateUser(userId);
|
|
|
|
+ sysDeptRechargeRecordMapper.insert(newRechargeRecord);
|
|
|
|
+ } else {
|
|
|
|
+ // 关联了上级包的情况
|
|
|
|
+ if (changeScore < 0) {
|
|
|
|
+ // 变动积分后比原先多,则校验上级可分配积分值
|
|
|
|
+ List<WmScorePackage> scorePackagekfpjf = wmScorePackageService.getScorePackagekfpjf(null, null, new String[]{"0", "1", "2"},
|
|
|
|
+ new String[]{wmScorePackage.getRelationScoreId()});
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(scorePackagekfpjf)) {
|
|
|
|
+ int kfpjf = scorePackagekfpjf.get(0).getKfpjf();
|
|
|
|
+ if (Math.abs(changeScore) > kfpjf) {
|
|
|
|
+ throw new RuntimeException("可分配积分值不足");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.ok(Boolean.TRUE);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询关联积分包列表
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 积分包信息
|
|
|
|
+ * @return 列表
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getRelationScoreList")
|
|
|
|
+ public R<?> getRelationScoreList(WmScorePackage wmScorePackage) {
|
|
|
|
+ return wmScorePackageService.getRelationScoreList(wmScorePackage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询接单对象范围
|
|
|
|
+ *
|
|
|
|
+ * @return {@link R}<{@link ?}>
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/list-package-user-scope")
|
|
|
|
+ public R<?> listPackageUserScope() {
|
|
|
|
+ Integer sendDeptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
+
|
|
|
|
+ QueryWrapper<WmScorePackage> queryWrapper = Wrappers.<WmScorePackage>query()
|
|
|
|
+ .select("package_user_scope")
|
|
|
|
+ .and(wrapper ->
|
|
|
|
+ wrapper.eq("package_type1", PackageTypeEnum.TYPE1_SCOTE_PACKAGE.val())
|
|
|
|
+ .eq("package_type2", PackageTypeEnum.TYPE2_TASK_PACKAGE.val())
|
|
|
|
+ .or(wrapper2 -> wrapper2.eq("package_type1", PackageTypeEnum.TYPE1_SCORE_AND_TASK_PACKAGE.val())
|
|
|
|
+ .eq("package_type2", PackageTypeEnum.TYPE2_SETTLE_PACKAGE.val())))
|
|
|
|
+ .eq("send_package_dept_id", sendDeptId)
|
|
|
|
+ .in("typeid", "3", "4", "5");
|
|
|
|
+ List<WmScorePackage> packages = wmScorePackageService.list(queryWrapper);
|
|
|
|
+ if (CollUtil.isEmpty(packages)) {
|
|
|
|
+ return R.ok(Collections.emptyList());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<String> pacakgeUserScores = packages.stream()
|
|
|
|
+ .map(WmScorePackage::getPackageUserScope)
|
|
|
|
+ .distinct().sorted().collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ List<Map<String, String>> result = new ArrayList<>();
|
|
|
|
+ Map<String, String> val1 = new HashMap<>();
|
|
|
|
+ val1.put("id", "1");
|
|
|
|
+ val1.put("name", "仅内部可见");
|
|
|
|
+ Map<String, String> val2 = new HashMap<>();
|
|
|
|
+ val2.put("id", "2");
|
|
|
|
+ val2.put("name", "全部可见");
|
|
|
|
+ result.add(val1);
|
|
|
|
+ result.add(val2);
|
|
|
|
+ // 查询团队名称
|
|
|
|
+ List<WmTeam> teams = wmTeamService.listByIds(pacakgeUserScores);
|
|
|
|
+ List<Map<String, String>> teamNameList = teams.stream().map(t -> {
|
|
|
|
+ Map<String, String> teamNameMap = new HashMap<>(2);
|
|
|
|
+ teamNameMap.put("id", String.valueOf(t.getId()));
|
|
|
|
+ teamNameMap.put("name", t.getName());
|
|
|
|
+ return teamNameMap;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ result.addAll(teamNameList);
|
|
|
|
+
|
|
|
|
+ return R.ok(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分配积分列表查询--派工平台
|
|
|
|
+ *
|
|
|
|
+ * @param acceptUser 接单对象,模糊查询
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getScorePackagePageForBC")
|
|
|
|
+ public R<?> getScorePackagePageForBC(@RequestParam(value = "current") Integer current,
|
|
|
|
+ @RequestParam(value = "size") Integer size,
|
|
|
|
+ @RequestParam(value = "deptId") Integer deptId,
|
|
|
|
+ Integer userId,
|
|
|
|
+ @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
+ @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
+ @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
+ @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
+ @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
+ @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
+ @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
+ @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
+ @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
+ @RequestParam(value = "toApproval", required = false) Boolean toApproval,
|
|
|
|
+ @RequestParam(value = "packageUserScope", required = false) String packageUserScope,
|
|
|
|
+ String sourceType
|
|
|
|
+ ) {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ LocalDateTime start = null;
|
|
|
|
+ LocalDateTime end = null;
|
|
|
|
+
|
|
|
|
+ if (StrUtil.isNotEmpty(monthStart) && StrUtil.isNotEmpty(monthEnd)) {
|
|
|
|
+ start = LocalDateTime.of(LocalDate.parse(monthStart + "-01", DatePattern.NORM_DATE_FORMATTER), LocalTime.MIN);
|
|
|
|
+ LocalDate e = LocalDate.parse(monthEnd + "-01", DatePattern.NORM_DATE_FORMATTER);
|
|
|
|
+ end = LocalDateTime.of(e.with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ QueryWrapper<WmScorePackage> queryWrapper = Wrappers.<WmScorePackage>query()
|
|
|
|
+ .eq("p.package_type1", packageType1)
|
|
|
|
+ .eq("p.package_type2", packageType2)
|
|
|
|
+ .eq(scorePackageStatus != null, "p.score_package_status", scorePackageStatus)
|
|
|
|
+ .eq("p.send_package_dept_id", deptId)
|
|
|
|
+ .between(start != null && end != null, "p.create_time", start, end);
|
|
|
|
+
|
|
|
|
+ if (StrUtil.isNotBlank(scorePackageName)) {
|
|
|
|
+ queryWrapper.and(wrapper -> wrapper.like("p.score_package_name", scorePackageName).or().like("p.pkg_sn", scorePackageName));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtil.isEmpty(typeId)) {
|
|
|
|
+ queryWrapper.in("p.typeid", "3", "4", "5");
|
|
|
|
+ } else {
|
|
|
|
+ List<String> split = StrUtil.split(typeId, StrUtil.COMMA);
|
|
|
|
+ queryWrapper.in("p.typeid", split);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 接单对象范围筛选
|
|
|
|
+ if (StrUtil.isNotBlank(packageUserScope)) {
|
|
|
|
+ queryWrapper.eq("p.package_user_scope", packageUserScope);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 用于问问的系统来源
|
|
|
|
+ if (StrUtil.isNotBlank(sourceType)) {
|
|
|
|
+ queryWrapper.eq("p.source_type", sourceType);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (userId != null) {
|
|
|
|
+ boolean onePersonScorePackageFlag = PackageTypeEnum.TYPE1_SCOTE_PACKAGE.val().equals(String.valueOf(packageType1))
|
|
|
|
+ && PackageTypeEnum.TYPE2_TASK_PACKAGE.val().equals(String.valueOf(packageType2));
|
|
|
|
+ boolean multiPersonScorePackageFlag = PackageTypeEnum.TYPE1_SCORE_AND_TASK_PACKAGE.val().equals(String.valueOf(packageType1))
|
|
|
|
+ && PackageTypeEnum.TYPE2_SETTLE_PACKAGE.val().equals(String.valueOf(packageType2));
|
|
|
|
+ if (onePersonScorePackageFlag || multiPersonScorePackageFlag) {
|
|
|
|
+ // 如果是个人承接-按积分值/多人承接-按积分值,判断当前用户是否配置了团队负责人
|
|
|
|
+ List<WmTeam> teamList = wmTeamService.list(Wrappers.<WmTeam>lambdaQuery()
|
|
|
|
+ .eq(WmTeam::getDeptId, deptId)
|
|
|
|
+ .eq(WmTeam::getEnableFlag, EnableEnum.ENABLE.val())
|
|
|
|
+ .eq(WmTeam::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
|
+ .apply("FIND_IN_SET({0}, leader)", String.valueOf(userId)));
|
|
|
|
+ if (CollectionUtil.isNotEmpty(teamList)) {
|
|
|
|
+ // 如果配置了,则只查询所在团队下发的积分包
|
|
|
|
+ List<String> teamIdList = teamList.stream().map(wmTeam -> String.valueOf(wmTeam.getId())).collect(Collectors.toList());
|
|
|
|
+ queryWrapper.in("p.package_user_scope", teamIdList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Page<WmScorePackage> wmScorePackagePage = wmScorePackageMapper.listScorePackage(new Page<>(current, size),
|
|
|
|
+ queryWrapper.orderByDesc("p.create_time"), acceptUser, relationScoreId, toApproval);
|
|
|
|
+
|
|
|
|
+ List<WmScorePackage> pageRecords = wmScorePackagePage.getRecords();
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(pageRecords)) {
|
|
|
|
+
|
|
|
|
+ Set<String> packageIds = pageRecords.stream().map(WmScorePackage::getId).collect(Collectors.toSet());
|
|
|
|
+
|
|
|
|
+ // 任务统计
|
|
|
|
+ List<WmTask> taskList = wmTaskMapper.selectList(Wrappers.<WmTask>lambdaQuery()
|
|
|
|
+ .eq(WmTask::getRealFlag, "0")
|
|
|
|
+ .eq(WmTask::getEnableFlag, "0")
|
|
|
|
+ .eq(WmTask::getDelFlag, "0")
|
|
|
|
+ .in(WmTask::getScorePackageId, packageIds)
|
|
|
|
+ );
|
|
|
|
+ Map<String, List<WmTask>> taskGoupMap = taskList.stream().collect(Collectors.groupingBy(WmTask::getScorePackageId));
|
|
|
|
+
|
|
|
|
+ // 领取积分包记录
|
|
|
|
+ List<WmScorePackageStatus> scorePackageStatusList = wmScorePackageStatusService.list(Wrappers.<WmScorePackageStatus>lambdaQuery()
|
|
|
|
+ .in(WmScorePackageStatus::getPackageId, packageIds)
|
|
|
|
+ );
|
|
|
|
+ Map<String, List<WmScorePackageStatus>> packageStatusGroupMap = scorePackageStatusList.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(WmScorePackageStatus::getPackageId));
|
|
|
|
+
|
|
|
|
+ //获取上级包
|
|
|
|
+ Set<String> parentPackageIds = pageRecords.stream().map(WmScorePackage::getRelationScoreId).collect(Collectors.toSet());
|
|
|
|
+ List<WmScorePackage> parentPackages = wmScorePackageMapper.selectList(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
+ .in(WmScorePackage::getId, parentPackageIds));
|
|
|
|
+ Map<String, WmScorePackage> parentPackageNameMap = parentPackages.stream()
|
|
|
|
+ .collect(Collectors.toMap(WmScorePackage::getId, Function.identity()));
|
|
|
|
+
|
|
|
|
+ // 类型标签
|
|
|
|
+ List<SysDictItem> dictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
+ .in(SysDictItem::getType, "package_type1", "package_type2"));
|
|
|
|
+ Map<String, List<SysDictItem>> dictItemMap = dictItems.stream().collect(Collectors.groupingBy(SysDictItem::getType));
|
|
|
|
+ List<SysDictItem> packageType1List = dictItemMap.get("package_type1");
|
|
|
|
+ List<SysDictItem> packageType2List = dictItemMap.get("package_type2");
|
|
|
|
+
|
|
|
|
+ // todo
|
|
|
|
+ //// 结算记录
|
|
|
|
+ //List<WmScorePackageSettleNote> noteList = settleNoteMapper.selectList(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
+ // .in(WmScorePackageSettleNote::getPackageId, packageIds));
|
|
|
|
+ //Map<String, List<WmScorePackageSettleNote>> noteMap = noteList.stream()
|
|
|
|
+ // .collect(Collectors.groupingBy(WmScorePackageSettleNote::getPackageId));
|
|
|
|
+
|
|
|
|
+ // 有效任务类型
|
|
|
|
+ List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(String.join(",", packageIds));
|
|
|
|
+ Map<String, List<WmScoreTaskType>> taskTypeMap = taskTypeList.stream().collect(Collectors.groupingBy(WmScoreTaskType::getScoreId));
|
|
|
|
+
|
|
|
|
+ //for (int i = 0; i < pageRecords.size(); i++) {
|
|
|
|
+ // WmScorePackage wmScorePackage = pageRecords.get(i);
|
|
|
|
+ //
|
|
|
|
+ // List<WmTask> tasks = taskGoupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ // List<WmScorePackageStatus> statuses = packageStatusGroupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ // List<WmScorePackageSettleNote> notes = noteMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ // List<WmScoreTaskType> scoreTaskTypes = taskTypeMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ //
|
|
|
|
+ // wmScorePackageService.buildScorePackageSync(wmScorePackage, packageType1, packageType2, tasks, statuses,
|
|
|
|
+ // packageType1List, packageType2List, parentPackageNameMap, notes, scoreTaskTypes);
|
|
|
|
+ //
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.ok(wmScorePackagePage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 分配积分列表查询--派工平台
|
|
|
|
+ *
|
|
|
|
+ * @param acceptUser 接单对象,模糊查询
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getScorePackagePage")
|
|
|
|
+ public R<?> getScorePackagePage(@RequestParam(value = "current") Integer current,
|
|
|
|
+ @RequestParam(value = "size") Integer size,
|
|
|
|
+ @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
+ @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
+ @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
+ @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
+ @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
+ @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
+ @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
+ @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
+ @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
+ @RequestParam(value = "toApproval", required = false) Boolean toApproval,
|
|
|
|
+ @RequestParam(value = "packageUserScope", required = false) String packageUserScope,
|
|
|
|
+ String sourceType
|
|
|
|
+ ) {
|
|
|
|
+
|
|
|
|
+ Integer sendDeptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
+ Integer userId = SecurityUtils.getUser().getId();
|
|
|
|
+
|
|
|
|
+ return this.getScorePackagePageForBC(current, size, sendDeptId, userId, packageType1, packageType2, scorePackageName, scorePackageStatus,
|
|
|
|
+ typeId, monthStart, monthEnd, acceptUser, relationScoreId, toApproval, packageUserScope, sourceType);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 积分包列表-其他(用于MAH结算:药企查询下级提交的) 用于BC
|
|
|
|
+ *
|
|
|
|
+ * @param acceptUser 接单对象,模糊查询
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getScorePackagePageForMahForBC")
|
|
|
|
+ public R getScorePackagePageForMahForBC(@RequestParam(value = "current") Integer current,
|
|
|
|
+ @RequestParam(value = "size") Integer size,
|
|
|
|
+ @RequestParam(value = "deptId") Integer deptId,
|
|
|
|
+ @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
+ @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
+ @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
+ @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
+ @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
+ @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
+ @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
+ @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
+ @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
+ @RequestParam(value = "toApproval", required = false) Boolean toApproval
|
|
|
|
+ ) {
|
|
|
|
+
|
|
|
|
+ LocalDateTime start = null;
|
|
|
|
+ LocalDateTime end = null;
|
|
|
|
+
|
|
|
|
+ if (StrUtil.isNotEmpty(monthStart) && StrUtil.isNotEmpty(monthEnd)) {
|
|
|
|
+ start = LocalDateTime.of(LocalDate.parse(monthStart + "-01", DatePattern.NORM_DATE_FORMATTER), LocalTime.MIN);
|
|
|
|
+ LocalDate e = LocalDate.parse(monthEnd + "-01", DatePattern.NORM_DATE_FORMATTER);
|
|
|
|
+ end = LocalDateTime.of(e.with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ QueryWrapper<WmScorePackage> queryWrapper = Wrappers.<WmScorePackage>query()
|
|
|
|
+ .eq("p.package_type1", packageType1)
|
|
|
|
+ .eq("p.package_type2", packageType2)
|
|
|
|
+ .eq(scorePackageStatus != null, "p.score_package_status", scorePackageStatus)
|
|
|
|
+ .eq("p.mah_settle_dept_id", deptId)
|
|
|
|
+ .in("p.mah_settle_step", UpmsType.MahSettleStep.BUSINESS.getType(), UpmsType.MahSettleStep.FINANCE.getType())
|
|
|
|
+ .between(start != null && end != null, "p.create_time", start, end);
|
|
|
|
+
|
|
|
|
+ if (StrUtil.isNotBlank(scorePackageName)) {
|
|
|
|
+ queryWrapper.and(wrapper -> wrapper.like("p.score_package_name", scorePackageName).or().like("p.pkg_sn", scorePackageName));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtil.isEmpty(typeId)) {
|
|
|
|
+ queryWrapper.in("p.typeid", "3", "4", "5");
|
|
|
|
+ } else {
|
|
|
|
+ List<String> split = StrUtil.split(typeId, StrUtil.COMMA);
|
|
|
|
+ queryWrapper.in("p.typeid", split);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Page<WmScorePackage> wmScorePackagePage = wmScorePackageMapper.listScorePackage(new Page<>(current, size),
|
|
|
|
+ queryWrapper.orderByDesc("p.settlement_date"), acceptUser, relationScoreId, toApproval);
|
|
|
|
+
|
|
|
|
+ List<WmScorePackage> pageRecords = wmScorePackagePage.getRecords();
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(pageRecords)) {
|
|
|
|
+ Set<String> packageIds = pageRecords.stream().map(WmScorePackage::getId).collect(Collectors.toSet());
|
|
|
|
+
|
|
|
|
+ // 任务统计
|
|
|
|
+ List<WmTask> taskList = wmTaskMapper.selectList(Wrappers.<WmTask>lambdaQuery()
|
|
|
|
+ .eq(WmTask::getRealFlag, "0")
|
|
|
|
+ .eq(WmTask::getEnableFlag, "0")
|
|
|
|
+ .eq(WmTask::getDelFlag, "0")
|
|
|
|
+ .in(WmTask::getScorePackageId, packageIds)
|
|
|
|
+ );
|
|
|
|
+ Map<String, List<WmTask>> taskGoupMap = taskList.stream().collect(Collectors.groupingBy(WmTask::getScorePackageId));
|
|
|
|
+
|
|
|
|
+ // 领取积分包记录
|
|
|
|
+ List<WmScorePackageStatus> scorePackageStatusList = wmScorePackageStatusService.list(Wrappers.<WmScorePackageStatus>lambdaQuery()
|
|
|
|
+ .in(WmScorePackageStatus::getPackageId, packageIds)
|
|
|
|
+ );
|
|
|
|
+ Map<String, List<WmScorePackageStatus>> packageStatusGroupMap = scorePackageStatusList.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(WmScorePackageStatus::getPackageId));
|
|
|
|
+
|
|
|
|
+ //获取上级包
|
|
|
|
+ Set<String> parentPackageIds = pageRecords.stream().map(WmScorePackage::getRelationScoreId).collect(Collectors.toSet());
|
|
|
|
+ List<WmScorePackage> parentPackages = wmScorePackageMapper.selectList(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
+ .in(WmScorePackage::getId, parentPackageIds));
|
|
|
|
+ Map<String, WmScorePackage> parentPackageNameMap = parentPackages.stream()
|
|
|
|
+ .collect(Collectors.toMap(WmScorePackage::getId, Function.identity()));
|
|
|
|
+
|
|
|
|
+ // 类型标签
|
|
|
|
+ List<SysDictItem> dictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
+ .in(SysDictItem::getType, "package_type1", "package_type2"));
|
|
|
|
+ Map<String, List<SysDictItem>> dictItemMap = dictItems.stream().collect(Collectors.groupingBy(SysDictItem::getType));
|
|
|
|
+ List<SysDictItem> packageType1List = dictItemMap.get("package_type1");
|
|
|
|
+ List<SysDictItem> packageType2List = dictItemMap.get("package_type2");
|
|
|
|
+
|
|
|
|
+ // todo
|
|
|
|
+ //// 结算记录
|
|
|
|
+ //List<WmScorePackageSettleNote> noteList = settleNoteMapper.selectList(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
+ // .in(WmScorePackageSettleNote::getPackageId, packageIds));
|
|
|
|
+ //Map<String, List<WmScorePackageSettleNote>> noteMap = noteList.stream()
|
|
|
|
+ // .collect(Collectors.groupingBy(WmScorePackageSettleNote::getPackageId));
|
|
|
|
+
|
|
|
|
+ // 有效任务类型
|
|
|
|
+ List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(String.join(",", packageIds));
|
|
|
|
+ Map<String, List<WmScoreTaskType>> taskTypeMap = taskTypeList.stream().collect(Collectors.groupingBy(WmScoreTaskType::getScoreId));
|
|
|
|
+
|
|
|
|
+ //for (int i = 0; i < pageRecords.size(); i++) {
|
|
|
|
+ // WmScorePackage wmScorePackage = pageRecords.get(i);
|
|
|
|
+ //
|
|
|
|
+ // List<WmTask> tasks = taskGoupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ // List<WmScorePackageStatus> statuses = packageStatusGroupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ // List<WmScorePackageSettleNote> notes = noteMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ // List<WmScoreTaskType> scoreTaskTypes = taskTypeMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ //
|
|
|
|
+ // wmScorePackageService.buildScorePackageSync(wmScorePackage, packageType1, packageType2, tasks, statuses,
|
|
|
|
+ // packageType1List, packageType2List, parentPackageNameMap, notes, scoreTaskTypes);
|
|
|
|
+ //
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 个人承接-其他 标记已读提醒
|
|
|
|
+ wmBizReminderService.markRead(UpmsType.BizReminderType.ASSIGN_POINTS_OTHER_REMINDER, deptId);
|
|
|
|
+
|
|
|
|
+ return R.ok(wmScorePackagePage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 积分包列表-其他(用于MAH结算:药企查询下级提交的)
|
|
|
|
+ *
|
|
|
|
+ * @param acceptUser 接单对象,模糊查询
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getScorePackagePageForMah")
|
|
|
|
+ public R getScorePackagePageForMah(@RequestParam(value = "current") Integer current,
|
|
|
|
+ @RequestParam(value = "size") Integer size,
|
|
|
|
+ @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
+ @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
+ @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
+ @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
+ @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
+ @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
+ @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
+ @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
+ @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
+ @RequestParam(value = "toApproval", required = false) Boolean toApproval
|
|
|
|
+ ) {
|
|
|
|
+
|
|
|
|
+ Integer sendDeptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
+
|
|
|
|
+ return this.getScorePackagePageForMahForBC(current, size, sendDeptId, packageType1, packageType2, scorePackageName,
|
|
|
|
+ scorePackageStatus, typeId, monthStart, monthEnd, acceptUser, relationScoreId, toApproval);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 个人承接积分值导出-用于BC
|
|
|
|
+ *
|
|
|
|
+ * @param acceptUser 接单对象,模糊查询
|
|
|
|
+ */
|
|
|
|
+ @ResponseExcel(name = "exportPackageSettle", sheet = "个人承接积分值导出")
|
|
|
|
+ @SysLog("个人承接积分值导出-用于BC")
|
|
|
|
+ @GetMapping("/export-score-package-for-bc")
|
|
|
|
+ public List<WmScorePackageExcelModel> exportScorePackageForBC(
|
|
|
|
+ @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
+ @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
+ @RequestParam(value = "deptId") Integer deptId,
|
|
|
|
+ Integer userId,
|
|
|
|
+ @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
+ @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
+ @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
+ @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
+ @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
+ @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
+ @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
+ @RequestParam(value = "toApproval", required = false) Boolean toApproval,
|
|
|
|
+ @RequestParam(value = "packageUserScope", required = false) String packageUserScope
|
|
|
|
+ ) {
|
|
|
|
+
|
|
|
|
+ LocalDateTime start = null;
|
|
|
|
+ LocalDateTime end = null;
|
|
|
|
+
|
|
|
|
+ if (StrUtil.isNotEmpty(monthStart) && StrUtil.isNotEmpty(monthEnd)) {
|
|
|
|
+ start = LocalDateTime.of(LocalDate.parse(monthStart + "-01", DatePattern.NORM_DATE_FORMATTER), LocalTime.MIN);
|
|
|
|
+ LocalDate e = LocalDate.parse(monthEnd + "-01", DatePattern.NORM_DATE_FORMATTER);
|
|
|
|
+ end = LocalDateTime.of(e.with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ QueryWrapper<WmScorePackage> queryWrapper = Wrappers.<WmScorePackage>query()
|
|
|
|
+ .eq("p.package_type1", packageType1)
|
|
|
|
+ .eq("p.package_type2", packageType2)
|
|
|
|
+ .eq(scorePackageStatus != null, "p.score_package_status", scorePackageStatus)
|
|
|
|
+ .eq("p.send_package_dept_id", deptId)
|
|
|
|
+ .between(start != null && end != null, "p.create_time", start, end);
|
|
|
|
+
|
|
|
|
+ if (StrUtil.isNotBlank(scorePackageName)) {
|
|
|
|
+ queryWrapper.and(wrapper -> wrapper.like("p.score_package_name", scorePackageName).or().like("p.pkg_sn", scorePackageName));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtil.isEmpty(typeId)) {
|
|
|
|
+ queryWrapper.in("p.typeid", "3", "4", "5");
|
|
|
|
+ } else {
|
|
|
|
+ List<String> split = StrUtil.split(typeId, StrUtil.COMMA);
|
|
|
|
+ queryWrapper.in("p.typeid", split);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 接单对象范围筛选
|
|
|
|
+ if (StrUtil.isNotBlank(packageUserScope)) {
|
|
|
|
+ queryWrapper.eq("p.package_user_scope", packageUserScope);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (userId != null) {
|
|
|
|
+ boolean onePersonScorePackageFlag = PackageTypeEnum.TYPE1_SCOTE_PACKAGE.val().equals(String.valueOf(packageType1))
|
|
|
|
+ && PackageTypeEnum.TYPE2_TASK_PACKAGE.val().equals(String.valueOf(packageType2));
|
|
|
|
+ boolean multiPersonScorePackageFlag = PackageTypeEnum.TYPE1_SCORE_AND_TASK_PACKAGE.val().equals(String.valueOf(packageType1))
|
|
|
|
+ && PackageTypeEnum.TYPE2_SETTLE_PACKAGE.val().equals(String.valueOf(packageType2));
|
|
|
|
+ if (onePersonScorePackageFlag || multiPersonScorePackageFlag) {
|
|
|
|
+ // 如果是个人承接-按积分值/多人承接-按积分值,判断当前用户是否配置了团队负责人
|
|
|
|
+ List<WmTeam> teamList = wmTeamService.list(Wrappers.<WmTeam>lambdaQuery()
|
|
|
|
+ .eq(WmTeam::getDeptId, deptId)
|
|
|
|
+ .eq(WmTeam::getEnableFlag, EnableEnum.ENABLE.val())
|
|
|
|
+ .eq(WmTeam::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
|
+ .apply("FIND_IN_SET({0}, leader)", String.valueOf(userId)));
|
|
|
|
+ if (CollectionUtil.isNotEmpty(teamList)) {
|
|
|
|
+ // 如果配置了,则只查询所在团队下发的积分包
|
|
|
|
+ List<String> teamIdList = teamList.stream().map(wmTeam -> String.valueOf(wmTeam.getId())).collect(Collectors.toList());
|
|
|
|
+ queryWrapper.in("p.package_user_scope", teamIdList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ long startMillis = System.currentTimeMillis();
|
|
|
|
+ List<WmScorePackage> scorePackageList = wmScorePackageMapper.listScorePackage(
|
|
|
|
+ queryWrapper.orderByDesc("p.create_time"), acceptUser, relationScoreId, toApproval);
|
|
|
|
+ log.info("积分包列表-不分页sql耗时:{}", System.currentTimeMillis() - startMillis);
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isEmpty(scorePackageList)) {
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ long buildStartMillis = System.currentTimeMillis();
|
|
|
|
+
|
|
|
|
+ Set<String> packageIds = scorePackageList.stream().map(WmScorePackage::getId).collect(Collectors.toSet());
|
|
|
|
+
|
|
|
|
+ // 任务统计
|
|
|
|
+ List<WmTask> taskList = wmTaskMapper.selectList(Wrappers.<WmTask>lambdaQuery()
|
|
|
|
+ .eq(WmTask::getRealFlag, "0")
|
|
|
|
+ .eq(WmTask::getEnableFlag, "0")
|
|
|
|
+ .eq(WmTask::getDelFlag, "0")
|
|
|
|
+ .in(WmTask::getScorePackageId, packageIds)
|
|
|
|
+ );
|
|
|
|
+ Map<String, List<WmTask>> taskGoupMap = taskList.stream().collect(Collectors.groupingBy(WmTask::getScorePackageId));
|
|
|
|
+
|
|
|
|
+ // 领取积分包记录
|
|
|
|
+ List<WmScorePackageStatus> scorePackageStatusList = wmScorePackageStatusService.list(Wrappers.<WmScorePackageStatus>lambdaQuery()
|
|
|
|
+ .in(WmScorePackageStatus::getPackageId, packageIds)
|
|
|
|
+ );
|
|
|
|
+ Map<String, List<WmScorePackageStatus>> packageStatusGroupMap = scorePackageStatusList.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(WmScorePackageStatus::getPackageId));
|
|
|
|
+
|
|
|
|
+ //获取上级包
|
|
|
|
+ Set<String> parentPackageIds = scorePackageList.stream().map(WmScorePackage::getRelationScoreId).collect(Collectors.toSet());
|
|
|
|
+ List<WmScorePackage> parentPackages = wmScorePackageMapper.selectList(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
+ .in(WmScorePackage::getId, parentPackageIds));
|
|
|
|
+ Map<String, WmScorePackage> parentPackageNameMap = parentPackages.stream()
|
|
|
|
+ .collect(Collectors.toMap(WmScorePackage::getId, Function.identity()));
|
|
|
|
+
|
|
|
|
+ // 类型标签
|
|
|
|
+ List<SysDictItem> dictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
+ .in(SysDictItem::getType, "package_type1", "package_type2"));
|
|
|
|
+ Map<String, List<SysDictItem>> dictItemMap = dictItems.stream().collect(Collectors.groupingBy(SysDictItem::getType));
|
|
|
|
+ List<SysDictItem> packageType1List = dictItemMap.get("package_type1");
|
|
|
|
+ List<SysDictItem> packageType2List = dictItemMap.get("package_type2");
|
|
|
|
+
|
|
|
|
+ // todo
|
|
|
|
+ //// 结算记录
|
|
|
|
+ //List<WmScorePackageSettleNote> noteList = settleNoteMapper.selectList(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
+ // .in(WmScorePackageSettleNote::getPackageId, packageIds));
|
|
|
|
+ //Map<String, List<WmScorePackageSettleNote>> noteMap = noteList.stream()
|
|
|
|
+ // .collect(Collectors.groupingBy(WmScorePackageSettleNote::getPackageId));
|
|
|
|
+
|
|
|
|
+ // 有效任务类型
|
|
|
|
+ List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(String.join(",", packageIds));
|
|
|
|
+ Map<String, List<WmScoreTaskType>> taskTypeMap = taskTypeList.stream().collect(Collectors.groupingBy(WmScoreTaskType::getScoreId));
|
|
|
|
+
|
|
|
|
+ List<WmScorePackageExcelModel> excelModelList = new ArrayList<>(scorePackageList.size());
|
|
|
|
+ for (int i = 0; i < scorePackageList.size(); i++) {
|
|
|
|
+ WmScorePackage wmScorePackage = scorePackageList.get(i);
|
|
|
|
+ log.info("====> 积分包SN:{}", wmScorePackage.getPackageSn());
|
|
|
|
+
|
|
|
|
+ List<WmTask> tasks = taskGoupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ List<WmScorePackageStatus> statuses = packageStatusGroupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ // todo
|
|
|
|
+ //List<WmScorePackageSettleNote> notes = noteMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ //List<WmScoreTaskType> scoreTaskTypes = taskTypeMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ //
|
|
|
|
+ //wmScorePackageService.buildScorePackageSync(wmScorePackage, packageType1, packageType2, tasks, statuses,
|
|
|
|
+ // packageType1List, packageType2List, parentPackageNameMap, notes, scoreTaskTypes);
|
|
|
|
+
|
|
|
|
+ WmScorePackageExcelModel excelModel = BeanUtil.copyProperties(wmScorePackage, WmScorePackageExcelModel.class);
|
|
|
|
+ if (StrUtil.isNotBlank(wmScorePackage.getScorePackageStatus())) {
|
|
|
|
+ excelModel.setScorePackageStatus(Objects.requireNonNull(ScorePackageStatusEnum.getByVal(wmScorePackage.getScorePackageStatus())).getDesc());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(wmScorePackage.getUserList())) {
|
|
|
|
+ excelModel.setUserNames(String.join(",", wmScorePackage.getUserList()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String typeid = wmScorePackage.getTypeid();
|
|
|
|
+ if (StrUtil.isNotBlank(typeid)) {
|
|
|
|
+ excelModel.setTypeidName("3".equals(typeid) ? "全职学术信息沟通专员" :
|
|
|
|
+ "4".equals(typeid) ? "兼职学术信息沟通专员" : "5".equals(typeid) ? "招商经理" : typeid);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ excelModel.setNumber(String.valueOf(i + 1));
|
|
|
|
+ if (wmScorePackage.getYshtt() != null) {
|
|
|
|
+ excelModel.setFinishRate(String.valueOf(wmScorePackage.getYshtt()));
|
|
|
|
+ }
|
|
|
|
+ excelModel.setPayScore(wmScorePackage.getShtg());
|
|
|
|
+ if (wmScorePackage.getShtgtt() != null) {
|
|
|
|
+ excelModel.setPayRate(String.valueOf(wmScorePackage.getShtgtt()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ excelModelList.add(excelModel);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ log.info("build积分包耗时:{}", System.currentTimeMillis() - buildStartMillis);
|
|
|
|
+
|
|
|
|
+ return excelModelList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 个人承接积分值导出
|
|
|
|
+ *
|
|
|
|
+ * @param acceptUser 接单对象,模糊查询
|
|
|
|
+ */
|
|
|
|
+ @ResponseExcel(name = "exportPackageSettle", sheet = "个人承接积分值导出")
|
|
|
|
+ @SysLog("个人承接积分值导出")
|
|
|
|
+ @GetMapping("/export-score-package")
|
|
|
|
+ public List<WmScorePackageExcelModel> exportScorePackage(
|
|
|
|
+ @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
+ @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
+ @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
+ @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
+ @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
+ @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
+ @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
+ @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
+ @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
+ @RequestParam(value = "toApproval", required = false) Boolean toApproval,
|
|
|
|
+ @RequestParam(value = "packageUserScope", required = false) String packageUserScope
|
|
|
|
+ ) {
|
|
|
|
+
|
|
|
|
+ Integer sendDeptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
+ Integer userId = SecurityUtils.getUser().getId();
|
|
|
|
+
|
|
|
|
+ return this.exportScorePackageForBC(packageType1, packageType2, sendDeptId, userId, scorePackageName,
|
|
|
|
+ scorePackageStatus, typeId, monthStart, monthEnd, acceptUser, relationScoreId, toApproval, packageUserScope);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 个人承接积分值-其他导出-用于BC
|
|
|
|
+ *
|
|
|
|
+ * @param acceptUser 接单对象,模糊查询
|
|
|
|
+ */
|
|
|
|
+ @ResponseExcel(name = "exportPackageSettle", sheet = "个人承接积分值-其他导出")
|
|
|
|
+ @SysLog("个人承接积分值-其他导出-用于BC")
|
|
|
|
+ @GetMapping("/export-score-package-mah-for-bc")
|
|
|
|
+ public List<WmScorePackageExcelModel> exportPackageSettleForMahForBC(
|
|
|
|
+ @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
+ @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
+ @RequestParam(value = "deptId") Integer deptId,
|
|
|
|
+ @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
+ @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
+ @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
+ @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
+ @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
+ @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
+ @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
+ @RequestParam(value = "toApproval", required = false) Boolean toApproval
|
|
|
|
+ ) {
|
|
|
|
+
|
|
|
|
+ LocalDateTime start = null;
|
|
|
|
+ LocalDateTime end = null;
|
|
|
|
+
|
|
|
|
+ if (StrUtil.isNotEmpty(monthStart) && StrUtil.isNotEmpty(monthEnd)) {
|
|
|
|
+ start = LocalDateTime.of(LocalDate.parse(monthStart + "-01", DatePattern.NORM_DATE_FORMATTER), LocalTime.MIN);
|
|
|
|
+ LocalDate e = LocalDate.parse(monthEnd + "-01", DatePattern.NORM_DATE_FORMATTER);
|
|
|
|
+ end = LocalDateTime.of(e.with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ QueryWrapper<WmScorePackage> queryWrapper = Wrappers.<WmScorePackage>query()
|
|
|
|
+ .eq("p.package_type1", packageType1)
|
|
|
|
+ .eq("p.package_type2", packageType2)
|
|
|
|
+ .eq(scorePackageStatus != null, "p.score_package_status", scorePackageStatus)
|
|
|
|
+ .eq("p.mah_settle_dept_id", deptId)
|
|
|
|
+ .in("p.mah_settle_step", UpmsType.MahSettleStep.BUSINESS.getType(), UpmsType.MahSettleStep.FINANCE.getType())
|
|
|
|
+ .between(start != null && end != null, "p.create_time", start, end);
|
|
|
|
+
|
|
|
|
+ if (StrUtil.isNotBlank(scorePackageName)) {
|
|
|
|
+ queryWrapper.and(wrapper -> wrapper.like("p.score_package_name", scorePackageName).or().like("p.pkg_sn", scorePackageName));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtil.isEmpty(typeId)) {
|
|
|
|
+ queryWrapper.in("p.typeid", "3", "4", "5");
|
|
|
|
+ } else {
|
|
|
|
+ List<String> split = StrUtil.split(typeId, StrUtil.COMMA);
|
|
|
|
+ queryWrapper.in("p.typeid", split);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ long startMillis = System.currentTimeMillis();
|
|
|
|
+ List<WmScorePackage> scorePackageList = wmScorePackageMapper.listScorePackage(
|
|
|
|
+ queryWrapper.orderByDesc("p.settlement_date"), acceptUser, relationScoreId, toApproval);
|
|
|
|
+
|
|
|
|
+ log.info("MAH积分包列表sql耗时:{}", System.currentTimeMillis() - startMillis);
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isEmpty(scorePackageList)) {
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ long buildStartMillis = System.currentTimeMillis();
|
|
|
|
+
|
|
|
|
+ Set<String> packageIds = scorePackageList.stream().map(WmScorePackage::getId).collect(Collectors.toSet());
|
|
|
|
+
|
|
|
|
+ // 任务统计
|
|
|
|
+ List<WmTask> taskList = wmTaskMapper.selectList(Wrappers.<WmTask>lambdaQuery()
|
|
|
|
+ .eq(WmTask::getRealFlag, "0")
|
|
|
|
+ .eq(WmTask::getEnableFlag, "0")
|
|
|
|
+ .eq(WmTask::getDelFlag, "0")
|
|
|
|
+ .in(WmTask::getScorePackageId, packageIds)
|
|
|
|
+ );
|
|
|
|
+ Map<String, List<WmTask>> taskGoupMap = taskList.stream().collect(Collectors.groupingBy(WmTask::getScorePackageId));
|
|
|
|
+
|
|
|
|
+ // 领取积分包记录
|
|
|
|
+ List<WmScorePackageStatus> scorePackageStatusList = wmScorePackageStatusService.list(Wrappers.<WmScorePackageStatus>lambdaQuery()
|
|
|
|
+ .in(WmScorePackageStatus::getPackageId, packageIds)
|
|
|
|
+ );
|
|
|
|
+ Map<String, List<WmScorePackageStatus>> packageStatusGroupMap = scorePackageStatusList.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(WmScorePackageStatus::getPackageId));
|
|
|
|
+
|
|
|
|
+ //获取上级包
|
|
|
|
+ Set<String> parentPackageIds = scorePackageList.stream().map(WmScorePackage::getRelationScoreId).collect(Collectors.toSet());
|
|
|
|
+ List<WmScorePackage> parentPackages = wmScorePackageMapper.selectList(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
+ .in(WmScorePackage::getId, parentPackageIds));
|
|
|
|
+ Map<String, WmScorePackage> parentPackageNameMap = parentPackages.stream()
|
|
|
|
+ .collect(Collectors.toMap(WmScorePackage::getId, Function.identity()));
|
|
|
|
+
|
|
|
|
+ // 类型标签
|
|
|
|
+ List<SysDictItem> dictItems = sysDictItemService.list(Wrappers.<SysDictItem>lambdaQuery()
|
|
|
|
+ .in(SysDictItem::getType, "package_type1", "package_type2"));
|
|
|
|
+ Map<String, List<SysDictItem>> dictItemMap = dictItems.stream().collect(Collectors.groupingBy(SysDictItem::getType));
|
|
|
|
+ List<SysDictItem> packageType1List = dictItemMap.get("package_type1");
|
|
|
|
+ List<SysDictItem> packageType2List = dictItemMap.get("package_type2");
|
|
|
|
+
|
|
|
|
+ // todo
|
|
|
|
+ // 结算记录
|
|
|
|
+ //List<WmScorePackageSettleNote> noteList = settleNoteMapper.selectList(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
+ // .in(WmScorePackageSettleNote::getPackageId, packageIds));
|
|
|
|
+ //Map<String, List<WmScorePackageSettleNote>> noteMap = noteList.stream()
|
|
|
|
+ // .collect(Collectors.groupingBy(WmScorePackageSettleNote::getPackageId));
|
|
|
|
+
|
|
|
|
+ // 有效任务类型
|
|
|
|
+ List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(String.join(",", packageIds));
|
|
|
|
+ Map<String, List<WmScoreTaskType>> taskTypeMap = taskTypeList.stream().collect(Collectors.groupingBy(WmScoreTaskType::getScoreId));
|
|
|
|
+
|
|
|
|
+ List<WmScorePackageExcelModel> excelModelList = new ArrayList<>(scorePackageList.size());
|
|
|
|
+ for (int i = 0; i < scorePackageList.size(); i++) {
|
|
|
|
+ WmScorePackage wmScorePackage = scorePackageList.get(i);
|
|
|
|
+ log.info("====> 积分包SN:{}", wmScorePackage.getPackageSn());
|
|
|
|
+
|
|
|
|
+ List<WmTask> tasks = taskGoupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ List<WmScorePackageStatus> statuses = packageStatusGroupMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ // todo
|
|
|
|
+ //List<WmScorePackageSettleNote> notes = noteMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ //List<WmScoreTaskType> scoreTaskTypes = taskTypeMap.getOrDefault(wmScorePackage.getId(), new ArrayList<>());
|
|
|
|
+ //
|
|
|
|
+ //wmScorePackageService.buildScorePackageSync(wmScorePackage, packageType1, packageType2, tasks, statuses,
|
|
|
|
+ // packageType1List, packageType2List, parentPackageNameMap, notes, scoreTaskTypes);
|
|
|
|
+
|
|
|
|
+ WmScorePackageExcelModel excelModel = BeanUtil.copyProperties(wmScorePackage, WmScorePackageExcelModel.class);
|
|
|
|
+ if (StrUtil.isNotBlank(wmScorePackage.getScorePackageStatus())) {
|
|
|
|
+ excelModel.setScorePackageStatus(Objects.requireNonNull(ScorePackageStatusEnum.getByVal(wmScorePackage.getScorePackageStatus())).getDesc());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(wmScorePackage.getUserList())) {
|
|
|
|
+ excelModel.setUserNames(String.join(",", wmScorePackage.getUserList()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String typeid = wmScorePackage.getTypeid();
|
|
|
|
+ if (StrUtil.isNotBlank(typeid)) {
|
|
|
|
+ excelModel.setTypeidName("3".equals(typeid) ? "全职学术信息沟通专员" :
|
|
|
|
+ "4".equals(typeid) ? "兼职学术信息沟通专员" : "5".equals(typeid) ? "招商经理" : typeid);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ excelModel.setNumber(String.valueOf(i + 1));
|
|
|
|
+ if (wmScorePackage.getYshtt() != null) {
|
|
|
|
+ excelModel.setFinishRate(String.valueOf(wmScorePackage.getYshtt()));
|
|
|
|
+ }
|
|
|
|
+ excelModel.setPayScore(wmScorePackage.getShtg());
|
|
|
|
+ if (wmScorePackage.getShtgtt() != null) {
|
|
|
|
+ excelModel.setPayRate(String.valueOf(wmScorePackage.getShtgtt()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ excelModelList.add(excelModel);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ log.info("build积分包耗时:{}", System.currentTimeMillis() - buildStartMillis);
|
|
|
|
+
|
|
|
|
+ return excelModelList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 个人承接积分值-其他导出
|
|
|
|
+ *
|
|
|
|
+ * @param acceptUser 接单对象,模糊查询
|
|
|
|
+ */
|
|
|
|
+ @ResponseExcel(name = "exportPackageSettle", sheet = "个人承接积分值-其他导出")
|
|
|
|
+ @SysLog("个人承接积分值-其他导出")
|
|
|
|
+ @GetMapping("/export-score-package-mah")
|
|
|
|
+ public List<WmScorePackageExcelModel> exportPackageSettleForMah(
|
|
|
|
+ @RequestParam(value = "packageType1") Integer packageType1,
|
|
|
|
+ @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
+ @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
+ @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
+ @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
+ @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
+ @RequestParam(value = "monthEnd", required = false) String monthEnd,
|
|
|
|
+ @RequestParam(value = "acceptUser", required = false) String acceptUser,
|
|
|
|
+ @RequestParam(value = "relationScoreId", required = false) String relationScoreId,
|
|
|
|
+ @RequestParam(value = "toApproval", required = false) Boolean toApproval
|
|
|
|
+ ) {
|
|
|
|
+
|
|
|
|
+ Integer sendDeptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
+
|
|
|
|
+ return this.exportPackageSettleForMahForBC(packageType1, packageType2, sendDeptId, scorePackageName, scorePackageStatus,
|
|
|
|
+ typeId, monthStart, monthEnd, acceptUser, relationScoreId, toApproval);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 积分包列表(结算包管理列表、无团队限制)
|
|
|
|
+ *
|
|
|
|
+ * @param packageType1 多个逗号分隔
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/page-settle-package")
|
|
|
|
+ public R<?> pageSettlePackage(@RequestParam(value = "current") Integer current,
|
|
|
|
+ @RequestParam(value = "size") Integer size,
|
|
|
|
+ @RequestParam(value = "packageType1") String packageType1,
|
|
|
|
+ @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
+ @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
+ @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
+ @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
+ @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
+ @RequestParam(value = "monthEnd", required = false) String monthEnd
|
|
|
|
+ ) {
|
|
|
|
+
|
|
|
|
+ Integer sendDeptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
+ Integer userId = SecurityUtils.getUser().getId();
|
|
|
|
+
|
|
|
|
+ LocalDateTime start = null;
|
|
|
|
+ LocalDateTime end = null;
|
|
|
|
+
|
|
|
|
+ if (StrUtil.isNotEmpty(monthStart) && StrUtil.isNotEmpty(monthEnd)) {
|
|
|
|
+ start = LocalDateTime.of(LocalDate.parse(monthStart + "-01", DatePattern.NORM_DATE_FORMATTER), LocalTime.MIN);
|
|
|
|
+ LocalDate e = LocalDate.parse(monthEnd + "-01", DatePattern.NORM_DATE_FORMATTER);
|
|
|
|
+ end = LocalDateTime.of(e.with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ LambdaQueryWrapper<WmScorePackage> queryWrapper = Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
+ .eq(WmScorePackage::getPackageType2, packageType2)
|
|
|
|
+ .like(StrUtil.isNotEmpty(scorePackageName), WmScorePackage::getScorePackageName, scorePackageName)
|
|
|
|
+ .eq(scorePackageStatus != null, WmScorePackage::getScorePackageStatus, scorePackageStatus)
|
|
|
|
+ .eq(WmScorePackage::getSendPackageDeptId, sendDeptId)
|
|
|
|
+ .between(start != null && end != null, WmScorePackage::getCreateTime, start, end);
|
|
|
|
+
|
|
|
|
+ List<String> packageType1List = StrUtil.split(packageType1, StrUtil.COMMA);
|
|
|
|
+ if (StrUtil.contains(packageType1, StrUtil.COMMA)) {
|
|
|
|
+ queryWrapper.in(WmScorePackage::getPackageType1, packageType1List);
|
|
|
|
+ } else {
|
|
|
|
+ queryWrapper.eq(WmScorePackage::getPackageType1, packageType1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (StringUtil.isEmpty(typeId)) {
|
|
|
|
+ queryWrapper.in(WmScorePackage::getTypeid, "3", "4");
|
|
|
|
+ } else {
|
|
|
|
+ List<String> split = StrUtil.split(typeId, StrUtil.COMMA);
|
|
|
|
+ queryWrapper.in(WmScorePackage::getTypeid, split);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //queryWrapper.ne(WmScorePackage::getLocation, SubjectLocation.MAH_SETTLE);
|
|
|
|
+
|
|
|
|
+ Page<WmScorePackage> wmScorePackagePage = wmScorePackageMapper.selectPage(new Page<>(current, size), queryWrapper
|
|
|
|
+ .orderByDesc(WmScorePackage::getCreateTime));
|
|
|
|
+
|
|
|
|
+ List<WmScorePackage> pageRecords = wmScorePackagePage.getRecords();
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(pageRecords)) {
|
|
// List<Future<WmScorePackage>> futureList = new ArrayList<>(pageRecords.size());
|
|
// List<Future<WmScorePackage>> futureList = new ArrayList<>(pageRecords.size());
|
|
|
|
|
|
- for (WmScorePackage scorePackage : pageRecords) {
|
|
|
|
- if (packageType2 == 2) {
|
|
|
|
-
|
|
|
|
- // todo
|
|
|
|
- //int wsNum = settleNoteMapper.selectCount(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
- // .eq(WmScorePackageSettleNote::getPackageId, scorePackage.getId())
|
|
|
|
- // .in(WmScorePackageSettleNote::getSettleNoteStatus, 2, 9));
|
|
|
|
- //int asNum = settleNoteMapper.selectCount(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
- // .eq(WmScorePackageSettleNote::getPackageId, scorePackage.getId())
|
|
|
|
- // .eq(WmScorePackageSettleNote::getSettleNoteStatus, 1));
|
|
|
|
- //scorePackage.setWsTaskNum(wsNum);
|
|
|
|
- //scorePackage.setAsTaskNum(asNum);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (PackageTypeEnum.TYPE1_HCP_PACKAGE.getName().equals(scorePackage.getPackageType1())) {
|
|
|
|
- // 如果是患者教育,则转换积分值 '分'-> '元'
|
|
|
|
- Integer score = scorePackage.getScore();
|
|
|
|
- String userScore = scorePackage.getUserScore();
|
|
|
|
- if (org.apache.commons.lang3.StringUtils.isNumeric(userScore)) {
|
|
|
|
- scorePackage.setUserScore(String.format("%.2f", Integer.parseInt(userScore) / 100.0));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(scorePackage.getId());
|
|
|
|
- if (CollUtil.isNotEmpty(taskTypeList)) {
|
|
|
|
- String taskTypes = taskTypeList.stream().map(
|
|
|
|
- WmScoreTaskType::getTaskTypeName).collect(Collectors.joining(","));
|
|
|
|
- scorePackage.setTaskTypes(taskTypes);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok(wmScorePackagePage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 结算包结算管理页面-其他(用于MAH结算)
|
|
|
|
- *
|
|
|
|
- * @param packageType1 多个逗号分隔
|
|
|
|
- */
|
|
|
|
- @GetMapping("/page-mah-settle-package")
|
|
|
|
- public R<?> pageMahSettlePackage(@RequestParam(value = "current") Integer current,
|
|
|
|
- @RequestParam(value = "size") Integer size,
|
|
|
|
- @RequestParam(value = "packageType1") String packageType1,
|
|
|
|
- @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
- @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
- @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
- @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
- @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
- @RequestParam(value = "monthEnd", required = false) String monthEnd
|
|
|
|
- ) {
|
|
|
|
-
|
|
|
|
- Integer sendDeptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
-
|
|
|
|
- LocalDateTime start = null;
|
|
|
|
- LocalDateTime end = null;
|
|
|
|
-
|
|
|
|
- if (StrUtil.isNotEmpty(monthStart) && StrUtil.isNotEmpty(monthEnd)) {
|
|
|
|
- start = LocalDateTime.of(LocalDate.parse(monthStart + "-01", DatePattern.NORM_DATE_FORMATTER), LocalTime.MIN);
|
|
|
|
- LocalDate e = LocalDate.parse(monthEnd + "-01", DatePattern.NORM_DATE_FORMATTER);
|
|
|
|
- end = LocalDateTime.of(e.with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- LambdaQueryWrapper<WmScorePackage> queryWrapper = Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
- .eq(WmScorePackage::getPackageType2, packageType2)
|
|
|
|
- .like(StrUtil.isNotEmpty(scorePackageName), WmScorePackage::getScorePackageName, scorePackageName)
|
|
|
|
- .eq(scorePackageStatus != null, WmScorePackage::getScorePackageStatus, scorePackageStatus)
|
|
|
|
- .eq(WmScorePackage::getMahSettleDeptId, sendDeptId)
|
|
|
|
- .eq(WmScorePackage::getMahSettleStep, UpmsType.MahSettleStep.FINANCE.getType())
|
|
|
|
- .between(start != null && end != null, WmScorePackage::getCreateTime, start, end);
|
|
|
|
-
|
|
|
|
- List<String> packageType1List = StrUtil.split(packageType1, StrUtil.COMMA);
|
|
|
|
- if (StrUtil.contains(packageType1, StrUtil.COMMA)) {
|
|
|
|
- queryWrapper.in(WmScorePackage::getPackageType1, packageType1List);
|
|
|
|
- } else {
|
|
|
|
- queryWrapper.eq(WmScorePackage::getPackageType1, packageType1);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (StringUtil.isEmpty(typeId)) {
|
|
|
|
- queryWrapper.in(WmScorePackage::getTypeid, "3", "4");
|
|
|
|
- } else {
|
|
|
|
- List<String> split = StrUtil.split(typeId, StrUtil.COMMA);
|
|
|
|
- queryWrapper.in(WmScorePackage::getTypeid, split);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- queryWrapper.eq(WmScorePackage::getLocation, SubjectLocation.MAH_SETTLE);
|
|
|
|
-
|
|
|
|
- Page<WmScorePackage> wmScorePackagePage = wmScorePackageMapper.selectPage(new Page<>(current, size), queryWrapper
|
|
|
|
- .orderByDesc(WmScorePackage::getCreateTime));
|
|
|
|
-
|
|
|
|
- List<WmScorePackage> pageRecords = wmScorePackagePage.getRecords();
|
|
|
|
-
|
|
|
|
- if (CollUtil.isNotEmpty(pageRecords)) {
|
|
|
|
-
|
|
|
|
- for (WmScorePackage scorePackage : pageRecords) {
|
|
|
|
- if (packageType2 == 2) {
|
|
|
|
-
|
|
|
|
- // todo
|
|
|
|
- //int wsNum = settleNoteMapper.selectCount(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
- // .eq(WmScorePackageSettleNote::getPackageId, scorePackage.getId())
|
|
|
|
- // .in(WmScorePackageSettleNote::getSettleNoteStatus, 2, 9));
|
|
|
|
- //int asNum = settleNoteMapper.selectCount(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
- // .eq(WmScorePackageSettleNote::getPackageId, scorePackage.getId())
|
|
|
|
- // .eq(WmScorePackageSettleNote::getSettleNoteStatus, 1));
|
|
|
|
- //scorePackage.setWsTaskNum(wsNum);
|
|
|
|
- //scorePackage.setAsTaskNum(asNum);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (PackageTypeEnum.TYPE1_HCP_PACKAGE.getName().equals(scorePackage.getPackageType1())) {
|
|
|
|
- // 如果是患者教育,则转换积分值 '分'-> '元'
|
|
|
|
- String userScore = scorePackage.getUserScore();
|
|
|
|
- if (org.apache.commons.lang3.StringUtils.isNumeric(userScore)) {
|
|
|
|
- scorePackage.setUserScore(String.format("%.2f", Integer.parseInt(userScore) / 100.0));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(scorePackage.getId());
|
|
|
|
- if (CollUtil.isNotEmpty(taskTypeList)) {
|
|
|
|
- String taskTypes = taskTypeList.stream().map(
|
|
|
|
- WmScoreTaskType::getTaskTypeName).collect(Collectors.joining(","));
|
|
|
|
- scorePackage.setTaskTypes(taskTypes);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok(wmScorePackagePage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 根据id查询积分包信息
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return 积分包信息
|
|
|
|
- */
|
|
|
|
- @GetMapping("/getScorePackagePageById")
|
|
|
|
- public R<?> getScorePackagePageById(WmScorePackage wmScorePackage) {
|
|
|
|
- return wmScorePackageService.getScorePackagePageById(wmScorePackage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 新增积分包
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return R
|
|
|
|
- */
|
|
|
|
- @SysLog("新增积分包(小包)")
|
|
|
|
- @PostMapping("/addWmScorePackage")
|
|
|
|
- public R<?> addWmScorePackage(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
- log.info("新增积分包(小包)入参:{}", wmScorePackage);
|
|
|
|
- //定额
|
|
|
|
- if (wmScorePackage.getPackageType1().equals("1")) {
|
|
|
|
- if (wmScorePackage.getScore() <= 0) {
|
|
|
|
- return R.failed("积分包分值必须大于0");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (StrUtil.isBlank(wmScorePackage.getPackageSn())) {
|
|
|
|
- return R.failed("积分包序列号必填");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (StrUtil.isNotBlank(wmScorePackage.getSubjectLocation())) {
|
|
|
|
- SubjectLocation location = Enum.valueOf(SubjectLocation.class, wmScorePackage.getSubjectLocation());
|
|
|
|
- wmScorePackage.setLocation(location);
|
|
|
|
- wmScorePackage.setSubType(String.valueOf(location.getGigType().getCode()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return wmScorePackageService.addWmScorePackage(wmScorePackage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @SysLog("修改积分包--删除、结算")
|
|
|
|
- @PostMapping("/updateEasy")
|
|
|
|
- public R updateEasy(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
-
|
|
|
|
- return wmScorePackageService.updateEasy(wmScorePackage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 更新积分包信息
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 积分包信息
|
|
|
|
- * @return 更新结果
|
|
|
|
- */
|
|
|
|
- @SysLog("修改积分包(小包)")
|
|
|
|
- @PostMapping("/updateWmScorePackage")
|
|
|
|
- public R<?> updateWmScorePackage(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
-
|
|
|
|
- log.info("修改积分包(小包)入参:{}", wmScorePackage);
|
|
|
|
-
|
|
|
|
- if (StrUtil.isBlank(wmScorePackage.getId())) {
|
|
|
|
- return R.failed("积分包id必填");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //定额
|
|
|
|
- if (wmScorePackage.getPackageType1().equals("1") && wmScorePackage.getScore() <= 0) {
|
|
|
|
- return R.failed("积分包分值必须大于0");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 被领取的积分包 不能修改
|
|
|
|
- int total = wmScorePackageStatusService.count(Wrappers.<WmScorePackageStatus>lambdaQuery().eq(WmScorePackageStatus::getPackageId, wmScorePackage.getId()).in(WmScorePackageStatus::getStatus, "1", "2"));
|
|
|
|
- if (total > 0) {
|
|
|
|
- return R.failed("积分包已被领取,不能修改");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 校验重名
|
|
|
|
- if (StrUtil.isNotBlank(wmScorePackage.getScorePackageName())) {
|
|
|
|
-
|
|
|
|
- long existed = wmScorePackageService.count(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
- .eq(WmScorePackage::getDelFlag, "0")
|
|
|
|
- .eq(WmScorePackage::getDeptId, wmScorePackage.getDeptId())
|
|
|
|
- .eq(WmScorePackage::getScorePackageName, wmScorePackage.getScorePackageName())
|
|
|
|
- .ne(WmScorePackage::getId, wmScorePackage.getId()));
|
|
|
|
- if (existed != 0) {
|
|
|
|
- return R.failed("积分包名称已存在");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return wmScorePackageService.updateWmScorePackage(wmScorePackage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 终止积分包(个人包)
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 参数
|
|
|
|
- * @return 结果
|
|
|
|
- */
|
|
|
|
- @SysLog("终止积分包(个人包)")
|
|
|
|
- @GetMapping("/updateEnable")
|
|
|
|
- public R<?> terminatePackageForPersonal(WmScorePackage wmScorePackage) {
|
|
|
|
- log.info("终止积分包(个人包)入参:{}", wmScorePackage);
|
|
|
|
- if (!StrUtil.equalsAny(wmScorePackage.getEnableType(), "1", "2") || StrUtil.isBlank(wmScorePackage.getId())) {
|
|
|
|
- return R.failed("参数错误");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- String cacheKey = CacheConstants.TERMINATE_PACKAGE_KEY + wmScorePackage.getId();
|
|
|
|
- Boolean absent = redisTemplate.opsForValue().setIfAbsent(cacheKey, JSONUtil.toJsonStr(wmScorePackage), 3L, TimeUnit.SECONDS);
|
|
|
|
- if (Boolean.FALSE.equals(absent)) {
|
|
|
|
- return R.failed("正在处理");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 查询积分包
|
|
|
|
- WmScorePackage scorePackage = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
-
|
|
|
|
- // 只有个人承接/多人承接积分包走这个逻辑, 其他的包走原有逻辑
|
|
|
|
- if (PackageTypeEnum.TYPE1_SCOTE_PACKAGE.val().equals(scorePackage.getPackageType1())
|
|
|
|
- || PackageTypeEnum.TYPE1_SCORE_AND_TASK_PACKAGE.val().equals(scorePackage.getPackageType1())) {
|
|
|
|
- return R.ok(wmScorePackageService.terminatePackageForPersonal(wmScorePackage.getId(),
|
|
|
|
- UpmsType.TerminatePackageType.getByEnableType(wmScorePackage.getEnableType())));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return wmScorePackageService.updateEnable(scorePackage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 查询已完成积分值
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @GetMapping("/selectSettleStatus")
|
|
|
|
- public Map<String, Object> selectSettleStatus(WmScorePackage wmScorePackage) {
|
|
|
|
- return wmScorePackageService.selectSettleStatus(wmScorePackage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 查询发包对象
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @GetMapping("/selectSendPackageDeptId")
|
|
|
|
- public List<SysDept> selectSendPackageDeptId(WmScorePackage wmScorePackage) {
|
|
|
|
- return wmScorePackageService.selectSendPackageDeptId(wmScorePackage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 查询发包对象
|
|
|
|
- *
|
|
|
|
- * @param wmScorePackage 积分包
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @GetMapping("/selectRelationScoreIdList")
|
|
|
|
- public WmScorePackage selectRelationScoreIdList(WmScorePackage wmScorePackage) {
|
|
|
|
- return wmScorePackageService.selectRelationScoreIdList(wmScorePackage);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取当前部门的基于所有积分包的相关信息
|
|
|
|
- *
|
|
|
|
- * @return 积分包的相关信息
|
|
|
|
- */
|
|
|
|
- @GetMapping("/getDeptScorePackageInfo")
|
|
|
|
- public R<?> getDeptScorePackageInfo() {
|
|
|
|
- Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
- Map<String, Object> result = wmScorePackageService.getDeptScorePackageInfo(deptId);
|
|
|
|
- return R.ok(result);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取积分包关联企业的药品列表
|
|
|
|
- *
|
|
|
|
- * @param page 分页信息
|
|
|
|
- * @param packageId 积分包id
|
|
|
|
- * @param drugName 药品名称
|
|
|
|
- * @return 药品列表
|
|
|
|
- */
|
|
|
|
- @SysLog("获取积分包关联企业的药品列表")
|
|
|
|
- @GetMapping(value = "/drugs")
|
|
|
|
- public R<?> listDrugsByPackageId(Page<WmDaDrugEntDrugtable> page,
|
|
|
|
- @RequestParam(value = "packageId") Integer packageId,
|
|
|
|
- @RequestParam(value = "name", required = false) String drugName) {
|
|
|
|
- return R.ok(wmScorePackageService.listDrugsByPackageId(page, packageId, drugName.trim()));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // ~ 批量下发积分包 ===================================================================================================
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取最近的记录
|
|
|
|
- *
|
|
|
|
- * @return 最近记录
|
|
|
|
- */
|
|
|
|
- @GetMapping(value = "/batch/history")
|
|
|
|
- public R<?> getBatchHistory() {
|
|
|
|
- HnqzUser user = SecurityUtils.getUser();
|
|
|
|
-
|
|
|
|
- // 缓存记录key
|
|
|
|
- String key = String.format(CacheConstants.BATCH_PACKAGE_HISTORY, user.getDeptId(), user.getId());
|
|
|
|
-
|
|
|
|
- String result = redisTemplate.opsForValue().get(key);
|
|
|
|
-
|
|
|
|
- if (StrUtil.isNotEmpty(result) && JSONUtil.isJson(result)) {
|
|
|
|
- JSONObject jsonObject = JSONUtil.parseObj(result);
|
|
|
|
- return R.ok(jsonObject);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 批量导入积分包
|
|
|
|
- *
|
|
|
|
- * @param batchPackageExcelModels 积分包信息文件
|
|
|
|
- * @param scorePackage 积分包创建信息
|
|
|
|
- * @return success/false
|
|
|
|
- */
|
|
|
|
- @SysLog("批量导入积分包")
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
- @PostMapping(value = "/batch")
|
|
|
|
- public R<?> batchCreatePackage(@RequestExcel(fileName = "excel", ignoreEmptyRow = true) List<BatchPackageExcelModel> batchPackageExcelModels,
|
|
|
|
- @RequestPart(value = "history") WmScorePackage scorePackage) {
|
|
|
|
-
|
|
|
|
- HnqzUser user = SecurityUtils.getUser();
|
|
|
|
-
|
|
|
|
- // 加锁防止多处理
|
|
|
|
-
|
|
|
|
- String lock = "lock:package:batch:" + user.getDeptId();
|
|
|
|
-
|
|
|
|
- if (!redisTemplate.opsForValue().setIfAbsent(lock, IdUtil.fastUUID())) {
|
|
|
|
- return R.failed("有在途的操作,请稍后");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- log.warn("==========================================批量导入积分包-插入redis:开始=====================================================");
|
|
|
|
- // 获取操作人
|
|
|
|
- // 记录历史信息
|
|
|
|
- // 缓存记录key
|
|
|
|
- String key = String.format(CacheConstants.BATCH_PACKAGE_HISTORY, user.getDeptId(), user.getId());
|
|
|
|
- Map<String, Object> history = new HashMap<>(2);
|
|
|
|
- scorePackage.setCreateTime(null);
|
|
|
|
- scorePackage.setUpdateTime(null);
|
|
|
|
- JSONObject jsonObject = JSONUtil.parseObj(scorePackage);
|
|
|
|
- jsonObject.set("relatedService", Integer.parseInt(scorePackage.getRelatedService()));
|
|
|
|
- history.put("history", jsonObject);
|
|
|
|
- history.put("timestamp", DateTimeFormatter.ofPattern(DatePattern.CHINESE_DATE_TIME_PATTERN).format(LocalDateTime.now()));
|
|
|
|
- redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(history));
|
|
|
|
-
|
|
|
|
- log.warn("==========================================批量导入积分包-插入redis:结束=====================================================");
|
|
|
|
-
|
|
|
|
- log.warn("==========================================批量导入积分包:开始=====================================================");
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- Multimap<String, Object> errorMap = ArrayListMultimap.create();
|
|
|
|
-
|
|
|
|
- TargetType targetType = null;
|
|
|
|
-
|
|
|
|
- // 全职
|
|
|
|
- if (StrUtil.equals("3", scorePackage.getTypeid())) {
|
|
|
|
- targetType = TargetType.FULL_TIME;
|
|
|
|
- }
|
|
|
|
- // 兼职
|
|
|
|
- else if (StrUtil.equals("4", scorePackage.getTypeid())) {
|
|
|
|
- targetType = TargetType.PART_TIME;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 重复的模型
|
|
|
|
- Map<String, List<BatchPackageExcelModel>> dupNameModel = batchPackageExcelModels.stream()
|
|
|
|
- .collect(Collectors.groupingBy(BatchPackageExcelModel::getScorePackageName));
|
|
|
|
- List<String> names = batchPackageExcelModels.stream().map(BatchPackageExcelModel::getScorePackageName).collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- for (Map.Entry<String, List<BatchPackageExcelModel>> entry : dupNameModel.entrySet()) {
|
|
|
|
- String name = entry.getKey();
|
|
|
|
- int size = entry.getValue().size();
|
|
|
|
- if (size > 1) {
|
|
|
|
- List<Integer> index = new ArrayList<>(size);
|
|
|
|
- List<String> temp = new ArrayList<>(names);
|
|
|
|
- Iterator<String> iterator = temp.iterator();
|
|
|
|
- while (iterator.hasNext()) {
|
|
|
|
- int idx = temp.lastIndexOf(name);
|
|
|
|
- if (idx != -1) {
|
|
|
|
- index.add(idx + 1);
|
|
|
|
- temp.remove(idx);
|
|
|
|
- } else {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- errorMap.put("模板内积分包名称重复", index.stream().sorted().collect(Collectors.toList()));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 业务校验
|
|
|
|
- for (int i = 0, batchScoreTotal = 0, rows = batchPackageExcelModels.size(); i < rows; i++) {
|
|
|
|
-
|
|
|
|
- batchScoreTotal += checkColumn(batchPackageExcelModels.get(i), targetType, errorMap, i + 1, user.getDeptId());
|
|
|
|
-
|
|
|
|
- // 额外校验可分配积分包
|
|
|
|
- if (!"-1".equals(scorePackage.getRelationScoreId()) && batchScoreTotal > (scorePackage.getKfpjf() == null ? 0 : scorePackage.getKfpjf())) {
|
|
|
|
- errorMap.put("批量下发总值大于可分配值", i + 1);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 存在错误全表打回
|
|
|
|
- if (!errorMap.isEmpty()) {
|
|
|
|
-
|
|
|
|
- List<Map<String, Object>> resultList = new ArrayList<>(errorMap.size());
|
|
|
|
- Map<String, Collection<Object>> asMap = errorMap.asMap();
|
|
|
|
-
|
|
|
|
- for (Map.Entry<String, Collection<Object>> entry : asMap.entrySet()) {
|
|
|
|
-
|
|
|
|
- Map<String, Object> m = new HashMap<>(2);
|
|
|
|
-
|
|
|
|
- m.put("reason", entry.getKey());
|
|
|
|
-
|
|
|
|
- m.put("line", entry.getValue());
|
|
|
|
- resultList.add(m);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return R.ok(resultList);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (BatchPackageExcelModel model : batchPackageExcelModels) {
|
|
|
|
-
|
|
|
|
- scorePackage.setScore(Integer.parseInt(model.getScore()));
|
|
|
|
- scorePackage.setScorePackageName(model.getScorePackageName());
|
|
|
|
- scorePackage.setDescription(model.getDescription());
|
|
|
|
- scorePackage.setUserList(StrUtil.isEmpty(model.getTargetId()) ? new ArrayList<>(1) :
|
|
|
|
- Collections.singletonList(model.getTargetId()));
|
|
|
|
- scorePackage.setPackageSn("PKG" + pkgSequence.nextNo());
|
|
|
|
-
|
|
|
|
- wmScorePackageService.addWmScorePackage(scorePackage);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- } finally {
|
|
|
|
- log.warn("==========================================批量导入积分包:结束=====================================================");
|
|
|
|
- redisTemplate.delete(lock);
|
|
|
|
- }
|
|
|
|
- return R.ok();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 校验model
|
|
|
|
- *
|
|
|
|
- * @param model model
|
|
|
|
- * @param targetType 接包人类型
|
|
|
|
- * @param errorMap 收集错误map
|
|
|
|
- * @param row 所在行
|
|
|
|
- * @param deptId 所属企业
|
|
|
|
- */
|
|
|
|
- private Integer checkColumn(BatchPackageExcelModel model, TargetType targetType,
|
|
|
|
- Multimap<String, Object> errorMap, Integer row, Integer deptId) {
|
|
|
|
-
|
|
|
|
- log.warn("==========================================校验批量下发积分包model:开始=====================================================");
|
|
|
|
-
|
|
|
|
- // 校验类型
|
|
|
|
- log.info("[{}]", model.getTargetType());
|
|
|
|
- if (!targetType.getDesc().equals(model.getTargetType())) {
|
|
|
|
- errorMap.put("接单对象类型不匹配", row);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 校验是否同名
|
|
|
|
- log.info("[{}]", model.getScorePackageName());
|
|
|
|
- if (StrUtil.isNotEmpty(model.getScorePackageName())) {
|
|
|
|
- int count = wmScorePackageService.count(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
- .eq(WmScorePackage::getScorePackageName, model.getScorePackageName()));
|
|
|
|
-
|
|
|
|
- if (count != 0) {
|
|
|
|
- errorMap.put("积分包重名了", row);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 校验积分制是否为空
|
|
|
|
- log.info("[{}]", model.getScore());
|
|
|
|
- if (StrUtil.isEmpty(model.getScore())) {
|
|
|
|
- errorMap.put("积分值未填", row);
|
|
|
|
- } else {
|
|
|
|
- // 校验是否是数字
|
|
|
|
- if (!Validator.isNumber(model.getScore())) {
|
|
|
|
- errorMap.put("积分值不是数字", row);
|
|
|
|
- } else if (model.getScore().contains(StrUtil.DOT) || Integer.parseInt(model.getScore()) <= 0) {
|
|
|
|
- errorMap.put("积分值必须是正整数", row);
|
|
|
|
- model.setScore("0");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 全职校验
|
|
|
|
- if (TargetType.FULL_TIME.equals(targetType)) {
|
|
|
|
-
|
|
|
|
- // 校验名称是否为空
|
|
|
|
- log.info("[{}]", model.getTargetName());
|
|
|
|
- if (StrUtil.isEmpty(model.getTargetName())) {
|
|
|
|
- errorMap.put("接单人姓名未填", row);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 校验名称是否为空,是否是企业下的人
|
|
|
|
- log.info("[{}]", model.getMobile());
|
|
|
|
- if (StrUtil.isEmpty(model.getMobile())) {
|
|
|
|
- errorMap.put("接单人手机号未填", row);
|
|
|
|
- } else {
|
|
|
|
- if (!Validator.isMobile(model.getMobile())) {
|
|
|
|
- errorMap.put("手机号格式不争取", row);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 校验是否是企业下的
|
|
|
|
- List<SysUser> target = sysUserService.list(Wrappers.<SysUser>lambdaQuery()
|
|
|
|
- .eq(SysUser::getRealname, model.getTargetName())
|
|
|
|
- .eq(SysUser::getUsername, model.getMobile())
|
|
|
|
- .eq(SysUser::getDeptId, deptId)
|
|
|
|
- .eq(SysUser::getDelFlag, CommonConstants.STATUS_NORMAL)
|
|
|
|
- .eq(SysUser::getLockFlag, CommonConstants.STATUS_NORMAL)
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- if (CollUtil.isEmpty(target) || target.size() > 1) {
|
|
|
|
- errorMap.put("查无此人", row);
|
|
|
|
- } else {
|
|
|
|
- model.setTargetId(String.valueOf(target.get(0).getUserId()));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // 兼职校验
|
|
|
|
- else {
|
|
|
|
- // 校验名称是否为空
|
|
|
|
- log.info("MOBILE: [{}], NAME: [{}]", model.getTargetName(), model.getTargetName());
|
|
|
|
- if (StrUtil.isNotEmpty(model.getTargetName()) || StrUtil.isNotEmpty(model.getMobile())) {
|
|
|
|
- errorMap.put("请勿使用全职模板", row);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- log.warn("==========================================校验批量下发积分包model:开始=====================================================");
|
|
|
|
- return Integer.parseInt(model.getScore());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 拆包
|
|
|
|
- *
|
|
|
|
- * @param unpackDTO 拆包参数
|
|
|
|
- * @return 拆包结果
|
|
|
|
- */
|
|
|
|
- @SysLog("拆包")
|
|
|
|
- @PostMapping("/unpack")
|
|
|
|
- public R<?> unpack(@Validated @RequestBody UnpackDTO unpackDTO) {
|
|
|
|
- log.info("======================================拆包开始执行===================================");
|
|
|
|
- log.info("拆包请求参数:{}", unpackDTO);
|
|
|
|
-
|
|
|
|
- Boolean unpack = wmScorePackageService.unpack(unpackDTO);
|
|
|
|
-
|
|
|
|
- log.info("======================================拆包执行完成===================================");
|
|
|
|
- return R.ok(unpack);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 积分包结算管理-发票上传
|
|
|
|
- *
|
|
|
|
- * @param param 发票参数
|
|
|
|
- * @return {@link R}<{@link ?}> 结果
|
|
|
|
- */
|
|
|
|
- @SysLog("积分包结算管理-发票上传")
|
|
|
|
- @PostMapping("/upload-invoice")
|
|
|
|
- public R<?> uploadInvoice(@RequestBody WmScorePackageSettleOutput param) {
|
|
|
|
- log.info("积分包结算管理-发票上传参数:{}", param);
|
|
|
|
- if (StrUtil.isBlank(param.getId()) || StrUtil.isBlank(param.getInvoiceNumber()) || ArrayUtil.isEmpty(param.getInvoiceFile())) {
|
|
|
|
- return R.failed("必填参数为空");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- WmScorePackage update = new WmScorePackage();
|
|
|
|
- update.setId(param.getId());
|
|
|
|
- update.setInvoiceNumber(param.getInvoiceNumber());
|
|
|
|
- update.setInvoiceFile(param.getInvoiceFile());
|
|
|
|
- update.setUpdateTime(LocalDateTime.now());
|
|
|
|
- update.setUpdateUser(SecurityUtils.getUser().getId());
|
|
|
|
-
|
|
|
|
- return R.ok(wmScorePackageService.updateById(update));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 重启积分包(默认延长1年)
|
|
|
|
- *
|
|
|
|
- * @param scorePackage 参数
|
|
|
|
- * @return 结果
|
|
|
|
- */
|
|
|
|
- @SysLog("重启积分包")
|
|
|
|
- @PostMapping("/restart")
|
|
|
|
- public R<?> restart(@RequestBody WmScorePackage scorePackage) {
|
|
|
|
- if (scorePackage.getId() == null) {
|
|
|
|
- return R.failed("积分包id必填");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- LocalDate now = LocalDate.now();
|
|
|
|
- WmScorePackage update = new WmScorePackage();
|
|
|
|
- update.setId(scorePackage.getId());
|
|
|
|
- if (scorePackage.getEndTime() != null) {
|
|
|
|
- update.setEndTime(scorePackage.getEndTime());
|
|
|
|
- } else {
|
|
|
|
- update.setEndTime(now.plusYears(1));
|
|
|
|
- }
|
|
|
|
- wmScorePackageService.updateById(update);
|
|
|
|
-
|
|
|
|
- return R.ok();
|
|
|
|
- }
|
|
|
|
|
|
+ for (WmScorePackage scorePackage : pageRecords) {
|
|
|
|
+ if (packageType2 == 2) {
|
|
|
|
+
|
|
|
|
+ // todo
|
|
|
|
+ //int wsNum = settleNoteMapper.selectCount(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
+ // .eq(WmScorePackageSettleNote::getPackageId, scorePackage.getId())
|
|
|
|
+ // .in(WmScorePackageSettleNote::getSettleNoteStatus, 2, 9));
|
|
|
|
+ //int asNum = settleNoteMapper.selectCount(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
+ // .eq(WmScorePackageSettleNote::getPackageId, scorePackage.getId())
|
|
|
|
+ // .eq(WmScorePackageSettleNote::getSettleNoteStatus, 1));
|
|
|
|
+ //scorePackage.setWsTaskNum(wsNum);
|
|
|
|
+ //scorePackage.setAsTaskNum(asNum);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (PackageTypeEnum.TYPE1_HCP_PACKAGE.getName().equals(scorePackage.getPackageType1())) {
|
|
|
|
+ // 如果是患者教育,则转换积分值 '分'-> '元'
|
|
|
|
+ Integer score = scorePackage.getScore();
|
|
|
|
+ String userScore = scorePackage.getUserScore();
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNumeric(userScore)) {
|
|
|
|
+ scorePackage.setUserScore(String.format("%.2f", Integer.parseInt(userScore) / 100.0));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(scorePackage.getId());
|
|
|
|
+ if (CollUtil.isNotEmpty(taskTypeList)) {
|
|
|
|
+ String taskTypes = taskTypeList.stream().map(
|
|
|
|
+ WmScoreTaskType::getTaskTypeName).collect(Collectors.joining(","));
|
|
|
|
+ scorePackage.setTaskTypes(taskTypes);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.ok(wmScorePackagePage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 结算包结算管理页面-其他(用于MAH结算)
|
|
|
|
+ *
|
|
|
|
+ * @param packageType1 多个逗号分隔
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/page-mah-settle-package")
|
|
|
|
+ public R<?> pageMahSettlePackage(@RequestParam(value = "current") Integer current,
|
|
|
|
+ @RequestParam(value = "size") Integer size,
|
|
|
|
+ @RequestParam(value = "packageType1") String packageType1,
|
|
|
|
+ @RequestParam(value = "packageType2") Integer packageType2,
|
|
|
|
+ @RequestParam(value = "scorePackageName", required = false) String scorePackageName,
|
|
|
|
+ @RequestParam(value = "scorePackageStatus", required = false) Integer scorePackageStatus,
|
|
|
|
+ @RequestParam(value = "typeid", required = false) String typeId,
|
|
|
|
+ @RequestParam(value = "monthStart", required = false) String monthStart,
|
|
|
|
+ @RequestParam(value = "monthEnd", required = false) String monthEnd
|
|
|
|
+ ) {
|
|
|
|
+
|
|
|
|
+ Integer sendDeptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
+
|
|
|
|
+ LocalDateTime start = null;
|
|
|
|
+ LocalDateTime end = null;
|
|
|
|
+
|
|
|
|
+ if (StrUtil.isNotEmpty(monthStart) && StrUtil.isNotEmpty(monthEnd)) {
|
|
|
|
+ start = LocalDateTime.of(LocalDate.parse(monthStart + "-01", DatePattern.NORM_DATE_FORMATTER), LocalTime.MIN);
|
|
|
|
+ LocalDate e = LocalDate.parse(monthEnd + "-01", DatePattern.NORM_DATE_FORMATTER);
|
|
|
|
+ end = LocalDateTime.of(e.with(TemporalAdjusters.lastDayOfMonth()), LocalTime.MAX);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ LambdaQueryWrapper<WmScorePackage> queryWrapper = Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
+ .eq(WmScorePackage::getPackageType2, packageType2)
|
|
|
|
+ .like(StrUtil.isNotEmpty(scorePackageName), WmScorePackage::getScorePackageName, scorePackageName)
|
|
|
|
+ .eq(scorePackageStatus != null, WmScorePackage::getScorePackageStatus, scorePackageStatus)
|
|
|
|
+ .eq(WmScorePackage::getMahSettleDeptId, sendDeptId)
|
|
|
|
+ .eq(WmScorePackage::getMahSettleStep, UpmsType.MahSettleStep.FINANCE.getType())
|
|
|
|
+ .between(start != null && end != null, WmScorePackage::getCreateTime, start, end);
|
|
|
|
+
|
|
|
|
+ List<String> packageType1List = StrUtil.split(packageType1, StrUtil.COMMA);
|
|
|
|
+ if (StrUtil.contains(packageType1, StrUtil.COMMA)) {
|
|
|
|
+ queryWrapper.in(WmScorePackage::getPackageType1, packageType1List);
|
|
|
|
+ } else {
|
|
|
|
+ queryWrapper.eq(WmScorePackage::getPackageType1, packageType1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (StringUtil.isEmpty(typeId)) {
|
|
|
|
+ queryWrapper.in(WmScorePackage::getTypeid, "3", "4");
|
|
|
|
+ } else {
|
|
|
|
+ List<String> split = StrUtil.split(typeId, StrUtil.COMMA);
|
|
|
|
+ queryWrapper.in(WmScorePackage::getTypeid, split);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //queryWrapper.eq(WmScorePackage::getLocation, SubjectLocation.MAH_SETTLE);
|
|
|
|
+
|
|
|
|
+ Page<WmScorePackage> wmScorePackagePage = wmScorePackageMapper.selectPage(new Page<>(current, size), queryWrapper
|
|
|
|
+ .orderByDesc(WmScorePackage::getCreateTime));
|
|
|
|
+
|
|
|
|
+ List<WmScorePackage> pageRecords = wmScorePackagePage.getRecords();
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(pageRecords)) {
|
|
|
|
+
|
|
|
|
+ for (WmScorePackage scorePackage : pageRecords) {
|
|
|
|
+ if (packageType2 == 2) {
|
|
|
|
+
|
|
|
|
+ // todo
|
|
|
|
+ //int wsNum = settleNoteMapper.selectCount(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
+ // .eq(WmScorePackageSettleNote::getPackageId, scorePackage.getId())
|
|
|
|
+ // .in(WmScorePackageSettleNote::getSettleNoteStatus, 2, 9));
|
|
|
|
+ //int asNum = settleNoteMapper.selectCount(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
|
+ // .eq(WmScorePackageSettleNote::getPackageId, scorePackage.getId())
|
|
|
|
+ // .eq(WmScorePackageSettleNote::getSettleNoteStatus, 1));
|
|
|
|
+ //scorePackage.setWsTaskNum(wsNum);
|
|
|
|
+ //scorePackage.setAsTaskNum(asNum);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (PackageTypeEnum.TYPE1_HCP_PACKAGE.getName().equals(scorePackage.getPackageType1())) {
|
|
|
|
+ // 如果是患者教育,则转换积分值 '分'-> '元'
|
|
|
|
+ String userScore = scorePackage.getUserScore();
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNumeric(userScore)) {
|
|
|
|
+ scorePackage.setUserScore(String.format("%.2f", Integer.parseInt(userScore) / 100.0));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<WmScoreTaskType> taskTypeList = wmScoreTaskTypeMapper.getScoreTaskTypeByScoreId(scorePackage.getId());
|
|
|
|
+ if (CollUtil.isNotEmpty(taskTypeList)) {
|
|
|
|
+ String taskTypes = taskTypeList.stream().map(
|
|
|
|
+ WmScoreTaskType::getTaskTypeName).collect(Collectors.joining(","));
|
|
|
|
+ scorePackage.setTaskTypes(taskTypes);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.ok(wmScorePackagePage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据id查询积分包信息
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return 积分包信息
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getScorePackagePageById")
|
|
|
|
+ public R<?> getScorePackagePageById(WmScorePackage wmScorePackage) {
|
|
|
|
+ return wmScorePackageService.getScorePackagePageById(wmScorePackage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增积分包
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @SysLog("新增积分包(小包)")
|
|
|
|
+ @PostMapping("/addWmScorePackage")
|
|
|
|
+ public R<?> addWmScorePackage(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
+ log.info("新增积分包(小包)入参:{}", wmScorePackage);
|
|
|
|
+ //定额
|
|
|
|
+ if (wmScorePackage.getPackageType1().equals("1")) {
|
|
|
|
+ if (wmScorePackage.getScore() <= 0) {
|
|
|
|
+ return R.failed("积分包分值必须大于0");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StrUtil.isBlank(wmScorePackage.getPackageSn())) {
|
|
|
|
+ return R.failed("积分包序列号必填");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //if (StrUtil.isNotBlank(wmScorePackage.getSubjectLocation())) {
|
|
|
|
+ // SubjectLocation location = Enum.valueOf(SubjectLocation.class, wmScorePackage.getSubjectLocation());
|
|
|
|
+ // wmScorePackage.setLocation(location);
|
|
|
|
+ // wmScorePackage.setSubType(String.valueOf(location.getGigType().getCode()));
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+ return wmScorePackageService.addWmScorePackage(wmScorePackage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @SysLog("修改积分包--删除、结算")
|
|
|
|
+ @PostMapping("/updateEasy")
|
|
|
|
+ public R updateEasy(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
+
|
|
|
|
+ return wmScorePackageService.updateEasy(wmScorePackage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 更新积分包信息
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 积分包信息
|
|
|
|
+ * @return 更新结果
|
|
|
|
+ */
|
|
|
|
+ @SysLog("修改积分包(小包)")
|
|
|
|
+ @PostMapping("/updateWmScorePackage")
|
|
|
|
+ public R<?> updateWmScorePackage(@RequestBody WmScorePackage wmScorePackage) {
|
|
|
|
+
|
|
|
|
+ log.info("修改积分包(小包)入参:{}", wmScorePackage);
|
|
|
|
+
|
|
|
|
+ if (StrUtil.isBlank(wmScorePackage.getId())) {
|
|
|
|
+ return R.failed("积分包id必填");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //定额
|
|
|
|
+ if (wmScorePackage.getPackageType1().equals("1") && wmScorePackage.getScore() <= 0) {
|
|
|
|
+ return R.failed("积分包分值必须大于0");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 被领取的积分包 不能修改
|
|
|
|
+ int total = wmScorePackageStatusService.count(Wrappers.<WmScorePackageStatus>lambdaQuery().eq(WmScorePackageStatus::getPackageId, wmScorePackage.getId()).in(WmScorePackageStatus::getStatus, "1", "2"));
|
|
|
|
+ if (total > 0) {
|
|
|
|
+ return R.failed("积分包已被领取,不能修改");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 校验重名
|
|
|
|
+ if (StrUtil.isNotBlank(wmScorePackage.getScorePackageName())) {
|
|
|
|
+
|
|
|
|
+ long existed = wmScorePackageService.count(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
+ .eq(WmScorePackage::getDelFlag, "0")
|
|
|
|
+ .eq(WmScorePackage::getDeptId, wmScorePackage.getDeptId())
|
|
|
|
+ .eq(WmScorePackage::getScorePackageName, wmScorePackage.getScorePackageName())
|
|
|
|
+ .ne(WmScorePackage::getId, wmScorePackage.getId()));
|
|
|
|
+ if (existed != 0) {
|
|
|
|
+ return R.failed("积分包名称已存在");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return wmScorePackageService.updateWmScorePackage(wmScorePackage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 终止积分包(个人包)
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 参数
|
|
|
|
+ * @return 结果
|
|
|
|
+ */
|
|
|
|
+ @SysLog("终止积分包(个人包)")
|
|
|
|
+ @GetMapping("/updateEnable")
|
|
|
|
+ public R<?> terminatePackageForPersonal(WmScorePackage wmScorePackage) {
|
|
|
|
+ log.info("终止积分包(个人包)入参:{}", wmScorePackage);
|
|
|
|
+ if (!StrUtil.equalsAny(wmScorePackage.getEnableType(), "1", "2") || StrUtil.isBlank(wmScorePackage.getId())) {
|
|
|
|
+ return R.failed("参数错误");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String cacheKey = CacheConstants.TERMINATE_PACKAGE_KEY + wmScorePackage.getId();
|
|
|
|
+ Boolean absent = redisTemplate.opsForValue().setIfAbsent(cacheKey, JSONUtil.toJsonStr(wmScorePackage), 3L, TimeUnit.SECONDS);
|
|
|
|
+ if (Boolean.FALSE.equals(absent)) {
|
|
|
|
+ return R.failed("正在处理");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 查询积分包
|
|
|
|
+ WmScorePackage scorePackage = wmScorePackageService.getById(wmScorePackage.getId());
|
|
|
|
+
|
|
|
|
+ // 只有个人承接/多人承接积分包走这个逻辑, 其他的包走原有逻辑
|
|
|
|
+ if (PackageTypeEnum.TYPE1_SCOTE_PACKAGE.val().equals(scorePackage.getPackageType1())
|
|
|
|
+ || PackageTypeEnum.TYPE1_SCORE_AND_TASK_PACKAGE.val().equals(scorePackage.getPackageType1())) {
|
|
|
|
+ return R.ok(wmScorePackageService.terminatePackageForPersonal(wmScorePackage.getId(),
|
|
|
|
+ UpmsType.TerminatePackageType.getByEnableType(wmScorePackage.getEnableType())));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return wmScorePackageService.updateEnable(scorePackage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询已完成积分值
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/selectSettleStatus")
|
|
|
|
+ public Map<String, Object> selectSettleStatus(WmScorePackage wmScorePackage) {
|
|
|
|
+ return wmScorePackageService.selectSettleStatus(wmScorePackage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询发包对象
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/selectSendPackageDeptId")
|
|
|
|
+ public List<SysDept> selectSendPackageDeptId(WmScorePackage wmScorePackage) {
|
|
|
|
+ return wmScorePackageService.selectSendPackageDeptId(wmScorePackage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询发包对象
|
|
|
|
+ *
|
|
|
|
+ * @param wmScorePackage 积分包
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/selectRelationScoreIdList")
|
|
|
|
+ public WmScorePackage selectRelationScoreIdList(WmScorePackage wmScorePackage) {
|
|
|
|
+ return wmScorePackageService.selectRelationScoreIdList(wmScorePackage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取当前部门的基于所有积分包的相关信息
|
|
|
|
+ *
|
|
|
|
+ * @return 积分包的相关信息
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/getDeptScorePackageInfo")
|
|
|
|
+ public R<?> getDeptScorePackageInfo() {
|
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
|
+ Map<String, Object> result = wmScorePackageService.getDeptScorePackageInfo(deptId);
|
|
|
|
+ return R.ok(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取积分包关联企业的药品列表
|
|
|
|
+ *
|
|
|
|
+ * @param page 分页信息
|
|
|
|
+ * @param packageId 积分包id
|
|
|
|
+ * @param drugName 药品名称
|
|
|
|
+ * @return 药品列表
|
|
|
|
+ */
|
|
|
|
+ @SysLog("获取积分包关联企业的药品列表")
|
|
|
|
+ @GetMapping(value = "/drugs")
|
|
|
|
+ public R<?> listDrugsByPackageId(Page<WmDaDrugEntDrugtable> page,
|
|
|
|
+ @RequestParam(value = "packageId") Integer packageId,
|
|
|
|
+ @RequestParam(value = "name", required = false) String drugName) {
|
|
|
|
+ return R.ok(wmScorePackageService.listDrugsByPackageId(page, packageId, drugName.trim()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // ~ 批量下发积分包 ===================================================================================================
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取最近的记录
|
|
|
|
+ *
|
|
|
|
+ * @return 最近记录
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/batch/history")
|
|
|
|
+ public R<?> getBatchHistory() {
|
|
|
|
+ HnqzUser user = SecurityUtils.getUser();
|
|
|
|
+
|
|
|
|
+ // 缓存记录key
|
|
|
|
+ String key = String.format(CacheConstants.BATCH_PACKAGE_HISTORY, user.getDeptId(), user.getId());
|
|
|
|
+
|
|
|
|
+ String result = redisTemplate.opsForValue().get(key);
|
|
|
|
+
|
|
|
|
+ if (StrUtil.isNotEmpty(result) && JSONUtil.isJson(result)) {
|
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(result);
|
|
|
|
+ return R.ok(jsonObject);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 批量导入积分包
|
|
|
|
+ *
|
|
|
|
+ * @param batchPackageExcelModels 积分包信息文件
|
|
|
|
+ * @param scorePackage 积分包创建信息
|
|
|
|
+ * @return success/false
|
|
|
|
+ */
|
|
|
|
+ @SysLog("批量导入积分包")
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ @PostMapping(value = "/batch")
|
|
|
|
+ public R<?> batchCreatePackage(@RequestExcel(fileName = "excel", ignoreEmptyRow = true) List<BatchPackageExcelModel> batchPackageExcelModels,
|
|
|
|
+ @RequestPart(value = "history") WmScorePackage scorePackage) {
|
|
|
|
+
|
|
|
|
+ HnqzUser user = SecurityUtils.getUser();
|
|
|
|
+
|
|
|
|
+ // 加锁防止多处理
|
|
|
|
+
|
|
|
|
+ String lock = "lock:package:batch:" + user.getDeptId();
|
|
|
|
+
|
|
|
|
+ if (!redisTemplate.opsForValue().setIfAbsent(lock, IdUtil.fastUUID())) {
|
|
|
|
+ return R.failed("有在途的操作,请稍后");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ log.warn("==========================================批量导入积分包-插入redis:开始=====================================================");
|
|
|
|
+ // 获取操作人
|
|
|
|
+ // 记录历史信息
|
|
|
|
+ // 缓存记录key
|
|
|
|
+ String key = String.format(CacheConstants.BATCH_PACKAGE_HISTORY, user.getDeptId(), user.getId());
|
|
|
|
+ Map<String, Object> history = new HashMap<>(2);
|
|
|
|
+ scorePackage.setCreateTime(null);
|
|
|
|
+ scorePackage.setUpdateTime(null);
|
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(scorePackage);
|
|
|
|
+ jsonObject.set("relatedService", Integer.parseInt(scorePackage.getRelatedService()));
|
|
|
|
+ history.put("history", jsonObject);
|
|
|
|
+ history.put("timestamp", DateTimeFormatter.ofPattern(DatePattern.CHINESE_DATE_TIME_PATTERN).format(LocalDateTime.now()));
|
|
|
|
+ redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(history));
|
|
|
|
+
|
|
|
|
+ log.warn("==========================================批量导入积分包-插入redis:结束=====================================================");
|
|
|
|
+
|
|
|
|
+ log.warn("==========================================批量导入积分包:开始=====================================================");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Multimap<String, Object> errorMap = ArrayListMultimap.create();
|
|
|
|
+
|
|
|
|
+ TargetType targetType = null;
|
|
|
|
+
|
|
|
|
+ // 全职
|
|
|
|
+ if (StrUtil.equals("3", scorePackage.getTypeid())) {
|
|
|
|
+ targetType = TargetType.FULL_TIME;
|
|
|
|
+ }
|
|
|
|
+ // 兼职
|
|
|
|
+ else if (StrUtil.equals("4", scorePackage.getTypeid())) {
|
|
|
|
+ targetType = TargetType.PART_TIME;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 重复的模型
|
|
|
|
+ Map<String, List<BatchPackageExcelModel>> dupNameModel = batchPackageExcelModels.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(BatchPackageExcelModel::getScorePackageName));
|
|
|
|
+ List<String> names = batchPackageExcelModels.stream().map(BatchPackageExcelModel::getScorePackageName).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ for (Map.Entry<String, List<BatchPackageExcelModel>> entry : dupNameModel.entrySet()) {
|
|
|
|
+ String name = entry.getKey();
|
|
|
|
+ int size = entry.getValue().size();
|
|
|
|
+ if (size > 1) {
|
|
|
|
+ List<Integer> index = new ArrayList<>(size);
|
|
|
|
+ List<String> temp = new ArrayList<>(names);
|
|
|
|
+ Iterator<String> iterator = temp.iterator();
|
|
|
|
+ while (iterator.hasNext()) {
|
|
|
|
+ int idx = temp.lastIndexOf(name);
|
|
|
|
+ if (idx != -1) {
|
|
|
|
+ index.add(idx + 1);
|
|
|
|
+ temp.remove(idx);
|
|
|
|
+ } else {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ errorMap.put("模板内积分包名称重复", index.stream().sorted().collect(Collectors.toList()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 业务校验
|
|
|
|
+ for (int i = 0, batchScoreTotal = 0, rows = batchPackageExcelModels.size(); i < rows; i++) {
|
|
|
|
+
|
|
|
|
+ batchScoreTotal += checkColumn(batchPackageExcelModels.get(i), targetType, errorMap, i + 1, user.getDeptId());
|
|
|
|
+
|
|
|
|
+ // 额外校验可分配积分包
|
|
|
|
+ if (!"-1".equals(scorePackage.getRelationScoreId()) && batchScoreTotal > (scorePackage.getKfpjf() == null ? 0 : scorePackage.getKfpjf())) {
|
|
|
|
+ errorMap.put("批量下发总值大于可分配值", i + 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 存在错误全表打回
|
|
|
|
+ if (!errorMap.isEmpty()) {
|
|
|
|
+
|
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>(errorMap.size());
|
|
|
|
+ Map<String, Collection<Object>> asMap = errorMap.asMap();
|
|
|
|
+
|
|
|
|
+ for (Map.Entry<String, Collection<Object>> entry : asMap.entrySet()) {
|
|
|
|
+
|
|
|
|
+ Map<String, Object> m = new HashMap<>(2);
|
|
|
|
+
|
|
|
|
+ m.put("reason", entry.getKey());
|
|
|
|
+
|
|
|
|
+ m.put("line", entry.getValue());
|
|
|
|
+ resultList.add(m);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.ok(resultList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (BatchPackageExcelModel model : batchPackageExcelModels) {
|
|
|
|
+
|
|
|
|
+ scorePackage.setScore(Integer.parseInt(model.getScore()));
|
|
|
|
+ scorePackage.setScorePackageName(model.getScorePackageName());
|
|
|
|
+ scorePackage.setDescription(model.getDescription());
|
|
|
|
+ scorePackage.setUserList(StrUtil.isEmpty(model.getTargetId()) ? new ArrayList<>(1) :
|
|
|
|
+ Collections.singletonList(model.getTargetId()));
|
|
|
|
+ scorePackage.setPackageSn("PKG" + pkgSequence.nextNo());
|
|
|
|
+
|
|
|
|
+ wmScorePackageService.addWmScorePackage(scorePackage);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ } finally {
|
|
|
|
+ log.warn("==========================================批量导入积分包:结束=====================================================");
|
|
|
|
+ redisTemplate.delete(lock);
|
|
|
|
+ }
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 校验model
|
|
|
|
+ *
|
|
|
|
+ * @param model model
|
|
|
|
+ * @param targetType 接包人类型
|
|
|
|
+ * @param errorMap 收集错误map
|
|
|
|
+ * @param row 所在行
|
|
|
|
+ * @param deptId 所属企业
|
|
|
|
+ */
|
|
|
|
+ private Integer checkColumn(BatchPackageExcelModel model, TargetType targetType,
|
|
|
|
+ Multimap<String, Object> errorMap, Integer row, Integer deptId) {
|
|
|
|
+
|
|
|
|
+ log.warn("==========================================校验批量下发积分包model:开始=====================================================");
|
|
|
|
+
|
|
|
|
+ // 校验类型
|
|
|
|
+ log.info("[{}]", model.getTargetType());
|
|
|
|
+ if (!targetType.getDesc().equals(model.getTargetType())) {
|
|
|
|
+ errorMap.put("接单对象类型不匹配", row);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 校验是否同名
|
|
|
|
+ log.info("[{}]", model.getScorePackageName());
|
|
|
|
+ if (StrUtil.isNotEmpty(model.getScorePackageName())) {
|
|
|
|
+ int count = wmScorePackageService.count(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
|
+ .eq(WmScorePackage::getScorePackageName, model.getScorePackageName()));
|
|
|
|
+
|
|
|
|
+ if (count != 0) {
|
|
|
|
+ errorMap.put("积分包重名了", row);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 校验积分制是否为空
|
|
|
|
+ log.info("[{}]", model.getScore());
|
|
|
|
+ if (StrUtil.isEmpty(model.getScore())) {
|
|
|
|
+ errorMap.put("积分值未填", row);
|
|
|
|
+ } else {
|
|
|
|
+ // 校验是否是数字
|
|
|
|
+ if (!Validator.isNumber(model.getScore())) {
|
|
|
|
+ errorMap.put("积分值不是数字", row);
|
|
|
|
+ } else if (model.getScore().contains(StrUtil.DOT) || Integer.parseInt(model.getScore()) <= 0) {
|
|
|
|
+ errorMap.put("积分值必须是正整数", row);
|
|
|
|
+ model.setScore("0");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 全职校验
|
|
|
|
+ if (TargetType.FULL_TIME.equals(targetType)) {
|
|
|
|
+
|
|
|
|
+ // 校验名称是否为空
|
|
|
|
+ log.info("[{}]", model.getTargetName());
|
|
|
|
+ if (StrUtil.isEmpty(model.getTargetName())) {
|
|
|
|
+ errorMap.put("接单人姓名未填", row);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 校验名称是否为空,是否是企业下的人
|
|
|
|
+ log.info("[{}]", model.getMobile());
|
|
|
|
+ if (StrUtil.isEmpty(model.getMobile())) {
|
|
|
|
+ errorMap.put("接单人手机号未填", row);
|
|
|
|
+ } else {
|
|
|
|
+ if (!Validator.isMobile(model.getMobile())) {
|
|
|
|
+ errorMap.put("手机号格式不争取", row);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 校验是否是企业下的
|
|
|
|
+ List<SysUser> target = sysUserService.list(Wrappers.<SysUser>lambdaQuery()
|
|
|
|
+ .eq(SysUser::getRealname, model.getTargetName())
|
|
|
|
+ .eq(SysUser::getUsername, model.getMobile())
|
|
|
|
+ .eq(SysUser::getDeptId, deptId)
|
|
|
|
+ .eq(SysUser::getDelFlag, CommonConstants.STATUS_NORMAL)
|
|
|
|
+ .eq(SysUser::getLockFlag, CommonConstants.STATUS_NORMAL)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isEmpty(target) || target.size() > 1) {
|
|
|
|
+ errorMap.put("查无此人", row);
|
|
|
|
+ } else {
|
|
|
|
+ model.setTargetId(String.valueOf(target.get(0).getUserId()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 兼职校验
|
|
|
|
+ else {
|
|
|
|
+ // 校验名称是否为空
|
|
|
|
+ log.info("MOBILE: [{}], NAME: [{}]", model.getTargetName(), model.getTargetName());
|
|
|
|
+ if (StrUtil.isNotEmpty(model.getTargetName()) || StrUtil.isNotEmpty(model.getMobile())) {
|
|
|
|
+ errorMap.put("请勿使用全职模板", row);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ log.warn("==========================================校验批量下发积分包model:开始=====================================================");
|
|
|
|
+ return Integer.parseInt(model.getScore());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 拆包
|
|
|
|
+ *
|
|
|
|
+ * @param unpackDTO 拆包参数
|
|
|
|
+ * @return 拆包结果
|
|
|
|
+ */
|
|
|
|
+ @SysLog("拆包")
|
|
|
|
+ @PostMapping("/unpack")
|
|
|
|
+ public R<?> unpack(@Validated @RequestBody UnpackDTO unpackDTO) {
|
|
|
|
+ log.info("======================================拆包开始执行===================================");
|
|
|
|
+ log.info("拆包请求参数:{}", unpackDTO);
|
|
|
|
+
|
|
|
|
+ Boolean unpack = wmScorePackageService.unpack(unpackDTO);
|
|
|
|
+
|
|
|
|
+ log.info("======================================拆包执行完成===================================");
|
|
|
|
+ return R.ok(unpack);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 积分包结算管理-发票上传
|
|
|
|
+ *
|
|
|
|
+ * @param param 发票参数
|
|
|
|
+ * @return {@link R}<{@link ?}> 结果
|
|
|
|
+ */
|
|
|
|
+ @SysLog("积分包结算管理-发票上传")
|
|
|
|
+ @PostMapping("/upload-invoice")
|
|
|
|
+ public R<?> uploadInvoice(@RequestBody WmScorePackageSettleOutput param) {
|
|
|
|
+ log.info("积分包结算管理-发票上传参数:{}", param);
|
|
|
|
+ if (StrUtil.isBlank(param.getId()) || StrUtil.isBlank(param.getInvoiceNumber()) || ArrayUtil.isEmpty(param.getInvoiceFile())) {
|
|
|
|
+ return R.failed("必填参数为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ WmScorePackage update = new WmScorePackage();
|
|
|
|
+ update.setId(param.getId());
|
|
|
|
+ update.setInvoiceNumber(param.getInvoiceNumber());
|
|
|
|
+ update.setInvoiceFile(param.getInvoiceFile());
|
|
|
|
+ update.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ update.setUpdateUser(SecurityUtils.getUser().getId());
|
|
|
|
+
|
|
|
|
+ return R.ok(wmScorePackageService.updateById(update));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 重启积分包(默认延长1年)
|
|
|
|
+ *
|
|
|
|
+ * @param scorePackage 参数
|
|
|
|
+ * @return 结果
|
|
|
|
+ */
|
|
|
|
+ @SysLog("重启积分包")
|
|
|
|
+ @PostMapping("/restart")
|
|
|
|
+ public R<?> restart(@RequestBody WmScorePackage scorePackage) {
|
|
|
|
+ if (scorePackage.getId() == null) {
|
|
|
|
+ return R.failed("积分包id必填");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
|
+ WmScorePackage update = new WmScorePackage();
|
|
|
|
+ update.setId(scorePackage.getId());
|
|
|
|
+ if (scorePackage.getEndTime() != null) {
|
|
|
|
+ update.setEndTime(scorePackage.getEndTime());
|
|
|
|
+ } else {
|
|
|
|
+ update.setEndTime(now.plusYears(1));
|
|
|
|
+ }
|
|
|
|
+ wmScorePackageService.updateById(update);
|
|
|
|
+
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
}
|
|
}
|