|
|
|
@ -18,14 +18,10 @@ import com.foreverwin.mesnac.dispatch.dto.WorkCenterWorkTimeDTO;
|
|
|
|
|
import com.foreverwin.mesnac.dispatch.mapper.SfcDispatchMapper;
|
|
|
|
|
import com.foreverwin.mesnac.dispatch.model.CallItem;
|
|
|
|
|
import com.foreverwin.mesnac.dispatch.model.SfcDispatch;
|
|
|
|
|
import com.foreverwin.mesnac.dispatch.model.ShopOrderRelease;
|
|
|
|
|
import com.foreverwin.mesnac.dispatch.model.UserResource;
|
|
|
|
|
import com.foreverwin.mesnac.dispatch.service.*;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.dto.WorkCenterLinkDTO;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.model.Router;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.model.Sfc;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.model.ShopOrder;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.model.UserGroup;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.model.*;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.service.*;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.util.StringUtils;
|
|
|
|
|
import com.foreverwin.modular.core.exception.BaseException;
|
|
|
|
@ -37,7 +33,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import sun.awt.geom.AreaOp;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
@ -61,8 +56,12 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
|
|
|
|
|
@Autowired
|
|
|
|
|
private SfcService sfcService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ResrceService resrceService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private RouterService routerService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private NwaUserService nwaUserService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ResrceService resourceService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private CallItemService callItemService;
|
|
|
|
@ -371,6 +370,15 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
|
|
|
|
|
//派工更新清单
|
|
|
|
|
List<SfcDispatch> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
//如果导入-查询所有用户
|
|
|
|
|
Map<String, List<NwaUser>> userMap = new HashMap<>();
|
|
|
|
|
if (DispatchStatusEnum.IMPORT.getCode().equals(type)) {
|
|
|
|
|
List<NwaUser> nwaUserList = nwaUserService.findAllUser(site);
|
|
|
|
|
if (nwaUserList != null && nwaUserList.size() > 0) {
|
|
|
|
|
userMap = nwaUserList.stream().collect(Collectors.groupingBy(NwaUser::getFullName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int seq = 0;
|
|
|
|
|
//状态标识,表示本次派工成功或是失败
|
|
|
|
|
Boolean flag = true;
|
|
|
|
@ -385,24 +393,6 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
|
|
|
|
|
String dispatchNo = sfcDispatchDto.getDispatchNo();
|
|
|
|
|
String resourceType = sfcDispatchDto.getResourceType();
|
|
|
|
|
|
|
|
|
|
//派工保存
|
|
|
|
|
if (DispatchStatusEnum.SAVE.getCode().equals(type)) {
|
|
|
|
|
//校验派工状态
|
|
|
|
|
String originalStatus = sfcDispatchDto.getDispatchStatus();
|
|
|
|
|
if (!DispatchStatusEnum.NEW.getCode().equals(originalStatus)) {
|
|
|
|
|
flag = false;
|
|
|
|
|
message.append(seq++ % 3 == 0 ? "\n" : "| |");
|
|
|
|
|
message.append("派工单[" + dispatchNo + "]的派工状态不是新建,不允许保存");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//时间
|
|
|
|
|
if (Constants.USER_GROUP_ZJH.equals(sfcDispatchDto.getRole())) {
|
|
|
|
|
sfcDispatchDto.setEarliestStartDate(sfcDispatchDto.getPlannedStartDate());
|
|
|
|
|
sfcDispatchDto.setLatestEndDate(sfcDispatchDto.getPlannedCompDate());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//派工导入
|
|
|
|
|
if (DispatchStatusEnum.IMPORT.getCode().equals(type)) {
|
|
|
|
|
String handle = HandleEnum.SFC_DISPATCH.getHandle(site, dispatchNo);
|
|
|
|
@ -427,8 +417,71 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
|
|
|
|
|
sfcDispatch.setHandle(handle);
|
|
|
|
|
//是否导入
|
|
|
|
|
sfcDispatch.setIsImport(Constants.BOOL_TRUE);
|
|
|
|
|
|
|
|
|
|
//导入的是人员名称-查找人员编号,设备
|
|
|
|
|
String employee = "";
|
|
|
|
|
String employeeDescription = sfcDispatchDto.getEmployee();
|
|
|
|
|
if (StringUtil.notBlank(employeeDescription)) {
|
|
|
|
|
String _employeeDescription;
|
|
|
|
|
|
|
|
|
|
String []employeeDescriptionArray = employeeDescription.split(",");
|
|
|
|
|
String []employeeArray = new String[employeeDescriptionArray.length];
|
|
|
|
|
for (int i = 0; i < employeeDescriptionArray.length; i++) {
|
|
|
|
|
_employeeDescription = employeeDescriptionArray[i];
|
|
|
|
|
List<NwaUser> _list = userMap.get(_employeeDescription);
|
|
|
|
|
if (_list != null && _list.size() > 0) {
|
|
|
|
|
String userName = _list.get(0).getUserName();
|
|
|
|
|
employee += (i == 0) ? userName : "," + userName;
|
|
|
|
|
employeeArray[i] = userName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询匹配的设备
|
|
|
|
|
List<Resrce> emResourceList = resrceService.getResourceListByUT(site, resourceType, employeeArray);
|
|
|
|
|
if (emResourceList != null && emResourceList.size() > 0) {
|
|
|
|
|
resource = emResourceList.get(0).getResrce();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//派工人员赋值
|
|
|
|
|
sfcDispatch.setIsDispatch("true");
|
|
|
|
|
sfcDispatch.setResrce(resource);
|
|
|
|
|
sfcDispatch.setEmployee(employee);
|
|
|
|
|
sfcDispatch.setEmployeeDescription(employeeDescription);
|
|
|
|
|
sfcDispatch.setRemark(sfcDispatchDto.getRemark());
|
|
|
|
|
sfcDispatch.setBlankingSize(sfcDispatchDto.getBlankingSize());
|
|
|
|
|
sfcDispatch.setPlannedStartDate(sfcDispatchDto.getPlannedStartDate());
|
|
|
|
|
sfcDispatch.setPlannedCompDate(sfcDispatchDto.getPlannedCompDate());
|
|
|
|
|
sfcDispatch.setEarliestStartDate(sfcDispatchDto.getEarliestStartDate());
|
|
|
|
|
sfcDispatch.setLatestEndDate(sfcDispatchDto.getLatestEndDate());
|
|
|
|
|
|
|
|
|
|
list.add(sfcDispatch);
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//派工保存
|
|
|
|
|
if (DispatchStatusEnum.SAVE.getCode().equals(type)) {
|
|
|
|
|
//校验派工状态
|
|
|
|
|
String originalStatus = sfcDispatchDto.getDispatchStatus();
|
|
|
|
|
if (!DispatchStatusEnum.NEW.getCode().equals(originalStatus)) {
|
|
|
|
|
flag = false;
|
|
|
|
|
message.append(seq++ % 3 == 0 ? "\n" : "| |");
|
|
|
|
|
message.append("派工单[" + dispatchNo + "]的派工状态不是新建,不允许保存");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//时间
|
|
|
|
|
if (Constants.USER_GROUP_ZJH.equals(sfcDispatchDto.getRole())) {
|
|
|
|
|
sfcDispatchDto.setEarliestStartDate(sfcDispatchDto.getPlannedStartDate());
|
|
|
|
|
sfcDispatchDto.setLatestEndDate(sfcDispatchDto.getPlannedCompDate());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//派工发布
|
|
|
|
|
if (DispatchStatusEnum.RELEASE.getCode().equals(type)) {
|
|
|
|
|
//校验派工状态
|
|
|
|
@ -486,13 +539,7 @@ public class SfcDispatchServiceImpl extends ServiceImpl<SfcDispatchMapper, SfcDi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//派工人员为多个(只要一个匹配)
|
|
|
|
|
String [] employeeArray = new String[1];
|
|
|
|
|
if (!employees.contains(",")) {
|
|
|
|
|
employeeArray[0] = employees;
|
|
|
|
|
} else {
|
|
|
|
|
employeeArray = employees.split(",");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String []employeeArray = employees.split(",");
|
|
|
|
|
Boolean isMatch = false;
|
|
|
|
|
for (int m = 0; m < employeeArray.length; m++) {
|
|
|
|
|
String employee = employeeArray[m];
|
|
|
|
|