|
|
|
@ -8,20 +8,19 @@ import com.dreamchaser.depository_manage.entity.*; |
|
|
|
import com.dreamchaser.depository_manage.exception.MyException; |
|
|
|
import com.dreamchaser.depository_manage.pojo.*; |
|
|
|
import com.dreamchaser.depository_manage.security.bean.UserToken; |
|
|
|
import com.dreamchaser.depository_manage.service.DepositoryService; |
|
|
|
import com.dreamchaser.depository_manage.service.MaterialService; |
|
|
|
import com.dreamchaser.depository_manage.service.PlaceService; |
|
|
|
import com.dreamchaser.depository_manage.service.RoleService; |
|
|
|
import com.dreamchaser.depository_manage.service.*; |
|
|
|
import com.dreamchaser.depository_manage.utils.CrudUtil; |
|
|
|
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|
|
|
import com.sun.mail.imap.protocol.ID; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.servlet.ModelAndView; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.io.IOException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
@ -46,6 +45,12 @@ public class MaterialController { |
|
|
|
@Autowired |
|
|
|
private RedisTemplate<Object, Object> redisTemplate; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RedisTemplate<String, String> redisTemplateForString; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MaterialTypeService materialTypeService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据物料进行查询 |
|
|
|
* |
|
|
|
@ -192,7 +197,7 @@ public class MaterialController { |
|
|
|
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|
|
|
Integer maindeparment = userToken.getMaindeparment(); |
|
|
|
List<Object> list = new ArrayList<>(); |
|
|
|
if ("1".equals(type)) { |
|
|
|
/*if ("1".equals(type)) { |
|
|
|
list = materialService.InitTreeMenus(mname); |
|
|
|
} else if ("2".equals(type)) { |
|
|
|
list = materialService.InitTreeMenus(mname, String.valueOf(maindeparment)); |
|
|
|
@ -201,11 +206,20 @@ public class MaterialController { |
|
|
|
String placeId = (String) map.get("placeId"); |
|
|
|
list = materialService.InitTreeMenus(mname, depositoryId, placeId); |
|
|
|
}else if("4".equals(type)){ |
|
|
|
list = materialService.InitTreeMenus_Test(mname); |
|
|
|
} |
|
|
|
list = materialService.InitTreeMenus_Test(); |
|
|
|
}*/ |
|
|
|
list = materialService.InitTreeMenus_Test(); |
|
|
|
return new RestResponse(list); |
|
|
|
} |
|
|
|
|
|
|
|
// 每天凌晨0点执行一次
|
|
|
|
@Scheduled(cron = "0 0 0 * * ?") |
|
|
|
private void getTransData() throws Exception { |
|
|
|
materialService.InitTreeMenus_Test(); |
|
|
|
// bankDataService.insertTD();
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 根据id获取物料 |
|
|
|
* |
|
|
|
@ -684,8 +698,7 @@ public class MaterialController { |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
Object pid = map.get("placeId"); |
|
|
|
String placeId = "0"; |
|
|
|
if(pid != null) |
|
|
|
{ |
|
|
|
if (pid != null) { |
|
|
|
placeId = pid.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -712,7 +725,7 @@ public class MaterialController { |
|
|
|
if (placeAndMaterialByMidAndPid == null) { |
|
|
|
// 如果当前物料不在该库位
|
|
|
|
flag = false; |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
@ -720,7 +733,7 @@ public class MaterialController { |
|
|
|
if (placeAndMaterialByMidAndPid == null) { |
|
|
|
// 如果当前物料不在该库位
|
|
|
|
flag = false; |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity()); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1063,9 +1076,9 @@ public class MaterialController { |
|
|
|
String barCode = (String) map.get("qrCode"); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
MaterialP material = null; |
|
|
|
Object pid = map.get("placeId"); |
|
|
|
Object pid = map.get("placeId"); |
|
|
|
String placeId = "0"; |
|
|
|
if(pid != null){ |
|
|
|
if (pid != null) { |
|
|
|
placeId = pid.toString(); |
|
|
|
} |
|
|
|
// 用于存储没有对应关系的条形码
|
|
|
|
@ -1227,7 +1240,7 @@ public class MaterialController { |
|
|
|
// 获取当前部门仓库
|
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
String code = map.get("code").toString(); |
|
|
|
String depositoryId = map.get("depositoryId").toString(); |
|
|
|
String depositoryId = map.get("depositoryId").toString(); |
|
|
|
String placeId = map.get("placeId").toString(); |
|
|
|
if ("".equals(code)) { |
|
|
|
return new RestResponse(null, 1, 200); |
|
|
|
@ -1276,39 +1289,40 @@ public class MaterialController { |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于查询当前扫描的二维码为仓库还是物料 |
|
|
|
* |
|
|
|
* @param map |
|
|
|
* @param request |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("/qywxScanCodeOut") |
|
|
|
public RestResponse qywxScanCodeOut(@RequestBody Map<String,Object> map,HttpServletRequest request){ |
|
|
|
public RestResponse qywxScanCodeOut(@RequestBody Map<String, Object> map, HttpServletRequest request) { |
|
|
|
String qrCode = (String) map.get("qrCode"); |
|
|
|
String materialCode = materialService.findMaterialCodeByQrCode(qrCode); |
|
|
|
Map<String,Object> result = new HashMap<>(); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
// 0为非法码,1为物料,2为库位,3为仓库
|
|
|
|
Integer flag = 0; |
|
|
|
if(materialCode != null){ |
|
|
|
if (materialCode != null) { |
|
|
|
// 如果当前不为空,则扫描的为物料二维码
|
|
|
|
flag = 1; |
|
|
|
Material materialByCode = materialService.findMaterialByCode(materialCode); |
|
|
|
result.put("material",materialByCode); |
|
|
|
}else{ |
|
|
|
result.put("material", materialByCode); |
|
|
|
} else { |
|
|
|
// 如果为空,则扫描的为条形码
|
|
|
|
MaterialAndBarCode materialByBarCode = materialService.findMaterialByBarCode(qrCode); |
|
|
|
if(materialByBarCode != null){ |
|
|
|
if (materialByBarCode != null) { |
|
|
|
// 如果不为空,则扫描的为物料条形码
|
|
|
|
Material material = materialService.findMaterialById(materialByBarCode.getMid()); |
|
|
|
flag = 1; |
|
|
|
result.put("material",material); |
|
|
|
}else{ |
|
|
|
result.put("material", material); |
|
|
|
} else { |
|
|
|
// 如果为空,则扫描的可能为库位码
|
|
|
|
PidOrDidAndCode locationByQrCode = placeService.findLocationByQrCode(qrCode); |
|
|
|
if(locationByQrCode != null){ |
|
|
|
if (locationByQrCode != null) { |
|
|
|
// 如果不为空,则是库位码
|
|
|
|
|
|
|
|
// 1为库位2为仓库
|
|
|
|
Integer locationFlag = locationByQrCode.getFlag(); |
|
|
|
if(Integer.compare(locationFlag,1) == 0){ |
|
|
|
if (Integer.compare(locationFlag, 1) == 0) { |
|
|
|
// 如果是库位
|
|
|
|
Place placeById = placeService.findPlaceById(ObjectFormatUtil.toInteger(locationByQrCode.getPid())); |
|
|
|
|
|
|
|
@ -1321,18 +1335,50 @@ public class MaterialController { |
|
|
|
mcodeList.add(materialById.getCode()); |
|
|
|
} |
|
|
|
pp.setMcodeList(mcodeList); |
|
|
|
result.put("place",pp); |
|
|
|
result.put("place", pp); |
|
|
|
flag = 2; |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
// 如果是仓库
|
|
|
|
Depository depository = depositoryService.findDepositoryRecordById(ObjectFormatUtil.toInteger(locationByQrCode.getDepositoryId())); |
|
|
|
result.put("depository",depository); |
|
|
|
result.put("depository", depository); |
|
|
|
flag = 3; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
result.put("flag",flag); |
|
|
|
result.put("flag", flag); |
|
|
|
return new RestResponse(result); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 用于再次获取新数据 |
|
|
|
* |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("/getNewTreeForMtId") |
|
|
|
public RestResponse getNewTreeForMtId(@RequestBody Map<String, Object> map, HttpServletRequest request) { |
|
|
|
String mname = (String) map.get("mname"); |
|
|
|
String type = (String) map.get("type"); |
|
|
|
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|
|
|
Integer maindeparment = userToken.getMaindeparment(); |
|
|
|
Object mtId = map.get("mtId"); |
|
|
|
List<Object> list = new ArrayList<>(); |
|
|
|
if (mtId != null) { |
|
|
|
if("2".equals(type)){ |
|
|
|
map.put("adminorg",String.valueOf(maindeparment)); |
|
|
|
}else if("3".equals(type)){ |
|
|
|
String depositoryId = (String) map.get("depositoryId"); |
|
|
|
String placeId = (String) map.get("placeId"); |
|
|
|
map.put("depositoryId", depositoryId); |
|
|
|
map.put("placeId", placeId); |
|
|
|
} |
|
|
|
list = materialService.AddInitTreeMenus(map); |
|
|
|
|
|
|
|
} else { |
|
|
|
throw new MyException("缺少必要参数"); |
|
|
|
} |
|
|
|
return new RestResponse(list); |
|
|
|
} |
|
|
|
} |
|
|
|
|