|
|
@ -3,22 +3,55 @@ package com.spring.modules.rohs.service.impl; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
import com.spring.common.utils.Constant; |
|
|
|
|
|
import com.spring.common.utils.DateUtils; |
|
|
import com.spring.common.utils.PageUtils; |
|
|
import com.spring.common.utils.PageUtils; |
|
|
import com.spring.common.utils.Query; |
|
|
import com.spring.common.utils.Query; |
|
|
|
|
|
import com.spring.modules.base.data.OaUserData; |
|
|
|
|
|
import com.spring.modules.change.entity.APIEntity.MainData; |
|
|
|
|
|
import com.spring.modules.change.entity.ParamData; |
|
|
|
|
|
import com.spring.modules.change.entity.ProcessFormEntity; |
|
|
|
|
|
import com.spring.modules.change.mapper.ChangeManagementMapper; |
|
|
|
|
|
import com.spring.modules.change.service.impl.ChangeManagementServiceImpl; |
|
|
import com.spring.modules.change.vo.ProcessFormVo; |
|
|
import com.spring.modules.change.vo.ProcessFormVo; |
|
|
|
|
|
import com.spring.modules.request.vo.PlmRequestDetailVo; |
|
|
import com.spring.modules.rohs.entity.RohsEntity; |
|
|
import com.spring.modules.rohs.entity.RohsEntity; |
|
|
import com.spring.modules.rohs.mapper.RohsMapper; |
|
|
import com.spring.modules.rohs.mapper.RohsMapper; |
|
|
import com.spring.modules.rohs.service.RohsService; |
|
|
import com.spring.modules.rohs.service.RohsService; |
|
|
|
|
|
import com.spring.modules.sys.dao.SysUserDao; |
|
|
|
|
|
import com.spring.modules.sys.entity.SysUserEntity; |
|
|
import org.apache.commons.lang.StringUtils; |
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.Collections; |
|
|
import java.util.Collections; |
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.LinkedHashSet; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
import static com.spring.modules.base.utils.CommonUtils.getPropertyValue; |
|
|
|
|
|
|
|
|
@Service("rohsService") |
|
|
@Service("rohsService") |
|
|
public class RohsServiceImpl extends ServiceImpl<RohsMapper, RohsEntity> implements RohsService { |
|
|
public class RohsServiceImpl extends ServiceImpl<RohsMapper, RohsEntity> implements RohsService { |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private SysUserDao sysUserDao; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ChangeManagementMapper changeManagementMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ChangeManagementServiceImpl changeManagementService; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${oa-control.control-flag}") |
|
|
|
|
|
private Boolean dataUrlOa; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageUtils queryPage(Map<String, Object> params) { |
|
|
public PageUtils queryPage(Map<String, Object> params) { |
|
|
String site = (String) params.get("site"); |
|
|
String site = (String) params.get("site"); |
|
|
@ -55,7 +88,8 @@ public class RohsServiceImpl extends ServiceImpl<RohsMapper, RohsEntity> impleme |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void issue(String site, String referenceNo) { |
|
|
|
|
|
|
|
|
@Transactional |
|
|
|
|
|
public void issue(String site, String referenceNo, String userName, String menuId) { |
|
|
RohsEntity rohs = this.getDetail(site, referenceNo); |
|
|
RohsEntity rohs = this.getDetail(site, referenceNo); |
|
|
if (rohs == null) { |
|
|
if (rohs == null) { |
|
|
throw new RuntimeException("未找到对应RoHs单据"); |
|
|
throw new RuntimeException("未找到对应RoHs单据"); |
|
|
@ -63,6 +97,97 @@ public class RohsServiceImpl extends ServiceImpl<RohsMapper, RohsEntity> impleme |
|
|
if (!"草稿".equals(rohs.getStatus())) { |
|
|
if (!"草稿".equals(rohs.getStatus())) { |
|
|
throw new RuntimeException("仅草稿状态的单据允许下达"); |
|
|
throw new RuntimeException("仅草稿状态的单据允许下达"); |
|
|
} |
|
|
} |
|
|
|
|
|
if (StringUtils.isBlank(userName)) { |
|
|
|
|
|
throw new RuntimeException("下达人不能为空"); |
|
|
|
|
|
} |
|
|
|
|
|
if (StringUtils.isBlank(menuId)) { |
|
|
|
|
|
throw new RuntimeException("菜单ID不能为空"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 关闭调用OA接口时,反刷单据状态为"已完成"(与变更下达一致) |
|
|
|
|
|
if (!dataUrlOa) { |
|
|
|
|
|
RohsEntity updateEntity = new RohsEntity(); |
|
|
|
|
|
updateEntity.setStatus("已完成"); |
|
|
|
|
|
QueryWrapper<RohsEntity> updateWrapper = new QueryWrapper<>(); |
|
|
|
|
|
updateWrapper.eq("site", site).eq("reference_no", referenceNo); |
|
|
|
|
|
this.update(updateEntity, updateWrapper); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取审批基础数据 |
|
|
|
|
|
Map<String, String> baseData = changeManagementService.getReleaseBaseData(site, userName, menuId, referenceNo); |
|
|
|
|
|
List<PlmRequestDetailVo> nodeDetails = changeManagementMapper.queryNodeDetailFirst(site, baseData.get("workflowId"), menuId); |
|
|
|
|
|
if (nodeDetails == null || nodeDetails.isEmpty()) { |
|
|
|
|
|
throw new RuntimeException("流程节点信息获取异常!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// RoHs仅主信息表:plm_rohs |
|
|
|
|
|
List<MainData> mainData = new ArrayList<>(); |
|
|
|
|
|
for (PlmRequestDetailVo nodeDetail : nodeDetails) { |
|
|
|
|
|
if (nodeDetail.getId() == null) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
MainData md = new MainData(); |
|
|
|
|
|
md.setFieldName(nodeDetail.getOaField()); |
|
|
|
|
|
String fieldValue = ""; |
|
|
|
|
|
if (StringUtils.isNotBlank(nodeDetail.getFieldValue())) { |
|
|
|
|
|
md.setFieldValue(nodeDetail.getFieldValue()); |
|
|
|
|
|
mainData.add(md); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
if ("plm_rohs".equals(nodeDetail.getPlmTable())) { |
|
|
|
|
|
Object valueObj = getPropertyValue(rohs, nodeDetail.getPlmField()); |
|
|
|
|
|
fieldValue = convertFieldValue(valueObj); |
|
|
|
|
|
if (StringUtils.isNotBlank(fieldValue) && "A".equals(nodeDetail.getFieldType())) { |
|
|
|
|
|
// 人员字段:PLM用户 -> 域控账号 -> OA人员ID |
|
|
|
|
|
SysUserEntity sysUser = sysUserDao.selectOne(new QueryWrapper<SysUserEntity>().eq("username", fieldValue)); |
|
|
|
|
|
if (sysUser == null) { |
|
|
|
|
|
throw new RuntimeException("未找到PLM用户信息,用户编码: " + fieldValue); |
|
|
|
|
|
} |
|
|
|
|
|
String account = sysUser.getDomainControlAccount(); |
|
|
|
|
|
if (StringUtils.isBlank(account)) { |
|
|
|
|
|
throw new RuntimeException("未获取到PLM人员域控账号,用户编码: " + fieldValue); |
|
|
|
|
|
} |
|
|
|
|
|
List<OaUserData> oaIds = sysUserDao.selectOaIdByAccount(account); |
|
|
|
|
|
if (oaIds == null || oaIds.isEmpty()) { |
|
|
|
|
|
throw new RuntimeException("未获取到域控账号对应的OA人员,域控账号: " + account); |
|
|
|
|
|
} |
|
|
|
|
|
fieldValue = oaIds.get(0).getId(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(fieldValue)) { |
|
|
|
|
|
md.setFieldValue(fieldValue); |
|
|
|
|
|
} else { |
|
|
|
|
|
if ("Y".equals(nodeDetail.getReview())) { |
|
|
|
|
|
String fieldName = changeManagementService.getFieldName(nodeDetail.getPlmTable(), nodeDetail.getPlmField()); |
|
|
|
|
|
throw new RuntimeException("[" + fieldName + "] 参数在当前节点是必填项,无法下达/提交该流程!"); |
|
|
|
|
|
} else if ("N".equals(nodeDetail.getReview()) && "A".equals(nodeDetail.getFieldType())) { |
|
|
|
|
|
// 可选人员字段没值时不传 |
|
|
|
|
|
continue; |
|
|
|
|
|
} else { |
|
|
|
|
|
md.setFieldValue(""); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
mainData.add(md); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ParamData paramData = new ParamData(site, baseData.get("domainControlAccount"), nodeDetails.get(0).getNodeId(), nodeDetails.get(0).getNodeName(), |
|
|
|
|
|
referenceNo, userName, baseData.get("classificationNo"), nodeDetails.get(0).getStepId(), baseData.get("menuId"), baseData.get("menuName"), |
|
|
|
|
|
baseData.get("userId"), baseData.get("workflowId"), baseData.get("workflowname"), baseData.get("requestName"), mainData, baseData.get("path"), |
|
|
|
|
|
"", "plm_rohs", "reference_no", "status"); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
changeManagementService.issueFunction(paramData, Constant.ROHS); |
|
|
|
|
|
// 正常下达后,状态更新为"审批中" |
|
|
|
|
|
if ("已完成".equals(paramData.getStatus())) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
changeManagementService.rollBackFunction(paramData, e); |
|
|
|
|
|
throw new RuntimeException(e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
RohsEntity updateEntity = new RohsEntity(); |
|
|
RohsEntity updateEntity = new RohsEntity(); |
|
|
updateEntity.setStatus("审批中"); |
|
|
updateEntity.setStatus("审批中"); |
|
|
QueryWrapper<RohsEntity> updateWrapper = new QueryWrapper<>(); |
|
|
QueryWrapper<RohsEntity> updateWrapper = new QueryWrapper<>(); |
|
|
@ -104,4 +229,50 @@ public class RohsServiceImpl extends ServiceImpl<RohsMapper, RohsEntity> impleme |
|
|
} |
|
|
} |
|
|
return this.baseMapper.getApprovalList(site, menuId, documentNo); |
|
|
return this.baseMapper.getApprovalList(site, menuId, documentNo); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public HashMap<String, String> getButtonCondition(String site, String referenceNo) { |
|
|
|
|
|
HashMap<String, String> result = new HashMap<>(); |
|
|
|
|
|
result.put("createBy2", ""); |
|
|
|
|
|
result.put("isReject", "Y"); |
|
|
|
|
|
result.put("tpProcessControl", "N"); |
|
|
|
|
|
result.put("csProcessControl", "N"); |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(site) || StringUtils.isBlank(referenceNo)) { |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<ProcessFormEntity> currentProcessList = changeManagementMapper.queryRequestId(site, "", referenceNo); |
|
|
|
|
|
if (currentProcessList == null || currentProcessList.isEmpty()) { |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Set<String> approvers = new LinkedHashSet<>(); |
|
|
|
|
|
for (ProcessFormEntity processForm : currentProcessList) { |
|
|
|
|
|
String approver = processForm.getUpdateBy(); |
|
|
|
|
|
if (StringUtils.isBlank(approver) && StringUtils.isNotBlank(processForm.getDomainControlAccount())) { |
|
|
|
|
|
SysUserEntity sysUser = sysUserDao.selectOne( |
|
|
|
|
|
new QueryWrapper<SysUserEntity>().eq("domain_control_account", processForm.getDomainControlAccount()) |
|
|
|
|
|
); |
|
|
|
|
|
if (sysUser != null) { |
|
|
|
|
|
approver = sysUser.getUsername(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (StringUtils.isNotBlank(approver)) { |
|
|
|
|
|
approvers.add(approver); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
result.put("createBy2", String.join(";", approvers)); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String convertFieldValue(Object valueObj) { |
|
|
|
|
|
if (valueObj == null) { |
|
|
|
|
|
return ""; |
|
|
|
|
|
} |
|
|
|
|
|
if (valueObj instanceof Date) { |
|
|
|
|
|
return DateUtils.format((Date) valueObj); |
|
|
|
|
|
} |
|
|
|
|
|
return String.valueOf(valueObj); |
|
|
|
|
|
} |
|
|
} |
|
|
} |