|
|
@@ -4,22 +4,22 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import com.ygtx.common.core.domain.model.LoginUser;
|
|
|
+import com.ygtx.common.exception.ServiceException;
|
|
|
import com.ygtx.common.utils.DateUtils;
|
|
|
import com.ygtx.common.utils.DictUtils;
|
|
|
import com.ygtx.common.core.domain.entity.SysDept;
|
|
|
import com.ygtx.framework.aspectj.DataScopeAspect;
|
|
|
+import com.ygtx.gxt.domain.*;
|
|
|
+import com.ygtx.system.mapper.SysUserMapper;
|
|
|
import com.ygtx.system.service.ISysConfigService;
|
|
|
import com.ygtx.system.service.ISysDeptService;
|
|
|
-import com.ygtx.gxt.domain.GxtRepairOrderPerson;
|
|
|
-import com.ygtx.gxt.domain.GxtWorkOrderPerson;
|
|
|
import com.ygtx.gxt.mapper.GxtRepairOrderPersonMapper;
|
|
|
+import com.ygtx.system.service.ISysUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.ygtx.gxt.mapper.GxtRepairOrderMapper;
|
|
|
-import com.ygtx.gxt.domain.GxtRepairOrder;
|
|
|
import com.ygtx.gxt.service.IGxtRepairOrderService;
|
|
|
import com.ygtx.gxt.service.IGxtRepairOrderFlowService;
|
|
|
-import com.ygtx.gxt.domain.GxtRepairOrderFlow;
|
|
|
import com.ygtx.common.annotation.DataScope;
|
|
|
import com.ygtx.common.core.domain.entity.SysRole;
|
|
|
import com.ygtx.common.core.domain.entity.SysUser;
|
|
|
@@ -51,6 +51,9 @@ public class GxtRepairOrderServiceImpl implements IGxtRepairOrderService
|
|
|
@Autowired
|
|
|
private ISysConfigService configService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询维修工单
|
|
|
*
|
|
|
@@ -1006,4 +1009,111 @@ public class GxtRepairOrderServiceImpl implements IGxtRepairOrderService
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String importGxtRepairOrder(List<GxtRepairOrder> repairOrderList, boolean updateSupport, String operName) {
|
|
|
+ if (StringUtils.isNull(repairOrderList) || repairOrderList.size() == 0)
|
|
|
+ {
|
|
|
+ throw new ServiceException("导入工单数据不能为空!");
|
|
|
+ }
|
|
|
+ int successNum = 0;
|
|
|
+ int failureNum = 0;
|
|
|
+ int row = 1;
|
|
|
+ StringBuilder successMsg = new StringBuilder();
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
+ for (GxtRepairOrder repairOrder : repairOrderList)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (StringUtils.isEmpty(repairOrder.getMisOrderNo())) {
|
|
|
+ throw new ServiceException("第" + row + "行MIS工单编码不能为空!");
|
|
|
+ }
|
|
|
+ if (repairOrder.getRealStartTime() == null) {
|
|
|
+ throw new ServiceException("第" + row + "行开始时间不能为空!");
|
|
|
+ }
|
|
|
+ if (repairOrder.getRealEndTime() == null) {
|
|
|
+ throw new ServiceException("第" + row + "行结束时间不能为空!");
|
|
|
+ }
|
|
|
+ /*if (StringUtils.isEmpty(repairOrder.getWorkGroupMemberName())) {
|
|
|
+ throw new ServiceException("第" + row + "行检修人员不能为空!");
|
|
|
+ }*/
|
|
|
+ // 根据misOrderNo验证是否存在这个工单
|
|
|
+ GxtRepairOrder repairOrderQuery = new GxtRepairOrder();
|
|
|
+ repairOrderQuery.setMisOrderNo(repairOrder.getMisOrderNo());
|
|
|
+ List<GxtRepairOrder> gxtRepairOrders = gxtRepairOrderMapper.selectGxtRepairOrderListNoPermi(repairOrderQuery);
|
|
|
+ if (gxtRepairOrders == null || gxtRepairOrders.isEmpty())
|
|
|
+ {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>" + failureNum + "、MIS工单编码 " + repairOrder.getMisOrderNo()
|
|
|
+ + " 在维修工单中不存在");
|
|
|
+ }
|
|
|
+ else if (gxtRepairOrders.size() > 1)
|
|
|
+ {
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>" + failureNum + "、MIS工单编码 " + repairOrder.getMisOrderNo()
|
|
|
+ + " 存在于多个维修工单中");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ GxtRepairOrder repairOrderI = gxtRepairOrders.get(0);
|
|
|
+ repairOrder.setId(repairOrderI.getId());
|
|
|
+ gxtRepairOrderMapper.updateGxtRepairOrder(repairOrder);
|
|
|
+ String workGroupMemberName = repairOrder.getWorkGroupMemberName();
|
|
|
+ if(StringUtils.isNotEmpty(workGroupMemberName)){
|
|
|
+ gxtRepairOrderPersonMapper.deleteGxtRepairOrderPersonByOrderId(repairOrder.getId());
|
|
|
+ String[] splitNames = repairOrder.getWorkGroupMemberName().split(",");
|
|
|
+ for (String name : splitNames) {
|
|
|
+ List<SysUser> sysUsers = sysUserService.selectUserByNickName(name);
|
|
|
+ if(sysUsers != null && !sysUsers.isEmpty()){
|
|
|
+ SysUser sysUser = null;
|
|
|
+ // 如果只有一个用户,直接使用
|
|
|
+ if (sysUsers.size() == 1) {
|
|
|
+ sysUser = sysUsers.get(0);
|
|
|
+ } else {
|
|
|
+ // 如果有多个用户,查找部门ID与pcsStationPid相同的用户
|
|
|
+ for (SysUser user : sysUsers) {
|
|
|
+ if (user.getDeptId() != null && (user.getDeptId().equals(repairOrder.getPcsStationPid()) || user.getDeptId().equals(repairOrder.getPcsStationId()))) {
|
|
|
+ sysUser = user;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果没找到部门匹配的用户,则使用第一个用户
|
|
|
+ if (sysUser == null) {
|
|
|
+ sysUser = sysUsers.get(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ GxtRepairOrderPerson person = new GxtRepairOrderPerson();
|
|
|
+ person.setUserId(sysUser.getUserId());
|
|
|
+ person.setNickName(sysUser.getNickName());
|
|
|
+ person.setOrderId(repairOrder.getId());
|
|
|
+ person.setOrderCode(repairOrderI.getWorkOrderProjectNo());
|
|
|
+ person.setStatus(1);
|
|
|
+ person.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ person.setCreateTime(DateUtils.getNowDate());
|
|
|
+ gxtRepairOrderPersonMapper.insertGxtRepairOrderPerson(person);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ successNum++;
|
|
|
+ successMsg.append("<br/>" + successNum + "、MIS工单编码 " + repairOrder.getMisOrderNo() + " 更新成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ failureNum++;
|
|
|
+ String msg = "<br/>" + failureNum + "、MIS工单编码 " + repairOrder.getMisOrderNo() + " 导入失败:";
|
|
|
+ failureMsg.append(msg + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (failureNum > 0)
|
|
|
+ {
|
|
|
+ failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
+ throw new ServiceException(failureMsg.toString());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
+ }
|
|
|
+ return successMsg.toString();
|
|
|
+ }
|
|
|
}
|