|
|
|
@ -26,6 +26,7 @@ import com.foreverwin.modular.core.exception.BaseException;
|
|
|
|
|
import com.foreverwin.modular.core.exception.BusinessException;
|
|
|
|
|
import com.foreverwin.modular.core.meext.MEServices;
|
|
|
|
|
import com.foreverwin.modular.core.util.CommonMethods;
|
|
|
|
|
import com.foreverwin.modular.core.util.R;
|
|
|
|
|
import com.sap.me.demand.ReleaseShopOrderRequest;
|
|
|
|
|
import com.sap.me.demand.ReleaseShopOrderResponse;
|
|
|
|
|
import com.sap.me.demand.ReleasedSfc;
|
|
|
|
@ -36,6 +37,7 @@ import com.sap.me.production.ChangeProductionContext;
|
|
|
|
|
import com.sap.me.production.ChangeProductionRequest;
|
|
|
|
|
import com.sap.me.production.ChangeProductionServiceInterface;
|
|
|
|
|
import com.sap.me.production.OperationPlacementTypeEnum;
|
|
|
|
|
import org.apache.commons.fileupload.FileItem;
|
|
|
|
|
import org.apache.commons.net.ftp.FTPClient;
|
|
|
|
|
import org.apache.ibatis.exceptions.PersistenceException;
|
|
|
|
|
import org.apache.ibatis.executor.BatchExecutorException;
|
|
|
|
@ -44,7 +46,9 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
@ -69,7 +73,7 @@ import static com.foreverwin.modular.core.meext.PapiServiceEnum.NCProductionServ
|
|
|
|
|
* Create Time: 2021/06/02
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Service("ShopOrderReleaseService")
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public class ShopOrderReleaseServiceImpl implements ShopOrderReleaseService {
|
|
|
|
|
|
|
|
|
@ -113,37 +117,50 @@ public class ShopOrderReleaseServiceImpl implements ShopOrderReleaseService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 工艺数据导入
|
|
|
|
|
* @param site
|
|
|
|
|
* @param user
|
|
|
|
|
* @param fileType
|
|
|
|
|
* @param message
|
|
|
|
|
* @param multipartFile
|
|
|
|
|
*
|
|
|
|
|
* @param fileItem
|
|
|
|
|
* @param req
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean importRouter(String site, String user, String fileType, StringBuffer message, MultipartFile multipartFile) throws Exception {
|
|
|
|
|
InputStream inputStream = null;
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public R importRouter(FileItem fileItem, HttpServletRequest req) throws Exception {
|
|
|
|
|
String fileType = req.getParameter("fileType");
|
|
|
|
|
String site = req.getParameter("site");
|
|
|
|
|
CommonMethods.setSite(site);
|
|
|
|
|
//工单List
|
|
|
|
|
List<shopOrderReleaseDto> shopOrderList;
|
|
|
|
|
List<ShopOrderRelease> shopOrderReleaseList = new ArrayList<ShopOrderRelease>();
|
|
|
|
|
try {
|
|
|
|
|
CommonsMultipartFile multipartFile = new CommonsMultipartFile(fileItem);
|
|
|
|
|
shopOrderList = ExcelUtils.readExcel(fileType, shopOrderReleaseDto.class, multipartFile, null);
|
|
|
|
|
} finally {
|
|
|
|
|
if (inputStream != null){
|
|
|
|
|
try {
|
|
|
|
|
inputStream.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
if (shopOrderList == null || shopOrderList.size() <= 0) {
|
|
|
|
|
return R.failed("上传的Excel没有数据或者数据格式不正确(Excel顶端标题行为:工单编号)!");
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
//导入数据成功
|
|
|
|
|
for (shopOrderReleaseDto orderReleaseDto : shopOrderList) {
|
|
|
|
|
if (!orderReleaseDto.getShopOrder().substring(0, 1).equals("Q") && !orderReleaseDto.getShopOrder().substring(0, 3).equals("000")) {
|
|
|
|
|
orderReleaseDto.setShopOrder("000" + orderReleaseDto.getShopOrder());
|
|
|
|
|
}
|
|
|
|
|
ShopOrderRelease orderRelease = new ShopOrderRelease();
|
|
|
|
|
orderRelease.setSite(site);
|
|
|
|
|
orderRelease.setShopOrder(orderReleaseDto.getShopOrder());
|
|
|
|
|
//判断系统是否存在此工单编号
|
|
|
|
|
List<ShopOrderRelease> shopOrderListBatchUpdate = this.findShopOrderListBatchUpdate(orderRelease);
|
|
|
|
|
if (shopOrderListBatchUpdate.size() == 1) {
|
|
|
|
|
shopOrderReleaseList.add(shopOrderListBatchUpdate.get(0));
|
|
|
|
|
} else {
|
|
|
|
|
return R.failed("此工单编号不存在:" + orderReleaseDto.getShopOrder());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Boolean result = this.changerouterRevision(shopOrderReleaseList, new StringBuffer(), "A");
|
|
|
|
|
return R.ok(result);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return R.failed(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
if (shopOrderList == null || shopOrderList.size() <= 0) {
|
|
|
|
|
throw BusinessException.build("上传的Excel没有数据,或者数据格式不正确!");
|
|
|
|
|
}else {
|
|
|
|
|
//导入数据成功
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|