|
@@ -8,6 +8,7 @@ import com.xpyy.xpyy.excel.ExcelUtils;
|
|
|
import com.xpyy.xpyy.service.CustomerService;
|
|
import com.xpyy.xpyy.service.CustomerService;
|
|
|
import com.xpyy.xpyy.service.MplanService;
|
|
import com.xpyy.xpyy.service.MplanService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
@@ -94,6 +95,7 @@ public class MplanController {
|
|
|
* @throws Exception
|
|
* @throws Exception
|
|
|
*/
|
|
*/
|
|
|
@PostMapping("/import")
|
|
@PostMapping("/import")
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Map<String, Object> importExcel(@RequestPart("file") MultipartFile file, HttpServletRequest request) throws Exception{
|
|
public Map<String, Object> importExcel(@RequestPart("file") MultipartFile file, HttpServletRequest request) throws Exception{
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
JSONArray array = ExcelUtils.readMultipartFile(file);
|
|
JSONArray array = ExcelUtils.readMultipartFile(file);
|
|
@@ -108,6 +110,16 @@ public class MplanController {
|
|
|
mplan.setModeCode(ModeCode);
|
|
mplan.setModeCode(ModeCode);
|
|
|
mplan.setPlanNum(jsonObject.get("数量").toString());
|
|
mplan.setPlanNum(jsonObject.get("数量").toString());
|
|
|
mplan.setPlandate(jsonObject.get("日期").toString());
|
|
mplan.setPlandate(jsonObject.get("日期").toString());
|
|
|
|
|
+ if (CusCode == null || CusCode.equals("")){
|
|
|
|
|
+ map.put("msg", "500");
|
|
|
|
|
+ map.put("errMsg", "客户不存在,请录入客户信息");
|
|
|
|
|
+ return map;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ModeCode == null || ModeCode.equals("")){
|
|
|
|
|
+ map.put("msg", "500");
|
|
|
|
|
+ map.put("errMsg", "客户没有录入改型号信息,请录入客户型号信息");
|
|
|
|
|
+ return map;
|
|
|
|
|
+ }
|
|
|
mplanService.importExcel(mplan);
|
|
mplanService.importExcel(mplan);
|
|
|
}
|
|
}
|
|
|
map.put("msg", "200");
|
|
map.put("msg", "200");
|