parent
8e3c4bfacc
commit
0777f99870
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.engine.salary.entity.push.param;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建推送记录
|
||||||
|
* <p>Copyright: Copyright (c) 2024</p>
|
||||||
|
* <p>Company: 泛微软件</p>
|
||||||
|
*
|
||||||
|
* @author qiantao
|
||||||
|
* @version 1.0
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CreatePushParam {
|
||||||
|
|
||||||
|
|
||||||
|
private List<Long> salaryAcctRecordIds;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -13,6 +13,8 @@ import lombok.NoArgsConstructor;
|
||||||
public class PushParam {
|
public class PushParam {
|
||||||
|
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
private Long salaryAcctRecordId;
|
private Long salaryAcctRecordId;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,19 +58,14 @@ public interface PushService {
|
||||||
*/
|
*/
|
||||||
void deleteItem(Long id);
|
void deleteItem(Long id);
|
||||||
|
|
||||||
/**
|
|
||||||
* 推送一条核算记录下的所有数据
|
|
||||||
*
|
|
||||||
* @param salaryAcctRecordId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void pushOneRecord(Long salaryAcctRecordId);
|
|
||||||
|
|
||||||
void createPushRecord(Long salaryAcctRecordId);
|
void createPushRecord(Long salaryAcctRecordId);
|
||||||
|
|
||||||
|
void push(Long id);
|
||||||
|
|
||||||
void removeRecords(List<Long> records);
|
void removeRecords(List<Long> records);
|
||||||
|
|
||||||
PageInfo<PushRecordDTO> recordList(RecordListQueryParam param);
|
PageInfo<PushRecordDTO> recordList(RecordListQueryParam param);
|
||||||
|
|
||||||
PageInfo<PushRecordDetailDTO> recordDetailList(RecordDetailListQueryParam param);
|
PageInfo<PushRecordDetailDTO> recordDetailList(RecordDetailListQueryParam param);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -246,120 +246,6 @@ public class PushServiceImpl extends Service implements PushService {
|
||||||
getPushSettingItemMapper().delete(PushSettingItemPO.builder().id(id).build());
|
getPushSettingItemMapper().delete(PushSettingItemPO.builder().id(id).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void pushOneRecord(Long salaryAcctRecordId) {
|
|
||||||
|
|
||||||
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId);
|
|
||||||
|
|
||||||
if (salaryAcctRecordPO == null) {
|
|
||||||
throw new SalaryRunTimeException("核算记录不存在!");
|
|
||||||
}
|
|
||||||
|
|
||||||
//查询核算人员
|
|
||||||
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salaryAcctRecordPO.getId());
|
|
||||||
|
|
||||||
//薪资项目
|
|
||||||
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listAll();
|
|
||||||
//查询薪资核算记录的薪资周期、考勤周期等
|
|
||||||
SalarySobCycleDTO salarySobCycleDTO = getSalaryAcctRecordService(user).getSalarySobCycleById(salaryAcctRecordPO.getId());
|
|
||||||
|
|
||||||
SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO()
|
|
||||||
.setSalaryAcctRecordPO(salaryAcctRecordPO)
|
|
||||||
.setSalarySobPO(new SalarySobPO())
|
|
||||||
.setSalarySobCycleDTO(salarySobCycleDTO)
|
|
||||||
.setOtherSalaryAcctRecordPOS(new ArrayList<>())
|
|
||||||
.setSalarySobItemPOS(new ArrayList<>())
|
|
||||||
.setSalaryItemIdWithPriorityList(new ArrayList<>())
|
|
||||||
.setExpressFormulas(new ArrayList<>())
|
|
||||||
.setSalaryItemPOS(salaryItemPOS)
|
|
||||||
.setSalarySobAdjustRulePOS(new ArrayList<>())
|
|
||||||
.setWelfareColumns(new HashMap<>())
|
|
||||||
.setAttendQuoteFieldListDTOS(new ArrayList<>())
|
|
||||||
.setSalaryAcctEmployeePOS(salaryAcctEmployeePOS)
|
|
||||||
.setIssuedFieldIds(new HashSet<>())
|
|
||||||
.setChildMonitor(null)
|
|
||||||
.setResults(null)
|
|
||||||
.setCalculateKey(null)
|
|
||||||
.setVariableItems(new ArrayList<>())
|
|
||||||
.setTaxDeclarationFunction(TaxDeclarationFunctionEnum.OPEN);
|
|
||||||
|
|
||||||
|
|
||||||
List<Long> employeeIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getSalaryAcctEmployeePOS(), SalaryAcctEmployeePO::getEmployeeId, Collectors.toList());
|
|
||||||
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds);
|
|
||||||
|
|
||||||
List<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getSalaryAcctEmployeePOS(), SalaryAcctEmployeePO::getId, Collectors.toList());
|
|
||||||
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds);
|
|
||||||
|
|
||||||
CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), salaryAcctResultPOS, new ArrayList<>(),new ArrayList<>());
|
|
||||||
Map<String, List<CalculateFormulaVarBO.FormulaVarValue>> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO);
|
|
||||||
|
|
||||||
|
|
||||||
List<PushSettingPO> pushSettingPOS = getPushSettingMapper().listSome(PushSettingPO.builder().able(1).build());
|
|
||||||
pushSettingPOS.stream()
|
|
||||||
.filter(po -> po.getSalarySobIds().contains(salaryAcctRecordPO.getSalarySobId()))
|
|
||||||
.forEach(setting -> {
|
|
||||||
|
|
||||||
Long id = setting.getId();
|
|
||||||
List<PushSettingItemPO> pushSettingItemPOS = getPushSettingItemMapper().listSome(PushSettingItemPO.builder().settingId(id).build());
|
|
||||||
|
|
||||||
|
|
||||||
//每个人插入一条
|
|
||||||
for (SalaryAcctEmployeePO emp : salaryAcctEmployeePOS) {
|
|
||||||
//1 获取当前薪资核算人员的公式中的变量的值
|
|
||||||
List<CalculateFormulaVarBO.FormulaVarValue> formulaVarValues = formulaVarMap.get(emp.getEmployeeId() + "_" + emp.getTaxAgentId());
|
|
||||||
//2 人员信息
|
|
||||||
List<CalculateFormulaVarBO.FormulaVarValue> empInfo = formulaVarMap.get(emp.getEmployeeId() + "");
|
|
||||||
formulaVarValues.addAll(empInfo);
|
|
||||||
Map<String, String> formulaVarValueMap = SalaryEntityUtil.convert2Map(formulaVarValues, CalculateFormulaVarBO.FormulaVarValue::getFieldId, CalculateFormulaVarBO.FormulaVarValue::getFieldValue);
|
|
||||||
|
|
||||||
Integer modeId = setting.getModeId();
|
|
||||||
|
|
||||||
List<String> fields = new ArrayList<String>() {{
|
|
||||||
add("formmodeid");
|
|
||||||
add("modedatacreater");
|
|
||||||
add("modedatacreatertype");
|
|
||||||
add("modedatacreatedate");
|
|
||||||
add("modedatacreatetime");
|
|
||||||
}};
|
|
||||||
String currDate = TimeUtil.getCurrentDateString();
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
|
||||||
String currTime = sdf.format(new Date());
|
|
||||||
List<Object> values = new ArrayList<Object>() {{
|
|
||||||
add(modeId);
|
|
||||||
add(1);
|
|
||||||
add(0);
|
|
||||||
add(String.format("'%s'", currDate));
|
|
||||||
add(String.format("'%s'", currTime));
|
|
||||||
}};
|
|
||||||
for (PushSettingItemPO item : pushSettingItemPOS) {
|
|
||||||
//数据库字段
|
|
||||||
String fieldName = item.getFieldName();
|
|
||||||
fields.add(fieldName);
|
|
||||||
// 公式变量的值
|
|
||||||
String field = item.getItem();
|
|
||||||
String value = formulaVarValueMap.getOrDefault(field, StringUtils.EMPTY);
|
|
||||||
PushItemFieldEnum pushItemFieldEnum = PushItemFieldEnum.parseByValue(item.getFieldType());
|
|
||||||
values.add(pushItemFieldEnum.convertValue(value));
|
|
||||||
}
|
|
||||||
String tableName = setting.getTableName();
|
|
||||||
String sql = String.format("insert into %s (%s) values (%s)", tableName, String.join(",", fields), values.stream().map(Object::toString).collect(Collectors.joining(",")));
|
|
||||||
RecordSet rs = new RecordSet();
|
|
||||||
rs.execute(sql);
|
|
||||||
|
|
||||||
if (modeId != null) {
|
|
||||||
rs.executeQuery("select max(id) from " + tableName);
|
|
||||||
int mainId = 0;
|
|
||||||
if (rs.next()) {
|
|
||||||
mainId = rs.getInt(1);
|
|
||||||
}
|
|
||||||
ModeRightInfo ModeRightInfo = new ModeRightInfo();
|
|
||||||
ModeRightInfo.setNewRight(true);
|
|
||||||
ModeRightInfo.editModeDataShare(1, modeId, mainId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createPushRecord(Long salaryAcctRecordId) {
|
public void createPushRecord(Long salaryAcctRecordId) {
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
|
@ -506,9 +392,9 @@ public class PushServiceImpl extends Service implements PushService {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("推送失败", e);
|
log.error("创建推送记录失败", e);
|
||||||
removeRecords(recordIds);
|
removeRecords(recordIds);
|
||||||
throw new SalaryRunTimeException("推送失败");
|
throw new SalaryRunTimeException("创建推送记录失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
//开始
|
//开始
|
||||||
|
|
@ -516,62 +402,65 @@ public class PushServiceImpl extends Service implements PushService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void push(Long id) {
|
||||||
|
//待推送
|
||||||
|
PushRecordPO pushRecordPO = getPushRecordMapper().getById(id);
|
||||||
|
pushRecordPO.setStatus(PushRecordStatusEnum.RUN_WAITING.getValue());
|
||||||
|
getPushRecordMapper().updateIgnoreNull(pushRecordPO);
|
||||||
|
|
||||||
|
try {
|
||||||
|
pushRecordPO.setStartTime(new Date());
|
||||||
|
pushRecordPO.setStatus(PushRecordStatusEnum.RUN_PROGRESS.getValue());
|
||||||
|
getPushRecordMapper().updateIgnoreNull(pushRecordPO);
|
||||||
|
List<PushRecordDetailPO> pushRecordDetailPOS = getPushRecordDetailMapper().listSome(PushRecordDetailPO.builder().recordId(pushRecordPO.getId()).build());
|
||||||
|
pushRecordDetailPOS.forEach(pushRecordDetailPO -> {
|
||||||
|
|
||||||
|
try {
|
||||||
|
String execute = pushRecordDetailPO.getExecute();
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
rs.execute(execute);
|
||||||
|
//建模需要权限重构
|
||||||
|
Integer modeId = pushRecordPO.getModeId();
|
||||||
|
if (modeId != null) {
|
||||||
|
String tableName = pushRecordPO.getTableName();
|
||||||
|
rs.executeQuery("select max(id) from " + tableName);
|
||||||
|
int mainId = 0;
|
||||||
|
if (rs.next()) {
|
||||||
|
mainId = rs.getInt(1);
|
||||||
|
}
|
||||||
|
ModeRightInfo ModeRightInfo = new ModeRightInfo();
|
||||||
|
ModeRightInfo.setNewRight(true);
|
||||||
|
ModeRightInfo.editModeDataShare(1, modeId, mainId);
|
||||||
|
}
|
||||||
|
|
||||||
|
pushRecordDetailPO.setStatus(PushRecordDetailStatusEnum.SUCCESS.getValue());
|
||||||
|
} catch (Exception e) {
|
||||||
|
pushRecordDetailPO.setFail_reason(e.getMessage());
|
||||||
|
pushRecordDetailPO.setStatus(PushRecordDetailStatusEnum.FAIL.getValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
pushRecordPO.setEndTime(new Date());
|
||||||
|
pushRecordPO.setStatus(PushRecordStatusEnum.RUN_SUCCESS.getValue());
|
||||||
|
} catch (Exception e) {
|
||||||
|
pushRecordPO.setFail_reason(e.getMessage());
|
||||||
|
pushRecordPO.setStatus(PushRecordStatusEnum.RUN_FAIL.getValue());
|
||||||
|
}
|
||||||
|
getPushRecordMapper().updateIgnoreNull(pushRecordPO);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动推送
|
* 启动推送
|
||||||
*
|
*
|
||||||
* @param recordIds
|
* @param recordIds
|
||||||
*/
|
*/
|
||||||
private void startBatchPush(List<Long> recordIds) {
|
private void startBatchPush(List<Long> recordIds) {
|
||||||
|
recordIds.forEach(this::push);
|
||||||
recordIds.forEach(recordId -> {
|
|
||||||
//待推送
|
|
||||||
PushRecordPO pushRecordPO = getPushRecordMapper().getById(recordId);
|
|
||||||
pushRecordPO.setStatus(PushRecordStatusEnum.RUN_WAITING.getValue());
|
|
||||||
getPushRecordMapper().updateIgnoreNull(pushRecordPO);
|
|
||||||
|
|
||||||
try {
|
|
||||||
pushRecordPO.setStartTime(new Date());
|
|
||||||
pushRecordPO.setStatus(PushRecordStatusEnum.RUN_PROGRESS.getValue());
|
|
||||||
getPushRecordMapper().updateIgnoreNull(pushRecordPO);
|
|
||||||
List<PushRecordDetailPO> pushRecordDetailPOS = getPushRecordDetailMapper().listSome(PushRecordDetailPO.builder().recordId(pushRecordPO.getId()).build());
|
|
||||||
pushRecordDetailPOS.forEach(pushRecordDetailPO -> {
|
|
||||||
|
|
||||||
try {
|
|
||||||
String execute = pushRecordDetailPO.getExecute();
|
|
||||||
RecordSet rs = new RecordSet();
|
|
||||||
rs.execute(execute);
|
|
||||||
//建模需要权限重构
|
|
||||||
Integer modeId = pushRecordPO.getModeId();
|
|
||||||
if (modeId != null) {
|
|
||||||
String tableName = pushRecordPO.getTableName();
|
|
||||||
rs.executeQuery("select max(id) from " + tableName);
|
|
||||||
int mainId = 0;
|
|
||||||
if (rs.next()) {
|
|
||||||
mainId = rs.getInt(1);
|
|
||||||
}
|
|
||||||
ModeRightInfo ModeRightInfo = new ModeRightInfo();
|
|
||||||
ModeRightInfo.setNewRight(true);
|
|
||||||
ModeRightInfo.editModeDataShare(1, modeId, mainId);
|
|
||||||
}
|
|
||||||
|
|
||||||
pushRecordDetailPO.setStatus(PushRecordDetailStatusEnum.SUCCESS.getValue());
|
|
||||||
} catch (Exception e) {
|
|
||||||
pushRecordDetailPO.setFail_reason(e.getMessage());
|
|
||||||
pushRecordDetailPO.setStatus(PushRecordDetailStatusEnum.FAIL.getValue());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
pushRecordPO.setEndTime(new Date());
|
|
||||||
pushRecordPO.setStatus(PushRecordStatusEnum.RUN_SUCCESS.getValue());
|
|
||||||
} catch (Exception e) {
|
|
||||||
pushRecordPO.setFail_reason(e.getMessage());
|
|
||||||
pushRecordPO.setStatus(PushRecordStatusEnum.RUN_FAIL.getValue());
|
|
||||||
}
|
|
||||||
getPushRecordMapper().updateIgnoreNull(pushRecordPO);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeRecords(List<Long> recordIds) {
|
public void removeRecords(List<Long> recordIds) {
|
||||||
recordIds.forEach(recordId -> {
|
recordIds.forEach(recordId -> {
|
||||||
|
|
|
||||||
|
|
@ -92,14 +92,6 @@ public class PushController {
|
||||||
return new ResponseResult<Long, String>(user).run(getPushWrapper(user)::deleteItem, id);
|
return new ResponseResult<Long, String>(user).run(getPushWrapper(user)::deleteItem, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("/push")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
public String push(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody PushParam param) {
|
|
||||||
User user = HrmUserVarify.getUser(request, response);
|
|
||||||
return new ResponseResult<PushParam, String>(user).run(getPushWrapper(user)::push, param);
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/record/list")
|
@Path("/record/list")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
|
@ -115,4 +107,20 @@ public class PushController {
|
||||||
User user = HrmUserVarify.getUser(request, response);
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
return new ResponseResult<RecordDetailListQueryParam, PageInfo<PushRecordDetailDTO>>(user).run(getPushWrapper(user)::recordDetailList, param);
|
return new ResponseResult<RecordDetailListQueryParam, PageInfo<PushRecordDetailDTO>>(user).run(getPushWrapper(user)::recordDetailList, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/record/create")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String createPushRecord(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody CreatePushParam param) {
|
||||||
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
|
return new ResponseResult<CreatePushParam, String>(user).run(getPushWrapper(user)::createPushRecord, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/record/push")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String push(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody PushParam param) {
|
||||||
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
|
return new ResponseResult<PushParam, String>(user).run(getPushWrapper(user)::push, param);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ public class PushWrapper extends Service {
|
||||||
|
|
||||||
return execute;
|
return execute;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PageInfo<PushSettingDTO> settingList(PushSettingQueryParam param) {
|
public PageInfo<PushSettingDTO> settingList(PushSettingQueryParam param) {
|
||||||
return getPushService(user).settingList(param);
|
return getPushService(user).settingList(param);
|
||||||
}
|
}
|
||||||
|
|
@ -60,14 +61,20 @@ public class PushWrapper extends Service {
|
||||||
getPushService(user).deleteItem(id);
|
getPushService(user).deleteItem(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void push(PushParam pushParam) {
|
public void createPushRecord(CreatePushParam param) {
|
||||||
// getPushService(user).pushOneRecord(pushParam.getSalaryAcctRecordId());
|
param.getSalaryAcctRecordIds().forEach(id -> {
|
||||||
getPushService(user).createPushRecord(pushParam.getSalaryAcctRecordId());
|
getPushService(user).createPushRecord(id);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public PageInfo<PushRecordDTO> recordList(RecordListQueryParam param) {
|
public void push(PushParam pushParam) {
|
||||||
|
getPushService(user).push(pushParam.getId());
|
||||||
|
}
|
||||||
|
|
||||||
return getPushService(user).recordList(param);
|
|
||||||
|
|
||||||
|
public PageInfo<PushRecordDTO> recordList(RecordListQueryParam param) {
|
||||||
|
return getPushService(user).recordList(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PageInfo<PushRecordDetailDTO> recordDetailList(RecordDetailListQueryParam param) {
|
public PageInfo<PushRecordDetailDTO> recordDetailList(RecordDetailListQueryParam param) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue