Merge remote-tracking branch 'origin/main'

main
王家东 4 months ago
commit 85382f676f
  1. 22
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualScore/service/impl/PersonalCompScoreServiceImpl.java
  2. 49
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/bigScreen/service/CompSystemBigScreenServiceImpl.java
  3. 90
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/expert/controller/ExpertController.java
  4. 6
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/expert/service/IExpertService.java
  5. 65
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/expert/service/impl/ExpertServiceImpl.java

@ -21,6 +21,10 @@ import org.jeecg.modules.demo.awardpersion.entity.AwardPersion;
import org.jeecg.modules.demo.awardpersion.service.IAwardPersionService;
import org.jeecg.modules.demo.comp.entity.Comp;
import org.jeecg.modules.demo.comp.service.ICompService;
import org.jeecg.modules.demo.comptype.entity.CompType;
import org.jeecg.modules.demo.comptype.service.ICompTypeService;
import org.jeecg.modules.demo.projectlevel.entity.Projectlevel;
import org.jeecg.modules.demo.projectlevel.service.IProjectlevelService;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysDepartService;
@ -58,7 +62,7 @@ public class PersonalCompScoreServiceImpl extends ServiceImpl<PersonalCompScoreM
private ITeamManagementService iTeamManagementService;
@Autowired
private ISysDepartService iSysDepartService;
private IProjectlevelService iProjectlevelService;
@Autowired
private ISysUserService iSysUserService;
@ -144,18 +148,24 @@ public class PersonalCompScoreServiceImpl extends ServiceImpl<PersonalCompScoreM
);
if (ObjectUtils.isEmpty(managementList)) return;
//3、计算积分 项目分值*项目奖项权重值/100
log.info("***************年度比赛项目-{},项目分值:{},奖项权重值:{}", annualCompPoint.getObjName(), compweight_val, weightVal);
double baseScore = ComputeUtils.mul(compweight_val, ComputeUtils.div2(new Double(weightVal), ONE_HUNDRED));
//modify 7.12 新需求
//3、计算积分 项目分值*项目级别权得百分比*获奖奖项权重百分比
// log.info("***************年度比赛项目-{},项目分值:{},奖项权重值:{}", annualCompPoint.getObjName(), compweight_val, weightVal);
Projectlevel projectlevel = iProjectlevelService.getById(annualCompPoint.getObjLevel());
double scale_ratio = ComputeUtils.div2(new Double(projectlevel.getScale()), ONE_HUNDRED);
double baseScore = ComputeUtils.mul2(ComputeUtils.mul2(compweight_val, ComputeUtils.div2(new Double(weightVal), ONE_HUNDRED)),scale_ratio);
log.info("***************年度比赛项目-{},项目分值:{}", annualCompPoint.getObjName(), compweight_val);
log.info("***************年度比赛项目-级别权重比值:{}", scale_ratio);
log.info("***************获奖奖项权重百分比:{}", weightVal);
AtomicReference<Double> score = new AtomicReference<>((double) 0);
if (StringUtils.equals("Y", entryForm)) { //团队赛
Optional.ofNullable(managementList).orElse(new ArrayList<>()).forEach(e -> {
// 参与形式是团队时,队长积分*0.5,职员积分*0.2
//captain 是否队长
if (StringUtils.equals("0", e.getCaptain())) {
score.set(ComputeUtils.mul(baseScore, ZERO_POINT_FIVE));
score.set(ComputeUtils.mul2(baseScore, ZERO_POINT_FIVE));
} else {
score.set(ComputeUtils.mul(baseScore, ZERO_POINT_TWO));
score.set(ComputeUtils.mul2(baseScore, ZERO_POINT_TWO));
}
PersonalCompScore bean = new PersonalCompScore();

@ -35,6 +35,8 @@ import org.jeecg.modules.demo.comp.entity.Comp;
import org.jeecg.modules.demo.comp.service.ICompService;
import org.jeecg.modules.demo.comptype.entity.CompType;
import org.jeecg.modules.demo.comptype.service.ICompTypeService;
import org.jeecg.modules.demo.projectlevel.entity.Projectlevel;
import org.jeecg.modules.demo.projectlevel.service.IProjectlevelService;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysDepartService;
@ -109,6 +111,9 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic
@Autowired
private IAnnualService iAnnualService;
@Autowired
private IProjectlevelService iProjectlevelService;
//二级部门id
private final String BASE_PARENT_ID = "1693446350597038081";
@ -325,9 +330,14 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic
);
if (ObjectUtils.isEmpty(managementList)) return;
//3、计算积分 项目分值*项目奖项权重值/100
log.info("***************年度比赛项目-{},项目分值:{},奖项权重值:{}", annualCompPoint.getObjName(), compweight_val, weightVal);
double baseScore = ComputeUtils.mul(compweight_val, ComputeUtils.div2(new Double(weightVal), ONE_HUNDRED));
//3、计算积分 项目分值*项目级别权得百分比*获奖奖项权重百分比
// log.info("***************年度比赛项目-{},项目分值:{},奖项权重值:{}", annualCompPoint.getObjName(), compweight_val, weightVal);
Projectlevel projectlevel = iProjectlevelService.getById(annualCompPoint.getObjLevel());
double scale_ratio = ComputeUtils.div2(new Double(projectlevel.getScale()), ONE_HUNDRED);
double baseScore = ComputeUtils.mul2(ComputeUtils.mul2(compweight_val, ComputeUtils.div2(new Double(weightVal), ONE_HUNDRED)), scale_ratio);
log.info("***************年度比赛项目-{},项目分值:{}", annualCompPoint.getObjName(), compweight_val);
log.info("***************年度比赛项目-级别权重比值:{}", scale_ratio);
log.info("***************获奖奖项权重比值:{}", weightVal);
AtomicReference<Double> score = new AtomicReference<>((double) 0);
if (StringUtils.equals("Y", entryForm)) { //团队赛
Optional.ofNullable(managementList).orElse(new ArrayList<>()).forEach(e -> {
@ -594,26 +604,31 @@ public class CompSystemBigScreenServiceImpl implements CompSystemBigScreenServic
List<Integer> years = DateUtils.getLastxYear(5);
List<Annual> annualList = iAnnualService.list(new LambdaQueryWrapper<Annual>()
.in(Annual::getAnnualName, years)
.eq(Annual::getSysOrgCode, sysDepart.getOrgCode())
// .eq(Annual::getSysOrgCode, sysDepart.getOrgCode())
.orderByAsc(Annual::getAnnualName));
List<Last5YearDataVo> last5YearDataVos = new LinkedList<>();
List<Comp> compList = iCompService.list(new LambdaQueryWrapper<Comp>().eq(Comp::getCompOrgan, departId));
Set<String> compIds = Optional.ofNullable(compList).orElse(new ArrayList<>()).stream().map(bo -> bo.getId()).collect(Collectors.toSet());
Optional.ofNullable(annualList).orElse(new LinkedList<>()).stream().forEach(annual -> {
Last5YearDataVo last5YearDataVo = new Last5YearDataVo();
last5YearDataVo.setYear(annual.getAnnualName());
AtomicReference<BigDecimal> personCount4Comp = new AtomicReference<>(BigDecimal.ZERO);
List<AnnualComp> annualCompList = iAnnualCompService.list(new LambdaQueryWrapper<AnnualComp>().eq(AnnualComp::getAnnualid, annual.getId()));
//比赛数
last5YearDataVo.setCompCount(annualCompList.size());
if (!ObjectUtils.isEmpty(annualCompList)) {
annualCompList.stream().forEach(ac -> {
AnnualCompPoint annualCompPoint = iAnnualCompPointService.getOne(new LambdaQueryWrapper<AnnualCompPoint>().eq(AnnualCompPoint::getAnnualCompId, ac.getId()));
if (!ObjectUtils.isEmpty(annualCompPoint)) {
long personCount4CompTemp = iAnnualCompetitionProjectRegistrationService.count(new LambdaQueryWrapper<AnnualCompetitionProjectRegistration>().
eq(AnnualCompetitionProjectRegistration::getAnnualCompid, annualCompPoint.getId()));
personCount4Comp.getAndUpdate(val -> val.add(new BigDecimal(personCount4CompTemp)));
}
});
if (ObjectUtils.isEmpty(compIds)) {
List<AnnualComp> annualCompList = iAnnualCompService.list(new LambdaQueryWrapper<AnnualComp>()
.eq(AnnualComp::getAnnualid, annual.getId())
.in(AnnualComp::getCompid, compIds));
//年度比赛数量
last5YearDataVo.setCompCount(annualCompList.size());
if (!ObjectUtils.isEmpty(annualCompList)) {
annualCompList.stream().forEach(ac -> {
AnnualCompPoint annualCompPoint = iAnnualCompPointService.getOne(new LambdaQueryWrapper<AnnualCompPoint>().eq(AnnualCompPoint::getAnnualCompId, ac.getId()));
if (!ObjectUtils.isEmpty(annualCompPoint)) {
long personCount4CompTemp = iAnnualCompetitionProjectRegistrationService.count(new LambdaQueryWrapper<AnnualCompetitionProjectRegistration>().
eq(AnnualCompetitionProjectRegistration::getAnnualCompid, annualCompPoint.getId()));
personCount4Comp.getAndUpdate(val -> val.add(new BigDecimal(personCount4CompTemp)));
}
});
}
}
last5YearDataVo.setPersonCount(personCount4Comp.get().intValue());
last5YearDataVos.add(last5YearDataVo);

@ -242,13 +242,33 @@ public class ExpertController extends JeecgController<Expert, IExpertService> {
CompExp compExp = new CompExp();
QueryWrapper<CompExp> queryWrapper1 = QueryGenerator.initQueryWrapper(compExp, req.getParameterMap());
queryWrapper1.eq("expid",model.getId());
List<CompExp> list1 = compExpService.list(queryWrapper1);
if(list1.size()>0) {
CompExp compExpModel=list1.get(0);
model.setCompid(compExpModel.getCompid());
model.setStat(compExpModel.getStat());
model.setCompName(compExpModel.getCompName());
String Compid = "";
String CompName = "";
String Stat = "";
// 使用 StringBuilder 来构建字符串,比直接使用字符串连接更高效
StringBuilder sbCompid = new StringBuilder();
StringBuilder sbCompName = new StringBuilder();
StringBuilder sbStat = new StringBuilder();
for(CompExp item: list1) {
if (sbCompid.length() > 0) {
sbCompid.append(","); // 只在不是第一个元素时添加逗号
sbCompName.append(",");
sbStat.append(",");
}
sbCompid.append(item.getCompid());
sbCompName.append(item.getCompName());
sbStat.append(item.getStat());
}
// 将 StringBuilder 转换为 String
Compid = sbCompid.toString();
CompName = sbCompName.toString();
Stat = sbStat.toString();
// 现在 Compid, CompName 和 Stat 包含了逗号分隔的值
model.setCompName(CompName);
model.setCompid(Compid);
model.setStat(Stat);
return Result.OK(model);
}
@ -413,65 +433,13 @@ public class ExpertController extends JeecgController<Expert, IExpertService> {
public Result<SysUser> editcompExp(@RequestBody JSONObject jsonObject,HttpServletRequest req) {
Result<SysUser> result = new Result<SysUser>();
try {
SysUser sysUser = sysUserService.getById(jsonObject.getString("id"));
baseCommonService.addLog("编辑用户,username: " +sysUser.getUsername() ,CommonConstant.LOG_TYPE_2, 2);
String user_id=jsonObject.getString("id");
SysUser sysUser = sysUserService.getById(user_id);
baseCommonService.addLog("编辑专家比赛,username: " +sysUser.getUsername() ,CommonConstant.LOG_TYPE_2, 2);
if(sysUser==null) {
result.error500("未找到对应实体");
}else {
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
user.setUpdateTime(new Date());
//String passwordEncode = PasswordUtil.encrypt(user.getUsername(), user.getPassword(), sysUser.getSalt());
user.setPassword(sysUser.getPassword());
String roles = "1731948288626339841";
String departs = jsonObject.getString("selecteddeparts");
String expSc = jsonObject.getString("expSc");
String expResume = jsonObject.getString("expResume");
String expTitle = jsonObject.getString("expTitle");
String compid = jsonObject.getString("compid");
String compName = jsonObject.getString("compName");
String stat = jsonObject.getString("stat");
String expXw = jsonObject.getString("expXw");//学位
String expZc = jsonObject.getString("expZc");//职称
String expYjfx = jsonObject.getString("expYjfx");//研究方向
String expCsgz = jsonObject.getString("expCsgz");//从事工作
if(oConvertUtils.isEmpty(departs)){
//vue3.0前端只传递了departIds
departs=user.getDepartIds();
}
//用户表字段org_code不能在这里设置他的值
user.setOrgCode(null);
// 修改用户走一个service 保证事务
//获取租户ids
String relTenantIds = jsonObject.getString("relTenantIds");
sysUserService.editUser(user, roles, departs, relTenantIds);
Expert expert = new Expert();
QueryWrapper<Expert> queryWrapper = QueryGenerator.initQueryWrapper(expert, req.getParameterMap());
queryWrapper.eq("user_id",user.getId());
List<Expert> listex = expertService.list(queryWrapper);
expert = listex.get(0);
expert.setUserId(user.getId());
expert.setExpImg(user.getAvatar());
expert.setExpSc(expSc);
expert.setExpResume(expResume);
expert.setExpTitle(expTitle);
expert.setName(user.getRealname());
expert.setExpXw(expXw);//学位
expert.setExpZc(expZc);//职称
expert.setExpYjfx(expYjfx);//研究方向
expert.setExpCsgz(expCsgz);//从事工作
expertService.updateById(expert);
CompExp compExp = new CompExp();
QueryWrapper<CompExp> queryWrapper1 = QueryGenerator.initQueryWrapper(compExp, req.getParameterMap());
queryWrapper1.eq("expid",expert.getId());
List<CompExp> listce = compExpService.list(queryWrapper1);
compExp = listce.get(0);
compExp.setCompid(compid);
compExp.setCompName(compName);
compExp.setExpid(expert.getId());
compExp.setStat(stat);
compExpService.updateById(compExp);
expertService.updateCompExpert(jsonObject);
result.success("修改成功!");
}
} catch (Exception e) {

@ -1,5 +1,6 @@
package org.jeecg.modules.demo.expert.service;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.modules.demo.expert.entity.Expert;
import com.baomidou.mybatisplus.extension.service.IService;
@ -11,4 +12,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface IExpertService extends IService<Expert> {
/**
* 修改专家项目之间的关系
* @param jsonObject
*/
void updateCompExpert(JSONObject jsonObject);
}

@ -1,12 +1,24 @@
package org.jeecg.modules.demo.expert.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.demo.compexp.entity.CompExp;
import org.jeecg.modules.demo.compexp.mapper.CompExpMapper;
import org.jeecg.modules.demo.expert.entity.Expert;
import org.jeecg.modules.demo.expert.mapper.ExpertMapper;
import org.jeecg.modules.demo.expert.service.IExpertService;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.entity.SysUserDepart;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
/**
* @Description: 专家表
* @Author: jeecg-boot
@ -16,4 +28,57 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service
public class ExpertServiceImpl extends ServiceImpl<ExpertMapper, Expert> implements IExpertService {
//专家比赛
@Autowired
private CompExpMapper compExpMapper;
/**
* 修改专家项目之间的关系
* @param jsonObject
*/
@Override
public void updateCompExpert(JSONObject jsonObject) {
String user_id = jsonObject.getString("id");
String compid = jsonObject.getString("compid");
String compName = jsonObject.getString("compName");
String stat = jsonObject.getString("stat");
String[] compNames = {};
String[] compids = {};
String[] stats = {};
if(oConvertUtils.isNotEmpty(compid)&&oConvertUtils.isNotEmpty(compName)){
compNames = compName.split(",");
compids = compid.split(",");
stats = stat.split(",");
}
stat=stats[0];
//根据user id查询专家
LambdaQueryWrapper<Expert> query = new LambdaQueryWrapper<Expert>()
.like(Expert::getUserId, user_id);
List<Expert> list = this.baseMapper.selectList(query);
if(list.size()>0)
{
Expert exp=list.get(0);
//先删后加
compExpMapper.delete(new QueryWrapper<CompExp>().lambda().eq(CompExp::getExpid, exp.getId()));
if(oConvertUtils.isNotEmpty(compid)) {
if (compNames.length == compids.length) {
for (int i = 0; i < compNames.length; i++) {
CompExp compExp = new CompExp();
compExp.setCompid(compids[i]);
compExp.setCompName(compNames[i]);
compExp.setExpid(exp.getId());
compExp.setStat(stat);
compExpMapper.insert(compExp);
}
} else {
throw new JeecgBootException("比赛项目数据错误!");
}
}
}else
{
throw new JeecgBootException("该专家不存在!");
}
}
}

Loading…
Cancel
Save