diff --git a/emis-api-web/src/main/java/com/xdadan/erp/apiweb/CommissionProfitController.java b/emis-api-web/src/main/java/com/xdadan/erp/apiweb/CommissionProfitController.java index 2713072..a625973 100644 --- a/emis-api-web/src/main/java/com/xdadan/erp/apiweb/CommissionProfitController.java +++ b/emis-api-web/src/main/java/com/xdadan/erp/apiweb/CommissionProfitController.java @@ -31,6 +31,7 @@ import com.xdadan.erp.emis.service.IEmisCommissionDtlService; import com.xdadan.erp.emis.service.IEmisCommissionProfitService; import com.xdadan.erp.emis.utils.WaybillHelper; import com.xdadan.erp.system.service.ISysUserService; +import com.xdadan.erp.common.core.domain.entity.SysUser; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -40,8 +41,10 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import java.lang.reflect.Method; import java.math.BigDecimal; import java.util.Date; +import java.util.HashMap; import java.util.List; /** @@ -81,9 +84,62 @@ public class CommissionProfitController extends BaseController startPage(); List list = emisCommissionProfitService.selectEmisCommissionProfitList(emisCommissionProfit); + + // 将每个对象的oaEmpCode设置到params中 + if (list != null && !list.isEmpty()) { + for (EmisCommissionProfit item : list) { + try { + // 通过empName查询获取oaEmpCode + String oaEmpCode = getOaEmpCodeByEmpName(item); +// if (StringUtils.isNotEmpty(oaEmpCode)) { +// // 确保params不为null +// if (item.getParams() == null) { +// item.setParams(new HashMap<>()); +// } +// // 将oaEmpCode设置到params中 +// item.getParams().put("oaEmpCode", oaEmpCode); +// } + // 将oaEmpCode设置到params中 + item.getParams().put("oaEmpCode", oaEmpCode); + } catch (Exception e) { + // 忽略异常,继续处理下一个对象 + log.debug("设置oaEmpCode到params失败: {}", e.getMessage()); + } + } + } + return getDataTable(list); } + /** + * 通过empName查询用户,获取oaEmpCode + */ + private String getOaEmpCodeByEmpName(EmisCommissionProfit item) { + if (item == null || sysUserService == null) { + return null; + } + try { + String empName = item.getEmpName(); + if (StringUtils.isEmpty(empName)) { + return null; + } + + // 使用empName查询用户 + SysUser queryUser = new SysUser(); + queryUser.setEmpName(empName); + List userList = sysUserService.selectUserList(queryUser); + + if (userList != null && !userList.isEmpty()) { + // 取第一个用户 + SysUser user = userList.get(0); + return user.getOaEmpCode(); + } + } catch (Exception e) { + log.debug("通过empName查询oaEmpCode失败: {}", e.getMessage()); + } + + return null; + } }