Browse Source

修改库存、物料、物料类型导入方法

lwx_dev
erdanergou 3 years ago
parent
commit
b5c6329224
  1. 7
      pom.xml
  2. 2
      src/main/java/com/dreamchaser/depository_manage/config/WebMvcConfig.java
  3. 22
      src/main/java/com/dreamchaser/depository_manage/config/WebSocketConfig.java
  4. 10
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java
  5. 90
      src/main/java/com/dreamchaser/depository_manage/controller/ExcelController.java
  6. 4
      src/main/java/com/dreamchaser/depository_manage/controller/GroupController.java
  7. 114
      src/main/java/com/dreamchaser/depository_manage/controller/WebSocketController.java
  8. 2
      src/main/java/com/dreamchaser/depository_manage/entity/ExcelInfoForMaterial.java
  9. 6
      src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.java
  10. 7
      src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml
  11. 4
      src/main/java/com/dreamchaser/depository_manage/scheduled/SaticScheduleTask.java
  12. 96
      src/main/java/com/dreamchaser/depository_manage/security/pool/ExcelFileInfoPool.java
  13. 21
      src/main/java/com/dreamchaser/depository_manage/service/ExcelService.java
  14. 2
      src/main/java/com/dreamchaser/depository_manage/service/MaterialService.java
  15. 654
      src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java
  16. 30
      src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java
  17. 2
      src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialTypeServiceImpl.java
  18. 86
      src/main/java/com/dreamchaser/depository_manage/utils/LinkInterfaceUtil.java
  19. 530
      src/main/resources/static/js/JcPrinter/layer/layer.js
  20. 97
      src/main/resources/templates/pages/depository/table-stock.html
  21. 276
      src/main/resources/templates/pages/material/material-out.html
  22. 135
      src/main/resources/templates/pages/materialtype/materialType_view.html
  23. 8
      src/test/java/com/dreamchaser/depository_manage/TestForOther.java
  24. 7
      target/classes/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml
  25. 530
      target/classes/static/js/JcPrinter/layer/layer.js
  26. 276
      target/classes/templates/pages/material/material-out.html
  27. 135
      target/classes/templates/pages/materialtype/materialType_view.html

7
pom.xml

@ -26,8 +26,13 @@
<artifactId>spring-boot-starter-tomcat</artifactId> <artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<!-- &lt;!&ndash;跨域工具包&ndash;&gt;--> <!-- &lt;!&ndash;跨域工具包&ndash;&gt;-->
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>com.thetransactioncompany</groupId>--> <!-- <groupId>com.thetransactioncompany</groupId>-->
<!-- <artifactId>cors-filter</artifactId>--> <!-- <artifactId>cors-filter</artifactId>-->

2
src/main/java/com/dreamchaser/depository_manage/config/WebMvcConfig.java

@ -15,7 +15,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new UserInterceptor()) registry.addInterceptor(new UserInterceptor())
.addPathPatterns("/**") .addPathPatterns("/**")
.excludePathPatterns("/login", "/register", "/sendCode", "/error","/callback","/QyWxLogin","/getMaterialAll","/approvalcallback") .excludePathPatterns("/webSocket/{number}","/login", "/register", "/sendCode", "/error","/callback","/QyWxLogin","/getMaterialAll","/approvalcallback")
.excludePathPatterns("classpath:/static/**") .excludePathPatterns("classpath:/static/**")
.excludePathPatterns("/static/**"); .excludePathPatterns("/static/**");
} }

22
src/main/java/com/dreamchaser/depository_manage/config/WebSocketConfig.java

@ -0,0 +1,22 @@
package com.dreamchaser.depository_manage.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* webSocket配置项
*/
@Configuration
public class WebSocketConfig {
/**
* 注入ServerEndpointExporter
* 这个bean会自动注册使用了@ServerEndpoint注解声明的Websocket endpoint
*/
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}

10
src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java

