Commit 1cb5c051 by Water Wang

add -- payscale pfd download

parent 8db2c3b3
......@@ -151,6 +151,11 @@
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
</dependencies>
<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;
import com.test.web.vo.TestRequestVO;
import com.yd.api.practitioner.service.PractitionerBasicInfoService;
import com.yd.api.practitioner.service.PractitionerService;
import com.yd.api.practitioner.vo.login.PractitionerLoginRequestVO;
......@@ -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.MediaGetRespVO;
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.PayScaleQueryResponseVO;
import com.yd.api.practitioner.vo.policy.PolicyListQueryRequestVO;
......@@ -22,10 +24,14 @@ import com.yd.api.practitioner.vo.subordinate.SubordinateSystemMemberQueryReques
import com.yd.api.practitioner.vo.subordinate.SubordinateSystemMemberQueryResponseVO;
import com.yd.api.result.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
@Controller
@RestController
......@@ -457,4 +463,16 @@ public class PractitionerController {
result.addResult(responseVO);
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;
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.PayScaleQueryResponseVO;
import com.yd.api.practitioner.vo.policy.PolicyListQueryRequestVO;
......@@ -8,6 +10,8 @@ import com.yd.api.practitioner.vo.policy.policyinfoquery.PolicyInfoQueryRequestV
import com.yd.api.practitioner.vo.policy.policyinfoquery.PolicyInfoQueryResponseVO;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
@Service("practitionerBasicInfoService")
public interface PractitionerBasicInfoService {
/**
......@@ -30,4 +34,12 @@ public interface PractitionerBasicInfoService {
* @return 相应
*/
PayScaleQueryResponseVO payScaleListQuery(PayScaleQueryRequestVO requestVO);
/**
* 获取经纪人的薪资表
* @param requestVO 请求信息
* @param response 请求信息
* @return 响应信息
*/
String payScalePdf(PayScalePdfRequestVO requestVO, HttpServletResponse response);
}
package com.yd.api.practitioner.service.impl;
import com.google.common.base.Strings;
import com.yd.api.practitioner.PayScalePdfRequestVO;
import com.yd.api.practitioner.service.PractitionerBasicInfoService;
import com.yd.api.practitioner.vo.payscale.PayScaleInfo;
import com.yd.api.practitioner.vo.payscale.PayScaleQueryRequestVO;
......@@ -29,6 +30,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.*;
@Service("practitionerBasicInfoService")
......@@ -103,20 +107,38 @@ public class PractitionerBasicInfoServiceImpl implements PractitionerBasicInfoSe
PayScaleQueryResponseVO responseVO = new PayScaleQueryResponseVO();
String practitionerIdEG = requestVO.getPractitionerIdEG();
if(!Strings.isNullOrEmpty(practitionerIdEG)){
List<PayScaleInfo> payScaleInfoList = aclPractitionerDALService.findPayScaleByPractitionerEG(practitionerIdEG);
if(!payScaleInfoList.isEmpty()){
List<PayScaleInfo> payScaleInfoListAll = aclPractitionerDALService.findPayScaleByPractitionerEG(practitionerIdEG);
if(!payScaleInfoListAll.isEmpty()){
Map<String,String> dtlTypeMap = new HashMap<>();
Map<String,String> titleMap = new HashMap<>();
List<OptionsEGolden> optionsEGoldenList = mdDropOptionsDALService.findByMasterIdsE(Collections.singletonList(101));
optionsEGoldenList.forEach(i->dtlTypeMap.put(i.getOptAttr(),i.getOptName()));
List<OptionsEGolden> titleList = mdDropOptionsDALService.findAllTitleEG();
titleList.forEach(i->titleMap.put(i.getTitleCode(),i.getTitleName()));
for(PayScaleInfo item : payScaleInfoList){
item.setDrpTitleCode(titleMap.get(item.getDrpTitleCode()));
item.setMonDtlType(dtlTypeMap.get(item.getMonDtlType()));
item.setMonDtlItem(getCommissionType(item.getMonDtlItem()));
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.setMonDtlType(dtlTypeMap.get(item.getMonDtlType()));
}
}
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")));
}else{
......@@ -126,6 +148,96 @@ public class PractitionerBasicInfoServiceImpl implements PractitionerBasicInfoSe
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) {
String orderNo = null;
if(!Strings.isNullOrEmpty(policyNo)){
......
......@@ -2,24 +2,15 @@ package com.yd.api.practitioner.vo.payscale;
public class PayScaleInfo {
private Integer monShId;
private String spcBusId;
private String spcDivId;
private String salMstId;
private String drpTitleCode;
private String monDtlType;
private String monDtlItem;
private String monDtlPeriod;
private Integer monDtlAmount;
private String monDtlRAmount;
private Integer monDtlPeriod;
private Double monDtlAmount;
private Double monDtlRAmount;
private String createDate;
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() {
return monShId;
......@@ -29,22 +20,6 @@ public class PayScaleInfo {
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() {
return salMstId;
}
......@@ -77,19 +52,19 @@ public class PayScaleInfo {
this.monDtlItem = monDtlItem;
}
public Integer getMonDtlAmount() {
public Double getMonDtlAmount() {
return monDtlAmount;
}
public void setMonDtlAmount(Integer monDtlAmount) {
public void setMonDtlAmount(Double monDtlAmount) {
this.monDtlAmount = monDtlAmount;
}
public String getMonDtlRAmount() {
public Double getMonDtlRAmount() {
return monDtlRAmount;
}
public void setMonDtlRAmount(String monDtlRAmount) {
public void setMonDtlRAmount(Double monDtlRAmount) {
this.monDtlRAmount = monDtlRAmount;
}
......@@ -109,67 +84,11 @@ public class PayScaleInfo {
this.createUser = createUser;
}
public String getModifyDate() {
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() {
public Integer getMonDtlPeriod() {
return monDtlPeriod;
}
public void setMonDtlPeriod(String monDtlPeriod) {
public void setMonDtlPeriod(Integer 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 {
PractitionerRankInfo getPractitionerRankInfoByPractitionerIdYD(@Param("practitionerId")Long practitionerId, @Param("time")Integer time);
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 {
* @return 结果
*/
List<PayScaleInfo> findPayScaleByPractitionerEG(String practitionerIdEG);
/**
* 查询经纪人薪资文件路径
* @param monShId 流水号
* @return 结果
*/
String findFilePathByMonShId(Integer monShId);
}
......@@ -142,4 +142,9 @@ public class AclPractitionerDALServiceImpl implements AclPractitionerDALService
public List<PayScaleInfo> findPayScaleByPractitionerEG(String practitionerIdEG) {
return aclPractitionerMapper.findPayScaleByPractitionerEG(practitionerIdEG);
}
@Override
public String findFilePathByMonShId(Integer monShId) {
return aclPractitionerMapper.findFilePathByMonShId(monShId);
}
}
......@@ -873,21 +873,20 @@
<select id="findPayScaleByPractitionerEG" resultType="com.yd.api.practitioner.vo.payscale.PayScaleInfo">
select
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_DRP_TITLE_CODE as drpTitleCode,
t.MON_DTL_TYPE as monDtlType,
t.MON_DTL_ITEM as monDtlItem,
t.MON_DTL_PERIOD as monDtlAmount,
t.MON_DTL_RAMOUNT as monDtlRAmount,
t.MON_DTL_PERIOD as monDtlPeriod,
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,
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
t.CREATE_USER as createUser
from mon011 t where FK_SAL_MST_ID = #{practitionerIdEG,jdbcType=VARCHAR};
</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>
\ 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