一二级入库添加审批人列表信息,并保存

master
liuqingkun 3 months ago
parent 96a0ff4459
commit f5b2909945
  1. 5
      src/main/java/com/nov/KgLowDurable/pojo/entity/LdTwoOutStorage.java
  2. 2
      src/main/java/com/nov/KgLowDurable/service/IUserService.java
  3. 8
      src/main/java/com/nov/KgLowDurable/service/Impl/LdOnePutStorageServiceImpl.java
  4. 15
      src/main/java/com/nov/KgLowDurable/service/Impl/LdTwoOutStorageServiceImpl.java
  5. 19
      src/main/java/com/nov/KgLowDurable/service/Impl/UserServiceImpl.java

@ -102,4 +102,9 @@ public class LdTwoOutStorage implements Serializable {
* 分组名称 * 分组名称
*/ */
private String groupName; private String groupName;
/**
* 审批人员
*/
private String approvers;
} }

@ -27,7 +27,7 @@ public interface IUserService extends IService<User> {
* @param formId * @param formId
* @return * @return
*/ */
boolean getApprover(String mainErDepartment, String type,Long formId); String getApprover(String mainErDepartment, String type,Long formId);
/** /**
* 获取部门负责人 * 获取部门负责人

@ -195,9 +195,13 @@ public class LdOnePutStorageServiceImpl extends ServiceImpl<LdOnePutStorageMappe
*/ */
private void setApproverInfo(LdOnePutStorageDto dto, UserInfoVO userInfo) { private void setApproverInfo(LdOnePutStorageDto dto, UserInfoVO userInfo) {
try { try {
boolean tuser = userService.getApprover( String approvers = userService.getApprover(
null, "0",dto.getId() null, "0", dto.getId()
); );
LdOnePutStorage ldOnePutStorage = onePutStorageMapper.selectById(dto.getId());
ldOnePutStorage.setApprovers(approvers);
onePutStorageMapper.updateById(ldOnePutStorage);
} catch (Exception e) { } catch (Exception e) {
throw new CustomerException("获取审批人失败: " + e.getMessage()); throw new CustomerException("获取审批人失败: " + e.getMessage());
} }

@ -16,6 +16,7 @@ import com.nov.KgLowDurable.pojo.vo.*;
import com.nov.KgLowDurable.service.*; import com.nov.KgLowDurable.service.*;
import com.nov.KgLowDurable.util.SerialNumberUtil; import com.nov.KgLowDurable.util.SerialNumberUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -31,6 +32,7 @@ import java.util.stream.Collectors;
* 服务实现类 * 服务实现类
* @author liweidong * @author liweidong
*/ */
@Slf4j
@Service @Service
@AllArgsConstructor @AllArgsConstructor
public class LdTwoOutStorageServiceImpl extends ServiceImpl<LdTwoOutStorageMapper, LdTwoOutStorage> implements ILdTwoOutStorageService { public class LdTwoOutStorageServiceImpl extends ServiceImpl<LdTwoOutStorageMapper, LdTwoOutStorage> implements ILdTwoOutStorageService {
@ -112,13 +114,14 @@ public class LdTwoOutStorageServiceImpl extends ServiceImpl<LdTwoOutStorageMappe
ldTwoOutStorageDetail.setOptTime(new Date()); ldTwoOutStorageDetail.setOptTime(new Date());
//处理剩余库存 //处理剩余库存
BigDecimal num = null; BigDecimal num = null;
if(BatchConstant.CONSUMER.equals(ldTwoOutStorageDetail.getType())){ if (BatchConstant.CONSUMER.equals(ldTwoOutStorageDetail.getType())) {
LdConsumerForm consumerForm = consumerFormService.getById(ldTwoOutStorageDetail.getTwoInventoryId()); LdConsumerForm consumerForm = consumerFormService.getById(ldTwoOutStorageDetail.getTwoInventoryId());
num = consumerForm.getNum(); num = consumerForm.getNum();
}else { } else {
LdDurableForm durableForm = durableFormService.getById(ldTwoOutStorageDetail.getTwoInventoryId()); LdDurableForm durableForm = durableFormService.getById(ldTwoOutStorageDetail.getTwoInventoryId());
num = durableForm.getNum(); num = durableForm.getNum();
} }
BigDecimal result = num.subtract(ldTwoOutStorageDetail.getNum()); BigDecimal result = num.subtract(ldTwoOutStorageDetail.getNum());
ldTwoOutStorageDetail.setResidueNum(result); ldTwoOutStorageDetail.setResidueNum(result);
@ -131,9 +134,10 @@ public class LdTwoOutStorageServiceImpl extends ServiceImpl<LdTwoOutStorageMappe
//获取审批人 //获取审批人
try { try {
boolean approver = userService.getApprover(ldTwoOutStorage.getDepartmentId(), String approvers = userService.getApprover(ldTwoOutStorage.getDepartmentId(),
"1", ldTwoOutStorage.getId()); "1", ldTwoOutStorage.getId());
ldTwoOutStorage.setApprovers(approvers);
twoOutStorageMapper.updateById(ldTwoOutStorage);
} catch (Exception e) { } catch (Exception e) {
throw new CustomerException("获取审批人失败: " + e.getMessage()); throw new CustomerException("获取审批人失败: " + e.getMessage());
} }
@ -174,7 +178,8 @@ public class LdTwoOutStorageServiceImpl extends ServiceImpl<LdTwoOutStorageMappe
new Content(TwoOutApproverConstant.TEXT, TwoOutApproverConstant.TEXT_RECEIVER, Value.textValue(dto.getLdTwoOutStorage().getProposerName())), new Content(TwoOutApproverConstant.TEXT, TwoOutApproverConstant.TEXT_RECEIVER, Value.textValue(dto.getLdTwoOutStorage().getProposerName())),
new Content(TwoOutApproverConstant.TEXT, TwoOutApproverConstant.TEXT_DEPARTMENT, Value.textValue(dto.getLdTwoOutStorage().getDepartment())), new Content(TwoOutApproverConstant.TEXT, TwoOutApproverConstant.TEXT_DEPARTMENT, Value.textValue(dto.getLdTwoOutStorage().getDepartment())),
new Content(TwoOutApproverConstant.TEXT, TwoOutApproverConstant.TEXT_ORDER_NO, Value.textValue(dto.getLdTwoOutStorage().getOrderNo())), new Content(TwoOutApproverConstant.TEXT, TwoOutApproverConstant.TEXT_ORDER_NO, Value.textValue(dto.getLdTwoOutStorage().getOrderNo())),
new Content(TwoOutApproverConstant.TEXT, TwoOutApproverConstant.OUT_GROUP, Value.textValue(dto.getLdTwoOutStorage().getGroupName().equals("自由出库") ? null : dto.getLdTwoOutStorage().getGroupName())), new Content(TwoOutApproverConstant.TEXT, TwoOutApproverConstant.OUT_GROUP, Value.textValue("自由出库".equals(dto.getLdTwoOutStorage().getGroupName()) ? null :
dto.getLdTwoOutStorage().getGroupName())),
new Content(TwoOutApproverConstant.TEXT, TwoOutApproverConstant.TEXTAREA_REASON, Value.textValue(dto.getLdTwoOutStorage().getReason())), new Content(TwoOutApproverConstant.TEXT, TwoOutApproverConstant.TEXTAREA_REASON, Value.textValue(dto.getLdTwoOutStorage().getReason())),
new Content(TwoOutApproverConstant.TABLE, TwoOutApproverConstant.TABLE_MATERIAL_LIST, new Content(TwoOutApproverConstant.TABLE, TwoOutApproverConstant.TABLE_MATERIAL_LIST,
Value.tableValue(tableRowList)) Value.tableValue(tableRowList))

@ -157,7 +157,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
"}"; "}";
@Override @Override
public boolean getApprover(String mainErDepartment, String type,Long formId) { public String getApprover(String mainErDepartment, String type,Long formId) {
// 参数校验 // 参数校验
if (!StringUtils.hasText(type)) { if (!StringUtils.hasText(type)) {
throw new IllegalArgumentException("审批类型不能为空"); throw new IllegalArgumentException("审批类型不能为空");
@ -169,9 +169,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
put("Content-Type", "application/json"); put("Content-Type", "application/json");
}}; }};
Map<String, String> querys = new HashMap<String, String>() {{ Map<String, String> querys = new HashMap();
put("type",type); querys. put("type",type);
}}; if ("1".equals(type)) {
querys.put("deptId", mainErDepartment);
}
String resp = null; String resp = null;
try { try {
@ -205,6 +207,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
// 3.保存审批人信息到数据库 // 3.保存审批人信息到数据库
List<LdApprove> approversToSave = new ArrayList<>(); List<LdApprove> approversToSave = new ArrayList<>();
// 构建审批人json结构 [{"level":1,"ids":"LiuXu"},{"level":2,"ids":"AnXingHe"},{"level":3,"ids":"LiuXu"}]
List<JSONObject> approvers = new ArrayList<>();
// 遍历所有审批层级(1, 2, 3...) // 遍历所有审批层级(1, 2, 3...)
for (String level : result.keySet()) { for (String level : result.keySet()) {
@ -219,6 +223,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
User user = users.get(i); User user = users.get(i);
LdApprove ldApprove = createLdApprove(user, level, formId, type); LdApprove ldApprove = createLdApprove(user, level, formId, type);
approversToSave.add(ldApprove); approversToSave.add(ldApprove);
JSONObject approver = new JSONObject();
approver.put("level", level);
approver.put("ids", user.getUserId());
approvers.add(approver);
} }
} }
@ -230,7 +239,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
throw new RuntimeException("未找到审批人信息"); throw new RuntimeException("未找到审批人信息");
} }
return saveSuccess; return JSONObject.toJSONString(approvers);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("处理审批人数据失败: " + e.getMessage(), e); throw new RuntimeException("处理审批人数据失败: " + e.getMessage(), e);

Loading…
Cancel
Save