change - 通过订单生成员工工资

boardTest
yinq 12 months ago
parent 4354c15770
commit 736d6e18ed

@ -53,5 +53,32 @@ public class PlanCodeUtils {
return (cal.getTimeInMillis() - System.currentTimeMillis()) / 1000;
}
/**
*
* @return
*/
public static String getTaskCode() {
LocalDate date = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMMdd");
String format = "task_code:" + date.format(formatter);
//以当日日期作为key
if (!SpringUtils.getBean(RedisCache.class).hasKey(format)) {
SpringUtils.getBean(RedisCache.class).setCacheObject(format, 1);
SpringUtils.getBean(RedisCache.class).expire(format, getSecondsNextEarlyMorning(), TimeUnit.SECONDS);
} else {
//获取当前的value在+1
Object cacheObject = SpringUtils.getBean(RedisCache.class).getCacheObject(format);
String value = String.valueOf(cacheObject);
Integer integer = Integer.parseInt(value) + 1;
SpringUtils.getBean(RedisCache.class).setCacheObject(format, integer);
SpringUtils.getBean(RedisCache.class).expire(format, getSecondsNextEarlyMorning(), TimeUnit.SECONDS);
}
Object cacheObject = SpringUtils.getBean(RedisCache.class).getCacheObject(format);
//转成string在转成int
String code = String.format("%04d", Integer.valueOf(String.valueOf(cacheObject)));
return "T" + date.format(formatter) + code;
}
}

