|
@@ -6,19 +6,14 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.management.platform.entity.ContractBonusDetail;
|
|
|
-import com.management.platform.entity.ContractBonusSummary;
|
|
|
-import com.management.platform.entity.User;
|
|
|
-import com.management.platform.entity.WxCorpInfo;
|
|
|
+import com.management.platform.entity.*;
|
|
|
import com.management.platform.entity.bo.BonusDataBO;
|
|
|
import com.management.platform.entity.excel.ProjectContractBonusExcelHead;
|
|
|
-import com.management.platform.entity.vo.ImportBonusTemplateVO;
|
|
|
-import com.management.platform.entity.vo.ProjectBonusTimeVO;
|
|
|
-import com.management.platform.entity.vo.ProjectBonusTotalTimeVO;
|
|
|
-import com.management.platform.entity.vo.UserProjectBonusTimeVO;
|
|
|
+import com.management.platform.entity.vo.*;
|
|
|
import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.ContractBonusDetailService;
|
|
|
import com.management.platform.service.WxCorpInfoService;
|
|
|
+import com.management.platform.util.ExcelUtil;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.MessageUtils;
|
|
|
import com.management.platform.util.converter.ExcelMergeStrategy;
|
|
@@ -68,6 +63,9 @@ public class ContractBonusDetailServiceImpl extends ServiceImpl<ContractBonusDet
|
|
|
@Resource
|
|
|
private BonusExcludeProjectMapper bonusExcludeProjectMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private UserCustomMapper userCustomMapper;
|
|
|
+
|
|
|
public static Map<Integer,String> bonusTypeMap = new HashMap<>();
|
|
|
static {
|
|
|
bonusTypeMap.put(1,"第一季度奖");
|
|
@@ -253,7 +251,12 @@ public class ContractBonusDetailServiceImpl extends ServiceImpl<ContractBonusDet
|
|
|
if(CollectionUtils.isNotEmpty(emptyJNUserList)){
|
|
|
List<User> checkEmptyPlate1 = emptyJNUserList.stream().filter(t -> StringUtils.isBlank(t.getPlate1())).collect(Collectors.toList());
|
|
|
if(CollectionUtils.isNotEmpty(checkEmptyPlate1)){
|
|
|
- httpRespMsg.setError("员工:"+checkEmptyPlate1.stream().map(User::getName).collect(Collectors.toList())+" 没有合同主体");
|
|
|
+ if(7737 == user.getCompanyId()){
|
|
|
+ httpRespMsg.setError("员工:"+checkEmptyPlate1.stream().map(User::getName).collect(Collectors.toList())+" 没有合同主体");
|
|
|
+ }else{
|
|
|
+ httpRespMsg.setError("员工:"+checkEmptyPlate1.stream().map(User::getName).collect(Collectors.toList())+" 自定义字段没有值");
|
|
|
+ }
|
|
|
+
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
checkEmptyPlate1.clear();
|
|
@@ -262,7 +265,11 @@ public class ContractBonusDetailServiceImpl extends ServiceImpl<ContractBonusDet
|
|
|
if(CollectionUtils.isNotEmpty(notEmptyJNUsers)){
|
|
|
List<User> checkNotEmptyPlate1 = notEmptyJNUsers.stream().filter(t -> StringUtils.isBlank(t.getPlate1())).collect(Collectors.toList());
|
|
|
if(CollectionUtils.isNotEmpty(checkNotEmptyPlate1)){
|
|
|
- httpRespMsg.setError("员工:"+checkNotEmptyPlate1.stream().map(User::getName).collect(Collectors.toList())+" 没有合同主体");
|
|
|
+ if(7737 == user.getCompanyId()){
|
|
|
+ httpRespMsg.setError("员工:"+checkNotEmptyPlate1.stream().map(User::getName).collect(Collectors.toList())+" 没有合同主体");
|
|
|
+ }else{
|
|
|
+ httpRespMsg.setError("员工:"+checkNotEmptyPlate1.stream().map(User::getName).collect(Collectors.toList())+" 自定义字段没有值");
|
|
|
+ }
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
checkNotEmptyPlate1.clear();
|
|
@@ -394,17 +401,18 @@ public class ContractBonusDetailServiceImpl extends ServiceImpl<ContractBonusDet
|
|
|
}
|
|
|
|
|
|
//该员工在该年内只能存在一条同奖金类型的数据
|
|
|
+ //12-25上传逻辑修改为删除所有再插入
|
|
|
contractBonusSummaryMapper.delete(new LambdaQueryWrapper<ContractBonusSummary>()
|
|
|
.eq(ContractBonusSummary::getCompanyId, user.getCompanyId())
|
|
|
.eq(ContractBonusSummary::getYear, useYear)
|
|
|
.eq(ContractBonusSummary::getBonusType,bonusType)
|
|
|
- .in(ContractBonusSummary::getUserId, checkUserTimeIdList)
|
|
|
+// .in(ContractBonusSummary::getUserId, checkUserTimeIdList)
|
|
|
);
|
|
|
contractBonusDetailMapper.delete(new LambdaQueryWrapper<ContractBonusDetail>()
|
|
|
.eq(ContractBonusDetail::getCompanyId, user.getCompanyId())
|
|
|
.eq(ContractBonusDetail::getBonusType,bonusType)
|
|
|
.eq(ContractBonusDetail::getYear,useYear)
|
|
|
- .in(ContractBonusDetail::getUserId,checkUserTimeIdList)
|
|
|
+// .in(ContractBonusDetail::getUserId,checkUserTimeIdList)
|
|
|
);
|
|
|
|
|
|
//插入数据
|
|
@@ -443,7 +451,7 @@ public class ContractBonusDetailServiceImpl extends ServiceImpl<ContractBonusDet
|
|
|
if(null ==user){
|
|
|
httpRespMsg.setError("登录凭证有误,请联系管理员");
|
|
|
}
|
|
|
- List<ProjectContractBonusExcelHead> contractProjectBonusList=contractBonusDetailMapper.getExportContractProjectBonus(year,user.getCompanyId());
|
|
|
+ List<ProjectContractBonusExcelHead> contractProjectBonusList=contractBonusDetailMapper.getExportContractProjectBonusForSpecial(year,user.getCompanyId());
|
|
|
httpRespMsg.setData(contractProjectBonusList);
|
|
|
return httpRespMsg;
|
|
|
}
|
|
@@ -459,7 +467,6 @@ public class ContractBonusDetailServiceImpl extends ServiceImpl<ContractBonusDet
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
- List<ProjectContractBonusExcelHead> dataList=contractBonusDetailMapper.getExportContractProjectBonus(year,user.getCompanyId());
|
|
|
|
|
|
String fileName = null;
|
|
|
try {
|
|
@@ -467,23 +474,65 @@ public class ContractBonusDetailServiceImpl extends ServiceImpl<ContractBonusDet
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
-
|
|
|
response.setContentType("application/vnd.ms-excel;chartset=utf-8");
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + null==fileName?"file":fileName);
|
|
|
-
|
|
|
- try (ServletOutputStream outputStream = response.getOutputStream()){
|
|
|
- EasyExcel.write(outputStream, ProjectContractBonusExcelHead.class)
|
|
|
- .excelType(ExcelTypeEnum.XLSX)
|
|
|
- .autoCloseStream(true)
|
|
|
- .registerWriteHandler(new ExcelMergeStrategy(
|
|
|
- dataList.stream().map(ProjectContractBonusExcelHead::getContract)
|
|
|
- .collect(Collectors.toList()), 0
|
|
|
- ))
|
|
|
+ if(7737 == user.getCompanyId()){
|
|
|
+ List<ProjectContractBonusExcelHead> dataList=contractBonusDetailMapper.getExportContractProjectBonusForSpecial(year,user.getCompanyId());
|
|
|
+ try (ServletOutputStream outputStream = response.getOutputStream()){
|
|
|
+ EasyExcel.write(outputStream, ProjectContractBonusExcelHead.class)
|
|
|
+ .excelType(ExcelTypeEnum.XLSX)
|
|
|
+ .autoCloseStream(true)
|
|
|
+ .registerWriteHandler(new ExcelMergeStrategy(
|
|
|
+ dataList.stream().map(ProjectContractBonusExcelHead::getContract)
|
|
|
+ .collect(Collectors.toList()), 0
|
|
|
+ ))
|
|
|
// .registerWriteHandler(new WidthStyleStrategy())
|
|
|
- .sheet("sheet01")
|
|
|
- .doWrite(dataList);
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ .sheet("sheet01")
|
|
|
+ .doWrite(dataList);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ //其他公司需要用ext1的自定义配置项读取
|
|
|
+ List<List<String>> allDatas = new ArrayList<>();
|
|
|
+ List<String> headList = new ArrayList<>();
|
|
|
+ UserCustom ext1UserCustom = userCustomMapper.selectOne(new LambdaQueryWrapper<UserCustom>()
|
|
|
+ .eq(UserCustom::getCompanyId, user.getCompanyId())
|
|
|
+ .last(" limit 1 ")
|
|
|
+ );
|
|
|
+ boolean checkExt1Exist = false;
|
|
|
+ if(null != ext1UserCustom){
|
|
|
+ checkExt1Exist = true;
|
|
|
+ String ext1Titile = ext1UserCustom.getName();
|
|
|
+ headList.add(ext1Titile);
|
|
|
+ }
|
|
|
+ headList.add("员工姓名");
|
|
|
+ headList.add("奖金类型");
|
|
|
+ headList.add("项目名称");
|
|
|
+ headList.add("员工该项目奖金金额");
|
|
|
+ headList.add("年月");
|
|
|
+ allDatas.add(headList);
|
|
|
+
|
|
|
+ List<ContractBonusDetailVO> contractBonusDetails = contractBonusDetailMapper.getExportContractProjectBonusForCommon(user.getCompanyId(),year);
|
|
|
+ for (ContractBonusDetailVO detailVO : contractBonusDetails) {
|
|
|
+ List<String> rowData = new ArrayList<>();
|
|
|
+ if(checkExt1Exist){
|
|
|
+ rowData.add(detailVO.getContract());
|
|
|
+ }
|
|
|
+ rowData.add(detailVO.getUserName());
|
|
|
+ rowData.add(detailVO.getBonusType());
|
|
|
+ rowData.add(detailVO.getProjectName());
|
|
|
+ rowData.add(detailVO.getBonusValue().setScale(4, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ rowData.add(detailVO.getYm());
|
|
|
+ allDatas.add(rowData);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ ExcelUtil.writeEasyExcel(fileName,allDatas,response);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|