@ -524,7 +524,7 @@ public class DepositoryRecordController {
String crypt = Md5.crypt(header); String crypt = Md5.crypt(header);
map.put("applicantId", userToken.getId()); map.put("applicantId", userToken.getId());
// 获取当前部门负责人 // 获取当前部门负责人
List<UserByPort> departmentHeadByUsers = LinkInterfaceUtil.findDepartmentHeadByUser(userToken); List<UserByPort> departmentHeadByUsers = LinkInterfaceUtil.findDepartmentHeadByUser(userToken,crypt);
StringBuilder departmentHeadId = new StringBuilder(); StringBuilder departmentHeadId = new StringBuilder();
StringBuilder departMentHeadQyWxName = new StringBuilder(); StringBuilder departMentHeadQyWxName = new StringBuilder();
// for (int i = 0; i < departmentHeadByUsers.size(); i++) { // for (int i = 0; i < departmentHeadByUsers.size(); i++) {
@ -1019,10 +1019,10 @@ public class DepositoryRecordController {
if (token == null) { if (token == null) {
token = (String) request.getSession().getAttribute("userToken"); token = (String) request.getSession().getAttribute("userToken");
} }
UserByPort userToken = AuthenticationTokenPool.getUserToken(token);
List<UserByPort> departmentHeadByUsers = LinkInterfaceUtil.findDepartmentHeadByUser(userToken);
String header = request.getHeader("user-agent"); String header = request.getHeader("user-agent");
String crypt = Md5.crypt(header); String crypt = Md5.crypt(header);
UserByPort userToken = AuthenticationTokenPool.getUserToken(token);
List<UserByPort> departmentHeadByUsers = LinkInterfaceUtil.findDepartmentHeadByUser(userToken,crypt);
StringBuilder departmentHeadId = new StringBuilder(); StringBuilder departmentHeadId = new StringBuilder();
StringBuilder departMentHeadQyWxName = new StringBuilder(); StringBuilder departMentHeadQyWxName = new StringBuilder();
// for (int i = 0; i < departmentHeadByUsers.size(); i++) { // for (int i = 0; i < departmentHeadByUsers.size(); i++) {
@ -1440,7 +1440,7 @@ public class DepositoryRecordController {
} else if ("out".equals(type)) { } else if ("out".equals(type)) {
// 获取部门负责人 // 获取部门负责人
List<UserByPort> departmentHeadByUsers = LinkInterfaceUtil.findDepartmentHeadByUser(userToken); List<UserByPort> departmentHeadByUsers = LinkInterfaceUtil.findDepartmentHeadByUser(userToken,crypt);
StringBuilder departmentHeadId = new StringBuilder(); StringBuilder departmentHeadId = new StringBuilder();
StringBuilder departMentHeadQyWxName = new StringBuilder(); StringBuilder departMentHeadQyWxName = new StringBuilder();
// for (int i = 0; i < departmentHeadByUsers.size(); i++) { // for (int i = 0; i < departmentHeadByUsers.size(); i++) {
@ -1701,7 +1701,7 @@ public class DepositoryRecordController {
sumQuantity += integer; sumQuantity += integer;
} }
// 获取部门负责人 // 获取部门负责人
List<UserByPort> departmentHeadByUsers = LinkInterfaceUtil.findDepartmentHeadByUser(userToken); List<UserByPort> departmentHeadByUsers = LinkInterfaceUtil.findDepartmentHeadByUser(userToken,crypt);
StringBuilder departmentHeadId = new StringBuilder(); StringBuilder departmentHeadId = new StringBuilder();
StringBuilder departMentHeadQyWxName = new StringBuilder(); StringBuilder departMentHeadQyWxName = new StringBuilder();
// for (int i = 0; i < departmentHeadByUsers.size(); i++) { // for (int i = 0; i < departmentHeadByUsers.size(); i++) {

90
src/main/java/com/dreamchaser/depository_manage/controller/ExcelController.java

@ -1,11 +1,16 @@
package com.dreamchaser.depository_manage.controller; package com.dreamchaser.depository_manage.controller;
import com.dreamchaser.depository_manage.entity.UserByPort;
import com.dreamchaser.depository_manage.pojo.RestResponse;
import com.dreamchaser.depository_manage.security.pool.AuthenticationTokenPool;
import com.dreamchaser.depository_manage.service.ExcelService; import com.dreamchaser.depository_manage.service.ExcelService;
import com.dreamchaser.depository_manage.utils.CrudUtil;
import com.dreamchaser.depository_manage.utils.ResultVo; import com.dreamchaser.depository_manage.utils.ResultVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.Map; import java.util.Map;
/** /**
@ -24,8 +29,13 @@ public class ExcelController {
* @return * @return
*/ */
@PostMapping("/importExcelByMaterial") @PostMapping("/importExcelByMaterial")
public ResultVo importExcelByMaterial(@RequestParam("file") MultipartFile excel) { public ResultVo importExcelByMaterial(@RequestParam("file") MultipartFile excel, HttpServletRequest request) {
return excelService.importExcelMaterial(excel, "material"); String token = request.getHeader("user-token");
if (token == null) {
token = (String) request.getSession().getAttribute("userToken");
}
UserByPort userToken = AuthenticationTokenPool.getUserToken(token);
return excelService.importExcelMaterial(excel,userToken);
} }
/** /**
@ -35,8 +45,13 @@ public class ExcelController {
* @return * @return
*/ */
@PostMapping("/importExcelByMT") @PostMapping("/importExcelByMT")
public ResultVo importExcelByMT(@RequestParam("file") MultipartFile excel) { public ResultVo importExcelByMT(@RequestParam("file") MultipartFile excel, HttpServletRequest request) {
return excelService.importExcelMaterialType(excel); String token = request.getHeader("user-token");
if (token == null) {
token = (String) request.getSession().getAttribute("userToken");
}
UserByPort userToken = AuthenticationTokenPool.getUserToken(token);
return excelService.importExcelMaterialType(excel,userToken);
} }
@ -44,18 +59,75 @@ public class ExcelController {
* 用于库存信息的导入 * 用于库存信息的导入
*/ */
@PostMapping("/importInventory") @PostMapping("/importInventory")
public ResultVo importInventory(@RequestParam("file") MultipartFile excel) { public ResultVo importInventory(@RequestParam("file") MultipartFile excel, HttpServletRequest request) {
return excelService.importExcelInventory(excel); String token = request.getHeader("user-token");
if (token == null) {
token = (String) request.getSession().getAttribute("userToken");
}
UserByPort userToken = AuthenticationTokenPool.getUserToken(token);
return excelService.importExcelInventory(excel,userToken);
} }
/**
* 用于实际导入库存信息
* @param map
*/
@PostMapping("/realImportInventory") @PostMapping("/realImportInventory")
public void realImportInventory(@RequestBody Map<String, String> map) { public RestResponse realImportInventory(@RequestBody Map<String, String> map,HttpServletRequest request) {
String s = map.get("result");
String token = request.getHeader("user-token");
if (token == null) {
token = (String) request.getSession().getAttribute("userToken");
}
UserByPort userToken = AuthenticationTokenPool.getUserToken(token);
if ("yes".equals(s)) {
excelService.executeImportForInventory(userToken);
}else{
excelService.clearImportFileData(userToken);
}
return CrudUtil.insertHandle(1,1);
}
/**
* 用于实际导入物料类型信息
* @param map
*/
@PostMapping("/realImportMaterialType")
public RestResponse realImportMaterialType(@RequestBody Map<String, String> map,HttpServletRequest request) {
String s = map.get("result"); String s = map.get("result");
String token = request.getHeader("user-token");
if (token == null) {
token = (String) request.getSession().getAttribute("userToken");
}
UserByPort userToken = AuthenticationTokenPool.getUserToken(token);
if ("yes".equals(s)) {
excelService.executeImportForMaterialType(userToken);
}else{
excelService.clearImportFileData(userToken);
}
return CrudUtil.insertHandle(1,1);
}
/**
* 用于实际导入物料信息
* @param map
*/
@PostMapping("/realImportMaterial")
public RestResponse realImportMaterial(@RequestBody Map<String, String> map, HttpServletRequest request) {
String s = map.get("result");
String token = request.getHeader("user-token");
if (token == null) {
token = (String) request.getSession().getAttribute("userToken");
}
UserByPort userToken = AuthenticationTokenPool.getUserToken(token);
if ("yes".equals(s)) { if ("yes".equals(s)) {
excelService.executeImportForInventory(); excelService.executeImportForMaterial(userToken);
}else{ }else{
excelService.clearImportFileData(); excelService.clearImportFileData(userToken);
} }
return CrudUtil.insertHandle(1,1);
} }

4
src/main/java/com/dreamchaser/depository_manage/controller/GroupController.java

@ -607,7 +607,7 @@ public class GroupController {
String crypt = Md5.crypt(header); String crypt = Md5.crypt(header);
map.put("applicantId", userToken.getId()); map.put("applicantId", userToken.getId());
// 获取当前部门负责人 // 获取当前部门负责人
List<UserByPort> departmentHeadByUsers = LinkInterfaceUtil.findDepartmentHeadByUser(userToken); List<UserByPort> departmentHeadByUsers = LinkInterfaceUtil.findDepartmentHeadByUser(userToken,crypt);
// 部门负责人id // 部门负责人id
StringBuilder departmentHeadId = new StringBuilder(); StringBuilder departmentHeadId = new StringBuilder();
// 部门负责人企业微信user // 部门负责人企业微信user
@ -774,7 +774,7 @@ public class GroupController {
String crypt = Md5.crypt(header); String crypt = Md5.crypt(header);
map.put("applicantId", userToken.getId()); map.put("applicantId", userToken.getId());
// 获取当前部门负责人 // 获取当前部门负责人
List<UserByPort> departmentHeadByUsers = LinkInterfaceUtil.findDepartmentHeadByUser(userToken); List<UserByPort> departmentHeadByUsers = LinkInterfaceUtil.findDepartmentHeadByUser(userToken,crypt);
// 部门负责人id // 部门负责人id
StringBuilder departmentHeadId = new StringBuilder(); StringBuilder departmentHeadId = new StringBuilder();
// 部门负责人企业微信user // 部门负责人企业微信user

114
src/main/java/com/dreamchaser/depository_manage/controller/WebSocketController.java

@ -0,0 +1,114 @@
package com.dreamchaser.depository_manage.controller;
import com.dreamchaser.depository_manage.entity.UserByPort;
import com.dreamchaser.depository_manage.security.pool.AuthenticationTokenPool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
@Component
// 主要是将目前的类定义成一个websocket服务器端
@ServerEndpoint("/webSocket/{number}") // 接收路径
@Slf4j
public class WebSocketController {
//concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
//虽然@Component默认是单例模式的,但springboot还是会为每个websocket连接初始化一个bean,所以可以用一个静态set保存起来
// 。
// 注:底下WebSocket是当前类名
private static CopyOnWriteArraySet<WebSocketController> webSockets = new CopyOnWriteArraySet<>();
// 用来存在线连接用户信息
private static ConcurrentHashMap<String, Session> sessionPool = new ConcurrentHashMap<String, Session>();
//与某个客户端的连接会话,需要通过它来给客户端发送数据
private Session session;
//接收sid
private String number = "";
/**
* 群发自定义消息
*/
public static void sendInfo(String message, @PathParam("number") String number) throws IOException {
Session session = sessionPool.get(number);
if (session != null && session.isOpen()) {
log.info("推送消息到窗口" + number + ",推送内容:" + message);
for (WebSocketController item : webSockets) {
try {
if (item.number.equals(number)) {
item.sendMessage(message);
}
} catch (IOException e) {
log.error(e.getMessage());
}
}
}
}
/**
* 链接成功调用的方法
*/
@OnOpen
public void onOpen(Session session, @PathParam("number") String number) {
try {
this.session = session;
webSockets.add(this);
sessionPool.put(number, session);
this.number = number;
System.out.println("连接成功");
log.info("【websocket消息】有新的连接,总数为:" + webSockets.size());
} catch (Exception e) {
}
}
/**
* 链接关闭调用的方法
*/
@OnClose
public void onClose() {
try {
sessionPool.remove(this.number);
webSockets.remove(this);
log.info("【websocket消息】连接断开,总数为:" + webSockets.size());
} catch (Exception e) {
}
}
/**
* 收到客户端消息后调用的方法
*
* @param message
*/
@OnMessage
public void onMessage(String message) {
log.info("【websocket消息】收到客户端消息:" + message);
}
/**
* 发送错误时的处理
*
* @param session
* @param error
*/
@OnError
public void onError(Session session, Throwable error) {
log.error("用户错误,原因:" + error.getMessage());
error.printStackTrace();
}
/**
* 实现服务器主动推送
*/
public void sendMessage(String message) throws IOException {
this.session.getBasicRemote().sendText(message);
}
}

2
src/main/java/com/dreamchaser/depository_manage/entity/ExcelInfo.java → src/main/java/com/dreamchaser/depository_manage/entity/ExcelInfoForMaterial.java

@ -17,7 +17,7 @@ import java.math.BigInteger;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class ExcelInfo { public class ExcelInfoForMaterial {
/** 物料编号 */ /** 物料编号 */
@ExcelProperty("EAS编号") @ExcelProperty("EAS编号")

6
src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.java

@ -1,7 +1,6 @@
package com.dreamchaser.depository_manage.mapper; package com.dreamchaser.depository_manage.mapper;
import com.dreamchaser.depository_manage.entity.*; import com.dreamchaser.depository_manage.entity.*;
import com.dreamchaser.depository_manage.pojo.MaterialP;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -47,7 +46,7 @@ public interface MaterialMapper {
* @param list 参数map * @param list 参数map
* @return 受影响的行数 * @return 受影响的行数
*/ */
Integer insertMaterials(List<ExcelInfo> list); Integer insertMaterials(List<ExcelInfoForMaterial> list);
/** /**
@ -282,6 +281,9 @@ public interface MaterialMapper {
*/ */
List<MaterialAndBarCode> findMaterialByBarCodeByCondition(Map<String,Object> map); List<MaterialAndBarCode> findMaterialByBarCodeByCondition(Map<String,Object> map);
Material findMaterialByCode(String code);
/** /**
* 通过条件获取条形码与物料的对应关系数量 * 通过条件获取条形码与物料的对应关系数量
* @param map * @param map

7
src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml

@ -652,6 +652,13 @@
FROM material m WHERE m.id =#{id} FROM material m WHERE m.id =#{id}
</select> </select>
<select id="findMaterialByCode" resultMap="materialMap" parameterType="string">
SELECT
<include refid="allColumns"/>
FROM material m WHERE m.code =#{code}
</select>
<select id="findInventoryById" resultMap="InventoryMap" parameterType="integer"> <select id="findInventoryById" resultMap="InventoryMap" parameterType="integer">
SELECT SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory"/> <include refid="allColumnsAndTypeNameOnViewByInventory"/>

4
src/main/java/com/dreamchaser/depository_manage/scheduled/SaticScheduleTask.java

@ -1,5 +1,6 @@
package com.dreamchaser.depository_manage.scheduled; package com.dreamchaser.depository_manage.scheduled;
import com.dreamchaser.depository_manage.controller.WebSocketController;
import com.dreamchaser.depository_manage.service.MaterialService; import com.dreamchaser.depository_manage.service.MaterialService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -23,4 +24,7 @@ public class SaticScheduleTask {
materialService.InitTreeMenus_Test(); materialService.InitTreeMenus_Test();
} }
} }

96
src/main/java/com/dreamchaser/depository_manage/security/pool/ExcelFileInfoPool.java

@ -0,0 +1,96 @@
package com.dreamchaser.depository_manage.security.pool;
import com.dreamchaser.depository_manage.entity.ExcelInfoByInventory;
import com.dreamchaser.depository_manage.entity.ExcelInfoByMT;
import com.dreamchaser.depository_manage.entity.ExcelInfoForMaterial;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* 用于设置用户的上传物料信息
*/
public class ExcelFileInfoPool {
private static Map<String, List<ExcelInfoByInventory>> excelVosForInventoryPool = new ConcurrentHashMap<>(1000);
private static Map<String, List<ExcelInfoByMT>> excelVosForMaterialTypePool = new ConcurrentHashMap<>(1000);
private static Map<String, List<ExcelInfoForMaterial>> excelVosForMaterialPool = new ConcurrentHashMap<>(1000);
/**
* 用于暂存当前用户的上传库存数据
* @param key 用户工号
*/
public static void addUserExcelInventoryInfo(String key, List<ExcelInfoByInventory> excelVosForInventory){
excelVosForInventoryPool.put(key, excelVosForInventory);
}
/**
* 获取当前用户上传的库存数据
* @param key
* @return
*/
public static List<ExcelInfoByInventory> getUserExcelInventoryInfo(String key){
return excelVosForInventoryPool.get(key);
}
/**
* 用于删除当前用户上传的库存数据
* @param key
*/
public static void removeUserExcelInventoryInfo(String key){
excelVosForInventoryPool.remove(key);
}
/**
* 用于暂存当前用户的上传物料数据
* @param key 用户工号
*/
public static void addUserExcelMaterialInfo(String key, List<ExcelInfoForMaterial> excelVosForMaterial){
excelVosForMaterialPool.put(key, excelVosForMaterial);
}
/**
* 获取当前用户上传的物料数据
* @param key
* @return
*/
public static List<ExcelInfoForMaterial> getUserExcelMaterialInfo(String key){
return excelVosForMaterialPool.get(key);
}
/**
* 用于删除当前用户上传的物料数据
* @param key
*/
public static void removeUserExcelMaterialInfo(String key){
excelVosForMaterialPool.remove(key);
}
/**
* 用于暂存当前用户的上传物料类型数据
* @param key 用户工号
*/
public static void addUserExcelMaterialTypeInfo(String key, List<ExcelInfoByMT> excelVosForMaterialType){
excelVosForMaterialTypePool.put(key, excelVosForMaterialType);
}
/**
* 获取当前用户上传的物料类型数据
* @param key
* @return
*/
public static List<ExcelInfoByMT> getUserExcelMaterialTypeInfo(String key){
return excelVosForMaterialTypePool.get(key);
}
/**
* 用于删除当前用户上传的物料类型数据
* @param key
*/
public static void removeUserExcelMaterialTypeInfo(String key){
excelVosForMaterialTypePool.remove(key);
}
}

21
src/main/java/com/dreamchaser/depository_manage/service/ExcelService.java

@ -13,24 +13,23 @@ public interface ExcelService {
/** /**
* 用于导入物料名称 * 用于导入物料名称
* @param file * @param file
* @param excelInfo
* @return * @return
*/ */
ResultVo importExcelMaterial(MultipartFile file,String excelInfo); ResultVo importExcelMaterial(MultipartFile file,UserByPort userByPort);
/** /**
* 用于导入物料分类 * 用于导入物料分类
* @param file * @param file
* @return * @return
*/ */
ResultVo importExcelMaterialType(MultipartFile file); ResultVo importExcelMaterialType(MultipartFile file,UserByPort userByPort);
/** /**
* 用于导入库存信息 * 用于导入库存信息
* @param file * @param file
* @return * @return
*/ */
ResultVo importExcelInventory(MultipartFile file); ResultVo importExcelInventory(MultipartFile file,UserByPort userByPort);
/** /**
@ -46,12 +45,22 @@ public interface ExcelService {
/** /**
* 用于执行库存导入方法 * 用于执行库存导入方法
*/ */
void executeImportForInventory(); void executeImportForInventory(UserByPort userByPort);
/**
* 用于执行物料类型导入方法
*/
void executeImportForMaterialType(UserByPort userByPort);
/**
* 用于执行物料导入方法
*/
void executeImportForMaterial(UserByPort userByPort);
/** /**
* 用于清空导入的数据 * 用于清空导入的数据
*/ */
public void clearImportFileData(); void clearImportFileData(UserByPort userByPort);
} }

2
src/main/java/com/dreamchaser/depository_manage/service/MaterialService.java

@ -27,7 +27,7 @@ public interface MaterialService {
* @param list 参数map * @param list 参数map
* @return 受影响的行数 * @return 受影响的行数
*/ */
Integer insertMaterials(List<ExcelInfo> list); Integer insertMaterials(List<ExcelInfoForMaterial> list);
/** /**
* 更新一条库存记录 * 更新一条库存记录

654
src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java

@ -8,10 +8,13 @@ import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.fill.FillConfig; import com.alibaba.excel.write.metadata.fill.FillConfig;
import com.alibaba.excel.write.metadata.fill.FillWrapper; import com.alibaba.excel.write.metadata.fill.FillWrapper;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.dreamchaser.depository_manage.controller.WebSocketController;
import com.dreamchaser.depository_manage.entity.*; import com.dreamchaser.depository_manage.entity.*;
import com.dreamchaser.depository_manage.mapper.ConstructionUnitMapper; import com.dreamchaser.depository_manage.mapper.ConstructionUnitMapper;
import com.dreamchaser.depository_manage.mapper.DepositoryRecordMapper; import com.dreamchaser.depository_manage.mapper.DepositoryRecordMapper;
import com.dreamchaser.depository_manage.mapper.MaterialMapper; import com.dreamchaser.depository_manage.mapper.MaterialMapper;
import com.dreamchaser.depository_manage.security.pool.ExcelFileInfoPool;
import com.dreamchaser.depository_manage.service.*; import com.dreamchaser.depository_manage.service.*;
import com.dreamchaser.depository_manage.utils.*; import com.dreamchaser.depository_manage.utils.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -62,19 +65,14 @@ public class ExcelServiceImpl implements ExcelService {
ConstructionUnitMapper constructionUnitMapper; ConstructionUnitMapper constructionUnitMapper;
List<ExcelInfoByInventory> excelVosForInventory = new ArrayList<>();
/** /**
* 用于导入物料名称 * 用于导入物料名称
* *
* @param file * @param file
* @param excelInfo
* @return * @return
*/ */
@Override @Override
public ResultVo importExcelMaterial(MultipartFile file, String excelInfo) { public ResultVo importExcelMaterial(MultipartFile file, UserByPort userByPort) {
// 1.入参校验 // 1.入参校验
ResultVo<String> checkExcelParam = excelutil.checkExcelParam(file); ResultVo<String> checkExcelParam = excelutil.checkExcelParam(file);
if (!checkExcelParam.checkSuccess()) { if (!checkExcelParam.checkSuccess()) {
@ -91,51 +89,79 @@ public class ExcelServiceImpl implements ExcelService {
return ResultVoUtil.error("【导入Excel文件】生成的Excel文件的路径为空"); return ResultVoUtil.error("【导入Excel文件】生成的Excel文件的路径为空");
} }
// 3.读取excel文件 // 3.读取excel文件
Map<String, Object> readResult = new HashMap<>(); Map<String, Object> readResult = excelutil.simpleExcelRead(filePath, ExcelInfoForMaterial.class);
if ("material".equals(excelInfo)) { List<ExcelInfoForMaterial> excelVosForMaterialList = (List<ExcelInfoForMaterial>) readResult.get("dataList");
readResult = excelutil.simpleExcelRead(filePath, ExcelInfo.class);
}
List<ExcelInfo> excelVos = (List<ExcelInfo>) readResult.get("dataList");
List<String> errMsg = (List<String>) readResult.get("errMsg"); List<String> errMsg = (List<String>) readResult.get("errMsg");
boolean empty = CollectionUtil.isEmpty(excelVos); List<String> dataIndex = (List<String>) readResult.get("dataIndex");
if ((CollectionUtil.isEmpty(excelVos) && errMsg.size() < 1) || (excelVos.size() < 2 && errMsg.size() < 1)) { boolean empty = CollectionUtil.isEmpty(excelVosForMaterialList);
if ((CollectionUtil.isEmpty(excelVosForMaterialList) && errMsg.size() < 1) || (excelVosForMaterialList.size() < 2 && errMsg.size() < 1)) {
log.error("【导入Excel文件】上传Excel文件{}为空", file.getOriginalFilename()); log.error("【导入Excel文件】上传Excel文件{}为空", file.getOriginalFilename());
return ResultVoUtil.error("上传Excel文件为空"); return ResultVoUtil.error("上传Excel文件为空");
} }
// 4.通过线程池开启一个线程去执行数据库操作,主线程继续往下执行
// 4.1开启一个线程
TaskCenterUtil taskCenterUtil = TaskCenterUtil.getTaskCenterUtil(); // 获取当前总数
taskCenterUtil.submitTask(() -> { int totalVal = excelVosForMaterialList.size();
List<Object> success = new ArrayList<>();
Map<String, Object> returnResult = new HashMap<>(); if (totalVal > 0) {
for (ExcelInfo excelVo : excelVos) { // 初始化
Map<String, Object> param = new HashMap<>(); ExcelFileInfoPool.addUserExcelMaterialInfo(userByPort.getNumber(), Collections.synchronizedList(new ArrayList<>()));
param.put("mname", excelVo.getMname()); // 定义分页数量
double size = 100.0;
param.put("code", excelVo.getCode());
param.put("unit", excelVo.getUnit()); // 定义线程数
param.put("version", excelVo.getVersion()); int threadSize = (int) Math.ceil(totalVal / size);
param.put("texture", excelVo.getTexture());
Long typeId = excelVo.getTypeId(); // 定义开启线程数目
if (typeId != null) { int openThreadSize = 0;
param.put("typeId", typeId); // 开启对应数量的线程
}else{ ExecutorService exs = Executors.newFixedThreadPool(threadSize);
String typeName = excelVo.getTypeName(); // 线程结果集
MaterialType materialTypeByName = materialTypeService.findMaterialTypeByName(typeName); List<Future<List<String>>> futureList = new ArrayList<Future<List<String>>>();
param.put("typeId", materialTypeByName.getOldId());
// 1.定义CompletionService
CompletionService<List<String>> completionService = new ExecutorCompletionService<>(exs);
// 定义组合id列表
List<ExcelInfoForMaterial> excelInfoForMaterialS = new ArrayList<>();
List<String> dataIndexList = new ArrayList<>();
System.out.println(excelVosForMaterialList.size());
for (int i = 0; i < excelVosForMaterialList.size(); i++) {
if (((i + 1) % 100) == 0) { // 如果有个开启线程进行处理
excelInfoForMaterialS.add(excelVosForMaterialList.get(i));
dataIndexList.add(dataIndex.get(i));
Future<List<String>> future = completionService.submit(new disposeImportMaterialFileData(excelInfoForMaterialS, dataIndexList, userByPort));
openThreadSize++;
futureList.add(future); // 添加到结果集
excelInfoForMaterialS = new ArrayList<>(); // 情况列表
dataIndexList = new ArrayList<>();
} else {
// 添加id到列表中
excelInfoForMaterialS.add(excelVosForMaterialList.get(i));
dataIndexList.add(dataIndex.get(i));
}
}
if (excelInfoForMaterialS.size() > 0) {
// 如果有剩余,开启线程进行处理
Future<List<String>> future = completionService.submit(new disposeImportMaterialFileData(excelInfoForMaterialS, dataIndexList, userByPort));
futureList.add(future);
openThreadSize++;
}
for (int i = 0; i < openThreadSize; i++) {
List<String> strings = new ArrayList<>();
try {
strings = completionService.take().get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
} }
param.put("id", excelVo.getId()); errMsg.addAll(strings);
param.put("brand", excelVo.getBrand());
param.put("price", excelVo.getPrice() == null ? "0" : excelVo.getPrice());
materialService.insertMaterial(param);
success.add(excelVo);
} }
}
System.out.println(ExcelFileInfoPool.getUserExcelMaterialInfo(userByPort.getNumber()).size());
readResult.put("dataList", ExcelFileInfoPool.getUserExcelMaterialInfo(userByPort.getNumber()));
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVos));
returnResult.put("success", success);
returnResult.put("errMsg", errMsg);
return ResultVoUtil.returnResultVo(200, returnResult, "结果");
});
// 4.2删除临时文件 // 4.2删除临时文件
boolean deleteFile = FileUtil.deleteFile(new File(filePath)); boolean deleteFile = FileUtil.deleteFile(new File(filePath));
if (!deleteFile) { if (!deleteFile) {
@ -153,7 +179,7 @@ public class ExcelServiceImpl implements ExcelService {
* @return * @return
*/ */
@Override @Override
public ResultVo importExcelMaterialType(MultipartFile file) { public ResultVo importExcelMaterialType(MultipartFile file, UserByPort userByPort) {
// 1.入参校验 // 1.入参校验
ResultVo<String> checkExcelParam = excelutil.checkExcelParam(file); ResultVo<String> checkExcelParam = excelutil.checkExcelParam(file);
if (!checkExcelParam.checkSuccess()) { if (!checkExcelParam.checkSuccess()) {
@ -171,44 +197,81 @@ public class ExcelServiceImpl implements ExcelService {
} }
// 3.读取excel文件 // 3.读取excel文件
Map<String, Object> readResult = excelutil.simpleExcelRead(filePath, ExcelInfoByMT.class); Map<String, Object> readResult = excelutil.simpleExcelRead(filePath, ExcelInfoByMT.class);
List<ExcelInfoByMT> excelVos = (List<ExcelInfoByMT>) readResult.get("dataList"); List<ExcelInfoByMT> excelInfoByMTList = (List<ExcelInfoByMT>) readResult.get("dataList");
List<String> errMsg = (List<String>) readResult.get("errMsg"); List<String> errMsg = (List<String>) readResult.get("errMsg");
boolean empty = CollectionUtil.isEmpty(excelVos); List<String> dataIndex = (List<String>) readResult.get("dataIndex");
if ((CollectionUtil.isEmpty(excelVos) && errMsg.size() < 1) || (excelVos.size() < 2 && errMsg.size() < 1)) { boolean empty = CollectionUtil.isEmpty(excelInfoByMTList);
if ((CollectionUtil.isEmpty(excelInfoByMTList) && errMsg.size() < 1) || (excelInfoByMTList.size() < 2 && errMsg.size() < 1)) {
log.error("【导入Excel文件】上传Excel文件{}为空", file.getOriginalFilename()); log.error("【导入Excel文件】上传Excel文件{}为空", file.getOriginalFilename());
return ResultVoUtil.error("上传Excel文件为空"); return ResultVoUtil.error("上传Excel文件为空");
} }
if ((CollectionUtil.isEmpty(excelVos) && errMsg.size() < 1) || (excelVos.size() < 2 && errMsg.size() < 1)) { if ((CollectionUtil.isEmpty(excelInfoByMTList) && errMsg.size() < 1) || (excelInfoByMTList.size() < 2 && errMsg.size() < 1)) {
log.error("【导入Excel文件】上传Excel文件{}为空", file.getOriginalFilename()); log.error("【导入Excel文件】上传Excel文件{}为空", file.getOriginalFilename());
return ResultVoUtil.error("上传Excel文件为空"); return ResultVoUtil.error("上传Excel文件为空");
} }
// 4.通过线程池开启一个线程去执行数据库操作,主线程继续往下执行
// 4.1开启一个线程
TaskCenterUtil taskCenterUtil = TaskCenterUtil.getTaskCenterUtil(); // 获取当前总数
taskCenterUtil.submitTask(() -> { int totalVal = excelInfoByMTList.size();
List<Object> success = new ArrayList<>();
Map<String, Object> returnResult = new HashMap<>(); if (totalVal > 0) {
// 初始化
for (int i = 0; i < excelVos.size(); i++) { ExcelFileInfoPool.addUserExcelMaterialTypeInfo(userByPort.getNumber(), Collections.synchronizedList(new ArrayList<>()));
Map<String, Object> insert = new HashMap<>(); // 定义分页数量
ExcelInfoByMT info = excelVos.get(i); double size = 100.0;
insert.put("oldId", info.getOldId());
insert.put("tname", info.getTname()); // 定义线程数
insert.put("introduce", info.getIntroduce()); int threadSize = (int) Math.ceil(totalVal / size);
if (info.getParentId() == null) {
insert.put("materialTypeId", 0); // 定义开启线程数目
int openThreadSize = 0;
// 开启对应数量的线程
ExecutorService exs = Executors.newFixedThreadPool(threadSize);
// 线程结果集
List<Future<List<String>>> futureList = new ArrayList<Future<List<String>>>();
// 1.定义CompletionService
CompletionService<List<String>> completionService = new ExecutorCompletionService<>(exs);
// 定义组合id列表
List<ExcelInfoByMT> excelInfoByMTS = new ArrayList<>();
List<String> dataIndexList = new ArrayList<>();
for (int i = 0; i < excelInfoByMTList.size(); i++) {
if (((i + 1) % 100) == 0) { // 如果有10个开启线程进行处理
excelInfoByMTS.add(excelInfoByMTList.get(i));
dataIndexList.add(dataIndex.get(i));
Future<List<String>> future = completionService.submit(new disposeImportMaterialTypeFileData(excelInfoByMTS, dataIndexList, userByPort));
openThreadSize++;
futureList.add(future); // 添加到结果集
excelInfoByMTS = new ArrayList<>(); // 情况列表
dataIndexList = new ArrayList<>();
} else { } else {
insert.put("materialTypeId", info.getParentId()); // 添加id到列表中
excelInfoByMTS.add(excelInfoByMTList.get(i));
dataIndexList.add(dataIndex.get(i));
}
}
if (excelInfoByMTS.size() > 0) {
// 如果有剩余,开启线程进行处理
Future<List<String>> future = completionService.submit(new disposeImportMaterialTypeFileData(excelInfoByMTS, dataIndexList, userByPort));
futureList.add(future);
openThreadSize++;
}
for (int i = 0; i < openThreadSize; i++) {
List<String> strings = new ArrayList<>();
try {
strings = completionService.take().get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
} }
materialTypeService.insertMaterialType(insert); errMsg.addAll(strings);
success.add(info);
} }
}
readResult.put("dataList", ExcelFileInfoPool.getUserExcelMaterialTypeInfo(userByPort.getNumber()));
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVos));
returnResult.put("success", success);
returnResult.put("errMsg", errMsg);
return ResultVoUtil.returnResultVo(200, returnResult, "结果");
});
// 4.2删除临时文件 // 4.2删除临时文件
boolean deleteFile = FileUtil.deleteFile(new File(filePath)); boolean deleteFile = FileUtil.deleteFile(new File(filePath));
if (!deleteFile) { if (!deleteFile) {
@ -217,8 +280,6 @@ public class ExcelServiceImpl implements ExcelService {
} }
log.info("【导入Excel文件】删除临时文件成功,临时文件路径为:{}", filePath); log.info("【导入Excel文件】删除临时文件成功,临时文件路径为:{}", filePath);
return ResultVoUtil.returnResultVo(200, readResult, "结果"); return ResultVoUtil.returnResultVo(200, readResult, "结果");
// return ResultVoUtil.success(excelVos);
} }
@ -229,7 +290,7 @@ public class ExcelServiceImpl implements ExcelService {
* @return * @return
*/ */
@Override @Override
public ResultVo importExcelInventory(MultipartFile file) { public ResultVo importExcelInventory(MultipartFile file, UserByPort userByPort) {
// 1.入参校验 // 1.入参校验
ResultVo<String> checkExcelParam = excelutil.checkExcelParam(file); ResultVo<String> checkExcelParam = excelutil.checkExcelParam(file);
if (!checkExcelParam.checkSuccess()) { if (!checkExcelParam.checkSuccess()) {
@ -263,9 +324,13 @@ public class ExcelServiceImpl implements ExcelService {
// 获取当前总数 // 获取当前总数
int totalVal = excelInfoByInventories.size(); int totalVal = excelInfoByInventories.size();
if(totalVal > 0){ if (totalVal > 0) {
// 初始化
ExcelFileInfoPool.addUserExcelInventoryInfo(userByPort.getNumber(), Collections.synchronizedList(new ArrayList<>()));
// 定义分页数量 // 定义分页数量
double size = 10.0; double size = 100.0;
// 定义线程数 // 定义线程数
int threadSize = (int) Math.ceil(totalVal / size); int threadSize = (int) Math.ceil(totalVal / size);
@ -287,7 +352,7 @@ public class ExcelServiceImpl implements ExcelService {
if (((i + 1) % 100) == 0) { // 如果有10个开启线程进行处理 if (((i + 1) % 100) == 0) { // 如果有10个开启线程进行处理
excelInfoByInventoryList.add(excelInfoByInventories.get(i)); excelInfoByInventoryList.add(excelInfoByInventories.get(i));
dataIndexList.add(dataIndex.get(i)); dataIndexList.add(dataIndex.get(i));
Future<List<String>> future = completionService.submit(new disposeImportInventoryFileData(excelInfoByInventoryList,dataIndexList)); Future<List<String>> future = completionService.submit(new disposeImportInventoryFileData(excelInfoByInventoryList, dataIndexList, userByPort));
openThreadSize++; openThreadSize++;
futureList.add(future); // 添加到结果集 futureList.add(future); // 添加到结果集
excelInfoByInventoryList = new ArrayList<>(); // 情况列表 excelInfoByInventoryList = new ArrayList<>(); // 情况列表
@ -300,7 +365,7 @@ public class ExcelServiceImpl implements ExcelService {
} }
if (excelInfoByInventoryList.size() > 0) { if (excelInfoByInventoryList.size() > 0) {
// 如果有剩余,开启线程进行处理 // 如果有剩余,开启线程进行处理
Future<List<String>> future = completionService.submit(new disposeImportInventoryFileData(excelInfoByInventoryList,dataIndexList)); Future<List<String>> future = completionService.submit(new disposeImportInventoryFileData(excelInfoByInventoryList, dataIndexList, userByPort));
futureList.add(future); futureList.add(future);
openThreadSize++; openThreadSize++;
} }
@ -317,7 +382,7 @@ public class ExcelServiceImpl implements ExcelService {
} }
readResult.put("dataList", excelVosForInventory); readResult.put("dataList", ExcelFileInfoPool.getUserExcelInventoryInfo(userByPort.getNumber()));
// 4.2删除临时文件 // 4.2删除临时文件
boolean deleteFile = FileUtil.deleteFile(new File(filePath)); boolean deleteFile = FileUtil.deleteFile(new File(filePath));
@ -516,125 +581,208 @@ public class ExcelServiceImpl implements ExcelService {
/** /**
* 用于执行库存导入方法 * 用于执行库存导入方法
*/ */
public void executeImportForInventory(){ public void executeImportForInventory(UserByPort userByPort) {
TaskCenterUtil taskCenterUtil = TaskCenterUtil.getTaskCenterUtil(); List<Object> success = new ArrayList<>();
Future<Object> objectFuture = taskCenterUtil.submitTask(() -> { String number = userByPort.getNumber();
List<Object> success = new ArrayList<>(); List<ExcelInfoByInventory> excelVosForInventory = ExcelFileInfoPool.getUserExcelInventoryInfo(number);
Map<String, Object> returnResult = new HashMap<>(); for (int i = 0; i < excelVosForInventory.size(); i++) {
for (ExcelInfoByInventory excelInfoByInventory : excelVosForInventory) { ExcelInfoByInventory excelInfoByInventory = excelVosForInventory.get(i);
Map<String, Object> insert = new HashMap<>(); Map<String, Object> insert = new HashMap<>();
insert.put("mname", excelInfoByInventory.getMname()); insert.put("mname", excelInfoByInventory.getMname());
insert.put("version", excelInfoByInventory.getVersion()); insert.put("version", excelInfoByInventory.getVersion());
Material material = materialService.findMaterialByMnameAndVersion(insert); Material material = materialService.findMaterialByMnameAndVersion(insert);
if (material == null) { if (material == null) {
String code = excelInfoByInventory.getCode(); String code = excelInfoByInventory.getCode();
if (code != null && !"".equals(code)) { if (code != null && !"".equals(code)) {
material = materialService.findMaterialByCode(code); material = materialService.findMaterialByCode(code);
} else { } else {
material = materialMapper.findMaterialByCondition(insert).get(0); material = materialMapper.findMaterialByCondition(insert).get(0);
}
} }
}
// 添加库存记录 // 添加库存记录
Integer depositoryId = excelInfoByInventory.getDepositoryId(); Integer depositoryId = excelInfoByInventory.getDepositoryId();
Double quantity = ObjectFormatUtil.toDouble(excelInfoByInventory.getQuantity()); Double quantity = ObjectFormatUtil.toDouble(excelInfoByInventory.getQuantity());
insert.put("tempPlaceCode", excelInfoByInventory.getDepositoryCode()); insert.put("tempPlaceCode", excelInfoByInventory.getDepositoryCode());
insert.put("quantity", String.valueOf(quantity)); insert.put("quantity", String.valueOf(quantity));
insert.put("depositoryId", depositoryId); insert.put("depositoryId", depositoryId);
insert.put("depositoryCode", excelInfoByInventory.getDepositoryCode()); insert.put("depositoryCode", excelInfoByInventory.getDepositoryCode());
insert.put("mid", material.getId()); insert.put("mid", material.getId());
// 插入库存记录 // 插入库存记录
materialService.insertInventoryForImport(insert); materialService.insertInventoryForImport(insert);
// 将该物料同时放入默认库位中 // 将该物料同时放入默认库位中
String placeCode = excelInfoByInventory.getDepositoryCode(); String placeCode = excelInfoByInventory.getDepositoryCode();
Place placeById = null; Place placeById = null;
Boolean isNew = (Boolean) insert.get("isNew"); Boolean isNew = (Boolean) insert.get("isNew");
if (isNew) { if (isNew) {
SplitInfo baseSplitInfoForMid = splitUnitService.findBaseSplitInfoForMid(material.getId()); SplitInfo baseSplitInfoForMid = splitUnitService.findBaseSplitInfoForMid(material.getId());
double quantity_residue = 0; double quantity_residue = 0;
if (baseSplitInfoForMid != null) { if (baseSplitInfoForMid != null) {
quantity_residue = quantity - Math.floor(quantity); quantity_residue = quantity - Math.floor(quantity);
quantity = quantity - quantity_residue; quantity = quantity - quantity_residue;
} }
MaterialAndPlace placeAndMaterialByMidAndPid = null; MaterialAndPlace placeAndMaterialByMidAndPid = null;
// 如果是新插入物料 // 如果是新插入物料
if (placeCode == null || placeCode.isEmpty() || "0".equals(placeCode) || "0000".equals(placeCode) || "000000".equals(placeCode)) { // 如果没有输入库位 if (placeCode == null || placeCode.isEmpty() || "0".equals(placeCode) || "0000".equals(placeCode) || "000000".equals(placeCode)) { // 如果没有输入库位
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
// 获取默认库位 // 获取默认库位
placeById = placeService.findPlaceById(0); placeById = placeService.findPlaceById(0);
// 修改默认库位库存 // 修改默认库位库存
placeById.setQuantity(placeById.getQuantity() + (int) (quantity * 100)); placeById.setQuantity(placeById.getQuantity() + (int) (quantity * 100));
placeService.UpdatePlace(placeById); placeService.UpdatePlace(placeById);
// 添加库位与物料的映射 // 添加库位与物料的映射
param.put("mid", insert.get("id")); param.put("mid", insert.get("id"));
param.put("pid", 0); param.put("pid", 0);
param.put("quantity", (int) (quantity * 100)); param.put("quantity", (int) (quantity * 100));
placeService.addMaterialOnPlace(param); placeService.addMaterialOnPlace(param);
placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialById(ObjectFormatUtil.toInteger(param.get("id"))); placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialById(ObjectFormatUtil.toInteger(param.get("id")));
} else { } else {
// 如果输入的库位不是默认库位 // 如果输入的库位不是默认库位
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
param.put("did", depositoryId); param.put("did", depositoryId);
param.put("kingdeecode", placeCode); param.put("kingdeecode", placeCode);
// 获取要导入的库位 // 获取要导入的库位
placeById = placeService.findPlaceByCondition(param).get(0); placeById = placeService.findPlaceByCondition(param).get(0);
// 修改库位物料数量 // 修改库位物料数量
placeById.setQuantity(placeById.getQuantity() + (int) (quantity * 100)); placeById.setQuantity(placeById.getQuantity() + (int) (quantity * 100));
placeService.UpdatePlace(placeById); placeService.UpdatePlace(placeById);
// 如果没有对应关系 // 如果没有对应关系
param.put("pid", placeById.getId()); param.put("pid", placeById.getId());
param.put("mid", insert.get("id")); param.put("mid", insert.get("id"));
param.put("quantity", (int) (quantity * 100)); param.put("quantity", (int) (quantity * 100));
// 添加对应关系 // 添加对应关系
placeService.addMaterialOnPlace(param); placeService.addMaterialOnPlace(param);
placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialById(ObjectFormatUtil.toInteger(param.get("id"))); placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialById(ObjectFormatUtil.toInteger(param.get("id")));
} }
if (baseSplitInfoForMid != null) { if (baseSplitInfoForMid != null) {
Map<String, Object> insertForSplitInfoStringObjectMap = new HashMap<>(); Map<String, Object> insertForSplitInfoStringObjectMap = new HashMap<>();
insertForSplitInfoStringObjectMap.put("depositoryId", depositoryId); insertForSplitInfoStringObjectMap.put("depositoryId", depositoryId);
insertForSplitInfoStringObjectMap.put("quantity", quantity_residue); insertForSplitInfoStringObjectMap.put("quantity", quantity_residue);
insertForSplitInfoStringObjectMap.put("placeId", placeById.getId().toString()); insertForSplitInfoStringObjectMap.put("placeId", placeById.getId().toString());
insertForSplitInfoStringObjectMap.put("mid", material.getId()); insertForSplitInfoStringObjectMap.put("mid", material.getId());
insertForSplitInfoStringObjectMap.put("unit", baseSplitInfoForMid.getNewUnit()); insertForSplitInfoStringObjectMap.put("unit", baseSplitInfoForMid.getNewUnit());
SplitInventory splitInventoryByIidAndSid = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), baseSplitInfoForMid.getId()); SplitInventory splitInventoryByIidAndSid = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), baseSplitInfoForMid.getId());
int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(baseSplitInfoForMid, -1); int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(baseSplitInfoForMid, -1);
splitUnitService.realInInventoryToDepository(quantity_residue * splitInfoScaleQuantity, splitInventoryByIidAndSid, insertForSplitInfoStringObjectMap, baseSplitInfoForMid, placeAndMaterialByMidAndPid, true); splitUnitService.realInInventoryToDepository(quantity_residue * splitInfoScaleQuantity, splitInventoryByIidAndSid, insertForSplitInfoStringObjectMap, baseSplitInfoForMid, placeAndMaterialByMidAndPid, true);
if (insertForSplitInfoStringObjectMap.containsKey("applicationInId")) { if (insertForSplitInfoStringObjectMap.containsKey("applicationInId")) {
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(insertForSplitInfoStringObjectMap.get("applicationInId"))); depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(insertForSplitInfoStringObjectMap.get("applicationInId")));
}
} }
}
}
success.add(excelInfoByInventory);
if ((i + 1) % 100 == 0 || excelVosForInventory.size() - 1 == i) {
// 如果凑够100条或者已经循环完成 发送消息
try {
WebSocketController.sendInfo(JSONObject.toJSONString(success), number);
success = new ArrayList<>();
} catch (IOException e) {
e.printStackTrace();
} }
success.add(excelInfoByInventory);
} }
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForInventory)); }
returnResult.put("success", success); ExcelFileInfoPool.removeUserExcelInventoryInfo(number);
excelVosForInventory = new ArrayList<>(); log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForInventory));
// returnResult.put("errMsg", errMsg);
return ResultVoUtil.returnResultVo(200, returnResult, "结果");
});
} }
/** /**
* 用于执行物料类型导入方法 * 用于执行物料类型导入方法
*/ */
public void executeImportForMaterialType(){ public void executeImportForMaterialType(UserByPort userByPort) {
// 4.通过线程池开启一个线程去执行数据库操作,主线程继续往下执行
// 4.1开启一个线程
List<Object> success = new ArrayList<>();
String number = userByPort.getNumber();
List<ExcelInfoByMT> excelVosForMaterialType = ExcelFileInfoPool.getUserExcelMaterialTypeInfo(number);
for (int i = 0; i < excelVosForMaterialType.size(); i++) {
ExcelInfoByMT excelInfoByMT = excelVosForMaterialType.get(i);
Map<String, Object> insert = new HashMap<>();
ExcelInfoByMT info = excelInfoByMT;
insert.put("oldId", info.getOldId());
insert.put("tname", info.getTname());
insert.put("introduce", info.getIntroduce());
if (info.getParentId() == null) {
insert.put("materialTypeId", 0);
} else {
insert.put("materialTypeId", info.getParentId());
}
materialTypeService.insertMaterialType(insert);
success.add(info);
if ((i + 1) % 100 == 0 || excelVosForMaterialType.size() - 1 == i) {
// 如果凑够100条或者已经循环完成 发送消息
try {
WebSocketController.sendInfo(JSONObject.toJSONString(success), number);
success = new ArrayList<>();
} catch (IOException e) {
e.printStackTrace();
}
}
}
ExcelFileInfoPool.removeUserExcelMaterialTypeInfo(number);
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForMaterialType));
}
/**
* 用于执行物料导入方法
*/
public void executeImportForMaterial(UserByPort userByPort) {
List<Object> success = new ArrayList<>();
String number = userByPort.getNumber();
List<ExcelInfoForMaterial> excelVosForMaterial = ExcelFileInfoPool.getUserExcelMaterialInfo(number);
for (int i = 0; i < excelVosForMaterial.size(); i++) {
ExcelInfoForMaterial excelVo = excelVosForMaterial.get(i);
Map<String, Object> param = new HashMap<>();
param.put("mname", excelVo.getMname());
param.put("code", excelVo.getCode());
param.put("unit", excelVo.getUnit());
param.put("version", excelVo.getVersion());
param.put("texture", excelVo.getTexture());
Long typeId = excelVo.getTypeId();
if (typeId != null) {
param.put("typeId", typeId);
} else {
String typeName = excelVo.getTypeName();
MaterialType materialTypeByName = materialTypeService.findMaterialTypeByName(typeName);
param.put("typeId", materialTypeByName.getOldId());
}
param.put("id", excelVo.getId());
param.put("brand", excelVo.getBrand());
param.put("price", excelVo.getPrice() == null ? "0" : excelVo.getPrice());
materialService.insertMaterial(param);
success.add(excelVo);
if ((i + 1) % 100 == 0 || excelVosForMaterial.size() - 1 == i) {
// 如果凑够100条或者已经循环完成 发送消息
try {
WebSocketController.sendInfo(JSONObject.toJSONString(success), number);
success = new ArrayList<>();
} catch (IOException e) {
e.printStackTrace();
}
}
}
ExcelFileInfoPool.removeUserExcelMaterialInfo(number);
log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForMaterial));
} }
/** /**
* 用于清空导入的数据 * 用于清空导入的数据
*/ */
public void clearImportFileData(){ public void clearImportFileData(UserByPort userByPort) {
excelVosForInventory = new ArrayList<>(); ExcelFileInfoPool.removeUserExcelInventoryInfo(userByPort.getNumber());
ExcelFileInfoPool.removeUserExcelMaterialInfo(userByPort.getNumber());
ExcelFileInfoPool.removeUserExcelMaterialTypeInfo(userByPort.getNumber());
} }
@ -653,11 +801,16 @@ public class ExcelServiceImpl implements ExcelService {
*/ */
List<String> dataIndex; List<String> dataIndex;
/**
* 当前用户
*/
UserByPort userByPort;
public disposeImportInventoryFileData(List<ExcelInfoByInventory> excelInfoByInventories, List<String> dataIndex) { public disposeImportInventoryFileData(List<ExcelInfoByInventory> excelInfoByInventories, List<String> dataIndex, UserByPort userByPort) {
this.excelInfoByInventories = excelInfoByInventories; this.excelInfoByInventories = excelInfoByInventories;
this.dataIndex = dataIndex; this.dataIndex = dataIndex;
this.userByPort = userByPort;
} }
@Override @Override
@ -722,7 +875,7 @@ public class ExcelServiceImpl implements ExcelService {
String msg = s + "出现异常:" + excelInfoByInventory.getDepositoryCode() + " 该库位无法存放当前数目的物料"; String msg = s + "出现异常:" + excelInfoByInventory.getDepositoryCode() + " 该库位无法存放当前数目的物料";
errMsg.add(msg); errMsg.add(msg);
} else { } else {
excelVosForInventory.add(excelInfoByInventory); ExcelFileInfoPool.getUserExcelInventoryInfo(userByPort.getNumber()).add(excelInfoByInventory);
pQuantity -= quantity; pQuantity -= quantity;
placeToQuantity.put(place.getId(), pQuantity); placeToQuantity.put(place.getId(), pQuantity);
} }
@ -734,17 +887,152 @@ public class ExcelServiceImpl implements ExcelService {
} }
} else { // 否则直接加入 } else { // 否则直接加入
excelInfoByInventory.setDepositoryCode("0"); // 设置默认库位 excelInfoByInventory.setDepositoryCode("0"); // 设置默认库位
excelVosForInventory.add(excelInfoByInventory); ExcelFileInfoPool.getUserExcelInventoryInfo(userByPort.getNumber()).add(excelInfoByInventory);
}
}
return errMsg;
}
}
/**
* 用于处理导入的物料类型数据
*/
class disposeImportMaterialTypeFileData implements Callable<List<String>> {
/**
* 待处理数据
*/
List<ExcelInfoByMT> excelInfoByMTS;
/**
* 待处理数据对应在excel中的位置
*/
List<String> dataIndex;
/**
* 当前用户
*/
UserByPort userByPort;
public disposeImportMaterialTypeFileData(List<ExcelInfoByMT> excelInfoByMT, List<String> dataIndex, UserByPort userByPort) {
this.excelInfoByMTS = excelInfoByMT;
this.userByPort = userByPort;
this.dataIndex = dataIndex;
}
@Override
public List<String> call() throws Exception {
/**
* 定义错误信息
*/
List<String> errMsg = new ArrayList<>();
for (int i = 0; i < excelInfoByMTS.size(); i++) {
ExcelInfoByMT excelInfoByMT = excelInfoByMTS.get(i);
// 根据类型编码获取对应物料类型
MaterialType materialTypeByOldId = materialTypeService.findMaterialTypeByOldId(excelInfoByMT.getOldId());
if (materialTypeByOldId != null) {
String s = dataIndex.get(i);
errMsg.add(s + "出现异常,编码为" + excelInfoByMT.getOldId() + "已存在对应类型");
continue;
} }
ExcelFileInfoPool.getUserExcelMaterialTypeInfo(userByPort.getNumber()).add(excelInfoByMT);
} }
return errMsg; return errMsg;
} }
} }
/**
* 用于处理导入的物料数据
*/
class disposeImportMaterialFileData implements Callable<List<String>> {
/**
* 待处理数据
*/
List<ExcelInfoForMaterial> excelInfoByMaterialS;
/**
* 待处理数据对应在excel中的位置
*/
List<String> dataIndex;
/**
* 当前用户
*/
UserByPort userByPort;
public disposeImportMaterialFileData(List<ExcelInfoForMaterial> excelInfoByMaterialS, List<String> dataIndex, UserByPort userByPort) {
this.excelInfoByMaterialS = excelInfoByMaterialS;
this.dataIndex = dataIndex;
this.userByPort = userByPort;
}
@Override
public List<String> call() throws Exception {
/**
* 定义错误信息
*/
List<String> errMsg = new ArrayList<>();
for (int i = 0; i < excelInfoByMaterialS.size(); i++) {
ExcelInfoForMaterial excelInfoForMaterial = excelInfoByMaterialS.get(i);
Map<String, Object> paramForMaterial = new HashMap<>();
String mname = excelInfoForMaterial.getMname();
if (mname == null) {
String s = dataIndex.get(i);
String msg = s + "出现异常,未填写物料名称";
errMsg.add(msg);
continue;
}
paramForMaterial.put("mname", mname);
paramForMaterial.put("version", excelInfoForMaterial.getVersion());
Material material = materialMapper.findMaterialByMnameAndVersion(paramForMaterial);
if (material != null) {
String s = dataIndex.get(i);
String msg = s + "出现异常,名称为:" + mname + ",型号为:" + excelInfoForMaterial.getVersion() + "的物料已存在";
errMsg.add(msg);
continue;
}
if (excelInfoForMaterial.getCode() != null) {
Material materialByCode = materialMapper.findMaterialByCode(excelInfoForMaterial.getCode());
if (materialByCode != null) {
String s = dataIndex.get(i);
String msg = s + "出现异常,编码为:" + excelInfoForMaterial.getCode() + "的物料已存在";
errMsg.add(msg);
continue;
}
}
if (excelInfoForMaterial.getTypeId() == null) {
if (excelInfoForMaterial.getTypeName() == null) {
String s = dataIndex.get(i);
String msg = s + "出现异常,未填写物料类型";
errMsg.add(msg);
continue;
} else {
MaterialType materialTypeByName = materialTypeService.findMaterialTypeByName(excelInfoForMaterial.getTypeName());
if (materialTypeByName == null) {
String s = dataIndex.get(i);
String msg = s + "出现异常" + excelInfoForMaterial.getTypeName() + "的物料类型不存在";
errMsg.add(msg);
continue;
}
}
} else {
MaterialType materialTypeByOldId = materialTypeService.findMaterialTypeByOldId(excelInfoForMaterial.getTypeId());
if (materialTypeByOldId == null) {
String s = dataIndex.get(i);
String msg = s + "出现异常,类型编码为" + excelInfoForMaterial.getTypeId() + "的物料类型不存在";
errMsg.add(msg);
continue;
}
}
ExcelFileInfoPool.getUserExcelMaterialInfo(userByPort.getNumber()).add(excelInfoForMaterial);
}
return errMsg;
}
}
} }

30
src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java

@ -18,7 +18,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
@ -108,19 +107,24 @@ public class MaterialServiceImpl implements MaterialService {
map.remove("shelfLife"); map.remove("shelfLife");
} }
// 获取当前类型 // 获取当前类型
if (map.containsKey("typeId")) { Object code = map.get("code");
Integer typeId = ObjectFormatUtil.toInteger(map.get("typeId").toString()); if(code == null){
MaterialType materialTypeById = materialTypeMapper.findMaterialTypeById(typeId); if (map.containsKey("typeId")) {
map.put("materialTypeId", materialTypeById.getOldId()); Integer typeId = ObjectFormatUtil.toInteger(map.get("typeId").toString());
String maxCode = materialMapper.findMaxMaterialCodeForMt(materialTypeById.getOldId()); MaterialType materialTypeById = materialTypeMapper.findMaterialTypeById(typeId);
String newCode = ""; map.put("materialTypeId", materialTypeById.getOldId());
if (maxCode == null) { String maxCode = materialMapper.findMaxMaterialCodeForMt(materialTypeById.getOldId());
newCode = String.format("%04d", 1); String newCode = "";
} else { if (maxCode == null) {
newCode = String.format("%04d",Integer.parseInt(maxCode) + 1); newCode = String.format("%04d", 1);
} else {
newCode = String.format("%04d",Integer.parseInt(maxCode) + 1);
}
map.put("code",newCode);
} }
map.put("code",newCode); }else{
map.put("materialTypeId", map.get("typeId"));
} }
if (map.containsKey("barCode")) { if (map.containsKey("barCode")) {
materialMapper.addBarCodeAndMcode(map); materialMapper.addBarCodeAndMcode(map);
@ -135,7 +139,7 @@ public class MaterialServiceImpl implements MaterialService {
* @return 受影响的行数 * @return 受影响的行数
*/ */
@Override @Override
public Integer insertMaterials(List<ExcelInfo> list) { public Integer insertMaterials(List<ExcelInfoForMaterial> list) {
return materialMapper.insertMaterials(list); return materialMapper.insertMaterials(list);
} }

2
src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialTypeServiceImpl.java

@ -166,7 +166,7 @@ public class MaterialTypeServiceImpl implements MaterialTypeService {
*/ */
@Override @Override
public MaterialType findMaterialTypeByName(String name) { public MaterialType findMaterialTypeByName(String name) {
return null; return materialTypeMapper.findMaterialTypeByName(name);
} }
@Override @Override

86
src/main/java/com/dreamchaser/depository_manage/utils/LinkInterfaceUtil.java

@ -3,9 +3,11 @@ package com.dreamchaser.depository_manage.utils;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.dreamchaser.depository_manage.config.PortConfig; import com.dreamchaser.depository_manage.config.PortConfig;
import com.dreamchaser.depository_manage.config.QyWxConfig;
import com.dreamchaser.depository_manage.entity.Administration; import com.dreamchaser.depository_manage.entity.Administration;
import com.dreamchaser.depository_manage.entity.Post; import com.dreamchaser.depository_manage.entity.Post;
import com.dreamchaser.depository_manage.entity.UserByPort; import com.dreamchaser.depository_manage.entity.UserByPort;
import com.dreamchaser.depository_manage.entity.qywxDepartment;
import com.dreamchaser.depository_manage.pojo.AdministrationP; import com.dreamchaser.depository_manage.pojo.AdministrationP;
import com.dreamchaser.depository_manage.security.pool.AuthenticationTokenPool; import com.dreamchaser.depository_manage.security.pool.AuthenticationTokenPool;
import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HTTP;
@ -24,7 +26,8 @@ public class LinkInterfaceUtil {
/** /**
* 根据条件查询用户 * 根据条件查询用户
* @param map 条件 *
* @param map 条件
* @param userToken 当前登录用户 * @param userToken 当前登录用户
* @return 查询结果 * @return 查询结果
*/ */
@ -54,7 +57,8 @@ public class LinkInterfaceUtil {
/** /**
* 根据用户id查询对应用户 * 根据用户id查询对应用户
* @param id 待查讯用户id *
* @param id 待查讯用户id
* @param userToken 登录用户 * @param userToken 登录用户
* @return 查询结果 * @return 查询结果
*/ */
@ -78,7 +82,8 @@ public class LinkInterfaceUtil {
/** /**
* 根据id查询对应的行政组织 * 根据id查询对应的行政组织
* @param id 待查讯组织id *
* @param id 待查讯组织id
* @param userByPort 登录用户 * @param userByPort 登录用户
* @return 查询结果 * @return 查询结果
*/ */
@ -102,7 +107,8 @@ public class LinkInterfaceUtil {
/** /**
* 根据上级查询对应的行政组织 * 根据上级查询对应的行政组织
* @param superior 上级编号 *
* @param superior 上级编号
* @param userByPort 登录用户 * @param userByPort 登录用户
* @return 查询结果 * @return 查询结果
*/ */
@ -110,8 +116,8 @@ public class LinkInterfaceUtil {
String url = PortConfig.external_url + "/org/govlist"; String url = PortConfig.external_url + "/org/govlist";
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("superior", superior); map.put("superior", superior);
map.put("level",4); map.put("level", 4);
map.put("state",1); map.put("state", 1);
String jsonString = JSONObject.toJSONString(map); String jsonString = JSONObject.toJSONString(map);
JSONObject paramObject = JSONObject.parseObject(jsonString); JSONObject paramObject = JSONObject.parseObject(jsonString);
String post = null; String post = null;
@ -138,7 +144,8 @@ public class LinkInterfaceUtil {
/** /**
* 根据岗位id查询对应的岗位信息 * 根据岗位id查询对应的岗位信息
* @param id 岗位id *
* @param id 岗位id
* @param userByPort 登录用户 * @param userByPort 登录用户
* @return 查询结果 * @return 查询结果
*/ */
@ -163,12 +170,13 @@ public class LinkInterfaceUtil {
/** /**
* 获取对应的验证码信息 * 获取对应的验证码信息
*
* @param request 请求体 * @param request 请求体
* @return 结果 * @return 结果
*/ */
public static JSONObject Captcha(HttpServletRequest request) { public static JSONObject Captcha(HttpServletRequest request) {
String token = request.getHeader("user-token"); String token = request.getHeader("user-token");
if(token == null){ if (token == null) {
token = (String) request.getSession().getAttribute("userToken"); token = (String) request.getSession().getAttribute("userToken");
} }
UserByPort userByPort = AuthenticationTokenPool.getUserToken(token); UserByPort userByPort = AuthenticationTokenPool.getUserToken(token);
@ -187,6 +195,7 @@ public class LinkInterfaceUtil {
/** /**
* 获取当前行政组织列表 * 获取当前行政组织列表
*
* @return * @return
*/ */
public static Map<String, Object> findAdministration(UserByPort userByPort) { public static Map<String, Object> findAdministration(UserByPort userByPort) {
@ -195,7 +204,7 @@ public class LinkInterfaceUtil {
String superior = "313"; String superior = "313";
map.put("superior", superior); map.put("superior", superior);
map.put("state", 1); map.put("state", 1);
map.put("level",3); map.put("level", 3);
String jsonString = JSONObject.toJSONString(map); String jsonString = JSONObject.toJSONString(map);
JSONObject paramObject = JSONObject.parseObject(jsonString); JSONObject paramObject = JSONObject.parseObject(jsonString);
String post = null; String post = null;
@ -225,43 +234,37 @@ public class LinkInterfaceUtil {
/** /**
* 获取当前登录用户的部门负责人 * 获取当前登录用户的部门负责人
*
* @param user * @param user
* @return * @return
*/ */
public static List<UserByPort> findDepartmentHeadByUser(UserByPort user){ public static List<UserByPort> findDepartmentHeadByUser(UserByPort user, String userAgent) {
List<UserByPort> DepartmentHeads = new ArrayList<>(); List<UserByPort> DepartmentHeads = new ArrayList<>();
if(Integer.compare(user.getId(),119) == 0){ if (Integer.compare(user.getId(), 119) == 0) {
// 如果申请人id为106 // 如果申请人id为106
DepartmentHeads.add(user); DepartmentHeads.add(user);
return DepartmentHeads; return DepartmentHeads;
} }
if(Integer.compare(user.getMaindeparment(),361) == 0){ if (Integer.compare(user.getMaindeparment(), 361) == 0) {
// 如果申请人部门为仓储 // 如果申请人部门为仓储
UserByPort userByPort = FindUserById(119, user); UserByPort userByPort = FindUserById(119, user);
DepartmentHeads.add(userByPort); DepartmentHeads.add(userByPort);
return DepartmentHeads; return DepartmentHeads;
} }
String url = PortConfig.external_url + "/staff/archiveslist"; // 获取当前登录用户部门与企业微信部门对照
Integer maindeparment = user.getMaindeparment(); JSONObject userPortByQyWx = PortConfig.getUserPortByQyWx(user.getMaindeparment());
Map<String,Object> map = new HashMap<>(); String portName = userPortByQyWx.getString("name");
map.put("adminorg",maindeparment); Integer portByQyWxInteger = userPortByQyWx.getInteger("wechatorganizationid");
String jsonString = JSONObject.toJSONString(map);
JSONObject paramObject = JSONObject.parseObject(jsonString); qywxDepartment qyWxDepartment = QyWxConfig.getQyWxDepartment(userAgent, portByQyWxInteger);
String post = null; // 获取部门负责人id列表
try { List<String> userIdList = new ArrayList<>(qyWxDepartment.getDepartment_leader());
post = HttpUtils.send(url, paramObject, HTTP.UTF_8,user); for (String userId : userIdList
} catch (IOException e) { ) {
e.printStackTrace();
} Map<String, Object> portInfo = PortConfig.findUserByQyWxUserId(userId);
JSONObject jsonObject = JSONObject.parseObject(post); UserByPort userByPort = (UserByPort) portInfo.get("user");
JSONObject data = (JSONObject) jsonObject.get("data"); if (userByPort != null) {
JSONArray list = (JSONArray) data.get("list");
if(list == null){
list = new JSONArray();
}
for (Object o : list) {
UserByPort userByPort = JSONObject.toJavaObject((JSONObject) o, UserByPort.class);
if (userByPort.getPersonincharge() == 1) {
DepartmentHeads.add(userByPort); DepartmentHeads.add(userByPort);
} }
} }
@ -271,21 +274,22 @@ public class LinkInterfaceUtil {
/** /**
* 用于获取行政组织树 * 用于获取行政组织树
*
* @param userByPort * @param userByPort
* @return * @return
*/ */
public static JSONArray getPostTree(UserByPort userByPort){ public static JSONArray getPostTree(UserByPort userByPort) {
String url = PortConfig.external_url + "/org/govthreeing"; String url = PortConfig.external_url + "/org/govthreeing";
Map<String,Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
param.put("id",userByPort.getCompany()); param.put("id", userByPort.getCompany());
param.put("idstr",""); param.put("idstr", "");
param.put("level",0); param.put("level", 0);
param.put("all",1); param.put("all", 1);
String jsonString = JSONObject.toJSONString(param); String jsonString = JSONObject.toJSONString(param);
JSONObject paramObject = JSONObject.parseObject(jsonString); JSONObject paramObject = JSONObject.parseObject(jsonString);
String post = null; String post = null;
try { try {
post = HttpUtils.send(url, paramObject, HTTP.UTF_8,userByPort); post = HttpUtils.send(url, paramObject, HTTP.UTF_8, userByPort);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

530
src/main/resources/static/js/JcPrinter/layer/layer.js

File diff suppressed because one or more lines are too long

97
src/main/resources/templates/pages/depository/table-stock.html

@ -83,6 +83,13 @@
</button> </button>
</script> </script>
<div id="showImportData"
style="height: 500px;width: 500px;position: absolute;overflow: auto;top: 10%;left: 25%;background: #ffffff;z-index: 1231234;display: none">
<div onclick="closeShowDataMessage()" style="position: absolute; right: 0; top: 2%; cursor: pointer;">
<i class="fa fa-window-close-o"></i>
</div>
</div>
</div> </div>
</div> </div>
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> <script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
@ -99,6 +106,16 @@
} }
function closeShowDataMessage() {
}
let socket;
let newIndexShade;
layui.use(['form', 'table', 'upload'], function () { layui.use(['form', 'table', 'upload'], function () {
var $ = layui.jquery, var $ = layui.jquery,
form = layui.form, form = layui.form,
@ -483,7 +500,32 @@
re += show re += show
} }
layer.open({ if ("WebSocket" in window) {
socket = new WebSocket('ws://127.0.0.1:11111/webSocket/300450');
switch (socket.readyState) {
case WebSocket.CONNECTING:
// 连接中
socket.onopen = function () {
console.log("连接成功")
};
break;
case WebSocket.OPEN:
// 连接成功
break;
case WebSocket.CLOSING:
// 连接正在关闭。
break;
case WebSocket.CLOSED:
// 连接关闭。
break;
default:
// this never happens
break;
}
}
newIndexShade = layer.open({
type: 1 type: 1
, title: false //不显示标题栏 , title: false //不显示标题栏
, closeBtn: false , closeBtn: false
@ -502,9 +544,18 @@
type: "post", type: "post",
data: JSON.stringify({"result":"yes"}), data: JSON.stringify({"result":"yes"}),
dataType: "json", dataType: "json",
contentType: "application/json;charset=utf-8" contentType: "application/json;charset=utf-8",
success: function () {
if (socket !== null) {
socket.close();
}
layer.msg("数据导入完成", {
icon: 0,
time: 1000
})
}
}); });
layer.close(index);//关闭当前页
} }
, btn2: function (index, layero) { , btn2: function (index, layero) {
@ -514,10 +565,17 @@
type: "post", type: "post",
data: JSON.stringify({"result":"no"}), data: JSON.stringify({"result":"no"}),
dataType: "json", dataType: "json",
contentType: "application/json;charset=utf-8" contentType: "application/json;charset=utf-8",
success: function () {
if (socket !== null) {
socket.close();
}
}
}) })
} }
}); });
} else { } else {
layer.msg(res.msg) layer.msg(res.msg)
} }
@ -534,6 +592,37 @@
}) })
} }
socket.addEventListener('message', function (event) {
layer.close(newIndexShade);
let shadeItem = '<div class="layui-layer-shade" id='+"layui-layer-shade-x"+newIndexShade+' times="753951" style="z-index:1231233; background-color: rgb(0, 0, 0); opacity: 0.8;"></div>';
if ($("#"+"layui-layer-shade-x"+newIndexShade).length <= 0) {
$('body').append(shadeItem);
}
let jsonObject = JSON.parse(event.data);
let re = "";
$("#showImportData").show();
for (let i = 0; i < jsonObject.length; i++) {
var code = jsonObject[i]["code"] === null ? '' : jsonObject[i]["code"];
var mname = jsonObject[i]["mname"];
var version = jsonObject[i]["version"] === null ? '' : jsonObject[i]["version"];
var quantity = jsonObject[i]["quantity"];
var show = "<p style='color: #00FF00'>" + code + ", " + mname + ", " + version + ", 数量为" + quantity + ":通过" + "</p>";
re += show
}
$("#showImportData").append(re);
});
closeShowDataMessage = function () {
$("#layui-layer-shade-x"+newIndexShade).remove();
$("#showImportData").hide();
$("#showImportData").empty();
if (socket !== null) {
socket.close();
}
};
}); });
</script> </script>

276
src/main/resources/templates/pages/material/material-out.html

@ -8,6 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all"> <link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all">
<link rel="stylesheet" href="/static/css/public.css" media="all"> <link rel="stylesheet" href="/static/css/public.css" media="all">
<link rel="stylesheet" href="/static/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
</head> </head>
<body> <body>
@ -17,60 +18,62 @@
<input style="display:none;" id="nowDay" th:value="${nowDay}"> <input style="display:none;" id="nowDay" th:value="${nowDay}">
<input style="display:none;" id="display" th:value="${display}"> <input style="display:none;" id="display" th:value="${display}">
<fieldset class="table-search-fieldset" > <fieldset class="table-search-fieldset">
<legend>搜索信息</legend> <legend>搜索信息</legend>
<div style="margin: 10px 10px 10px 10px" > <div style="margin: 10px 10px 10px 10px">
<form class="layui-form layui-form-pane" action=""> <form class="layui-form layui-form-pane" action="">
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label">种类</label> <label class="layui-form-label">种类</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="text" placeholder="请选择物料类型" class="layui-input" id="openSonByMateralType" <input type="text" placeholder="请选择物料类型" class="layui-input" id="openSonByMateralType"
readonly/> readonly/>
<input type="text" id="materialTypeId" placeholder="请选择物料类型" name="materialTypeId" <input type="text" id="materialTypeId" placeholder="请选择物料类型" name="materialTypeId"
class="layui-input" style="display: none"/> class="layui-input" style="display: none"/>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">物料名称</label>
<div class="layui-input-block">
<input type="text" name="mname" autocomplete="off" class="layui-input" placeholder="请输入物料名称">
</div>
</div> </div>
<div class="layui-inline"> </div>
<label class="layui-form-label">型号</label> <div class="layui-inline">
<div class="layui-input-block"> <label class="layui-form-label">物料名称</label>
<input type="text" class="layui-input" id="version" name="version" autocomplete="off" placeholder="请输入物料型号"/> <div class="layui-input-block">
</div> <input type="text" name="mname" autocomplete="off" class="layui-input"
placeholder="请输入物料名称">
</div> </div>
<div class="layui-inline"> </div>
<label class="layui-form-label">物料编码</label> <div class="layui-inline">
<div class="layui-input-block"> <label class="layui-form-label">型号</label>
<input type="text" name="code" autocomplete="off" class="layui-input" placeholder="请输入物料编码"> <div class="layui-input-block">
</div> <input type="text" class="layui-input" id="version" name="version" autocomplete="off"
placeholder="请输入物料型号"/>
</div> </div>
<div class="layui-inline"> </div>
<label class="layui-form-label">状态</label> <div class="layui-inline">
<div class="layui-input-block"> <label class="layui-form-label">物料编码</label>
<select name="state"> <div class="layui-input-block">
<option value="">请选择状态</option> <input type="text" name="code" autocomplete="off" class="layui-input"
<option value="1">启用</option> placeholder="请输入物料编码">
<option value="2">禁用</option>
</select>
</div>
</div> </div>
<div class="layui-inline"> </div>
<button type="submit" class="layui-btn layui-btn-primary" lay-submit <div class="layui-inline">
lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索 <label class="layui-form-label">状态</label>
</button> <div class="layui-input-block">
<select name="state">
<option value="">请选择状态</option>
<option value="1">启用</option>
<option value="2">禁用</option>
</select>
</div> </div>
</div> </div>
</form> <div class="layui-inline">
</div > <button type="submit" class="layui-btn layui-btn-primary" lay-submit
</fieldset> lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索
</button>
</div>
</div>
</form>
</div>
</fieldset>
<!-- 状态展示--> <!-- 状态展示-->
@ -82,7 +85,9 @@
<script type="text/html" id="toolbarDemo"> <script type="text/html" id="toolbarDemo">
<div class="layui-btn-container"> <div class="layui-btn-container">
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加</button> <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加</button>
<button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete" th:style="'display:'+${display}"> 删除</button> <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"
th:style="'display:'+${display}"> 删除
</button>
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="applicationIn"> 入库申请 <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="applicationIn"> 入库申请
</button> </button>
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" id="u_fileUpload" <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" id="u_fileUpload"
@ -95,24 +100,42 @@
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter" style="margin-top: 123px"></table> <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter" style="margin-top: 123px"></table>
<script id="materialCode" type="text/html"> <script id="materialCode" type="text/html">
<a id="{{d.id}}" onclick="showDetail(this)">{{d.code}}</a> <a id="{{d.id}}" onclick="showDetail(this)">{{d.code}}</a>
</script> </script>
<script type="text/html" id="currentTableBar"> <script type="text/html" id="currentTableBar">
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="detail">详情</a> <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="detail">详情</a>
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" th:style="'display:'+${display}" lay-event="delete">删除</a> <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" th:style="'display:'+${display}"
lay-event="delete">删除</a>
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" th:style="'display:'+${display}" <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" th:style="'display:'+${display}"
lay-event="realDelete">彻底删除</a> lay-event="realDelete">彻底删除</a>
</script> </script>
<div id="showImportData"
style="height: 500px;width: 500px;position: absolute;overflow: auto;top: 10%;left: 25%;background: #ffffff;z-index: 1231234;display: none">
<div onclick="closeShowDataMessage()" style="position: absolute; right: 0; top: 2%; cursor: pointer;">
<i class="fa fa-window-close-o"></i>
</div>
</div>
</div> </div>
</div> </div>
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> <script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script> <script>
function bindTableToolbarFunction(){ function bindTableToolbarFunction() {
}
function showDetail() {
} }
function showDetail(){
function closeShowDataMessage() {
} }
let socket;
let newIndexShade;
layui.use(['form', 'table', 'upload'], function () { layui.use(['form', 'table', 'upload'], function () {
var $ = layui.jquery, var $ = layui.jquery,
form = layui.form, form = layui.form,
@ -130,12 +153,12 @@
move: '.layui-layer-title', move: '.layui-layer-title',
fixed: false, fixed: false,
content: '/selectType', content: '/selectType',
success: function(layero, index){ success: function (layero, index) {
var children = layero.children(); var children = layero.children();
var content = $(children[1]); var content = $(children[1]);
var iframeChildren = $(content.children()); var iframeChildren = $(content.children());
content.css('height','100%'); content.css('height', '100%');
iframeChildren.css('height','100%'); iframeChildren.css('height', '100%');
} }
}); });
}); });
@ -205,18 +228,18 @@
] ]
], ],
limits: [10, 15, 20, 25, 50,100], limits: [10, 15, 20, 25, 50, 100],
limit: 10, limit: 10,
page: true, page: true,
skin: 'line', skin: 'line',
done: function (res, curr, count) { done: function (res, curr, count) {
let display = $("#display").val(); let display = $("#display").val();
if("inline-block" === display){ if ("inline-block" === display) {
if(flagForRelod){ if (flagForRelod) {
flagForRelod = false; flagForRelod = false;
let col = {field: 'price', width: 150, title: '物料单价'}; let col = {field: 'price', width: 150, title: '物料单价'};
cols.splice(6,0,col); cols.splice(6, 0, col);
table.reload('currentTableId',{cols:[cols]}); table.reload('currentTableId', {cols: [cols]});
bindTableToolbarFunction(); bindTableToolbarFunction();
} }
@ -255,16 +278,85 @@
var texture = res.data.dataList[i]["texture"] == null || res.data.dataList[i]["texture"] === undefined ? "" : res.data.dataList[i]["texture"]; var texture = res.data.dataList[i]["texture"] == null || res.data.dataList[i]["texture"] === undefined ? "" : res.data.dataList[i]["texture"];
var unit = res.data.dataList[i]["unit"] == null || res.data.dataList[i]["unit"] === undefined ? "" : res.data.dataList[i]["unit"]; var unit = res.data.dataList[i]["unit"] == null || res.data.dataList[i]["unit"] === undefined ? "" : res.data.dataList[i]["unit"];
var typeId = res.data.dataList[i]["typeId"] == null || res.data.dataList[i]["typeId"] === undefined ? "" : res.data.dataList[i]["typeId"]; var typeId = res.data.dataList[i]["typeId"] == null || res.data.dataList[i]["typeId"] === undefined ? "" : res.data.dataList[i]["typeId"];
var show = "<p style='color: #00FF00'>" + mname + " " + version + " " + code + " " + texture + " " + unit + " " + typeId + " :成功" + "</p>"; var show = "<p style='color: #00FF00'>" + mname + " " + version + " " + code + " " + texture + " " + unit + " " + typeId + " :通过" + "</p>";
re += show re += show
} }
layer.open({ if ("WebSocket" in window) {
type: 1, socket = new WebSocket('ws://127.0.0.1:11111/webSocket/300450');
skin: 'layui-layer-rim', //加上边框 switch (socket.readyState) {
area: ['500px', '500px'], //宽高 case WebSocket.CONNECTING:
content: re // 连接中
}) socket.onopen = function () {
console.log("连接成功")
};
break;
case WebSocket.OPEN:
// 连接成功
break;
case WebSocket.CLOSING:
// 连接正在关闭。
break;
case WebSocket.CLOSED:
// 连接关闭。
break;
default:
// this never happens
break;
}
}
newIndexShade = layer.open({
type: 1
, title: false //不显示标题栏
, closeBtn: false
, area: ['500px', '500px']
, shade: 0.8
, id: 'LAY_layuipro' //设定一个id,防止重复弹出
, resize: false
, btn: ['导入', '取消']
, btnAlign: 'c'
, moveType: 1 //拖拽模式,0或者1
, content: re
, yes: function (index, layero) {
//按钮【按钮一】的回调
$.ajax({
url: "/excel/realImportMaterial",
type: "post",
data: JSON.stringify({"result": "yes"}),
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function () {
if (socket !== null) {
socket.close();
}
layer.msg("数据导入完成", {
icon: 0,
time: 1000
})
}
});
}
, btn2: function (index, layero) {
//按钮【按钮二】的回调
$.ajax({
url: "/excel/realImportMaterial",
type: "post",
data: JSON.stringify({"result": "no"}),
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function () {
if (socket !== null) {
socket.close();
}
}
})
}
});
} else { } else {
layer.msg(res.msg) layer.msg(res.msg)
} }
@ -281,6 +373,38 @@
}); });
} }
socket.addEventListener('message', function (event) {
layer.close(newIndexShade);
let shadeItem = '<div class="layui-layer-shade" id='+"layui-layer-shade-x"+newIndexShade+' times="753951" style="z-index:1231233; background-color: rgb(0, 0, 0); opacity: 0.8;"></div>';
if ($("#"+"layui-layer-shade-x"+newIndexShade).length <= 0) {
$('body').append(shadeItem);
}
let jsonObject = JSON.parse(event.data);
let re = "";
$("#showImportData").show();
for (let i = 0; i < jsonObject.length; i++) {
var mname = jsonObject[i]["mname"];
var code = jsonObject[i]["code"] == null || jsonObject[i]["code"] === undefined ? "" : jsonObject[i]["code"];
var version = jsonObject[i]["version"] == null || jsonObject[i]["version"] === undefined ? "" : jsonObject[i]["version"];
var texture = jsonObject[i]["texture"] == null || jsonObject[i]["texture"] === undefined ? "" : jsonObject[i]["texture"];
var unit = jsonObject[i]["unit"] == null || jsonObject[i]["unit"] === undefined ? "" : jsonObject[i]["unit"];
var typeId = jsonObject[i]["typeId"] == null || jsonObject[i]["typeId"] === undefined ? "" : jsonObject[i]["typeId"];
var show = "<p style='color: #00FF00'>" + mname + " " + version + " " + code + " " + texture + " " + unit + " " + typeId + " :成功" + "</p>";
re += show;
}
$("#showImportData").append(re);
});
closeShowDataMessage = function () {
$("#layui-layer-shade-x"+newIndexShade).remove();
$("#showImportData").hide();
$("#showImportData").empty();
if (socket !== null) {
socket.close();
}
};
// 监听搜索操作 // 监听搜索操作
@ -332,8 +456,7 @@
$(window).on("resize", function () { $(window).on("resize", function () {
layer.full(index); layer.full(index);
}); });
} } else if (obj.event === 'delete') { // 监听删除操作
else if (obj.event === 'delete') { // 监听删除操作
var checkStatus = table.checkStatus('currentTableId') var checkStatus = table.checkStatus('currentTableId')
, data = checkStatus.data; , data = checkStatus.data;
var req = {}; var req = {};
@ -378,8 +501,7 @@
layer.msg("未选中记录,请确认!"); layer.msg("未选中记录,请确认!");
return false; return false;
} }
} } else if (obj.event === 'applicationIn') {
else if (obj.event === 'applicationIn') {
// 入库申请 // 入库申请
var checkStatus = table.checkStatus('currentTableId') var checkStatus = table.checkStatus('currentTableId')
, data = checkStatus.data; , data = checkStatus.data;
@ -400,7 +522,7 @@
}, },
success: function (d) { success: function (d) {
layer.close(this.layerIndex); layer.close(this.layerIndex);
if (d.status == 200) { if (d.status === 200) {
layer.open({ layer.open({
type: 2, type: 2,
title: '入库', title: '入库',
@ -420,14 +542,12 @@
} }
}) })
} } else if (obj.event === 'downloadFile') {
else if (obj.event === 'downloadFile') { window.open("/download/materialImportDownload", "_self");
window.open("/download/materialImportDownload","_self");
} }
}); });
//监听表格复选框选择 //监听表格复选框选择
table.on('checkbox(currentTableFilter)', function (obj) { table.on('checkbox(currentTableFilter)', function (obj) {
console.log(obj) console.log(obj)

135
src/main/resources/templates/pages/materialtype/materialType_view.html

@ -85,6 +85,13 @@
lay-event="realDelete">彻底删除</a> lay-event="realDelete">彻底删除</a>
</script> </script>
<div id="showImportData"
style="height: 500px;width: 500px;position: absolute;overflow: auto;top: 10%;left: 25%;background: #ffffff;z-index: 1231234;display: none">
<div onclick="closeShowDataMessage()" style="position: absolute; right: 0; top: 2%; cursor: pointer;">
<i class="fa fa-window-close-o"></i>
</div>
</div>
</div> </div>
</div> </div>
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> <script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
@ -92,6 +99,17 @@
function bindTableToolbarFunction(){ function bindTableToolbarFunction(){
} }
function closeShowDataMessage() {
}
let socket;
let newIndexShade;
layui.use(['form', 'table', 'upload'], function () { layui.use(['form', 'table', 'upload'], function () {
var $ = layui.jquery, var $ = layui.jquery,
form = layui.form, form = layui.form,
@ -245,27 +263,98 @@
exts: 'xls|xlsx|csv', exts: 'xls|xlsx|csv',
done: function (res) { done: function (res) {
//如果上传成功 //如果上传成功
if (res.code == 200) { if (res.code === 200) {
var re = ""; var re = "";
for (let i = 0; i < res.data.errMsg.length; i++) { for (let i = 0; i < res.data.errMsg.length; i++) {
var show = "<p style='color: #ff211e'>" + res.data.errMsg[i] + ":错误" + "</p>"; var show = "<p style='color: #ff211e'>" + res.data.errMsg[i] + ":错误" + "</p>";
re += show re += show
} }
console.log(res.data.dataList.length);
for (let i = 0; i < res.data.dataList.length; i++) { for (let i = 0; i < res.data.dataList.length; i++) {
var tname = res.data.dataList[i]["tname"]; var tname = res.data.dataList[i]["tname"];
var id = res.data.dataList[i]["oldId"]; var id = res.data.dataList[i]["oldId"];
var parentId = res.data.dataList[i]["parentId"] == null ? "" : res.data.dataList[i]["parentId"]; var parentId = res.data.dataList[i]["parentId"] == null ? "" : res.data.dataList[i]["parentId"];
var introduce = res.data.dataList[i]["introduce"] == null ? "" : res.data.dataList[i]["introduce"]; var introduce = res.data.dataList[i]["introduce"] == null ? "" : res.data.dataList[i]["introduce"];
var show = "<p style='color: #00FF00'>" + tname + " " + id + " " + parentId + "成功" + "</p>"; var show = "<p style='color: #00FF00'>" + tname + " " + id + " " + parentId + "通过" + "</p>";
re += show re += show
} }
layer.open({ if ("WebSocket" in window) {
type: 1, socket = new WebSocket('ws://127.0.0.1:11111/webSocket/300450');
skin: 'layui-layer-rim', //加上边框 switch (socket.readyState) {
area: ['500px', '500px'], //宽高 case WebSocket.CONNECTING:
content: re // 连接中
}) socket.onopen = function () {
console.log("连接成功")
};
break;
case WebSocket.OPEN:
// 连接成功
break;
case WebSocket.CLOSING:
// 连接正在关闭。
break;
case WebSocket.CLOSED:
// 连接关闭。
break;
default:
// this never happens
break;
}
}
newIndexShade = layer.open({
type: 1
, title: false //不显示标题栏
, closeBtn: false
, area: ['500px', '500px']
, shade: 0.8
, id: 'LAY_layuipro' //设定一个id,防止重复弹出
, resize: false
, btn: ['导入', '取消']
, btnAlign: 'c'
, moveType: 1 //拖拽模式,0或者1
, content: re
, yes: function (index, layero) {
//按钮【按钮一】的回调
$.ajax({
url:"/excel/realImportMaterialType",
type: "post",
data: JSON.stringify({"result":"yes"}),
dataType: "json",
contentType: "application/json;charset=utf-8",
success:function () {
if (socket !== null) {
socket.close();
}
layer.msg("数据导入完成", {
icon: 0,
time: 1000
})
}
});
}
, btn2: function (index, layero) {
//按钮【按钮二】的回调
$.ajax({
url:"/excel/realImportMaterialType",
type: "post",
data: JSON.stringify({"result":"no"}),
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function () {
if (socket !== null) {
socket.close();
}
}
})
}
});
} else { } else {
layer.msg(res.msg) layer.msg(res.msg)
} }
@ -281,6 +370,36 @@
}); });
} }
socket.addEventListener('message', function (event) {
layer.close(newIndexShade);
let shadeItem = '<div class="layui-layer-shade" id='+"layui-layer-shade-x"+newIndexShade+' times="753951" style="z-index:1231233; background-color: rgb(0, 0, 0); opacity: 0.8;"></div>';
if ($("#"+"layui-layer-shade-x"+newIndexShade).length <= 0) {
$('body').append(shadeItem);
}
let jsonObject = JSON.parse(event.data);
let re = "";
$("#showImportData").show();
for (let i = 0; i < jsonObject.length; i++) {
var tname = jsonObject[i]["tname"];
var id = jsonObject[i]["oldId"];
var parentId = jsonObject[i]["parentId"] == null ? "" : jsonObject[i]["parentId"];
var introduce = jsonObject[i]["introduce"] == null ? "" : jsonObject[i]["introduce"];
var show = "<p style='color: #00FF00'>" + tname + " " + id + " " + parentId + "成功" + "</p>";
re += show
}
$("#showImportData").append(re);
});
closeShowDataMessage = function () {
$("#layui-layer-shade-x"+newIndexShade).remove();
$("#showImportData").hide();
$("#showImportData").empty();
if (socket !== null) {
socket.close();
}
};
//监听表格复选框选择 //监听表格复选框选择
table.on('checkbox(currentTableFilter)', function (obj) { table.on('checkbox(currentTableFilter)', function (obj) {

8
src/test/java/com/dreamchaser/depository_manage/TestForOther.java

@ -65,9 +65,15 @@ public class TestForOther {
// approvalInfo.setApprover(approver); // approvalInfo.setApprover(approver);
// depositoryRecordService.reviewByQyWxApprovalOut("1",approvalInfo,"599076aa8e931b27af7935eb69db4243","2","202303290034", false,2); // depositoryRecordService.reviewByQyWxApprovalOut("1",approvalInfo,"599076aa8e931b27af7935eb69db4243","2","202303290034", false,2);
// depositoryRecordService.reviewByQyWxApprovalIn("[1]",approvalInfo,"460f46eaefb46bb0c171029f62e2cea6","2","202303220009"); // depositoryRecordService.reviewByQyWxApprovalIn("[1]",approvalInfo,"460f46eaefb46bb0c171029f62e2cea6","2","202303220009");
// UserByPort userByPort = LinkInterfaceUtil.FindUserById(78, null); UserByPort userByPort = LinkInterfaceUtil.FindUserById(76, null);
// List<String> s = excelService.writeExcelForPrint(2, 4,userByPort); // List<String> s = excelService.writeExcelForPrint(2, 4,userByPort);
// GetMonthStartAndEnd(); // GetMonthStartAndEnd();
// List<UserByPort> departmentHeadByUser = LinkInterfaceUtil.findDepartmentHeadByUser(userByPort);
// System.out.println(departmentHeadByUser);
System.out.println(userByPort);
List<String> a = new ArrayList<>();
List<String> list = Collections.synchronizedList(a);
} }

7
target/classes/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml

@ -652,6 +652,13 @@
FROM material m WHERE m.id =#{id} FROM material m WHERE m.id =#{id}
</select> </select>
<select id="findMaterialByCode" resultMap="materialMap" parameterType="string">
SELECT
<include refid="allColumns"/>
FROM material m WHERE m.code =#{code}
</select>
<select id="findInventoryById" resultMap="InventoryMap" parameterType="integer"> <select id="findInventoryById" resultMap="InventoryMap" parameterType="integer">
SELECT SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory"/> <include refid="allColumnsAndTypeNameOnViewByInventory"/>

530
target/classes/static/js/JcPrinter/layer/layer.js

File diff suppressed because one or more lines are too long

276
target/classes/templates/pages/material/material-out.html

@ -8,6 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all"> <link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all">
<link rel="stylesheet" href="/static/css/public.css" media="all"> <link rel="stylesheet" href="/static/css/public.css" media="all">
<link rel="stylesheet" href="/static/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
</head> </head>
<body> <body>
@ -17,60 +18,62 @@
<input style="display:none;" id="nowDay" th:value="${nowDay}"> <input style="display:none;" id="nowDay" th:value="${nowDay}">
<input style="display:none;" id="display" th:value="${display}"> <input style="display:none;" id="display" th:value="${display}">
<fieldset class="table-search-fieldset" > <fieldset class="table-search-fieldset">
<legend>搜索信息</legend> <legend>搜索信息</legend>
<div style="margin: 10px 10px 10px 10px" > <div style="margin: 10px 10px 10px 10px">
<form class="layui-form layui-form-pane" action=""> <form class="layui-form layui-form-pane" action="">
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label">种类</label> <label class="layui-form-label">种类</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="text" placeholder="请选择物料类型" class="layui-input" id="openSonByMateralType" <input type="text" placeholder="请选择物料类型" class="layui-input" id="openSonByMateralType"
readonly/> readonly/>
<input type="text" id="materialTypeId" placeholder="请选择物料类型" name="materialTypeId" <input type="text" id="materialTypeId" placeholder="请选择物料类型" name="materialTypeId"
class="layui-input" style="display: none"/> class="layui-input" style="display: none"/>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">物料名称</label>
<div class="layui-input-block">
<input type="text" name="mname" autocomplete="off" class="layui-input" placeholder="请输入物料名称">
</div>
</div> </div>
<div class="layui-inline"> </div>
<label class="layui-form-label">型号</label> <div class="layui-inline">
<div class="layui-input-block"> <label class="layui-form-label">物料名称</label>
<input type="text" class="layui-input" id="version" name="version" autocomplete="off" placeholder="请输入物料型号"/> <div class="layui-input-block">
</div> <input type="text" name="mname" autocomplete="off" class="layui-input"
placeholder="请输入物料名称">
</div> </div>
<div class="layui-inline"> </div>
<label class="layui-form-label">物料编码</label> <div class="layui-inline">
<div class="layui-input-block"> <label class="layui-form-label">型号</label>
<input type="text" name="code" autocomplete="off" class="layui-input" placeholder="请输入物料编码"> <div class="layui-input-block">
</div> <input type="text" class="layui-input" id="version" name="version" autocomplete="off"
placeholder="请输入物料型号"/>
</div> </div>
<div class="layui-inline"> </div>
<label class="layui-form-label">状态</label> <div class="layui-inline">
<div class="layui-input-block"> <label class="layui-form-label">物料编码</label>
<select name="state"> <div class="layui-input-block">
<option value="">请选择状态</option> <input type="text" name="code" autocomplete="off" class="layui-input"
<option value="1">启用</option> placeholder="请输入物料编码">
<option value="2">禁用</option>
</select>
</div>
</div> </div>
<div class="layui-inline"> </div>
<button type="submit" class="layui-btn layui-btn-primary" lay-submit <div class="layui-inline">
lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索 <label class="layui-form-label">状态</label>
</button> <div class="layui-input-block">
<select name="state">
<option value="">请选择状态</option>
<option value="1">启用</option>
<option value="2">禁用</option>
</select>
</div> </div>
</div> </div>
</form> <div class="layui-inline">
</div > <button type="submit" class="layui-btn layui-btn-primary" lay-submit
</fieldset> lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索
</button>
</div>
</div>
</form>
</div>
</fieldset>
<!-- 状态展示--> <!-- 状态展示-->
@ -82,7 +85,9 @@
<script type="text/html" id="toolbarDemo"> <script type="text/html" id="toolbarDemo">
<div class="layui-btn-container"> <div class="layui-btn-container">
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加</button> <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加</button>
<button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete" th:style="'display:'+${display}"> 删除</button> <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"
th:style="'display:'+${display}"> 删除
</button>
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="applicationIn"> 入库申请 <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="applicationIn"> 入库申请
</button> </button>
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" id="u_fileUpload" <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" id="u_fileUpload"
@ -95,24 +100,42 @@
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter" style="margin-top: 123px"></table> <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter" style="margin-top: 123px"></table>
<script id="materialCode" type="text/html"> <script id="materialCode" type="text/html">
<a id="{{d.id}}" onclick="showDetail(this)">{{d.code}}</a> <a id="{{d.id}}" onclick="showDetail(this)">{{d.code}}</a>
</script> </script>
<script type="text/html" id="currentTableBar"> <script type="text/html" id="currentTableBar">
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="detail">详情</a> <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="detail">详情</a>
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" th:style="'display:'+${display}" lay-event="delete">删除</a> <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" th:style="'display:'+${display}"
lay-event="delete">删除</a>
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" th:style="'display:'+${display}" <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" th:style="'display:'+${display}"
lay-event="realDelete">彻底删除</a> lay-event="realDelete">彻底删除</a>
</script> </script>
<div id="showImportData"
style="height: 500px;width: 500px;position: absolute;overflow: auto;top: 10%;left: 25%;background: #ffffff;z-index: 1231234;display: none">
<div onclick="closeShowDataMessage()" style="position: absolute; right: 0; top: 2%; cursor: pointer;">
<i class="fa fa-window-close-o"></i>
</div>
</div>
</div> </div>
</div> </div>
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> <script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script> <script>
function bindTableToolbarFunction(){ function bindTableToolbarFunction() {
}
function showDetail() {
} }
function showDetail(){
function closeShowDataMessage() {
} }
let socket;
let newIndexShade;
layui.use(['form', 'table', 'upload'], function () { layui.use(['form', 'table', 'upload'], function () {
var $ = layui.jquery, var $ = layui.jquery,
form = layui.form, form = layui.form,
@ -130,12 +153,12 @@
move: '.layui-layer-title', move: '.layui-layer-title',
fixed: false, fixed: false,
content: '/selectType', content: '/selectType',
success: function(layero, index){ success: function (layero, index) {
var children = layero.children(); var children = layero.children();
var content = $(children[1]); var content = $(children[1]);
var iframeChildren = $(content.children()); var iframeChildren = $(content.children());
content.css('height','100%'); content.css('height', '100%');
iframeChildren.css('height','100%'); iframeChildren.css('height', '100%');
} }
}); });
}); });
@ -205,18 +228,18 @@
] ]
], ],
limits: [10, 15, 20, 25, 50,100], limits: [10, 15, 20, 25, 50, 100],
limit: 10, limit: 10,
page: true, page: true,
skin: 'line', skin: 'line',
done: function (res, curr, count) { done: function (res, curr, count) {
let display = $("#display").val(); let display = $("#display").val();
if("inline-block" === display){ if ("inline-block" === display) {
if(flagForRelod){ if (flagForRelod) {
flagForRelod = false; flagForRelod = false;
let col = {field: 'price', width: 150, title: '物料单价'}; let col = {field: 'price', width: 150, title: '物料单价'};
cols.splice(6,0,col); cols.splice(6, 0, col);
table.reload('currentTableId',{cols:[cols]}); table.reload('currentTableId', {cols: [cols]});
bindTableToolbarFunction(); bindTableToolbarFunction();
} }
@ -255,16 +278,85 @@
var texture = res.data.dataList[i]["texture"] == null || res.data.dataList[i]["texture"] === undefined ? "" : res.data.dataList[i]["texture"]; var texture = res.data.dataList[i]["texture"] == null || res.data.dataList[i]["texture"] === undefined ? "" : res.data.dataList[i]["texture"];
var unit = res.data.dataList[i]["unit"] == null || res.data.dataList[i]["unit"] === undefined ? "" : res.data.dataList[i]["unit"]; var unit = res.data.dataList[i]["unit"] == null || res.data.dataList[i]["unit"] === undefined ? "" : res.data.dataList[i]["unit"];
var typeId = res.data.dataList[i]["typeId"] == null || res.data.dataList[i]["typeId"] === undefined ? "" : res.data.dataList[i]["typeId"]; var typeId = res.data.dataList[i]["typeId"] == null || res.data.dataList[i]["typeId"] === undefined ? "" : res.data.dataList[i]["typeId"];
var show = "<p style='color: #00FF00'>" + mname + " " + version + " " + code + " " + texture + " " + unit + " " + typeId + " :成功" + "</p>"; var show = "<p style='color: #00FF00'>" + mname + " " + version + " " + code + " " + texture + " " + unit + " " + typeId + " :通过" + "</p>";
re += show re += show
} }
layer.open({ if ("WebSocket" in window) {
type: 1, socket = new WebSocket('ws://127.0.0.1:11111/webSocket/300450');
skin: 'layui-layer-rim', //加上边框 switch (socket.readyState) {
area: ['500px', '500px'], //宽高 case WebSocket.CONNECTING:
content: re // 连接中
}) socket.onopen = function () {
console.log("连接成功")
};
break;
case WebSocket.OPEN:
// 连接成功
break;
case WebSocket.CLOSING:
// 连接正在关闭。
break;
case WebSocket.CLOSED:
// 连接关闭。
break;
default:
// this never happens
break;
}
}
newIndexShade = layer.open({
type: 1
, title: false //不显示标题栏
, closeBtn: false
, area: ['500px', '500px']
, shade: 0.8
, id: 'LAY_layuipro' //设定一个id,防止重复弹出
, resize: false
, btn: ['导入', '取消']
, btnAlign: 'c'
, moveType: 1 //拖拽模式,0或者1
, content: re
, yes: function (index, layero) {
//按钮【按钮一】的回调
$.ajax({
url: "/excel/realImportMaterial",
type: "post",
data: JSON.stringify({"result": "yes"}),
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function () {
if (socket !== null) {
socket.close();
}
layer.msg("数据导入完成", {
icon: 0,
time: 1000
})
}
});
}
, btn2: function (index, layero) {
//按钮【按钮二】的回调
$.ajax({
url: "/excel/realImportMaterial",
type: "post",
data: JSON.stringify({"result": "no"}),
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function () {
if (socket !== null) {
socket.close();
}
}
})
}
});
} else { } else {
layer.msg(res.msg) layer.msg(res.msg)
} }
@ -281,6 +373,38 @@
}); });
} }
socket.addEventListener('message', function (event) {
layer.close(newIndexShade);
let shadeItem = '<div class="layui-layer-shade" id='+"layui-layer-shade-x"+newIndexShade+' times="753951" style="z-index:1231233; background-color: rgb(0, 0, 0); opacity: 0.8;"></div>';
if ($("#"+"layui-layer-shade-x"+newIndexShade).length <= 0) {
$('body').append(shadeItem);
}
let jsonObject = JSON.parse(event.data);
let re = "";
$("#showImportData").show();
for (let i = 0; i < jsonObject.length; i++) {
var mname = jsonObject[i]["mname"];
var code = jsonObject[i]["code"] == null || jsonObject[i]["code"] === undefined ? "" : jsonObject[i]["code"];
var version = jsonObject[i]["version"] == null || jsonObject[i]["version"] === undefined ? "" : jsonObject[i]["version"];
var texture = jsonObject[i]["texture"] == null || jsonObject[i]["texture"] === undefined ? "" : jsonObject[i]["texture"];
var unit = jsonObject[i]["unit"] == null || jsonObject[i]["unit"] === undefined ? "" : jsonObject[i]["unit"];
var typeId = jsonObject[i]["typeId"] == null || jsonObject[i]["typeId"] === undefined ? "" : jsonObject[i]["typeId"];
var show = "<p style='color: #00FF00'>" + mname + " " + version + " " + code + " " + texture + " " + unit + " " + typeId + " :成功" + "</p>";
re += show;
}
$("#showImportData").append(re);
});
closeShowDataMessage = function () {
$("#layui-layer-shade-x"+newIndexShade).remove();
$("#showImportData").hide();
$("#showImportData").empty();
if (socket !== null) {
socket.close();
}
};
// 监听搜索操作 // 监听搜索操作
@ -332,8 +456,7 @@
$(window).on("resize", function () { $(window).on("resize", function () {
layer.full(index); layer.full(index);
}); });
} } else if (obj.event === 'delete') { // 监听删除操作
else if (obj.event === 'delete') { // 监听删除操作
var checkStatus = table.checkStatus('currentTableId') var checkStatus = table.checkStatus('currentTableId')
, data = checkStatus.data; , data = checkStatus.data;
var req = {}; var req = {};
@ -378,8 +501,7 @@
layer.msg("未选中记录,请确认!"); layer.msg("未选中记录,请确认!");
return false; return false;
} }
} } else if (obj.event === 'applicationIn') {
else if (obj.event === 'applicationIn') {
// 入库申请 // 入库申请
var checkStatus = table.checkStatus('currentTableId') var checkStatus = table.checkStatus('currentTableId')
, data = checkStatus.data; , data = checkStatus.data;
@ -400,7 +522,7 @@
}, },
success: function (d) { success: function (d) {
layer.close(this.layerIndex); layer.close(this.layerIndex);
if (d.status == 200) { if (d.status === 200) {
layer.open({ layer.open({
type: 2, type: 2,
title: '入库', title: '入库',
@ -420,14 +542,12 @@
} }
}) })
} } else if (obj.event === 'downloadFile') {
else if (obj.event === 'downloadFile') { window.open("/download/materialImportDownload", "_self");
window.open("/download/materialImportDownload","_self");
} }
}); });
//监听表格复选框选择 //监听表格复选框选择
table.on('checkbox(currentTableFilter)', function (obj) { table.on('checkbox(currentTableFilter)', function (obj) {
console.log(obj) console.log(obj)

135
target/classes/templates/pages/materialtype/materialType_view.html

@ -85,6 +85,13 @@
lay-event="realDelete">彻底删除</a> lay-event="realDelete">彻底删除</a>
</script> </script>
<div id="showImportData"
style="height: 500px;width: 500px;position: absolute;overflow: auto;top: 10%;left: 25%;background: #ffffff;z-index: 1231234;display: none">
<div onclick="closeShowDataMessage()" style="position: absolute; right: 0; top: 2%; cursor: pointer;">
<i class="fa fa-window-close-o"></i>
</div>
</div>
</div> </div>
</div> </div>
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> <script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
@ -92,6 +99,17 @@
function bindTableToolbarFunction(){ function bindTableToolbarFunction(){
} }
function closeShowDataMessage() {
}
let socket;
let newIndexShade;
layui.use(['form', 'table', 'upload'], function () { layui.use(['form', 'table', 'upload'], function () {
var $ = layui.jquery, var $ = layui.jquery,
form = layui.form, form = layui.form,
@ -245,27 +263,98 @@
exts: 'xls|xlsx|csv', exts: 'xls|xlsx|csv',
done: function (res) { done: function (res) {
//如果上传成功 //如果上传成功
if (res.code == 200) { if (res.code === 200) {
var re = ""; var re = "";
for (let i = 0; i < res.data.errMsg.length; i++) { for (let i = 0; i < res.data.errMsg.length; i++) {
var show = "<p style='color: #ff211e'>" + res.data.errMsg[i] + ":错误" + "</p>"; var show = "<p style='color: #ff211e'>" + res.data.errMsg[i] + ":错误" + "</p>";
re += show re += show
} }
console.log(res.data.dataList.length);
for (let i = 0; i < res.data.dataList.length; i++) { for (let i = 0; i < res.data.dataList.length; i++) {
var tname = res.data.dataList[i]["tname"]; var tname = res.data.dataList[i]["tname"];
var id = res.data.dataList[i]["oldId"]; var id = res.data.dataList[i]["oldId"];
var parentId = res.data.dataList[i]["parentId"] == null ? "" : res.data.dataList[i]["parentId"]; var parentId = res.data.dataList[i]["parentId"] == null ? "" : res.data.dataList[i]["parentId"];
var introduce = res.data.dataList[i]["introduce"] == null ? "" : res.data.dataList[i]["introduce"]; var introduce = res.data.dataList[i]["introduce"] == null ? "" : res.data.dataList[i]["introduce"];
var show = "<p style='color: #00FF00'>" + tname + " " + id + " " + parentId + "成功" + "</p>"; var show = "<p style='color: #00FF00'>" + tname + " " + id + " " + parentId + "通过" + "</p>";
re += show re += show
} }
layer.open({ if ("WebSocket" in window) {
type: 1, socket = new WebSocket('ws://127.0.0.1:11111/webSocket/300450');
skin: 'layui-layer-rim', //加上边框 switch (socket.readyState) {
area: ['500px', '500px'], //宽高 case WebSocket.CONNECTING:
content: re // 连接中
}) socket.onopen = function () {
console.log("连接成功")
};
break;
case WebSocket.OPEN:
// 连接成功
break;
case WebSocket.CLOSING:
// 连接正在关闭。
break;
case WebSocket.CLOSED:
// 连接关闭。
break;
default:
// this never happens
break;
}
}
newIndexShade = layer.open({
type: 1
, title: false //不显示标题栏
, closeBtn: false
, area: ['500px', '500px']
, shade: 0.8
, id: 'LAY_layuipro' //设定一个id,防止重复弹出
, resize: false
, btn: ['导入', '取消']
, btnAlign: 'c'
, moveType: 1 //拖拽模式,0或者1
, content: re
, yes: function (index, layero) {
//按钮【按钮一】的回调
$.ajax({
url:"/excel/realImportMaterialType",
type: "post",
data: JSON.stringify({"result":"yes"}),
dataType: "json",
contentType: "application/json;charset=utf-8",
success:function () {
if (socket !== null) {
socket.close();
}
layer.msg("数据导入完成", {
icon: 0,
time: 1000
})
}
});
}
, btn2: function (index, layero) {
//按钮【按钮二】的回调
$.ajax({
url:"/excel/realImportMaterialType",
type: "post",
data: JSON.stringify({"result":"no"}),
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function () {
if (socket !== null) {
socket.close();
}
}
})
}
});
} else { } else {
layer.msg(res.msg) layer.msg(res.msg)
} }
@ -281,6 +370,36 @@
}); });
} }
socket.addEventListener('message', function (event) {
layer.close(newIndexShade);
let shadeItem = '<div class="layui-layer-shade" id='+"layui-layer-shade-x"+newIndexShade+' times="753951" style="z-index:1231233; background-color: rgb(0, 0, 0); opacity: 0.8;"></div>';
if ($("#"+"layui-layer-shade-x"+newIndexShade).length <= 0) {
$('body').append(shadeItem);
}
let jsonObject = JSON.parse(event.data);
let re = "";
$("#showImportData").show();
for (let i = 0; i < jsonObject.length; i++) {
var tname = jsonObject[i]["tname"];
var id = jsonObject[i]["oldId"];
var parentId = jsonObject[i]["parentId"] == null ? "" : jsonObject[i]["parentId"];
var introduce = jsonObject[i]["introduce"] == null ? "" : jsonObject[i]["introduce"];
var show = "<p style='color: #00FF00'>" + tname + " " + id + " " + parentId + "成功" + "</p>";
re += show
}
$("#showImportData").append(re);
});
closeShowDataMessage = function () {
$("#layui-layer-shade-x"+newIndexShade).remove();
$("#showImportData").hide();
$("#showImportData").empty();
if (socket !== null) {
socket.close();
}
};
//监听表格复选框选择 //监听表格复选框选择
table.on('checkbox(currentTableFilter)', function (obj) { table.on('checkbox(currentTableFilter)', function (obj) {

Loading…
Cancel
Save