@ -3,6 +3,7 @@ package com.os.mes.api.service.impl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.os.common.utils.StringUtils;
import com.os.mes.api.domain.ERPParamDto;
import com.os.mes.api.domain.LatestSalary;
import com.os.mes.api.domain.RecordData;
@ -121,6 +122,16 @@ public class ERPPortServiceImpl implements IERPPortService {
LatestSalary latestSalary = null;
String requestParam = null;
String result = null;
if (StringUtils.isEmpty(paramDto.getAppCode())){
paramDto.setAppCode(ERPConstants.salaryAppCode);
}
if (StringUtils.isEmpty(paramDto.getController())){
paramDto.setController(ERPConstants.salaryController);
}
if (StringUtils.isEmpty(paramDto.getActionName())){
paramDto.setActionName(ERPConstants.salaryActionName);
}
try {
// 创建ObjectMapper实例 对象转JSON字符串
ObjectMapper objectMapper = new ObjectMapper();

@ -97,4 +97,17 @@ public class RecordStaffSalaryController extends BaseController {
public AjaxResult remove(@PathVariable Long[] objIds) {
return toAjax(recordStaffSalaryService.deleteRecordStaffSalaryByObjIds(objIds));
}
/**
*
* @param recordStaffSalary
* @return
*/
@GetMapping("/selectTeamEmployeesWages")
public AjaxResult selectTeamEmployeesWages(RecordStaffSalary recordStaffSalary) {
List<RecordStaffSalary> list = recordStaffSalaryService.selectTeamEmployeesWages(recordStaffSalary);
return success(list);
}
}

@ -1,5 +1,6 @@
package com.os.mes.record.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
@ -29,8 +30,8 @@ public class RecordStaffSalary extends BaseEntity
private String groupId;
/** 事件日期 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "事件日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "事件日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date eventDate;
/** 薪资类别 */
@ -43,7 +44,7 @@ public class RecordStaffSalary extends BaseEntity
/** 收入金额 */
@Excel(name = "收入金额")
private Long revenueAmount;
private BigDecimal revenueAmount;
/** 收入理由 */
@Excel(name = "收入理由")
@ -55,7 +56,7 @@ public class RecordStaffSalary extends BaseEntity
/** 扣罚金额 */
@Excel(name = "扣罚金额")
private Long fineAmount;
private BigDecimal fineAmount;
/** 扣罚理由 */
@Excel(name = "扣罚理由")
@ -67,9 +68,77 @@ public class RecordStaffSalary extends BaseEntity
/** 工资系数 */
@Excel(name = "工资系数")
private Long salaryCoefficient;
private BigDecimal salaryCoefficient;
public void setObjId(Long objId)
/**
*
*/
@Excel(name = "员工名称")
private String staffName;
/**
*
*/
@Excel(name = "员工卡号")
private String cardId;
/**
*
*/
@Excel(name = "班组名称")
private String teamName;
/** 开始日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "开始日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date beginDate;
/** 结束日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "结束日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date endDate;
public Date getBeginDate() {
return beginDate;
}
public void setBeginDate(Date beginDate) {
this.beginDate = beginDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public String getStaffName() {
return staffName;
}
public void setStaffName(String staffName) {
this.staffName = staffName;
}
public String getCardId() {
return cardId;
}
public void setCardId(String cardId) {
this.cardId = cardId;
}
public String getTeamName() {
return teamName;
}
public void setTeamName(String teamName) {
this.teamName = teamName;
}
public void setObjId(Long objId)
{
this.objId = objId;
}
@ -123,12 +192,12 @@ public class RecordStaffSalary extends BaseEntity
{
return revenueClass;
}
public void setRevenueAmount(Long revenueAmount)
public void setRevenueAmount(BigDecimal revenueAmount)
{
this.revenueAmount = revenueAmount;
}
public Long getRevenueAmount()
public BigDecimal getRevenueAmount()
{
return revenueAmount;
}
@ -150,12 +219,12 @@ public class RecordStaffSalary extends BaseEntity
{
return fineClass;
}
public void setFineAmount(Long fineAmount)
public void setFineAmount(BigDecimal fineAmount)
{
this.fineAmount = fineAmount;
}
public Long getFineAmount()
public BigDecimal getFineAmount()
{
return fineAmount;
}
@ -177,12 +246,12 @@ public class RecordStaffSalary extends BaseEntity
{
return taskCode;
}
public void setSalaryCoefficient(Long salaryCoefficient)
public void setSalaryCoefficient(BigDecimal salaryCoefficient)
{
this.salaryCoefficient = salaryCoefficient;
}
public Long getSalaryCoefficient()
public BigDecimal getSalaryCoefficient()
{
return salaryCoefficient;
}

@ -58,4 +58,11 @@ public interface IRecordStaffSalaryService {
* @return
*/
public int deleteRecordStaffSalaryByObjId(Long objId);
/**
*
* @param recordStaffSalary
* @return
*/
List<RecordStaffSalary> selectTeamEmployeesWages(RecordStaffSalary recordStaffSalary);
}

@ -1,8 +1,25 @@
package com.os.mes.record.service.impl;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
import com.os.common.utils.DateUtils;
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.BaseStaffInfo;
import com.os.mes.base.domain.BaseTeamMembers;
import com.os.mes.base.mapper.BaseStaffInfoMapper;
import com.os.mes.base.mapper.BaseTeamMembersMapper;
import com.os.mes.prod.domain.ProdOrderDetail;
import com.os.mes.prod.domain.ProdOrderInfo;
import com.os.mes.prod.mapper.ProdOrderInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.os.mes.record.mapper.RecordStaffSalaryMapper;
@ -20,6 +37,18 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService {
@Autowired
private RecordStaffSalaryMapper recordStaffSalaryMapper;
@Autowired
private BaseTeamMembersMapper baseTeamMembersMapper;
@Autowired
private BaseStaffInfoMapper baseStaffInfoMapper;
@Autowired
private ProdOrderInfoMapper prodOrderInfoMapper;
@Autowired
private IERPPortService portService;
/**
*
*
@ -86,4 +115,82 @@ public class RecordStaffSalaryServiceImpl implements IRecordStaffSalaryService {
public int deleteRecordStaffSalaryByObjId(Long objId) {
return recordStaffSalaryMapper.deleteRecordStaffSalaryByObjId(objId);
}
/**
*
* @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();
orderInfo.setParams(recordStaffSalary.getParams());
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());
result.add(staffSalary);
}
}
return result;
}
}

@ -245,6 +245,9 @@
<if test="createdTime != null ">and poi.created_time = #{createdTime}</if>
<if test="updatedBy != null and updatedBy != ''">and poi.updated_by = #{updatedBy}</if>
<if test="updatedTime != null ">and poi.updated_time = #{updatedTime}</if>
<if test="params.beginOrderDate != null and params.beginOrderDate != '' and params.endOrderDate != null and params.endOrderDate != ''">
and pod.OrderDate between #{params.beginOrderDate} and #{params.endOrderDate}
</if>
</where>
</select>

@ -19,6 +19,8 @@
<result property="createTime" column="create_time"/>
<result property="taskCode" column="task_code"/>
<result property="salaryCoefficient" column="salary_coefficient"/>
<result property="beginDate" column="begin_date"/>
<result property="endDate" column="end_date"/>
</resultMap>
<sql id="selectRecordStaffSalaryVo">
@ -35,7 +37,9 @@
fine_reason,
create_time,
task_code,
salary_coefficient
salary_coefficient,
begin_date,
end_date
from record_staff_salary
</sql>
@ -56,6 +60,8 @@
<if test="fineReason != null and fineReason != ''">and fine_reason = #{fineReason}</if>
<if test="taskCode != null and taskCode != ''">and task_code = #{taskCode}</if>
<if test="salaryCoefficient != null ">and salary_coefficient = #{salaryCoefficient}</if>
<if test="beginDate != null ">and begin_date = #{beginDate}</if>
<if test="endDate != null ">and end_date = #{endDate}</if>
</where>
</select>
@ -80,6 +86,8 @@
<if test="createTime != null">create_time,</if>
<if test="taskCode != null">task_code,</if>
<if test="salaryCoefficient != null">salary_coefficient,</if>
<if test="beginDate != null">begin_date,</if>
<if test="endDate != null">end_date,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="idCard != null">#{idCard},</if>
@ -95,6 +103,8 @@
<if test="createTime != null">#{createTime},</if>
<if test="taskCode != null">#{taskCode},</if>
<if test="salaryCoefficient != null">#{salaryCoefficient},</if>
<if test="beginDate != null">#{beginDate},</if>
<if test="endDate != null">#{endDate},</if>
</trim>
</insert>
@ -114,6 +124,8 @@
<if test="createTime != null">create_time = #{createTime},</if>
<if test="taskCode != null">task_code = #{taskCode},</if>
<if test="salaryCoefficient != null">salary_coefficient = #{salaryCoefficient},</if>
<if test="beginDate != null">begin_date = #{beginDate},</if>
<if test="endDate != null">end_date = #{endDate},</if>
</trim>
where obj_id = #{objId}
</update>

Loading…
Cancel
Save