|
@@ -1,17 +1,13 @@
|
|
|
package com.phm.manage.controller;
|
|
|
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
-import com.phm.common.annotation.Log;
|
|
|
-import com.phm.common.core.controller.BaseController;
|
|
|
-import com.phm.common.core.domain.AjaxResult;
|
|
|
-import com.phm.common.core.page.TableDataInfo;
|
|
|
-import com.phm.common.enums.BusinessType;
|
|
|
-import com.phm.common.utils.poi.ExcelUtil;
|
|
|
-import com.phm.manage.domain.OrderConfig;
|
|
|
-import com.phm.manage.domain.common.CommonResult;
|
|
|
-import com.phm.manage.domain.common.OrderXmlVO;
|
|
|
-import com.phm.manage.service.IOrderConfigService;
|
|
|
-import com.phm.manage.util.JaxbUtil;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.xml.bind.JAXBContext;
|
|
|
+import javax.xml.bind.JAXBException;
|
|
|
+import javax.xml.bind.Unmarshaller;
|
|
|
+
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
@@ -23,9 +19,23 @@ import org.springframework.web.bind.annotation.PutMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.util.List;
|
|
|
+import com.phm.common.annotation.Log;
|
|
|
+import com.phm.common.core.controller.BaseController;
|
|
|
+import com.phm.common.core.domain.AjaxResult;
|
|
|
+import com.phm.common.core.page.TableDataInfo;
|
|
|
+import com.phm.common.enums.BusinessType;
|
|
|
+import com.phm.common.exception.GlobalException;
|
|
|
+import com.phm.common.utils.bean.BeanUtils;
|
|
|
+import com.phm.common.utils.poi.ExcelUtil;
|
|
|
+import com.phm.manage.domain.OrderConfig;
|
|
|
+import com.phm.manage.domain.common.CommonResult;
|
|
|
+import com.phm.manage.domain.common.OrderXmlVO;
|
|
|
+import com.phm.manage.service.IOrderConfigService;
|
|
|
+import com.phm.manage.util.JaxbUtil;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
|
/**
|
|
|
* 指令配置Controller
|
|
@@ -113,4 +123,31 @@ public class OrderConfigController extends BaseController {
|
|
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
return toAjax(orderConfigService.deleteOrderConfigByIds(ids));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入xml
|
|
|
+ *
|
|
|
+ * @param file file
|
|
|
+ * @param updateSupport updateSupport
|
|
|
+ * @return res
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/import/xml")
|
|
|
+ public CommonResult<Integer> importData(MultipartFile file, boolean updateSupport) {
|
|
|
+ OrderXmlVO orderXmlVO = new OrderXmlVO();
|
|
|
+ OrderConfig orderConfig = new OrderConfig();
|
|
|
+ try {
|
|
|
+ JAXBContext jaxbContext = JAXBContext.newInstance(OrderXmlVO.class);
|
|
|
+ Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
|
|
|
+ orderXmlVO = (OrderXmlVO)jaxbUnmarshaller.unmarshal(file.getInputStream());
|
|
|
+ } catch (JAXBException | IOException exception) {
|
|
|
+ logger.error("XML解析错误,信息:{}", exception.getMessage());
|
|
|
+ throw new GlobalException("XML解析错误,请假查XMl格式");
|
|
|
+ }
|
|
|
+ BeanUtils.copyBeanProp(orderConfig, orderXmlVO);
|
|
|
+ OrderConfig order = orderConfigService.selectOrderConfigByCode(orderConfig.getOrderCode());
|
|
|
+ if (ObjectUtils.isNotEmpty(order)) {
|
|
|
+ return CommonResult.error("指令编码已存在,请重新输入!");
|
|
|
+ }
|
|
|
+ return CommonResult.success(orderConfigService.insertOrderConfig(orderConfig));
|
|
|
+ }
|
|
|
}
|