|
|
|
@ -3,31 +3,35 @@ package com.os.mes.record.service.impl;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import com.os.common.constant.MesConstants;
|
|
|
|
|
import com.os.common.exception.ServiceException;
|
|
|
|
|
import com.os.common.utils.DateUtils;
|
|
|
|
|
import com.os.common.utils.SecurityUtils;
|
|
|
|
|
import com.os.common.utils.StringUtils;
|
|
|
|
|
import com.os.common.utils.uuid.PlanCodeUtils;
|
|
|
|
|
import com.os.mes.api.domain.ERPParamDto;
|
|
|
|
|
import com.os.mes.api.domain.LatestSalary;
|
|
|
|
|
import com.os.mes.api.service.IERPPortService;
|
|
|
|
|
import com.os.mes.base.domain.BaseProcessInfo;
|
|
|
|
|
import com.os.mes.base.domain.BaseStaffInfo;
|
|
|
|
|
import com.os.mes.base.domain.BaseTeamMembers;
|
|
|
|
|
import com.os.mes.base.mapper.BaseProcessInfoMapper;
|
|
|
|
|
import com.os.mes.base.mapper.BaseStaffInfoMapper;
|
|
|
|
|
import com.os.mes.base.mapper.BaseTeamMembersMapper;
|
|
|
|
|
import com.os.mes.prod.domain.ProdOrderInfo;
|
|
|
|
|
import com.os.mes.prod.domain.ProdPlanDetail;
|
|
|
|
|
import com.os.mes.prod.domain.ProdPlanInfo;
|
|
|
|
|
import com.os.mes.prod.domain.ProdPlanExecuteUser;
|
|
|
|
|
import com.os.mes.prod.mapper.ProdOrderInfoMapper;
|
|
|
|
|
import com.os.mes.prod.mapper.ProdPlanExecuteUserMapper;
|
|
|
|
|
import com.os.mes.prod.mapper.ProdPlanInfoMapper;
|
|
|
|
|
import com.os.mes.record.domain.RecordStaffCommute;
|
|
|
|
|
import com.os.mes.record.mapper.RecordStaffCommuteMapper;
|
|
|
|
|
import com.os.mes.record.domain.ReportSalarySummary;
|
|
|
|
|
import com.os.mes.record.domain.StaffSalaryVo;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.os.mes.record.mapper.RecordStaffSalaryMapper;
|
|
|
|
|
import com.os.mes.record.domain.RecordStaffSalary;
|
|
|
|
|
import com.os.mes.record.service.IRecordStaffSalaryService;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 员工工资记录Service业务层处理
|
|
|
|
@ -56,7 +60,7 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService {
|
|
|
|
|
private BaseProcessInfoMapper baseProcessInfoMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RecordStaffCommuteMapper recordStaffCommuteMapper;
|
|
|
|
|
private ProdPlanExecuteUserMapper prodPlanExecuteUserMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IERPPortService portService;
|
|
|
|
@ -80,7 +84,23 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService {
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<RecordStaffSalary> selectRecordStaffSalaryList(RecordStaffSalary recordStaffSalary) {
|
|
|
|
|
return recordStaffSalaryMapper.selectRecordStaffSalaryList(recordStaffSalary);
|
|
|
|
|
List<RecordStaffSalary> recordStaffSalaryList = recordStaffSalaryMapper.selectRecordStaffSalaryList(recordStaffSalary);
|
|
|
|
|
List<BaseTeamMembers> teamMembers = baseTeamMembersMapper.selectBaseTeamMembersList(new BaseTeamMembers());
|
|
|
|
|
for (RecordStaffSalary staffSalary : recordStaffSalaryList) {
|
|
|
|
|
if (StringUtils.isEmpty(staffSalary.getGroupId())) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
for (BaseTeamMembers teamMember : teamMembers) {
|
|
|
|
|
if (staffSalary.getGroupId().contains(teamMember.getTeamCode())) {
|
|
|
|
|
if (StringUtils.isEmpty(staffSalary.getTeamName())) {
|
|
|
|
|
staffSalary.setTeamName(teamMember.getTeamName());
|
|
|
|
|
} else {
|
|
|
|
|
staffSalary.setTeamName(staffSalary.getTeamName() + "," + teamMember.getTeamName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return recordStaffSalaryList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -130,19 +150,216 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生成班组员工工资
|
|
|
|
|
* (工序硫化的工资计算方法 = 硫化系数*硫化面积*(工资系数/参加该工序的所有人的工资系数的总和)
|
|
|
|
|
* 这里的硫化面积=硫化米数/客户要求总米数*硫化面积)
|
|
|
|
|
* <p>
|
|
|
|
|
* 1、需知道每个员工在时间范围内的上班天数
|
|
|
|
|
* 2、需要知道时间范围内生产工单生产完成多少米
|
|
|
|
|
* 3、工序硫化员工工资 = 硫化系数 * (每个工单的实际硫化米数/客户要求总米数*硫化面积) * (员工的工资系数/参加该工序的所有人的工资系数的总和)
|
|
|
|
|
*
|
|
|
|
|
* @param recordStaffSalary
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = ServiceException.class)
|
|
|
|
|
public List<RecordStaffSalary> selectTeamEmployeesWages(RecordStaffSalary recordStaffSalary) {
|
|
|
|
|
List<RecordStaffSalary> result = new ArrayList<>();
|
|
|
|
|
//调用最新工资系数接口
|
|
|
|
|
LatestSalary salaryData = portService.getERPLatestSalaryData(new ERPParamDto());
|
|
|
|
|
|
|
|
|
|
// List<BaseTeamMembers> teamMembers = baseTeamMembersMapper.selectBaseTeamMembersList(new BaseTeamMembers());
|
|
|
|
|
|
|
|
|
|
Map<String, Object> params = recordStaffSalary.getParams();
|
|
|
|
|
ProdPlanExecuteUser selectExecuteUser = new ProdPlanExecuteUser();
|
|
|
|
|
selectExecuteUser.setParams(params); //beginOffWorkTime、beginOffWorkTime 下班后才可以计算之前的工资
|
|
|
|
|
selectExecuteUser.setIsFlag(MesConstants.MES_IS_SALARY_NO);//未生成工资
|
|
|
|
|
List<ProdPlanExecuteUser> planUserList = prodPlanExecuteUserMapper.selectProdPlanExecuteUserList(selectExecuteUser);
|
|
|
|
|
|
|
|
|
|
Date beginOrderDate = null;
|
|
|
|
|
Date endOrderDate = null;
|
|
|
|
|
if (params.containsKey("beginOffWorkTime")) {
|
|
|
|
|
beginOrderDate = DateUtils.parseDate(String.valueOf(params.get("beginOffWorkTime")));
|
|
|
|
|
}
|
|
|
|
|
if (params.containsKey("endOffWorkTime")) {
|
|
|
|
|
endOrderDate = DateUtils.parseDate(String.valueOf(params.get("endOffWorkTime")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String taskCode = PlanCodeUtils.getTaskCode();
|
|
|
|
|
|
|
|
|
|
Map<String, List<ProdPlanExecuteUser>> offWorkTimeUserMap = planUserList.stream().collect(Collectors.groupingBy(ProdPlanExecuteUser::getOffWorkTime));
|
|
|
|
|
|
|
|
|
|
for (String offWorkTime : offWorkTimeUserMap.keySet()) {
|
|
|
|
|
List<ProdPlanExecuteUser> executeUserTimeList = offWorkTimeUserMap.get(offWorkTime);
|
|
|
|
|
Map<String, List<ProdPlanExecuteUser>> orderCodeMap = executeUserTimeList.stream().collect(Collectors.groupingBy(ProdPlanExecuteUser::getOrderCode));
|
|
|
|
|
for (String orderCode : orderCodeMap.keySet()) {
|
|
|
|
|
List<ProdPlanExecuteUser> orderCodeUserList = orderCodeMap.get(orderCode);
|
|
|
|
|
for (ProdPlanExecuteUser prodPlanExecuteUser : orderCodeUserList) {
|
|
|
|
|
//获取员工收入金额
|
|
|
|
|
BigDecimal revenueAmount = this.getStaffreVenueAmount(orderCodeUserList, prodPlanExecuteUser, salaryData);
|
|
|
|
|
String teamCode = prodPlanExecuteUser.getTeamCode();
|
|
|
|
|
String teamName = prodPlanExecuteUser.getTeamName();
|
|
|
|
|
String idCard = prodPlanExecuteUser.getIdCard();
|
|
|
|
|
BigDecimal completeAmount = prodPlanExecuteUser.getCompleteAmount();
|
|
|
|
|
String revenueReason = prodPlanExecuteUser.getStationName().substring(0, 2) + " "
|
|
|
|
|
+ prodPlanExecuteUser.getBeltLengthSpecifications() + " " + prodPlanExecuteUser.getOrderCode();
|
|
|
|
|
RecordStaffSalary staffSalary = new RecordStaffSalary();
|
|
|
|
|
for (RecordStaffSalary staff : result) {
|
|
|
|
|
if (staff.getIdCard().equals(idCard) && staff.getGroupId().equals(prodPlanExecuteUser.getTeamCode())
|
|
|
|
|
&& staff.getRevenueReason().equals(revenueReason) && offWorkTime.equals(DateUtils.dateTime(staff.getEventDate()))) {
|
|
|
|
|
staffSalary = staff;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isEmpty(staffSalary.getCardId())) {
|
|
|
|
|
staffSalary.setTaskCode(taskCode);
|
|
|
|
|
staffSalary.setIdCard(prodPlanExecuteUser.getIdCard());
|
|
|
|
|
staffSalary.setGroupId(teamCode);
|
|
|
|
|
staffSalary.setEventDate(DateUtils.parseDate(offWorkTime));
|
|
|
|
|
staffSalary.setSalaryCategory("收入");
|
|
|
|
|
staffSalary.setRevenueClass("完成生产任务");
|
|
|
|
|
revenueAmount = revenueAmount.setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
staffSalary.setRevenueAmount(revenueAmount);
|
|
|
|
|
staffSalary.setSalaryCoefficient(prodPlanExecuteUser.getWageCoefficient());
|
|
|
|
|
staffSalary.setStaffName(prodPlanExecuteUser.getStaffName());
|
|
|
|
|
staffSalary.setCardId(idCard);
|
|
|
|
|
staffSalary.setTeamName(teamName);
|
|
|
|
|
staffSalary.setBeginDate(beginOrderDate);
|
|
|
|
|
staffSalary.setEndDate(endOrderDate);
|
|
|
|
|
staffSalary.setRevenueReason(revenueReason);
|
|
|
|
|
staffSalary.setOrderCode(prodPlanExecuteUser.getOrderCode());
|
|
|
|
|
staffSalary.setPlanCode(prodPlanExecuteUser.getPlanCode());
|
|
|
|
|
staffSalary.setIsErp(MesConstants.MES_IS_ERP_NO);
|
|
|
|
|
staffSalary.setProdNumber(completeAmount);
|
|
|
|
|
result.add(staffSalary);
|
|
|
|
|
} else {
|
|
|
|
|
staffSalary.setRevenueAmount(staffSalary.getRevenueAmount().add(revenueAmount));
|
|
|
|
|
staffSalary.setProdNumber(staffSalary.getProdNumber().add(completeAmount));
|
|
|
|
|
staffSalary.setGroupId(teamCode);
|
|
|
|
|
staffSalary.setTeamName(teamName);
|
|
|
|
|
}
|
|
|
|
|
ProdPlanExecuteUser updateExecuteUser = new ProdPlanExecuteUser();
|
|
|
|
|
updateExecuteUser.setObjId(prodPlanExecuteUser.getObjId());
|
|
|
|
|
updateExecuteUser.setIsFlag(MesConstants.MES_IS_SALARY_YES);
|
|
|
|
|
updateExecuteUser.setUpdatedBy(SecurityUtils.getUsername());
|
|
|
|
|
updateExecuteUser.setUpdatedTime(DateUtils.getNowDate());
|
|
|
|
|
prodPlanExecuteUserMapper.updateProdPlanExecuteUser(updateExecuteUser);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
for (RecordStaffSalary salary : result) {
|
|
|
|
|
this.insertRecordStaffSalary(salary);
|
|
|
|
|
}
|
|
|
|
|
recordStaffSalary.setIsErp(MesConstants.MES_IS_ERP_NO);
|
|
|
|
|
return this.selectRecordStaffSalaryList(recordStaffSalary);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取订单的员工工资
|
|
|
|
|
* @param orderCodeUserList
|
|
|
|
|
* @param prodPlanExecuteUser
|
|
|
|
|
* @param salaryData
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private BigDecimal getStaffreVenueAmount(List<ProdPlanExecuteUser> orderCodeUserList, ProdPlanExecuteUser prodPlanExecuteUser, LatestSalary salaryData) {
|
|
|
|
|
//工序工资系数
|
|
|
|
|
BigDecimal coefficient = new BigDecimal(0);
|
|
|
|
|
//工序生产面积
|
|
|
|
|
BigDecimal totalArea = new BigDecimal(0);
|
|
|
|
|
///参加该工序的所有人的工资系数的总和
|
|
|
|
|
BigDecimal wageCoefficientSum = new BigDecimal(0);
|
|
|
|
|
///该工序的输送带面积
|
|
|
|
|
BigDecimal beltTotalArea = new BigDecimal(0);
|
|
|
|
|
//当前工序编号
|
|
|
|
|
String currentProcessCode = null;
|
|
|
|
|
//硫化工序 工序硫化的工资 = 硫化系数*硫化面积*(工资系数/参加该工序的所有人的工资系数的总和)
|
|
|
|
|
//硫化面积=硫化米数/客户要求总米数*硫化面积
|
|
|
|
|
if (prodPlanExecuteUser.getProcessCode().equals(MesConstants.MES_PROCESS_VULCANIZATION)) {
|
|
|
|
|
coefficient = salaryData.getVulcanizationCoefficient();
|
|
|
|
|
beltTotalArea = prodPlanExecuteUser.getSulfurizationArea();
|
|
|
|
|
}
|
|
|
|
|
//出布工序
|
|
|
|
|
if (prodPlanExecuteUser.getProcessCode().equals(MesConstants.MES_PROCESS_OUT_CLOTH)) {
|
|
|
|
|
coefficient = salaryData.getDistributionCoefficient();
|
|
|
|
|
beltTotalArea = prodPlanExecuteUser.getRolledFabricArea();
|
|
|
|
|
}
|
|
|
|
|
//成型工序
|
|
|
|
|
if (prodPlanExecuteUser.getProcessCode().equals(MesConstants.MES_PROCESS_FORMING)) {
|
|
|
|
|
beltTotalArea = prodPlanExecuteUser.getFormingArea();
|
|
|
|
|
}
|
|
|
|
|
//包胶工序
|
|
|
|
|
if (prodPlanExecuteUser.getProcessCode().equals(MesConstants.MES_PROCESS_LAGGING)) {
|
|
|
|
|
coefficient = salaryData.getEncapsulationCoefficient();
|
|
|
|
|
beltTotalArea = prodPlanExecuteUser.getRollCoatingArea();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
totalArea = prodPlanExecuteUser.getCompleteAmount()
|
|
|
|
|
.divide(prodPlanExecuteUser.getBeltRequiredLength(), 12, RoundingMode.HALF_UP)
|
|
|
|
|
.multiply(beltTotalArea);
|
|
|
|
|
|
|
|
|
|
wageCoefficientSum = orderCodeUserList.stream().filter(e -> e.getPlanCode().equals(prodPlanExecuteUser.getPlanCode())
|
|
|
|
|
&& e.getBatchNumber().equals(prodPlanExecuteUser.getBatchNumber()))
|
|
|
|
|
.map(ProdPlanExecuteUser::getWageCoefficient).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
|
|
|
|
BigDecimal revenueAmount = new BigDecimal(0);//员工收入
|
|
|
|
|
if (wageCoefficientSum.compareTo(BigDecimal.ZERO) > 0){
|
|
|
|
|
BigDecimal staffCoefficient = prodPlanExecuteUser.getWageCoefficient().divide(wageCoefficientSum, 12, RoundingMode.HALF_UP);
|
|
|
|
|
revenueAmount = coefficient.multiply(totalArea).multiply(staffCoefficient).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
}
|
|
|
|
|
return revenueAmount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 该工序所有员工的工序工资系数
|
|
|
|
|
*
|
|
|
|
|
* @param processCode
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<StaffSalaryVo> selectSumEmployeeSalary(String processCode) {
|
|
|
|
|
List<StaffSalaryVo> employeeList = new ArrayList<>();
|
|
|
|
|
BaseTeamMembers teamMembers = new BaseTeamMembers();
|
|
|
|
|
teamMembers.setProcessCode(processCode);
|
|
|
|
|
List<BaseTeamMembers> members = baseTeamMembersMapper.selectBaseTeamMembersList(teamMembers);
|
|
|
|
|
BigDecimal sumSalaryCoefficient = new BigDecimal(0);
|
|
|
|
|
for (BaseTeamMembers member : members) {
|
|
|
|
|
BaseStaffInfo staffInfo = new BaseStaffInfo();
|
|
|
|
|
staffInfo.setTeamCode(member.getTeamCode());
|
|
|
|
|
List<BaseStaffInfo> staffInfoList = baseStaffInfoMapper.selectBaseStaffInfoList(staffInfo);
|
|
|
|
|
for (BaseStaffInfo baseStaffInfo : staffInfoList) {
|
|
|
|
|
StaffSalaryVo salary = new StaffSalaryVo();
|
|
|
|
|
salary.setProcessCode(processCode);
|
|
|
|
|
salary.setStaffId(baseStaffInfo.getStaffId());
|
|
|
|
|
salary.setStaffName(baseStaffInfo.getStaffName());
|
|
|
|
|
salary.setSalaryCoefficient(baseStaffInfo.getWageCoefficient());
|
|
|
|
|
sumSalaryCoefficient = sumSalaryCoefficient.add(baseStaffInfo.getWageCoefficient());
|
|
|
|
|
boolean isRepeat = true;
|
|
|
|
|
for (StaffSalaryVo salaryVo : employeeList) {
|
|
|
|
|
if (salaryVo.getStaffId().equals(baseStaffInfo.getStaffId())) {
|
|
|
|
|
salaryVo.setSalaryCoefficient(salaryVo.getSumSalaryCoefficient().add(sumSalaryCoefficient));
|
|
|
|
|
isRepeat = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isRepeat) {
|
|
|
|
|
employeeList.add(salary);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (StaffSalaryVo salaryVo : employeeList) {
|
|
|
|
|
salaryVo.setSumSalaryCoefficient(sumSalaryCoefficient);
|
|
|
|
|
}
|
|
|
|
|
return employeeList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* @Override
|
|
|
|
|
public List<RecordStaffSalary> selectTeamEmployeesWages(RecordStaffSalary recordStaffSalary) {
|
|
|
|
|
List<RecordStaffSalary> result = new ArrayList<>();
|
|
|
|
|
//调用最新工资系数接口
|
|
|
|
|
LatestSalary salaryData = portService.getERPLatestSalaryData(new ERPParamDto());
|
|
|
|
|
|
|
|
|
|
//遍历工序
|
|
|
|
|
List<BaseProcessInfo> processInfoList = baseProcessInfoMapper.selectBaseProcessInfoList(new BaseProcessInfo());
|
|
|
|
|
BaseProcessInfo selectProcessInfo = new BaseProcessInfo();
|
|
|
|
|
selectProcessInfo.setProcessCode(recordStaffSalary.getProcessCode());
|
|
|
|
|
List<BaseProcessInfo> processInfoList = baseProcessInfoMapper.selectBaseProcessInfoList(selectProcessInfo);
|
|
|
|
|
|
|
|
|
|
ProdPlanInfo planInfo = new ProdPlanInfo();
|
|
|
|
|
Map<String, Object> params = recordStaffSalary.getParams();
|
|
|
|
@ -256,95 +473,7 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
// * 生成班组员工工资
|
|
|
|
|
// * @param recordStaffSalary
|
|
|
|
|
// * @return
|
|
|
|
|
// */
|
|
|
|
|
// @Override
|
|
|
|
|
// public List<RecordStaffSalary> selectTeamEmployeesWages(RecordStaffSalary recordStaffSalary) {
|
|
|
|
|
// List<RecordStaffSalary> result = new ArrayList<>();
|
|
|
|
|
// BaseTeamMembers members = new BaseTeamMembers();
|
|
|
|
|
// members.setTeamCode(recordStaffSalary.getGroupId());
|
|
|
|
|
// List<BaseTeamMembers> membersList = baseTeamMembersMapper.selectBaseTeamMembersList(members);
|
|
|
|
|
// //调用最新工资系数接口
|
|
|
|
|
// LatestSalary salaryData = portService.getERPLatestSalaryData(new ERPParamDto());
|
|
|
|
|
//
|
|
|
|
|
// ProdOrderInfo orderInfo = new ProdOrderInfo();
|
|
|
|
|
// Map<String, Object> params = recordStaffSalary.getParams();
|
|
|
|
|
// Date beginOrderDate = null;
|
|
|
|
|
// Date endOrderDate = null;
|
|
|
|
|
// if (params.containsKey("beginOrderDate")){
|
|
|
|
|
// beginOrderDate = DateUtils.parseDate(String.valueOf(params.get("beginOrderDate")));
|
|
|
|
|
// }
|
|
|
|
|
// if (params.containsKey("endOrderDate")){
|
|
|
|
|
// endOrderDate = DateUtils.parseDate(String.valueOf(params.get("endOrderDate")));
|
|
|
|
|
// }
|
|
|
|
|
// orderInfo.setParams(params);
|
|
|
|
|
// List<ProdOrderInfo> orderInfoList = prodOrderInfoMapper.selectProdOrderInfoList(orderInfo);
|
|
|
|
|
//
|
|
|
|
|
// long objId = 1L;
|
|
|
|
|
// String taskCode = PlanCodeUtils.getTaskCode();
|
|
|
|
|
// //按照班组 分工资;
|
|
|
|
|
// for (BaseTeamMembers team : membersList) {
|
|
|
|
|
// String processCode = team.getProcessCode();
|
|
|
|
|
// //工序工资系数
|
|
|
|
|
// BigDecimal coefficient = new BigDecimal(0);
|
|
|
|
|
// //工序生产面积
|
|
|
|
|
// BigDecimal totalArea = new BigDecimal(0);
|
|
|
|
|
//
|
|
|
|
|
// //硫化工序 工序硫化的工资 = 硫化系数*硫化面积*(工资系数/参加该工序的所有人的工资系数的总和)
|
|
|
|
|
// //硫化面积=硫化米数/客户要求总米数*硫化面积
|
|
|
|
|
// if(processCode.equals("1002")){
|
|
|
|
|
// coefficient = salaryData.getVulcanizationCoefficient();
|
|
|
|
|
// totalArea = orderInfoList.stream().map(ProdOrderInfo::getOrderDetail)
|
|
|
|
|
// .map(e -> e.getBeltRequiredLength().divide(e.getBeltRequiredLength(), 6, RoundingMode.HALF_UP)
|
|
|
|
|
// .multiply(e.getSulfurizationArea()))
|
|
|
|
|
// .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
// }
|
|
|
|
|
// //成型工序
|
|
|
|
|
// if(processCode.equals("1001")){
|
|
|
|
|
// coefficient = salaryData.getFormingCoefficient();
|
|
|
|
|
// totalArea = orderInfoList.stream().map(ProdOrderInfo::getOrderDetail)
|
|
|
|
|
// .map(e -> e.getBeltRequiredLength().divide(e.getBeltRequiredLength(), 6, RoundingMode.HALF_UP)
|
|
|
|
|
// .multiply(e.getFormingArea()))
|
|
|
|
|
// .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
// }
|
|
|
|
|
// //获取这个时间段内员工打卡记录
|
|
|
|
|
// BaseStaffInfo selectStaffInfo = new BaseStaffInfo();
|
|
|
|
|
// selectStaffInfo.setTeamCode(team.getTeamCode());
|
|
|
|
|
// selectStaffInfo.setDelFlag("0");
|
|
|
|
|
// List<BaseStaffInfo> staffInfoList = baseStaffInfoMapper.selectBaseStaffInfoList(selectStaffInfo);
|
|
|
|
|
// BigDecimal totalWageCoefficient = staffInfoList.stream().map(BaseStaffInfo::getWageCoefficient)
|
|
|
|
|
// .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
//
|
|
|
|
|
// for (BaseStaffInfo staffInfo : staffInfoList) {
|
|
|
|
|
// RecordStaffSalary staffSalary = new RecordStaffSalary();
|
|
|
|
|
// staffSalary.setObjId(objId++);
|
|
|
|
|
// staffSalary.setTaskCode(taskCode);
|
|
|
|
|
// staffSalary.setIdCard(staffInfo.getPassWord());
|
|
|
|
|
// staffSalary.setGroupId(team.getTeamCode());
|
|
|
|
|
// staffSalary.setEventDate(new Date());
|
|
|
|
|
// staffSalary.setSalaryCategory("收入");
|
|
|
|
|
// staffSalary.setRevenueClass("完成生产任务");
|
|
|
|
|
// BigDecimal staffCoefficient = staffInfo.getWageCoefficient().divide(totalWageCoefficient, 6, RoundingMode.HALF_UP);
|
|
|
|
|
// BigDecimal revenueAmount = coefficient.multiply(totalArea).multiply(staffCoefficient);
|
|
|
|
|
// revenueAmount = revenueAmount.setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
// staffSalary.setRevenueAmount(revenueAmount);
|
|
|
|
|
// staffSalary.setSalaryCoefficient(staffInfo.getWageCoefficient());
|
|
|
|
|
// staffSalary.setStaffName(staffInfo.getStaffName());
|
|
|
|
|
// staffSalary.setCardId(staffInfo.getCardId());
|
|
|
|
|
// staffSalary.setTeamName(team.getTeamName());
|
|
|
|
|
// staffSalary.setBeginDate(beginOrderDate);
|
|
|
|
|
// staffSalary.setEndDate(endOrderDate);
|
|
|
|
|
// result.add(staffSalary);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// return result;
|
|
|
|
|
// }
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 维护员工工资记录
|
|
|
|
@ -354,12 +483,18 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService {
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = ServiceException.class)
|
|
|
|
|
public int uploadERPStaffSalary(List<RecordStaffSalary> recordStaffSalaryList) {
|
|
|
|
|
Thread thread = new Thread(() -> {
|
|
|
|
|
for (RecordStaffSalary staffSalary : recordStaffSalaryList) {
|
|
|
|
|
String objectId = portService.addSalaryBreakdown(staffSalary);
|
|
|
|
|
staffSalary.setObjectId(objectId);
|
|
|
|
|
recordStaffSalaryMapper.insertRecordStaffSalary(staffSalary);
|
|
|
|
|
//更新ERP上传标识
|
|
|
|
|
RecordStaffSalary updateSalary = new RecordStaffSalary();
|
|
|
|
|
updateSalary.setObjId(staffSalary.getObjId());
|
|
|
|
|
updateSalary.setObjectId(objectId);
|
|
|
|
|
updateSalary.setIsErp(MesConstants.MES_IS_ERP_YES);
|
|
|
|
|
updateSalary.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
recordStaffSalaryMapper.updateRecordStaffSalary(updateSalary);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
thread.start(); //启动新线程
|
|
|
|
@ -367,4 +502,30 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 员工工资汇总报表
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<ReportSalarySummary> salarySummaryReport(Map hashMap) {
|
|
|
|
|
List<ReportSalarySummary> summaryList = recordStaffSalaryMapper.salarySummaryReport(hashMap);
|
|
|
|
|
List<BaseTeamMembers> teamMembers = baseTeamMembersMapper.selectBaseTeamMembersList(new BaseTeamMembers());
|
|
|
|
|
for (ReportSalarySummary staffSalary : summaryList) {
|
|
|
|
|
if (StringUtils.isEmpty(staffSalary.getGroupId())) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
for (BaseTeamMembers teamMember : teamMembers) {
|
|
|
|
|
if (staffSalary.getGroupId().contains(teamMember.getTeamCode())) {
|
|
|
|
|
if (StringUtils.isEmpty(staffSalary.getTeamName())) {
|
|
|
|
|
staffSalary.setTeamName(teamMember.getTeamName());
|
|
|
|
|
} else {
|
|
|
|
|
staffSalary.setTeamName(staffSalary.getTeamName() + "," + teamMember.getTeamName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return summaryList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|