Commit 1cb5c051 by Water Wang

add -- payscale pfd download

parent 8db2c3b3
...@@ -151,6 +151,11 @@ ...@@ -151,6 +151,11 @@
<artifactId>jsoup</artifactId> <artifactId>jsoup</artifactId>
<version>1.13.1</version> <version>1.13.1</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.yd.api.practitioner;
public class PayScalePdfRequestVO {
private Integer monShId;
public Integer getMonShId() {
return monShId;
}
public void setMonShId(Integer monShId) {
this.monShId = monShId;
}
}
package com.yd.api.practitioner; package com.yd.api.practitioner;
import com.test.web.vo.TestRequestVO;
import com.yd.api.practitioner.service.PractitionerBasicInfoService; import com.yd.api.practitioner.service.PractitionerBasicInfoService;
import com.yd.api.practitioner.service.PractitionerService; import com.yd.api.practitioner.service.PractitionerService;
import com.yd.api.practitioner.vo.login.PractitionerLoginRequestVO; import com.yd.api.practitioner.vo.login.PractitionerLoginRequestVO;
...@@ -7,6 +8,7 @@ import com.yd.api.practitioner.vo.login.PractitionerLoginResponseVO; ...@@ -7,6 +8,7 @@ import com.yd.api.practitioner.vo.login.PractitionerLoginResponseVO;
import com.yd.api.practitioner.vo.media.MediaGetReqVO; import com.yd.api.practitioner.vo.media.MediaGetReqVO;
import com.yd.api.practitioner.vo.media.MediaGetRespVO; import com.yd.api.practitioner.vo.media.MediaGetRespVO;
import com.yd.api.practitioner.vo.opportunity.*; import com.yd.api.practitioner.vo.opportunity.*;
import com.yd.api.practitioner.vo.payscale.PayScalePdfResponseVO;
import com.yd.api.practitioner.vo.payscale.PayScaleQueryRequestVO; import com.yd.api.practitioner.vo.payscale.PayScaleQueryRequestVO;
import com.yd.api.practitioner.vo.payscale.PayScaleQueryResponseVO; import com.yd.api.practitioner.vo.payscale.PayScaleQueryResponseVO;
import com.yd.api.practitioner.vo.policy.PolicyListQueryRequestVO; import com.yd.api.practitioner.vo.policy.PolicyListQueryRequestVO;
...@@ -22,10 +24,14 @@ import com.yd.api.practitioner.vo.subordinate.SubordinateSystemMemberQueryReques ...@@ -22,10 +24,14 @@ import com.yd.api.practitioner.vo.subordinate.SubordinateSystemMemberQueryReques
import com.yd.api.practitioner.vo.subordinate.SubordinateSystemMemberQueryResponseVO; import com.yd.api.practitioner.vo.subordinate.SubordinateSystemMemberQueryResponseVO;
import com.yd.api.result.JsonResult; import com.yd.api.result.JsonResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
@Controller @Controller
@RestController @RestController
...@@ -457,4 +463,16 @@ public class PractitionerController { ...@@ -457,4 +463,16 @@ public class PractitionerController {
result.addResult(responseVO); result.addResult(responseVO);
return result; return result;
} }
/**
* 获取经纪人的薪资表
* @param requestVO 请求信息
* @param response 请求信息
* @return 返回信息
*/
@PostMapping(value = "/payScalePdf", produces = MediaType.APPLICATION_PDF_VALUE)
public String payScalePdf(@RequestBody PayScalePdfRequestVO requestVO, HttpServletResponse response){
return practitionerBasicInfoService.payScalePdf(requestVO,response);
}
} }
package com.yd.api.practitioner.service; package com.yd.api.practitioner.service;
import com.yd.api.practitioner.PayScalePdfRequestVO;
import com.yd.api.practitioner.vo.payscale.PayScalePdfResponseVO;
import com.yd.api.practitioner.vo.payscale.PayScaleQueryRequestVO; import com.yd.api.practitioner.vo.payscale.PayScaleQueryRequestVO;
import com.yd.api.practitioner.vo.payscale.PayScaleQueryResponseVO; import com.yd.api.practitioner.vo.payscale.PayScaleQueryResponseVO;
import com.yd.api.practitioner.vo.policy.PolicyListQueryRequestVO; import com.yd.api.practitioner.vo.policy.PolicyListQueryRequestVO;
...@@ -8,6 +10,8 @@ import com.yd.api.practitioner.vo.policy.policyinfoquery.PolicyInfoQueryRequestV ...@@ -8,6 +10,8 @@ import com.yd.api.practitioner.vo.policy.policyinfoquery.PolicyInfoQueryRequestV
import com.yd.api.practitioner.vo.policy.policyinfoquery.PolicyInfoQueryResponseVO; import com.yd.api.practitioner.vo.policy.policyinfoquery.PolicyInfoQueryResponseVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
@Service("practitionerBasicInfoService") @Service("practitionerBasicInfoService")
public interface PractitionerBasicInfoService { public interface PractitionerBasicInfoService {
/** /**
...@@ -30,4 +34,12 @@ public interface PractitionerBasicInfoService { ...@@ -30,4 +34,12 @@ public interface PractitionerBasicInfoService {
* @return 相应 * @return 相应
*/ */
PayScaleQueryResponseVO payScaleListQuery(PayScaleQueryRequestVO requestVO); PayScaleQueryResponseVO payScaleListQuery(PayScaleQueryRequestVO requestVO);
/**
* 获取经纪人的薪资表
* @param requestVO 请求信息
* @param response 请求信息
* @return 响应信息
*/
String payScalePdf(PayScalePdfRequestVO requestVO, HttpServletResponse response);
} }
package com.yd.api.practitioner.service.impl; package com.yd.api.practitioner.service.impl;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.yd.api.practitioner.PayScalePdfRequestVO;
import com.yd.api.practitioner.service.PractitionerBasicInfoService; import com.yd.api.practitioner.service.PractitionerBasicInfoService;
import com.yd.api.practitioner.vo.payscale.PayScaleInfo; import com.yd.api.practitioner.vo.payscale.PayScaleInfo;
import com.yd.api.practitioner.vo.payscale.PayScaleQueryRequestVO; import com.yd.api.practitioner.vo.payscale.PayScaleQueryRequestVO;
...@@ -29,6 +30,9 @@ import org.springframework.beans.BeanUtils; ...@@ -29,6 +30,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.*; import java.util.*;
@Service("practitionerBasicInfoService") @Service("practitionerBasicInfoService")
...@@ -103,20 +107,38 @@ public class PractitionerBasicInfoServiceImpl implements PractitionerBasicInfoSe ...@@ -103,20 +107,38 @@ public class PractitionerBasicInfoServiceImpl implements PractitionerBasicInfoSe
PayScaleQueryResponseVO responseVO = new PayScaleQueryResponseVO(); PayScaleQueryResponseVO responseVO = new PayScaleQueryResponseVO();
String practitionerIdEG = requestVO.getPractitionerIdEG(); String practitionerIdEG = requestVO.getPractitionerIdEG();
if(!Strings.isNullOrEmpty(practitionerIdEG)){ if(!Strings.isNullOrEmpty(practitionerIdEG)){
List<PayScaleInfo> payScaleInfoList = aclPractitionerDALService.findPayScaleByPractitionerEG(practitionerIdEG); List<PayScaleInfo> payScaleInfoListAll = aclPractitionerDALService.findPayScaleByPractitionerEG(practitionerIdEG);
if(!payScaleInfoList.isEmpty()){ if(!payScaleInfoListAll.isEmpty()){
Map<String,String> dtlTypeMap = new HashMap<>(); Map<String,String> dtlTypeMap = new HashMap<>();
Map<String,String> titleMap = new HashMap<>(); Map<String,String> titleMap = new HashMap<>();
List<OptionsEGolden> optionsEGoldenList = mdDropOptionsDALService.findByMasterIdsE(Collections.singletonList(101)); List<OptionsEGolden> optionsEGoldenList = mdDropOptionsDALService.findByMasterIdsE(Collections.singletonList(101));
optionsEGoldenList.forEach(i->dtlTypeMap.put(i.getOptAttr(),i.getOptName())); optionsEGoldenList.forEach(i->dtlTypeMap.put(i.getOptAttr(),i.getOptName()));
List<OptionsEGolden> titleList = mdDropOptionsDALService.findAllTitleEG(); List<OptionsEGolden> titleList = mdDropOptionsDALService.findAllTitleEG();
titleList.forEach(i->titleMap.put(i.getTitleCode(),i.getTitleName())); titleList.forEach(i->titleMap.put(i.getTitleCode(),i.getTitleName()));
for(PayScaleInfo item : payScaleInfoList){ Map<Integer,PayScaleInfo> payScaleInfoMap = new HashMap<>();
PayScaleInfo payScaleInfo;
Integer time;
for(PayScaleInfo item : payScaleInfoListAll){
time = item.getMonDtlPeriod();
if(payScaleInfoMap.containsKey(time)){
payScaleInfo = payScaleInfoMap.get(time);
calculateRAmount(payScaleInfo,item);
}else{
calculateRAmount(item,item);
item.setMonDtlItem("实发薪水");
payScaleInfoMap.put(time,item);
item.setDrpTitleCode(titleMap.get(item.getDrpTitleCode())); item.setDrpTitleCode(titleMap.get(item.getDrpTitleCode()));
item.setMonDtlType(dtlTypeMap.get(item.getMonDtlType())); item.setMonDtlType(dtlTypeMap.get(item.getMonDtlType()));
item.setMonDtlItem(getCommissionType(item.getMonDtlItem()));
}
} }
responseVO.setPayScaleInfos(payScaleInfoList); //修改金钱格式
for(PayScaleInfo item : payScaleInfoListAll){
item.setMonDtlRAmount(CommonUtil.doubleFormat(item.getMonDtlRAmount(),2));
}
List<PayScaleInfo> resultList = new ArrayList<>(payScaleInfoMap.values());
resultList.sort(Comparator.comparingInt(PayScaleInfo :: getMonDtlPeriod).reversed());
responseVO.setPayScaleInfos(resultList);
} }
responseVO.setCommonResult(new CommonResult(true,ZHBErrorConfig.getErrorInfo("800000"))); responseVO.setCommonResult(new CommonResult(true,ZHBErrorConfig.getErrorInfo("800000")));
}else{ }else{
...@@ -126,6 +148,96 @@ public class PractitionerBasicInfoServiceImpl implements PractitionerBasicInfoSe ...@@ -126,6 +148,96 @@ public class PractitionerBasicInfoServiceImpl implements PractitionerBasicInfoSe
return responseVO; return responseVO;
} }
@Override
public String payScalePdf(PayScalePdfRequestVO requestVO, HttpServletResponse response) {
Integer monShId = requestVO.getMonShId();
if(monShId != null){
String filePath = aclPractitionerDALService.findFilePathByMonShId(monShId);
if(!Strings.isNullOrEmpty(filePath)){
String[] str = filePath.split("salaryCalculation/");
if(str.length == 2){
filePath = "/home/egolden/shareSalaryCalculation"+str[1];
getPayScalePdf(filePath,response);
return "下载成功!";
}
}
}
return "下载失败!";
}
private void getPayScalePdf(String filePath, HttpServletResponse response) {
File file = new File(filePath);
// 如果文件名存在,则进行下载
if (file.exists()) {
// 配置文件下载
String[] str = filePath.split("/");
String fileName = str[str.length-1];
response.setHeader("content-type", "application/pdf");
response.setHeader("Cache-Control", "max-age=30");
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("Pragma", "public");
// 下载文件能正常显示中文
try {
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
response.setContentType("application/pdf");
// 实现文件下载
byte[] buffer = new byte[1024];
FileInputStream fis = null;
BufferedInputStream bis = null;
try {
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
OutputStream os = response.getOutputStream();
int i = bis.read(buffer);
while (i != -1) {
os.write(buffer, 0, i);
i = bis.read(buffer);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bis != null) {
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
private void calculateRAmount(PayScaleInfo payScaleInfoMain, PayScaleInfo payScaleInfoElse) {
if(payScaleInfoMain != null && payScaleInfoElse != null){
Integer shIdMain = payScaleInfoMain.getMonShId();
Integer shIdElse = payScaleInfoElse.getMonShId();
Double all = payScaleInfoMain.getMonDtlRAmount();
double allA = (shIdMain.equals(shIdElse))? 0D : payScaleInfoMain.getMonDtlAmount();
Double temp = payScaleInfoElse.getMonDtlAmount();
String type = payScaleInfoElse.getMonDtlItem();
if(!Strings.isNullOrEmpty(type)){
if(type.startsWith("W")){
all = all - temp;
}else{
all = all + temp;
allA = allA + temp;
}
payScaleInfoMain.setMonDtlRAmount(all);
payScaleInfoMain.setMonDtlAmount(allA);
}
}
}
private String getOrderNoE(String policyNo) { private String getOrderNoE(String policyNo) {
String orderNo = null; String orderNo = null;
if(!Strings.isNullOrEmpty(policyNo)){ if(!Strings.isNullOrEmpty(policyNo)){
......
...@@ -2,24 +2,15 @@ package com.yd.api.practitioner.vo.payscale; ...@@ -2,24 +2,15 @@ package com.yd.api.practitioner.vo.payscale;
public class PayScaleInfo { public class PayScaleInfo {
private Integer monShId; private Integer monShId;
private String spcBusId;
private String spcDivId;
private String salMstId; private String salMstId;
private String drpTitleCode; private String drpTitleCode;
private String monDtlType; private String monDtlType;
private String monDtlItem; private String monDtlItem;
private String monDtlPeriod; private Integer monDtlPeriod;
private Integer monDtlAmount; private Double monDtlAmount;
private String monDtlRAmount; private Double monDtlRAmount;
private String createDate; private String createDate;
private String createUser; private String createUser;
private String modifyDate;
private String modifyUser;
private Integer dtlFun;
private String uploadPath;
private String uploadTime;
private String payScaleUrl;
private String payScaleData;
public Integer getMonShId() { public Integer getMonShId() {
return monShId; return monShId;
...@@ -29,22 +20,6 @@ public class PayScaleInfo { ...@@ -29,22 +20,6 @@ public class PayScaleInfo {
this.monShId = monShId; this.monShId = monShId;
} }
public String getSpcBusId() {
return spcBusId;
}
public void setSpcBusId(String spcBusId) {
this.spcBusId = spcBusId;
}
public String getSpcDivId() {
return spcDivId;
}
public void setSpcDivId(String spcDivId) {
this.spcDivId = spcDivId;
}
public String getSalMstId() { public String getSalMstId() {
return salMstId; return salMstId;
} }
...@@ -77,19 +52,19 @@ public class PayScaleInfo { ...@@ -77,19 +52,19 @@ public class PayScaleInfo {
this.monDtlItem = monDtlItem; this.monDtlItem = monDtlItem;
} }
public Integer getMonDtlAmount() { public Double getMonDtlAmount() {
return monDtlAmount; return monDtlAmount;
} }
public void setMonDtlAmount(Integer monDtlAmount) { public void setMonDtlAmount(Double monDtlAmount) {
this.monDtlAmount = monDtlAmount; this.monDtlAmount = monDtlAmount;
} }
public String getMonDtlRAmount() { public Double getMonDtlRAmount() {
return monDtlRAmount; return monDtlRAmount;
} }
public void setMonDtlRAmount(String monDtlRAmount) { public void setMonDtlRAmount(Double monDtlRAmount) {
this.monDtlRAmount = monDtlRAmount; this.monDtlRAmount = monDtlRAmount;
} }
...@@ -109,67 +84,11 @@ public class PayScaleInfo { ...@@ -109,67 +84,11 @@ public class PayScaleInfo {
this.createUser = createUser; this.createUser = createUser;
} }
public String getModifyDate() { public Integer getMonDtlPeriod() {
return modifyDate;
}
public void setModifyDate(String modifyDate) {
this.modifyDate = modifyDate;
}
public String getModifyUser() {
return modifyUser;
}
public void setModifyUser(String modifyUser) {
this.modifyUser = modifyUser;
}
public Integer getDtlFun() {
return dtlFun;
}
public void setDtlFun(Integer dtlFun) {
this.dtlFun = dtlFun;
}
public String getUploadPath() {
return uploadPath;
}
public void setUploadPath(String uploadPath) {
this.uploadPath = uploadPath;
}
public String getUploadTime() {
return uploadTime;
}
public void setUploadTime(String uploadTime) {
this.uploadTime = uploadTime;
}
public String getPayScaleUrl() {
return payScaleUrl;
}
public void setPayScaleUrl(String payScaleUrl) {
this.payScaleUrl = payScaleUrl;
}
public String getPayScaleData() {
return payScaleData;
}
public void setPayScaleData(String payScaleData) {
this.payScaleData = payScaleData;
}
public String getMonDtlPeriod() {
return monDtlPeriod; return monDtlPeriod;
} }
public void setMonDtlPeriod(String monDtlPeriod) { public void setMonDtlPeriod(Integer monDtlPeriod) {
this.monDtlPeriod = monDtlPeriod; this.monDtlPeriod = monDtlPeriod;
} }
} }
package com.yd.api.practitioner.vo.payscale;
import com.yd.api.result.CommonResult;
public class PayScalePdfResponseVO {
private CommonResult commonResult;
public CommonResult getCommonResult() {
return commonResult;
}
public void setCommonResult(CommonResult commonResult) {
this.commonResult = commonResult;
}
}
...@@ -57,4 +57,6 @@ public interface AclPractitionerMapper { ...@@ -57,4 +57,6 @@ public interface AclPractitionerMapper {
PractitionerRankInfo getPractitionerRankInfoByPractitionerIdYD(@Param("practitionerId")Long practitionerId, @Param("time")Integer time); PractitionerRankInfo getPractitionerRankInfoByPractitionerIdYD(@Param("practitionerId")Long practitionerId, @Param("time")Integer time);
List<PayScaleInfo> findPayScaleByPractitionerEG(@Param("practitionerIdEG")String practitionerIdEG); List<PayScaleInfo> findPayScaleByPractitionerEG(@Param("practitionerIdEG")String practitionerIdEG);
String findFilePathByMonShId(@Param("monShId")Integer monShId);
} }
\ No newline at end of file
...@@ -147,4 +147,11 @@ public interface AclPractitionerDALService { ...@@ -147,4 +147,11 @@ public interface AclPractitionerDALService {
* @return 结果 * @return 结果
*/ */
List<PayScaleInfo> findPayScaleByPractitionerEG(String practitionerIdEG); List<PayScaleInfo> findPayScaleByPractitionerEG(String practitionerIdEG);
/**
* 查询经纪人薪资文件路径
* @param monShId 流水号
* @return 结果
*/
String findFilePathByMonShId(Integer monShId);
} }
...@@ -142,4 +142,9 @@ public class AclPractitionerDALServiceImpl implements AclPractitionerDALService ...@@ -142,4 +142,9 @@ public class AclPractitionerDALServiceImpl implements AclPractitionerDALService
public List<PayScaleInfo> findPayScaleByPractitionerEG(String practitionerIdEG) { public List<PayScaleInfo> findPayScaleByPractitionerEG(String practitionerIdEG) {
return aclPractitionerMapper.findPayScaleByPractitionerEG(practitionerIdEG); return aclPractitionerMapper.findPayScaleByPractitionerEG(practitionerIdEG);
} }
@Override
public String findFilePathByMonShId(Integer monShId) {
return aclPractitionerMapper.findFilePathByMonShId(monShId);
}
} }
...@@ -873,21 +873,20 @@ ...@@ -873,21 +873,20 @@
<select id="findPayScaleByPractitionerEG" resultType="com.yd.api.practitioner.vo.payscale.PayScaleInfo"> <select id="findPayScaleByPractitionerEG" resultType="com.yd.api.practitioner.vo.payscale.PayScaleInfo">
select select
t.MON_SH_ID as monShId, t.MON_SH_ID as monShId,
t.FK_SPC_BUS_ID as spcBusId,
t.FK_SPC_DIV_ID as spcDivId,
t.FK_SAL_MST_ID as salMstId, t.FK_SAL_MST_ID as salMstId,
t.FK_DRP_TITLE_CODE as drpTitleCode, t.FK_DRP_TITLE_CODE as drpTitleCode,
t.MON_DTL_TYPE as monDtlType, t.MON_DTL_TYPE as monDtlType,
t.MON_DTL_ITEM as monDtlItem, t.MON_DTL_ITEM as monDtlItem,
t.MON_DTL_PERIOD as monDtlAmount, t.MON_DTL_PERIOD as monDtlPeriod,
t.MON_DTL_RAMOUNT as monDtlRAmount, ifnull(t.MON_DTL_AMOUNT,0) as monDtlAmount,
ifnull(t.MON_DTL_RAMOUNT,0) as monDtlRAmount,
date_format(t.CREATE_DATE, '%Y-%m-%d %H:%i:%s') as createDate, date_format(t.CREATE_DATE, '%Y-%m-%d %H:%i:%s') as createDate,
t.CREATE_USER as createUser, t.CREATE_USER as createUser
t.MON_DTL_FUN as dtlFun,
t.UPLOAD_PATH as uploadPath,
t.MODIFY_USER as modifyUser,
date_format(t.MODIFY_DATE, '%Y-%m-%d %H:%i:%s') as modifyDate,
date_format(t.UPLOAD_TIME, '%Y-%m-%d %H:%i:%s') as uploadTime
from mon011 t where FK_SAL_MST_ID = #{practitionerIdEG,jdbcType=VARCHAR}; from mon011 t where FK_SAL_MST_ID = #{practitionerIdEG,jdbcType=VARCHAR};
</select> </select>
<select id="findFilePathByMonShId" resultType="java.lang.String">
select t.UPLOAD_PATH
from mon011 t where t.MON_SH_ID = #{monShId,jdbcType=INTEGER}
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment