|
|
|
@ -3,7 +3,9 @@ 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.StringUtils;
|
|
|
|
@ -19,8 +21,10 @@ 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.ProdPlanExecuteUser;
|
|
|
|
|
import com.os.mes.prod.domain.ProdPlanInfo;
|
|
|
|
|
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.domain.StaffSalaryVo;
|
|
|
|
@ -60,7 +64,7 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService {
|
|
|
|
|
private BaseProcessInfoMapper baseProcessInfoMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RecordStaffCommuteMapper recordStaffCommuteMapper;
|
|
|
|
|
private ProdPlanExecuteUserMapper prodPlanExecuteUserMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IERPPortService portService;
|
|
|
|
@ -134,12 +138,12 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生成班组员工工资
|
|
|
|
|
* (工序硫化的工资计算方法 = 硫化系数*硫化面积*(工资系数/参加该工序的所有人的工资系数的总和)
|
|
|
|
|
* 这里的硫化面积=硫化米数/客户要求总米数*硫化面积)
|
|
|
|
|
*
|
|
|
|
|
* (工序硫化的工资计算方法 = 硫化系数*硫化面积*(工资系数/参加该工序的所有人的工资系数的总和)
|
|
|
|
|
* 这里的硫化面积=硫化米数/客户要求总米数*硫化面积)
|
|
|
|
|
* <p>
|
|
|
|
|
* 1、需知道每个员工在时间范围内的上班天数
|
|
|
|
|
* 2、需要知道时间范围内生产工单生产完成多少米
|
|
|
|
|
* 3、工序硫化员工工资 = 硫化系数 * (每个工单的实际硫化米数/客户要求总米数*硫化面积) * (员工的工资系数/参加该工序的所有人的工资系数的总和) * (当前员工在班时长/该工序的所有人在班时长)
|
|
|
|
|
* 3、工序硫化员工工资 = 硫化系数 * (每个工单的实际硫化米数/客户要求总米数*硫化面积) * (员工的工资系数/参加该工序的所有人的工资系数的总和)
|
|
|
|
|
*
|
|
|
|
|
* @param recordStaffSalary
|
|
|
|
|
* @return
|
|
|
|
@ -150,14 +154,12 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService {
|
|
|
|
|
//调用最新工资系数接口
|
|
|
|
|
LatestSalary salaryData = portService.getERPLatestSalaryData(new ERPParamDto());
|
|
|
|
|
|
|
|
|
|
//遍历工序
|
|
|
|
|
BaseProcessInfo selectProcessInfo = new BaseProcessInfo();
|
|
|
|
|
selectProcessInfo.setProcessCode(recordStaffSalary.getProcessCode());
|
|
|
|
|
List<BaseProcessInfo> processInfoList = baseProcessInfoMapper.selectBaseProcessInfoList(selectProcessInfo);
|
|
|
|
|
List<BaseTeamMembers> teamMembers = baseTeamMembersMapper.selectBaseTeamMembersList(new BaseTeamMembers());
|
|
|
|
|
|
|
|
|
|
ProdPlanInfo planInfo = new ProdPlanInfo();
|
|
|
|
|
Map<String, Object> params = recordStaffSalary.getParams();
|
|
|
|
|
planInfo.setParams(params);
|
|
|
|
|
ProdPlanExecuteUser selectExecuteUser = new ProdPlanExecuteUser();
|
|
|
|
|
selectExecuteUser.setParams(params); //beginOrderDate、endOrderDate
|
|
|
|
|
List<ProdPlanExecuteUser> planUserList = prodPlanExecuteUserMapper.selectProdPlanExecuteUserList(selectExecuteUser);
|
|
|
|
|
|
|
|
|
|
Date beginOrderDate = null;
|
|
|
|
|
Date endOrderDate = null;
|
|
|
|
@ -170,14 +172,104 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService {
|
|
|
|
|
|
|
|
|
|
long objId = 1L;
|
|
|
|
|
String taskCode = PlanCodeUtils.getTaskCode();
|
|
|
|
|
Map<String, List<ProdPlanExecuteUser>> orderCodeMap = planUserList.stream().collect(Collectors.groupingBy(ProdPlanExecuteUser::getOrderCode));
|
|
|
|
|
for (String orderCode : orderCodeMap.keySet()) {
|
|
|
|
|
List<ProdPlanExecuteUser> orderCodeUserList = orderCodeMap.get(orderCode);
|
|
|
|
|
for (ProdPlanExecuteUser prodPlanExecuteUser : orderCodeUserList) {
|
|
|
|
|
//工序工资系数
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//(每个工单的实际硫化米数/客户要求总米数*硫化面积)
|
|
|
|
|
for (BaseProcessInfo processInfo : processInfoList) {
|
|
|
|
|
List<StaffSalaryVo> salaryVoList = selectSumEmployeeSalary(processInfo.getProcessCode());
|
|
|
|
|
for (StaffSalaryVo staffSalaryVo : salaryVoList) {
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(prodPlanExecuteUser.getTeamCode())) {
|
|
|
|
|
for (BaseTeamMembers teamMember : teamMembers) {
|
|
|
|
|
if (prodPlanExecuteUser.getTeamCode().contains(teamMember.getTeamCode())) {
|
|
|
|
|
if (StringUtils.isEmpty(prodPlanExecuteUser.getTeamName())) {
|
|
|
|
|
prodPlanExecuteUser.setTeamName(teamMember.getTeamName());
|
|
|
|
|
} else {
|
|
|
|
|
prodPlanExecuteUser.setTeamName(prodPlanExecuteUser.getTeamName() + "," + teamMember.getTeamName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String teamCode = prodPlanExecuteUser.getTeamCode();
|
|
|
|
|
String teamName = prodPlanExecuteUser.getTeamName();
|
|
|
|
|
String idCard = prodPlanExecuteUser.getIdCard();
|
|
|
|
|
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)) {
|
|
|
|
|
staffSalary = staff;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isEmpty(staffSalary.getCardId())) {
|
|
|
|
|
staffSalary.setObjId(objId++);
|
|
|
|
|
staffSalary.setTaskCode(taskCode);
|
|
|
|
|
staffSalary.setIdCard(prodPlanExecuteUser.getIdCard());
|
|
|
|
|
staffSalary.setGroupId(teamCode);
|
|
|
|
|
staffSalary.setEventDate(new Date());
|
|
|
|
|
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());
|
|
|
|
|
result.add(staffSalary);
|
|
|
|
|
} else {
|
|
|
|
|
staffSalary.setRevenueAmount(staffSalary.getRevenueAmount().add(revenueAmount));
|
|
|
|
|
staffSalary.setGroupId(teamCode);
|
|
|
|
|
staffSalary.setTeamName(teamName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
@ -186,6 +278,7 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 该工序所有员工的工序工资系数
|
|
|
|
|
*
|
|
|
|
|
* @param processCode
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -208,12 +301,12 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService {
|
|
|
|
|
sumSalaryCoefficient = sumSalaryCoefficient.add(baseStaffInfo.getWageCoefficient());
|
|
|
|
|
boolean isRepeat = true;
|
|
|
|
|
for (StaffSalaryVo salaryVo : employeeList) {
|
|
|
|
|
if (salaryVo.getStaffId().equals(baseStaffInfo.getStaffId())){
|
|
|
|
|
if (salaryVo.getStaffId().equals(baseStaffInfo.getStaffId())) {
|
|
|
|
|
salaryVo.setSalaryCoefficient(salaryVo.getSumSalaryCoefficient().add(sumSalaryCoefficient));
|
|
|
|
|
isRepeat = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isRepeat){
|
|
|
|
|
if (isRepeat) {
|
|
|
|
|
employeeList.add(salary);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -363,7 +456,13 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService {
|
|
|
|
|
for (RecordStaffSalary staffSalary : recordStaffSalaryList) {
|
|
|
|
|
String objectId = portService.addSalaryBreakdown(staffSalary);
|
|
|
|
|
staffSalary.setObjectId(objectId);
|
|
|
|
|
staffSalary.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
recordStaffSalaryMapper.insertRecordStaffSalary(staffSalary);
|
|
|
|
|
//更新ERP上传标识
|
|
|
|
|
ProdOrderInfo orderInfo = new ProdOrderInfo();
|
|
|
|
|
orderInfo.setOrderCode(staffSalary.getOrderCode());
|
|
|
|
|
orderInfo.setIsFlag("1");
|
|
|
|
|
prodOrderInfoMapper.updateProdOrderInfo(orderInfo);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
thread.start(); //启动新线程
|
|
|
|
|