Browse Source

Merge branch 'master' of http://47.112.200.206:3000/shenhao/sys

wuwen 3 years ago
parent
commit
022260e849

+ 2 - 2
src/main/java/com/ssj/api/controller/ApiManagerTeacherController.java

@@ -515,8 +515,8 @@ public class ApiManagerTeacherController extends BaseController {
      */
     @RequestMapping(value="/registerTeacherImport")
     @ResponseBody
-    public Response registerTeacherImport(Model model, @RequestParam("file") MultipartFile file) {
-        Response response = new  Response();
+    public ResponseEntity registerTeacherImport(Model model, @RequestParam("file") MultipartFile file) {
+        ResponseEntity response = new  ResponseEntity();
         try {
             List<Map<String,String>> datas=analysisExFile(file);
             if(datas!=null && datas.size()>0){

+ 10 - 1
src/main/java/com/ssj/bean/sys/fx/domain/Device.java

@@ -90,7 +90,7 @@ public class Device extends PersistentEntity {
 	
 	private String lastMerchantId;
 	
-	
+	private boolean lastPosCode;
 	
 	@OneToOne(cascade = { CascadeType.PERSIST}, fetch=FetchType.EAGER)
 	@JoinColumn(name="merchantId",updatable =false,insertable =false)
@@ -352,6 +352,15 @@ public class Device extends PersistentEntity {
 	public void setDeviceRealNumber(String deviceRealNumber) {
 		this.deviceRealNumber = deviceRealNumber;
 	}
+
+	@Transient
+	public boolean isLastPosCode() {
+		return lastPosCode;
+	}
+
+	public void setLastPosCode(boolean lastPosCode) {
+		this.lastPosCode = lastPosCode;
+	}
 }
 	
 

+ 12 - 4
src/main/java/com/ssj/sys/controller/FxController.java

@@ -1512,9 +1512,17 @@ public class FxController  extends BaseController {
                 //-------------开始解析文件----------------
             	List<Device> devices=ExcelUtils.readDeviceFile(new File( PropertiesUtil.getValue("file_save_path")+fileInfos.get(0).getFilePath()));
             	String batchCode=DateHelper.format(new Date(), "yyyyMMddHHmmssSS");
+            	List<DeviceAct> list = new ArrayList<>();
+				Merchant merchant= null;
             	for (Device device : devices) {
             		if(StringUtils.isNotEmpty(device.getPosCode())){
-            			Merchant merchant=merchantService.getMerchantByPosCode(device.getPosCode());
+            			if(merchant ==null){
+							merchant=merchantService.getMerchantByPosCode(device.getPosCode());
+						}else{
+            				if(!device.isLastPosCode()){
+								merchant=merchantService.getMerchantByPosCode(device.getPosCode());
+							}
+						}
             			device.setMerchantId(merchant.getId());
             			device.setOrgCode(merchant.getOrgCode());
             			device.setStatus(1);
@@ -1531,7 +1539,8 @@ public class FxController  extends BaseController {
 						deviceAct.setRemarks("设备入库:导入入库");
 						deviceAct.setBatchCode(batchCode);
 						deviceAct.setType(3);
-            			deviceActService.save(deviceAct);
+						list.add(deviceAct);
+
             			
             			ConchDerver conchDerver=conchDerverService.getConchDerverByImei(device.getImei());
             			if(conchDerver!=null){
@@ -1543,10 +1552,9 @@ public class FxController  extends BaseController {
             		}
 
 				}
-
+				deviceActService.save(list);
             	deviceService.save(devices);
                 //-------------结束解析文件----------------
-            	
                 responseEntity.success(data, "上传文件成功 ");
             } else {
                 responseEntity.failure(ResponseConstant.CODE_000, "上传文件失败");

+ 24 - 13
src/main/java/com/ssj/sys/controller/ImLibUserController.java

@@ -2,13 +2,8 @@ package com.ssj.sys.controller;
 
 import java.io.IOException;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
 
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
@@ -261,11 +256,17 @@ public class ImLibUserController extends BaseController {
 						iserror=true;
 						break;
 					}
-//					if(StringUtils.isEmpty(tbLibImStudentTemp.getGrade())){
-//						response.failure("年级不能为空");
-//						iserror=true;
-//						break;
-//					}
+					if(StringUtils.isEmpty(tbLibImStudentTemp.getGrade())){
+						response.failure("年级不能为空");
+						iserror=true;
+						break;
+					}else{
+						if(!checkGrade(tbLibImStudentTemp.getGrade())){
+							response.failure("年级输入不正确,请输入类似一年级、二年级等");
+							iserror=true;
+							break;
+						}
+					}
 					if(StringUtils.isEmpty(tbLibImStudentTemp.getLeagueName())){
 						response.failure("机构不能为空");
 						iserror=true;
@@ -343,7 +344,17 @@ public class ImLibUserController extends BaseController {
 		return response;
 	}	
 
-	
+
+	private boolean checkGrade(String grade){
+		boolean check = true;
+		String[] gradeArr = new String[]{"一年级","二年级","三年级","四年级","五年级","六年级","七年级","八年级","九年级"};
+		List<String> list = Arrays.stream(gradeArr).collect(Collectors.toList());
+		if(!list.contains(grade)){
+			check = false;
+		}
+		return check;
+	}
+
 	//学生列表
 	@RequestMapping(value="/student/list/{libId}")
 	public String studentList(Model model,@PathVariable String libId,

+ 7 - 0
src/main/java/com/ssj/sys/utils/ExcelUtils.java

@@ -30,6 +30,7 @@ public class ExcelUtils {
   		Sheet sheet = wb.getSheetAt(0);
   		int rowIndex = 0;
   		Row row = null;
+  		String posCode = "";
   		for (Iterator<Row> it = sheet.rowIterator(); it.hasNext();) {
   			row = it.next();
   			if (rowIndex++ == 0) {
@@ -55,6 +56,12 @@ public class ExcelUtils {
   			device.setDeviceCode(gettxt(row.getCell(6)));
   			device.setDeviceSn(gettxt(row.getCell(7)));
   			device.setPosCode(gettxt(row.getCell(8)));
+  			if(device.getPosCode().equals(posCode)){
+  				device.setLastPosCode(true);
+			}else{
+  				posCode = device.getPosCode();
+				device.setLastPosCode(false);
+			}
   			device.setRemarks(gettxt(row.getCell(9)));
   			
   			device.setEmsNumber(gettxt(row.getCell(10)));

+ 15 - 18
src/main/resources/templates/sys/fx/deviceAllList.html

@@ -765,7 +765,19 @@
 	
 	
     $("#importdevicefile").click(function () {
-		layuiLoading("上传中……");
+    	var index = top.layer.load(1, {shade: [0.8, '#393D49'], time: 0});
+		// var index = layer.load(2, { // icon0-2 加载中,页面显示不同样式
+		// 	shade: [0.8, '#393D49'], // 0.4为透明度 ,#000 为颜色
+		// 	content: '数据提交中',
+		// 	time:0,
+		// 	success: function (obj) {
+		// 		obj.find('.layui-layer-content').css({
+		// 			'color': 'white',
+		// 			'padding-top': '40px', // 图标与样式会重合,这样设置可以错开
+		// 			'width': '200px' // 文字显示的宽度
+		// 		});
+		// 	}
+		// });
         var formData = new FormData();
         formData.append("importdevice", document.getElementById("importdevice").files[0]);
         $.ajax({
@@ -782,7 +794,7 @@
             */
             processData: false,
             success: function (data) {
-				layuiRemoveLoading();
+				top.layer.close(index);
                 if (data.status == "success") {
                 	parent.layer.msg("上传成功",{icon:1});
 			    	setTimeout(function(){
@@ -793,26 +805,11 @@
                 }
             },
             error: function () {
-				layuiRemoveLoading();
+				top.layer.close(index);
                 alert("上传失败,请刷新后重试。");
             }
         });
     });
-
-
-	function layuiLoading(msg) {
-		layui.use(['layer', 'form'], function () {
-			index = layer.load(0, {shade: false});
-		});
-	}
-
-	function layuiRemoveLoading(){
-		layui.use(['layer', 'form'], function(){
-			var layer = layui.layer
-			layer.close(index);
-			//调用close方法,关闭全局变量index对应的加载效果
-		});
-	}
 </script>
 
 <script type="text/javascript">