39 changed files with 3856 additions and 183 deletions
@ -0,0 +1,217 @@ |
|||
package com.dreamchaser.depository_manage.controller; |
|||
|
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.dreamchaser.depository_manage.entity.Place; |
|||
import com.dreamchaser.depository_manage.entity.UserByPort; |
|||
import com.dreamchaser.depository_manage.pojo.RestResponse; |
|||
import com.dreamchaser.depository_manage.pojo.SimpleStockTakingP; |
|||
import com.dreamchaser.depository_manage.pojo.StatusInfo; |
|||
import com.dreamchaser.depository_manage.service.MaterialService; |
|||
import com.dreamchaser.depository_manage.service.MaterialTypeService; |
|||
import com.dreamchaser.depository_manage.service.PlaceService; |
|||
import com.dreamchaser.depository_manage.service.StockTakingService; |
|||
import com.dreamchaser.depository_manage.service.impl.QyWxOperationService; |
|||
import com.dreamchaser.depository_manage.utils.CrudUtil; |
|||
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.data.redis.core.RedisTemplate; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
/** |
|||
* 库存盘点控制器 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/stockTaking") |
|||
public class StockTakingController { |
|||
@Autowired |
|||
MaterialService materialService; |
|||
|
|||
@Autowired |
|||
MaterialTypeService materialTypeService; |
|||
|
|||
@Autowired |
|||
StockTakingService stockTakingService; |
|||
|
|||
@Autowired |
|||
PlaceService placeService; |
|||
|
|||
@Autowired |
|||
QyWxOperationService qyWxOperationService; |
|||
|
|||
@Autowired |
|||
private RedisTemplate<String,String> redisTemplateForHash; |
|||
|
|||
// 用于添加盘点记录
|
|||
@PostMapping("/addStockTakingRecord") |
|||
public RestResponse addStockTakingRecord(@RequestBody Map<String,Object> map, HttpServletRequest request){ |
|||
|
|||
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|||
List params = (ArrayList) map.get("params"); |
|||
String departmentManagerId = (String) map.get("departmentManagerId"); |
|||
// map.put("departmentManager",departmentManagerId);
|
|||
map.put("departmentManager","6235"); |
|||
// 用于设置企业微信接收人
|
|||
StringBuilder QyWxDepartmentManager = new StringBuilder(); |
|||
/*String[] split = departmentManagerId.split(","); |
|||
for (int i = 0; i < split.length; i++) { |
|||
String s = split[i]; |
|||
if("".equals(s)){ |
|||
continue; |
|||
} |
|||
UserByPort departmentManager = PageController.FindUserById(ObjectFormatUtil.toInteger(s), userToken); |
|||
QyWxDepartmentManager.append(departmentManager.getWorkwechat()+","); |
|||
}*/ |
|||
QyWxDepartmentManager.append("PangFuZhen").append(","); |
|||
map.put("state",3); |
|||
map.remove("departmentManagerId"); |
|||
map.put("originator",userToken.getId()); |
|||
String mcode = (String) map.get("code"); |
|||
map.remove("code"); |
|||
Integer success = 0; |
|||
if(params.size() > 0){ |
|||
// 如果有多个表
|
|||
Map<String,Object> param = new HashMap<>(); |
|||
param.put("depositoryId",map.get("depositoryId")); |
|||
param.put("placeId",map.get("placeId")); |
|||
param.put("departmentManager",map.get("departmentManager")); |
|||
param.put("state",3); |
|||
param.put("originator",userToken.getId()); |
|||
for (int i = 0; i < params.size(); i++) { |
|||
Integer temp = ObjectFormatUtil.toInteger(params.get(i)); |
|||
map.remove("code"); |
|||
param.put("mid",map.get("mid"+temp)); |
|||
param.put("barCode",map.get("barCode"+temp)); |
|||
param.put("oldInventory",map.get("oldInventory"+temp)); |
|||
param.put("newInventory",map.get("newInventory"+temp)); |
|||
param.put("takingResult",map.get("takingResult"+temp)); |
|||
param.put("inventory",map.get("inventory"+temp)); |
|||
success += stockTakingService.insertStockTaking(param); |
|||
param.remove("id"); |
|||
} |
|||
param.put("mid",map.get("mid")); |
|||
param.put("barCode",map.get("barCode")); |
|||
param.put("oldInventory",map.get("oldInventory")); |
|||
param.put("newInventory",map.get("newInventory")); |
|||
param.put("takingResult",map.get("takingResult")); |
|||
param.put("inventory",map.get("inventory")); |
|||
success += stockTakingService.insertStockTaking(param); |
|||
|
|||
Object mainId = param.get("mainId"); |
|||
// 向企业微信发送消息
|
|||
JSONObject jsonObject = qyWxOperationService.sendQyWxToStockTakingMessage(QyWxDepartmentManager.toString(), ObjectFormatUtil.toInteger(mainId)); |
|||
// 将当前返回结果保存到redis中
|
|||
Map<String,Object> QyWxMessageMap = new HashMap<>(); |
|||
QyWxMessageMap.put("MsgId",jsonObject.getString("msgid")); |
|||
QyWxMessageMap.put("responseCode",jsonObject.getString("response_code")); |
|||
// key user:300450:QyWxOut:1
|
|||
// 申请人number
|
|||
redisTemplateForHash.opsForHash().putAll("user:"+userToken.getNumber()+":QyWxStockTakingId:"+mainId,QyWxMessageMap); |
|||
// 设置过期时间为三天
|
|||
redisTemplateForHash.expire("user:"+userToken.getNumber()+":QyWxStockTakingId:"+mainId,72, TimeUnit.HOURS); |
|||
} |
|||
else{ |
|||
// 如果只有一个表
|
|||
success += stockTakingService.insertStockTaking(map); |
|||
// 向企业微信发送消息
|
|||
Object mainId = map.get("mainId"); |
|||
JSONObject jsonObject = qyWxOperationService.sendQyWxToStockTakingMessage(QyWxDepartmentManager.toString(), ObjectFormatUtil.toInteger(mainId)); |
|||
// 将当前返回结果保存到redis中
|
|||
Map<String,Object> QyWxMessageMap = new HashMap<>(); |
|||
QyWxMessageMap.put("MsgId",jsonObject.getString("msgid")); |
|||
QyWxMessageMap.put("responseCode",jsonObject.getString("response_code")); |
|||
// key user:300450:QyWxOut:1
|
|||
// 申请人number
|
|||
redisTemplateForHash.opsForHash().putAll("user:"+userToken.getNumber()+":QyWxStockTakingId:"+mainId,QyWxMessageMap); |
|||
// 设置过期时间为三天
|
|||
redisTemplateForHash.expire("user:"+userToken.getNumber()+":QyWxStockTakingId:"+mainId,72, TimeUnit.HOURS); |
|||
} |
|||
|
|||
if(params.size() > 0 ){ |
|||
return CrudUtil.postHandle(success,params.size() + 1); |
|||
} |
|||
else{ |
|||
return CrudUtil.postHandle(success,1); |
|||
} |
|||
} |
|||
|
|||
|
|||
// 用于查询需要用户审核的盘点
|
|||
@GetMapping("/myTask") |
|||
public RestResponse myTask(@RequestParam Map<String,Object> map,HttpServletRequest request) { |
|||
UserByPort userToken= (UserByPort) request.getAttribute("userToken"); |
|||
map.put("userId",userToken.getId()); |
|||
List<SimpleStockTakingP> myTask = stockTakingService.findMyTask(map, request); |
|||
return new RestResponse(myTask,stockTakingService.findMyTaskCount(map),200); |
|||
} |
|||
|
|||
// 用于审核
|
|||
@PostMapping("/review") |
|||
public RestResponse review(@RequestBody Map<String,Object> map,HttpServletRequest request){ |
|||
UserByPort userToken= (UserByPort) request.getAttribute("userToken"); |
|||
Map<String, Object> review = stockTakingService.review(map, userToken); |
|||
|
|||
if(review.containsKey("errMsg")){ |
|||
// 如果有出错情况
|
|||
return new RestResponse(review,666,new StatusInfo("有错误","发现错误")); |
|||
}else { |
|||
return CrudUtil.postHandle(1, 1); |
|||
} |
|||
|
|||
} |
|||
|
|||
// 用于查询用户提交的盘点
|
|||
@GetMapping("/myApply") |
|||
public RestResponse myApply(@RequestParam Map<String,Object> map,HttpServletRequest request) { |
|||
UserByPort userToken= (UserByPort) request.getAttribute("userToken"); |
|||
map.put("userId",userToken.getId()); |
|||
List<SimpleStockTakingP> myTask = stockTakingService.findMyApply(map, request); |
|||
return new RestResponse(myTask,stockTakingService.findMyApplyCount(map),200); |
|||
} |
|||
|
|||
|
|||
// 用于查询转入位置的容量
|
|||
@PostMapping("/findInventoryByLocation") |
|||
public RestResponse findInventoryByLocation(@RequestBody Map<String,Object> map,HttpServletRequest request) { |
|||
UserByPort userToken= (UserByPort) request.getAttribute("userToken"); |
|||
String depositoryId = (String) map.get("depositoryId"); |
|||
String placeId = (String) map.get("placeId"); |
|||
// 获取当前库位
|
|||
Place placeById = placeService.findPlaceById(ObjectFormatUtil.toInteger(placeId)); |
|||
// 获取当前库位的容量
|
|||
Integer inventory = placeById.getMax() - placeById.getQuantity(); |
|||
return new RestResponse(inventory); |
|||
} |
|||
|
|||
|
|||
// 用于进行盘点库存转移
|
|||
@PostMapping("/stockTransfer") |
|||
public RestResponse stockTransfer(@RequestBody Map<String,Object> map,HttpServletRequest request) { |
|||
|
|||
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|||
|
|||
String minIds = (String) map.get("minIds"); |
|||
String[] split = minIds.split(","); |
|||
List<Integer> minIdList = new ArrayList<>(); |
|||
for (int i = 0; i < split.length; i++) { |
|||
String s = split[i]; |
|||
if("".equals(s)){ |
|||
continue; |
|||
} |
|||
minIdList.add(ObjectFormatUtil.toInteger(s)); |
|||
|
|||
} |
|||
map.put("minIds",minIdList); |
|||
map.put("inventory",map.get("invnetory5")); |
|||
map.remove("invnetory5"); |
|||
Integer transfer = stockTakingService.stockTakingTransfer(map, userToken); |
|||
return CrudUtil.postHandle(transfer,minIdList.size()); |
|||
} |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package com.dreamchaser.depository_manage.entity; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 盘点子类 |
|||
*/ |
|||
@Data |
|||
public class StockTakingChild { |
|||
/** |
|||
* id |
|||
*/ |
|||
private Integer id; |
|||
/** |
|||
* 物料id |
|||
*/ |
|||
private Integer mid; |
|||
/** |
|||
* 库存容量 |
|||
*/ |
|||
private Integer oldInventory; |
|||
/** |
|||
* 盘点数量 |
|||
*/ |
|||
private Integer newInventory; |
|||
/** |
|||
* 盘点结果 |
|||
*/ |
|||
private String takingResult; |
|||
/** |
|||
* 盈亏数量 |
|||
*/ |
|||
private Integer inventory; |
|||
/** |
|||
* 主表id |
|||
*/ |
|||
private Long mainId; |
|||
} |
|||
@ -0,0 +1,176 @@ |
|||
package com.dreamchaser.depository_manage.mapper; |
|||
|
|||
|
|||
import com.dreamchaser.depository_manage.entity.StockTaking; |
|||
import com.dreamchaser.depository_manage.entity.StockTakingChild; |
|||
import com.dreamchaser.depository_manage.pojo.StockTakingChildP; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Repository |
|||
@Mapper |
|||
public interface StockTakingMapper { |
|||
|
|||
/** |
|||
* 用于插入盘点记录主表 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
Integer insertStockTaking(Map<String,Object> map); |
|||
|
|||
/** |
|||
* 用于插入盘点记录主表 |
|||
* @param st |
|||
* @return |
|||
*/ |
|||
Integer insertStockTaking(StockTaking st); |
|||
|
|||
/** |
|||
* 用于插入盘点记录子表 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
Integer insertStockTakingChild(Map<String,Object> map); |
|||
|
|||
/** |
|||
* 用于插入盘点记录子表 |
|||
* @param stc |
|||
* @return |
|||
*/ |
|||
Integer insertStockTakingChild(StockTakingChild stc); |
|||
|
|||
|
|||
/** |
|||
* 根据主键id删除子表 |
|||
* @param id |
|||
* @return |
|||
*/ |
|||
Integer deleteStockTakingChild(Integer id); |
|||
|
|||
/** |
|||
* 根据主键id批量删除子表 |
|||
* @param list |
|||
* @return |
|||
*/ |
|||
Integer deleteStockTakingChilds(List<Integer> list); |
|||
|
|||
/** |
|||
* 根据主键删除主表 |
|||
* @param id |
|||
* @return |
|||
*/ |
|||
Integer deleteStockTaking(Integer id); |
|||
|
|||
/** |
|||
* 根据主键批量删除主表 |
|||
* @param list |
|||
* @return |
|||
*/ |
|||
Integer deleteStockTakings(List<Integer> list); |
|||
|
|||
/** |
|||
* 修改主表记录 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
Integer updateStockTaking(Map<String,Object> map); |
|||
|
|||
/** |
|||
* 修改主表记录 |
|||
* @param st |
|||
* @return |
|||
*/ |
|||
Integer updateStockTaking(StockTaking st); |
|||
|
|||
|
|||
/** |
|||
* 修改子表记录 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
Integer updateStockTakingChild(Map<String,Object> map); |
|||
|
|||
|
|||
/** |
|||
* 修改子表记录 |
|||
* @param stc |
|||
* @return |
|||
*/ |
|||
Integer updateStockTakingChild(StockTakingChild stc); |
|||
|
|||
|
|||
/** |
|||
* 根据主表id查询所有子表 |
|||
* @param mainId |
|||
* @return |
|||
*/ |
|||
List<StockTakingChildP> selectStockTakingChildByMainId(Integer mainId); |
|||
|
|||
|
|||
/** |
|||
* 根据条件查询主表 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
List<StockTaking> selectStockTakingByCondition(Map<String,Object> map); |
|||
|
|||
|
|||
/** |
|||
* 根据条件查询盘点详情 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
List<StockTakingChildP> selectStockTakingChildPByCondition(Map<String,Object> map); |
|||
|
|||
/** |
|||
* 根据主键查找主表 |
|||
* @param id |
|||
* @return |
|||
*/ |
|||
StockTaking selectStockTakingById(Integer id); |
|||
|
|||
/** |
|||
* 根据主键查找主表 |
|||
* @param id |
|||
* @return |
|||
*/ |
|||
StockTaking selectStockTakingById(Long id); |
|||
/** |
|||
* 根据主键查找盘点详情 |
|||
* @param id |
|||
* @return |
|||
*/ |
|||
StockTakingChildP selectStockTakingChildPById(Integer id); |
|||
|
|||
|
|||
/** |
|||
* 查询用户的任务 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
List<StockTaking> findMyTask(Map<String,Object> map); |
|||
|
|||
/** |
|||
* 查询用户的任务数量 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
Integer findMyTaskCount(Map<String,Object> map); |
|||
|
|||
/** |
|||
* 查询用户的申请 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
List<StockTaking> findMyApply(Map<String,Object> map); |
|||
|
|||
/** |
|||
* 查询用户的申请数量 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
Integer findMyApplyCount(Map<String,Object> map); |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
package com.dreamchaser.depository_manage.pojo; |
|||
|
|||
import com.dreamchaser.depository_manage.entity.StockTaking; |
|||
import com.dreamchaser.depository_manage.utils.DateUtil; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 用于简化输出 |
|||
*/ |
|||
@Data |
|||
public class SimpleStockTakingP { |
|||
/** |
|||
* id |
|||
*/ |
|||
private Long id; |
|||
|
|||
/** |
|||
* 盘点单号 |
|||
*/ |
|||
private String code; |
|||
|
|||
/** |
|||
* 仓库名称 |
|||
*/ |
|||
private String depositoryName; |
|||
|
|||
/* |
|||
发起人姓名 |
|||
*/ |
|||
private String originatorName; |
|||
|
|||
/** |
|||
* 申请时间 |
|||
*/ |
|||
private String createTime; |
|||
|
|||
public SimpleStockTakingP(StockTaking st) { |
|||
this.id = st.getId(); |
|||
this.code = st.getCode(); |
|||
this.createTime = DateUtil.TimeStampToDateTime(st.getCreateTime()); |
|||
} |
|||
} |
|||
@ -0,0 +1,108 @@ |
|||
package com.dreamchaser.depository_manage.service; |
|||
|
|||
import com.dreamchaser.depository_manage.entity.StockTaking; |
|||
import com.dreamchaser.depository_manage.entity.StockTakingChild; |
|||
import com.dreamchaser.depository_manage.entity.UserByPort; |
|||
import com.dreamchaser.depository_manage.pojo.SimpleApplicationOutRecordP; |
|||
import com.dreamchaser.depository_manage.pojo.SimpleStockTakingP; |
|||
import com.dreamchaser.depository_manage.pojo.StockTakingChildP; |
|||
import com.dreamchaser.depository_manage.pojo.StockTakingP; |
|||
import com.dreamchaser.depository_manage.pojo.callBackXml.callBackXml_button_templatecard.TemplateCard; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface StockTakingService { |
|||
/** |
|||
* 用于插入盘点记录主表 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
Integer insertStockTaking(Map<String,Object> map); |
|||
|
|||
/** |
|||
* 用于插入盘点记录主表 |
|||
* @param st |
|||
* @return |
|||
*/ |
|||
Integer insertStockTaking(StockTaking st); |
|||
|
|||
/** |
|||
* 根据条件查询自己的任务(根据isDone来决定查询已完成或者未完成的任务),同时支持分页查询(需要begin和size参数) |
|||
* @param map 查询参数 |
|||
* @return 我的任务 |
|||
*/ |
|||
List<SimpleStockTakingP> findMyTask(Map<String, Object> map, HttpServletRequest request); |
|||
|
|||
/** |
|||
* 查询用户的任务数量 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
Integer findMyTaskCount(Map<String,Object> map); |
|||
|
|||
/** |
|||
* 根据条件查询自己的申请 |
|||
* @param map 查询参数 |
|||
* @return 我的任务 |
|||
*/ |
|||
List<SimpleStockTakingP> findMyApply(Map<String, Object> map, HttpServletRequest request); |
|||
|
|||
/** |
|||
* 查询用户的申请数量 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
Integer findMyApplyCount(Map<String,Object> map); |
|||
|
|||
/** |
|||
* 根据主键查询主表 |
|||
* @param id |
|||
* @return |
|||
*/ |
|||
StockTaking findStockTakingById(Integer id); |
|||
|
|||
/** |
|||
* 根据主键查询主表 |
|||
* @param id |
|||
* @return |
|||
*/ |
|||
StockTaking findStockTakingById(Long id); |
|||
|
|||
/** |
|||
* 根据主表获取所有子表 |
|||
* @param mainId |
|||
* @return |
|||
*/ |
|||
List<StockTakingChildP> findStockTakingChildPByMainId(Integer mainId); |
|||
|
|||
/** |
|||
* 根据主键获取子表 |
|||
* @param id |
|||
* @return |
|||
*/ |
|||
StockTakingChildP findStockTakingChildPById(Integer id); |
|||
|
|||
/** |
|||
* 用于对盘点进行审核 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
Map<String,Object> review(Map<String,Object> map, UserByPort userToken); |
|||
|
|||
/** |
|||
* 用于进行盘点结果转移 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
Integer stockTakingTransfer(Map<String,Object> map,UserByPort userToken); |
|||
|
|||
/** |
|||
* 用于企业微信的审核申请处理 |
|||
* @param templateCard |
|||
* @return |
|||
*/ |
|||
Integer reviewByQyWx(TemplateCard templateCard); |
|||
|
|||
} |
|||
@ -0,0 +1,867 @@ |
|||
package com.dreamchaser.depository_manage.service.impl; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.dreamchaser.depository_manage.config.PortConfig; |
|||
import com.dreamchaser.depository_manage.controller.PageController; |
|||
import com.dreamchaser.depository_manage.entity.*; |
|||
import com.dreamchaser.depository_manage.exception.MyException; |
|||
import com.dreamchaser.depository_manage.mapper.DepositoryMapper; |
|||
import com.dreamchaser.depository_manage.mapper.MaterialMapper; |
|||
import com.dreamchaser.depository_manage.mapper.PlaceMapper; |
|||
import com.dreamchaser.depository_manage.mapper.StockTakingMapper; |
|||
import com.dreamchaser.depository_manage.pojo.SimpleStockTakingP; |
|||
import com.dreamchaser.depository_manage.pojo.StockTakingChildP; |
|||
import com.dreamchaser.depository_manage.pojo.callBackXml.callBackXml_button_templatecard.TemplateCard; |
|||
import com.dreamchaser.depository_manage.service.DepositoryRecordService; |
|||
import com.dreamchaser.depository_manage.service.StockTakingService; |
|||
import com.dreamchaser.depository_manage.utils.DateUtil; |
|||
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|||
import com.dreamchaser.depository_manage.utils.WordUtil; |
|||
import org.redisson.api.RLock; |
|||
import org.redisson.api.RedissonClient; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.data.redis.core.RedisTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.*; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
@Service |
|||
public class StockTakingServiceImpl implements StockTakingService { |
|||
|
|||
|
|||
@Autowired |
|||
StockTakingMapper stockTakingMapper; |
|||
|
|||
@Autowired |
|||
DepositoryMapper depositoryMapper; |
|||
|
|||
@Autowired |
|||
PlaceMapper placeMapper; |
|||
|
|||
@Autowired |
|||
RedissonClient redissonClient; |
|||
|
|||
@Autowired |
|||
RedisTemplate<String, String> redisTemplate; |
|||
|
|||
@Autowired |
|||
MaterialMapper materialMapper; |
|||
|
|||
@Autowired |
|||
DepositoryRecordService depositoryRecordService; |
|||
|
|||
@Autowired |
|||
QyWxOperationService qyWxOperationService; |
|||
|
|||
/** |
|||
* 用于插入盘点记录主表 |
|||
* |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
@Transactional |
|||
@Override |
|||
public Integer insertStockTaking(Map<String, Object> map) { |
|||
// 设置盘点时间
|
|||
String simpleTime = DateUtil.getSimpleTime(new Date()); |
|||
map.put("createTime", DateUtil.DateTimeToTimeStamp(simpleTime)); |
|||
// 获取盘点位置
|
|||
String placeId = (String) map.get("placeId"); |
|||
Depository depository = null; |
|||
if ("0".equals(placeId)) { |
|||
// 如果是默认库位
|
|||
|
|||
// 获取仓库
|
|||
depository = depositoryMapper.findDepositoryById(ObjectFormatUtil.toInteger(map.get("depositoryId"))); |
|||
} else { |
|||
Place place = placeMapper.findPlaceById(ObjectFormatUtil.toInteger(placeId)); |
|||
depository = depositoryMapper.findDepositoryById(place.getDid()); |
|||
} |
|||
map.put("code", createTakingCode(depository.getDname())); |
|||
if (!map.containsKey("mainId")) { |
|||
stockTakingMapper.insertStockTaking(map); |
|||
Object id = map.get("id"); |
|||
map.remove("id"); |
|||
map.put("mainId", id); |
|||
} |
|||
return stockTakingMapper.insertStockTakingChild(map); |
|||
} |
|||
|
|||
/** |
|||
* 用于插入盘点记录主表 |
|||
* |
|||
* @param st |
|||
* @return |
|||
*/ |
|||
@Transactional |
|||
@Override |
|||
public Integer insertStockTaking(StockTaking st) { |
|||
return null; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 根据条件查询自己的任务(根据isDone来决定查询已完成或者未完成的任务),同时支持分页查询(需要begin和size参数) |
|||
* |
|||
* @param map 查询参数 |
|||
* @return 我的任务 |
|||
*/ |
|||
@Override |
|||
public List<SimpleStockTakingP> findMyTask(Map<String, Object> map, HttpServletRequest request) { |
|||
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|||
Integer size = 10, page = 1; |
|||
if (map.containsKey("size")) { |
|||
size = ObjectFormatUtil.toInteger(map.get("size")); |
|||
map.put("size", size); |
|||
} |
|||
if (map.containsKey("page")) { |
|||
page = ObjectFormatUtil.toInteger(map.get("page")); |
|||
map.put("begin", (page - 1) * size); |
|||
} |
|||
List<StockTaking> myTask = stockTakingMapper.findMyTask(map); |
|||
List<SimpleStockTakingP> stockTakingPS = new ArrayList<>(); |
|||
for (int i = 0; i < myTask.size(); i++) { |
|||
StockTaking stockTaking = myTask.get(i); |
|||
SimpleStockTakingP ssp = new SimpleStockTakingP(stockTaking); |
|||
Depository depositoryRecordById = depositoryMapper.findDepositoryById(stockTaking.getDepositoryId()); |
|||
ssp.setDepositoryName(depositoryRecordById.getDname()); |
|||
UserByPort userByPort = PageController.FindUserById(stockTaking.getOriginator(), userToken); |
|||
ssp.setOriginatorName(userByPort.getName()); |
|||
stockTakingPS.add(ssp); |
|||
} |
|||
return stockTakingPS; |
|||
} |
|||
|
|||
/** |
|||
* 根据条件查询自己的任务数目 |
|||
* |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public Integer findMyTaskCount(Map<String, Object> map) { |
|||
return stockTakingMapper.findMyTaskCount(map); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 根据条件查询自己的申请 |
|||
* @param map 查询参数 |
|||
* @return 我的任务 |
|||
*/ |
|||
@Override |
|||
public List<SimpleStockTakingP> findMyApply(Map<String, Object> map, HttpServletRequest request) { |
|||
Integer size = 10, page = 1; |
|||
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|||
if (map.containsKey("size")) { |
|||
size = ObjectFormatUtil.toInteger(map.get("size")); |
|||
map.put("size", size); |
|||
} |
|||
if (map.containsKey("page")) { |
|||
page = ObjectFormatUtil.toInteger(map.get("page")); |
|||
map.put("begin", (page - 1) * size); |
|||
} |
|||
List<StockTaking> myTask = stockTakingMapper.findMyTask(map); |
|||
List<SimpleStockTakingP> stockTakingPS = new ArrayList<>(); |
|||
for (int i = 0; i < myTask.size(); i++) { |
|||
StockTaking stockTaking = myTask.get(i); |
|||
SimpleStockTakingP ssp = new SimpleStockTakingP(stockTaking); |
|||
Depository depositoryRecordById = depositoryMapper.findDepositoryById(stockTaking.getDepositoryId()); |
|||
ssp.setDepositoryName(depositoryRecordById.getDname()); |
|||
UserByPort userByPort = PageController.FindUserById(stockTaking.getOriginator(), userToken); |
|||
ssp.setOriginatorName(userByPort.getName()); |
|||
stockTakingPS.add(ssp); |
|||
} |
|||
return stockTakingPS; |
|||
} |
|||
|
|||
/** |
|||
* 查询用户的申请数量 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public Integer findMyApplyCount(Map<String, Object> map) { |
|||
return stockTakingMapper.findMyApplyCount(map); |
|||
} |
|||
|
|||
/** |
|||
* 根据主键查询主表 |
|||
* |
|||
* @param id |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public StockTaking findStockTakingById(Integer id) { |
|||
return stockTakingMapper.selectStockTakingById(id); |
|||
} |
|||
|
|||
/** |
|||
* 根据主键查询主表 |
|||
* |
|||
* @param id |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public StockTaking findStockTakingById(Long id) { |
|||
return stockTakingMapper.selectStockTakingById(id); |
|||
} |
|||
|
|||
/** |
|||
* 根据主表获取所有子表 |
|||
* |
|||
* @param mainId |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public List<StockTakingChildP> findStockTakingChildPByMainId(Integer mainId) { |
|||
List<StockTakingChildP> stockTakingChildPS = stockTakingMapper.selectStockTakingChildByMainId(mainId); |
|||
for (int i = 0; i < stockTakingChildPS.size(); i++) { |
|||
StockTakingChildP stockTakingChildP = stockTakingChildPS.get(i); |
|||
if ("Inventory_up".equals(stockTakingChildP.getTakingResult())) { |
|||
stockTakingChildPS.get(i).setTakingResultShow("盘盈"); |
|||
} else if ("Inventory_down".equals(stockTakingChildP.getTakingResult())) { |
|||
stockTakingChildPS.get(i).setTakingResultShow("盘亏"); |
|||
} else { |
|||
stockTakingChildPS.get(i).setTakingResultShow("正常"); |
|||
} |
|||
} |
|||
return stockTakingChildPS; |
|||
} |
|||
|
|||
/** |
|||
* 根据主键获取子表 |
|||
* |
|||
* @param id |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public StockTakingChildP findStockTakingChildPById(Integer id) { |
|||
return stockTakingMapper.selectStockTakingChildPById(id); |
|||
} |
|||
|
|||
/** |
|||
* 用于对盘点进行审核 |
|||
* |
|||
* @param map |
|||
* @param userToken |
|||
* @return |
|||
*/ |
|||
@Transactional |
|||
@Override |
|||
public Map<String, Object> review(Map<String, Object> map, UserByPort userToken) { |
|||
|
|||
|
|||
Map<String, Object> result = new HashMap<>(); |
|||
|
|||
StringBuilder QyWxUid = new StringBuilder(); |
|||
Integer state = ObjectFormatUtil.toInteger(map.get("state")); |
|||
Object o = (map.get("mainId")); |
|||
Integer res = 0; |
|||
if (o == null) { |
|||
throw new MyException("缺少必要参数"); |
|||
} |
|||
String stockTakingResult = "驳回"; |
|||
// 获取主表编号
|
|||
Integer mainId = ObjectFormatUtil.toInteger(o); |
|||
// 获取主单
|
|||
StockTaking mainRecord = stockTakingMapper.selectStockTakingById(mainId); |
|||
|
|||
// 获取负责人
|
|||
String departmentManager = mainRecord.getDepartmentManager(); |
|||
String[] split = departmentManager.split(","); |
|||
for (int i = 0; i < split.length; i++) { |
|||
String s = split[i]; |
|||
if("".equals(s)){ |
|||
continue; |
|||
} |
|||
UserByPort userByPort = PageController.FindUserById(ObjectFormatUtil.toInteger(s), userToken); |
|||
QyWxUid.append(userByPort.getWorkwechat()).append(","); |
|||
} |
|||
if (Integer.compare(state, 1) == 0) { |
|||
// 如果审核通过
|
|||
stockTakingResult = "通过"; |
|||
|
|||
// 定义错误信息
|
|||
Map<String, Object> errMsg = new HashMap<>(); |
|||
// 定义出错单号
|
|||
List<Long> errIds = new ArrayList<>(); |
|||
// 定义出错信息
|
|||
List<String> err = new ArrayList<>(); |
|||
|
|||
Integer placeId = mainRecord.getPlaceId(); |
|||
// 获取库位详情
|
|||
Place placeById = placeMapper.findPlaceById(placeId); |
|||
Integer depositoryId = mainRecord.getDepositoryId(); |
|||
// 获取仓库详情
|
|||
Depository depositoryById = depositoryMapper.findDepositoryById(depositoryId); |
|||
|
|||
// 获取所有子单
|
|||
List<StockTakingChildP> minRecordList = stockTakingMapper.selectStockTakingChildByMainId(mainId); |
|||
for (int i = 0; i < minRecordList.size(); i++) { |
|||
// 获取子单详情
|
|||
StockTakingChildP minRecord = minRecordList.get(i); |
|||
// 获取盘点的物料详情
|
|||
|
|||
// 获取当前盘点结果
|
|||
String takingResult = minRecord.getTakingResult(); |
|||
if ("Inventory_normal".equals(takingResult)) { |
|||
// 如果盘点结果正常
|
|||
continue; |
|||
} |
|||
|
|||
// 获取盈亏数量
|
|||
Integer inventory = minRecord.getInventory(); |
|||
|
|||
|
|||
Material materialById = materialMapper.findMaterialById(minRecord.getMid()); |
|||
|
|||
Map<String, Object> paramForMaterialAndPlace = new HashMap<>(); |
|||
paramForMaterialAndPlace.put("mid", materialById.getId()); |
|||
paramForMaterialAndPlace.put("pid", placeById.getId()); |
|||
// 获取物料与库位的对应关系
|
|||
MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace); |
|||
|
|||
// 根据盘点结果重新计算物料的单价
|
|||
|
|||
// 数据库中的总额
|
|||
Double amounts = (materialById.getAmounts() / 100); |
|||
|
|||
Integer newInventory = minRecord.getNewInventory(); |
|||
Double avgPrice = 0.0; |
|||
if (Integer.compare(newInventory, 0) != 0) { |
|||
// 如果新的库存不是0
|
|||
|
|||
// 新的均价
|
|||
avgPrice = (amounts / newInventory) * 100; |
|||
} |
|||
|
|||
|
|||
materialById.setPrice(avgPrice); |
|||
|
|||
// 获取当前库位上物料数量
|
|||
Integer oldQuantity = materialById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity(); |
|||
|
|||
materialById.setQuantity(oldQuantity + newInventory); |
|||
|
|||
|
|||
|
|||
// 用于计算新的库位数量
|
|||
Integer newNumberForPlace = 0; |
|||
// 用于计算新的库位与物料对应关系的数量
|
|||
Integer newNumberForMatrialAndPlace = 0; |
|||
if ("Inventory_up".equals(takingResult)) { |
|||
// 如果盘盈
|
|||
|
|||
// 更新当前库位数量
|
|||
newNumberForPlace = placeById.getQuantity() + inventory; |
|||
|
|||
if (newNumberForPlace < placeById.getMax()) { |
|||
|
|||
// 如果更新后的库位数量没有上溢
|
|||
|
|||
// 更新当前库位的数量
|
|||
placeById.setQuantity(newNumberForPlace); |
|||
} else { |
|||
// 添加错误信息
|
|||
errIds.add(minRecord.getId()); |
|||
err.add("当前库位数量溢出,需要转移"); |
|||
|
|||
continue; |
|||
} |
|||
|
|||
newNumberForMatrialAndPlace = placeAndMaterialByMidAndPid.getQuantity() + inventory; |
|||
// 更新物料与库位对应关系的数量
|
|||
placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace); |
|||
|
|||
} else { |
|||
|
|||
// 如果盘亏
|
|||
newNumberForPlace = placeById.getQuantity() - inventory; |
|||
|
|||
if (newNumberForPlace > placeById.getMin()) { |
|||
//如果更新后的库位数量没有下溢
|
|||
|
|||
// 更新当前库位数量
|
|||
placeById.setQuantity(newNumberForPlace); |
|||
|
|||
// 更新物料与库位对应关系的数量
|
|||
newNumberForMatrialAndPlace = placeAndMaterialByMidAndPid.getQuantity() - inventory; |
|||
|
|||
} else { |
|||
placeById.setQuantity(0); |
|||
newNumberForMatrialAndPlace = 0; |
|||
} |
|||
|
|||
|
|||
placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace); |
|||
|
|||
} |
|||
|
|||
|
|||
// 更新库位
|
|||
placeMapper.UpdatePlace(placeById); |
|||
|
|||
|
|||
// 更新库位与物料的对应关系
|
|||
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|||
|
|||
|
|||
// 更新当前物料信息
|
|||
materialMapper.updateMaterial(materialById); |
|||
|
|||
} |
|||
|
|||
if (errIds.size() > 0) { |
|||
// 如果有出错的情况
|
|||
|
|||
errMsg.put("errIds", errIds); |
|||
errMsg.put("errMsg", err); |
|||
|
|||
result.put("errMsg", errMsg); |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
// 更新结果
|
|||
map.put("id", mainId); |
|||
String simpleTime = DateUtil.getSimpleTime(new Date()); |
|||
map.put("completeTime", DateUtil.DateTimeToTimeStamp(simpleTime)); |
|||
map.put("departmentManager",userToken.getId()); |
|||
stockTakingMapper.updateStockTaking(map); |
|||
|
|||
// 更新
|
|||
String finalStockTakingResult = stockTakingResult; |
|||
new Thread(new Runnable() { |
|||
@Override |
|||
public void run() { |
|||
// 获取responseCode(key为申请人number)
|
|||
//获取申请人信息
|
|||
String key = "user:"+userToken.getNumber()+":QyWxStockTakingId:"+mainId; |
|||
String responseCode = (String) redisTemplate.opsForHash().get(key, "responseCode"); |
|||
qyWxOperationService.updateTemplateCard(responseCode,userToken.getName(), finalStockTakingResult); |
|||
} |
|||
}).start(); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
/** |
|||
* 用于进行盘点结果转移 |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
@Transactional |
|||
@Override |
|||
public Integer stockTakingTransfer(Map<String, Object> map,UserByPort userToken) { |
|||
List<Integer> minIds = (List<Integer>) map.get("minIds"); |
|||
|
|||
Integer res = 0; |
|||
|
|||
// 获取对应主订单
|
|||
StockTaking mainRecord = null; |
|||
for (int i = 0; i < minIds.size(); i++) { |
|||
|
|||
Integer minId = minIds.get(i); |
|||
// 获取对应子订单
|
|||
StockTakingChildP minRecord = stockTakingMapper.selectStockTakingChildPById(minId); |
|||
|
|||
// 获取当前物料
|
|||
Material material = materialMapper.findMaterialById(minRecord.getMid()); |
|||
|
|||
// 获取对应主订单
|
|||
mainRecord = stockTakingMapper.selectStockTakingById(minRecord.getMainId()); |
|||
|
|||
// 获取转移数量
|
|||
Integer inventory = ObjectFormatUtil.toInteger(map.get("inventory")); |
|||
// 获取转移前的库位
|
|||
Integer oldPlaceId = ObjectFormatUtil.toInteger(mainRecord.getPlaceId()); |
|||
Place oldPlace = placeMapper.findPlaceById(oldPlaceId); |
|||
|
|||
|
|||
// 获取转移后的数量
|
|||
Integer newInventory = minRecord.getNewInventory() - inventory; |
|||
// 获取转移到的库位
|
|||
Integer newPlaceId = ObjectFormatUtil.toInteger(map.get("placeId")); |
|||
Place newPlace = placeMapper.findPlaceById(newPlaceId); |
|||
|
|||
|
|||
if(Integer.compare(newPlace.getDid(),oldPlace.getDid()) != 0){ |
|||
// 转移前后不在同一仓库
|
|||
|
|||
material.setQuantity(newInventory); |
|||
|
|||
// 进行物料转移
|
|||
|
|||
Map<String,Object> paramForMaterialToDepository = new HashMap<>(); |
|||
paramForMaterialToDepository.put("depositoryId",newPlace.getDid()); |
|||
paramForMaterialToDepository.put("code",material.getCode()); |
|||
|
|||
// 获取转移后的仓库中的该物料
|
|||
List<Material> materialByDepository = materialMapper.findInventory(paramForMaterialToDepository); |
|||
if(materialByDepository.size() > 0){ |
|||
// 如果转移后的仓库中存在该物料
|
|||
Material transferMaterial = materialByDepository.get(0); |
|||
|
|||
//获取物料与转移后库位的对应关系
|
|||
Map<String,Object> paramForMaterialAndPlace = new HashMap<>(); |
|||
paramForMaterialAndPlace.put("mid",transferMaterial.getId()); |
|||
paramForMaterialAndPlace.put("pid",newPlace.getId()); |
|||
MaterialAndPlace newPlaceAndMaterial = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace); |
|||
if(newPlaceAndMaterial == null){ |
|||
// 如果转移之后没有该物料
|
|||
paramForMaterialAndPlace.put("quantity",inventory); |
|||
placeMapper.addMaterialOnPlace(paramForMaterialAndPlace); |
|||
}else{ |
|||
// 如果转移之后有该物料
|
|||
newPlaceAndMaterial.setQuantity(newPlaceAndMaterial.getQuantity() + inventory); |
|||
placeMapper.updateMaterialAndPlace(newPlaceAndMaterial); |
|||
} |
|||
} |
|||
else{ |
|||
// 如果不存在
|
|||
Material mt = new Material(); |
|||
|
|||
|
|||
mt.setQuantity(inventory); |
|||
mt.setDepositoryId(newPlace.getDid()); |
|||
mt.setAmounts(inventory * material.getPrice()); |
|||
mt.setPrice(material.getPrice()); |
|||
mt.setMaterialTypeId(material.getMaterialTypeId()); |
|||
mt.setTexture(material.getTexture()); |
|||
mt.setUnit(material.getUnit()); |
|||
mt.setVersion(material.getVersion()); |
|||
mt.setMname(material.getMname()); |
|||
mt.setCode(material.getCode()); |
|||
mt.setState(material.getState()); |
|||
|
|||
materialMapper.insertMaterial(mt); |
|||
|
|||
// 添加当前物料与库位之间的映射
|
|||
Map<String,Object> paramForMaterialAndPlace = new HashMap<>(); |
|||
paramForMaterialAndPlace.put("mid",mt.getId()); |
|||
paramForMaterialAndPlace.put("pid",newPlace.getId()); |
|||
paramForMaterialAndPlace.put("quantity",newInventory); |
|||
placeMapper.addMaterialOnPlace(paramForMaterialAndPlace); |
|||
|
|||
} |
|||
|
|||
//获取物料与转移前库位的对应关系
|
|||
Map<String,Object> paramForMaterialAndPlace = new HashMap<>(); |
|||
paramForMaterialAndPlace.put("mid",material.getId()); |
|||
paramForMaterialAndPlace.put("pid",oldPlace.getId()); |
|||
MaterialAndPlace oldPlaceAndMaterial = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace); |
|||
if(oldPlaceAndMaterial == null){ |
|||
// 如果转移之前没有该物料
|
|||
paramForMaterialAndPlace.put("quantity",newInventory); |
|||
placeMapper.addMaterialOnPlace(paramForMaterialAndPlace); |
|||
} |
|||
else{ |
|||
// 如果转移之前有该物料
|
|||
oldPlaceAndMaterial.setQuantity(oldPlaceAndMaterial.getQuantity() + newInventory); |
|||
placeMapper.updateMaterialAndPlace(oldPlaceAndMaterial); |
|||
} |
|||
|
|||
|
|||
} |
|||
else{ |
|||
// 如果在同一仓库
|
|||
|
|||
// 更新物料容量
|
|||
material.setQuantity(minRecord.getNewInventory()); |
|||
|
|||
//获取物料与转移前库位的对应关系
|
|||
Map<String,Object> paramForMaterialAndPlace = new HashMap<>(); |
|||
paramForMaterialAndPlace.put("mid",material.getId()); |
|||
paramForMaterialAndPlace.put("pid",oldPlace.getId()); |
|||
MaterialAndPlace oldPlaceAndMaterial = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace); |
|||
if(oldPlaceAndMaterial == null){ |
|||
// 如果转移之前没有该物料
|
|||
paramForMaterialAndPlace.put("quantity",newInventory); |
|||
placeMapper.addMaterialOnPlace(paramForMaterialAndPlace); |
|||
}else{ |
|||
// 如果转移之前有该物料
|
|||
oldPlaceAndMaterial.setQuantity(oldPlaceAndMaterial.getQuantity() + newInventory); |
|||
placeMapper.updateMaterialAndPlace(oldPlaceAndMaterial); |
|||
} |
|||
|
|||
// 获取物料与转移后库位的对应关系
|
|||
paramForMaterialAndPlace.put("pid",newPlace.getId()); |
|||
MaterialAndPlace newPlaceAndMaterial = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace); |
|||
if(newPlaceAndMaterial == null){ |
|||
// 如果转移后没有该物料
|
|||
paramForMaterialAndPlace.put("quantity",inventory); |
|||
placeMapper.addMaterialOnPlace(paramForMaterialAndPlace); |
|||
}else{ |
|||
// 如果转移后有该物料
|
|||
newPlaceAndMaterial.setQuantity(newPlaceAndMaterial.getQuantity() + inventory); |
|||
placeMapper.updateMaterialAndPlace(newPlaceAndMaterial); |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
// 更新要转移的物料数据
|
|||
|
|||
res += materialMapper.updateMaterial(material); |
|||
|
|||
// 更新转移前库位数量
|
|||
oldPlace.setQuantity(oldPlace.getQuantity() + newInventory); |
|||
placeMapper.UpdatePlace(oldPlace); |
|||
// 更新转移后库位数量
|
|||
newPlace.setQuantity(newPlace.getQuantity() + inventory); |
|||
placeMapper.UpdatePlace(newPlace); |
|||
} |
|||
|
|||
// 开启一个线程用于发送抄送信息给盘点人员
|
|||
StockTaking finalMainRecord = mainRecord; |
|||
new Thread(new Runnable() { |
|||
@Override |
|||
public void run() { |
|||
Integer originator = finalMainRecord.getOriginator(); |
|||
StringBuilder departMentHeadQyWxName = new StringBuilder(); |
|||
UserByPort userByPort = PageController.FindUserById(ObjectFormatUtil.toInteger(originator), userToken); |
|||
// departMentHeadQyWxName.append(userByPort.getWorkwechat()+",");
|
|||
departMentHeadQyWxName.append("PangFuZhen,"); |
|||
JSONObject jsonObject = qyWxOperationService.sendCcStockTakingMessageToHead(departMentHeadQyWxName.toString(), map, userToken, finalMainRecord); |
|||
} |
|||
}).start(); |
|||
|
|||
/* // 开启一个线程用于发送抄送信息给盘点人员
|
|||
StockTaking finalMainRecord = mainRecord; |
|||
new Thread(new Runnable() { |
|||
@Override |
|||
public void run() { |
|||
String departmentManager = finalMainRecord.getDepartmentManager(); |
|||
String[] strings = departmentManager.split(","); |
|||
StringBuilder departMentHeadQyWxName = new StringBuilder(); |
|||
for (int j = 0; j < strings.length; j++) { |
|||
String s = strings[j]; |
|||
if("".equals(s)){ |
|||
continue; |
|||
} |
|||
UserByPort userByPort = PageController.FindUserById(ObjectFormatUtil.toInteger(s), userToken); |
|||
departMentHeadQyWxName.append(userByPort.getWorkwechat()+","); |
|||
} |
|||
JSONObject jsonObject = qyWxOperationService.sendCcStockTakingMessageToHead(departMentHeadQyWxName.toString(), map, userToken, finalMainRecord); |
|||
} |
|||
}).start();*/ |
|||
|
|||
|
|||
|
|||
return res; |
|||
} |
|||
|
|||
/** |
|||
* 用于企业微信的审核申请处理 |
|||
* @param templateCard |
|||
* @return |
|||
*/ |
|||
@Transactional |
|||
@Override |
|||
public Integer reviewByQyWx(TemplateCard templateCard) { |
|||
|
|||
|
|||
Map<String, Object> result = new HashMap<>(); |
|||
|
|||
|
|||
// 获取点击的按钮
|
|||
String clickKey = templateCard.getEventKey().split("_")[1]; |
|||
|
|||
// 点击用户
|
|||
String fromUserName = templateCard.getFromUserName(); |
|||
// 根据userId获取处理人
|
|||
Map<String, Object> portInfo = PortConfig.findUserByQyWxUserId(fromUserName); |
|||
UserByPort userByPort = (UserByPort) portInfo.get("user"); |
|||
|
|||
// 用于最终更新
|
|||
Map<String,Object> map = new HashMap<>(); |
|||
|
|||
// 获取主表编号
|
|||
String o = templateCard.getEventKey().split("wms_pass_StockTakingId")[1]; |
|||
Integer mainId = ObjectFormatUtil.toInteger(o); |
|||
|
|||
// 获取主单
|
|||
StockTaking mainRecord = stockTakingMapper.selectStockTakingById(mainId); |
|||
Integer state = 2; |
|||
if ("pass".equals(clickKey)) { |
|||
// 如果审核通过
|
|||
|
|||
state = 1; |
|||
// 定义错误信息
|
|||
Map<String, Object> errMsg = new HashMap<>(); |
|||
// 定义出错单号
|
|||
List<Long> errIds = new ArrayList<>(); |
|||
// 定义出错信息
|
|||
List<String> err = new ArrayList<>(); |
|||
|
|||
Integer placeId = mainRecord.getPlaceId(); |
|||
// 获取库位详情
|
|||
Place placeById = placeMapper.findPlaceById(placeId); |
|||
Integer depositoryId = mainRecord.getDepositoryId(); |
|||
// 获取仓库详情
|
|||
Depository depositoryById = depositoryMapper.findDepositoryById(depositoryId); |
|||
|
|||
// 获取所有子单
|
|||
List<StockTakingChildP> minRecordList = stockTakingMapper.selectStockTakingChildByMainId(mainId); |
|||
for (int i = 0; i < minRecordList.size(); i++) { |
|||
// 获取子单详情
|
|||
StockTakingChildP minRecord = minRecordList.get(i); |
|||
// 获取盘点的物料详情
|
|||
|
|||
// 获取当前盘点结果
|
|||
String takingResult = minRecord.getTakingResult(); |
|||
if ("Inventory_normal".equals(takingResult)) { |
|||
// 如果盘点结果正常
|
|||
continue; |
|||
} |
|||
|
|||
// 获取盈亏数量
|
|||
Integer inventory = minRecord.getInventory(); |
|||
|
|||
|
|||
Material materialById = materialMapper.findMaterialById(minRecord.getMid()); |
|||
|
|||
Map<String, Object> paramForMaterialAndPlace = new HashMap<>(); |
|||
paramForMaterialAndPlace.put("mid", materialById.getId()); |
|||
paramForMaterialAndPlace.put("pid", placeById.getId()); |
|||
// 获取物料与库位的对应关系
|
|||
MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace); |
|||
|
|||
// 根据盘点结果重新计算物料的单价
|
|||
|
|||
// 数据库中的总额
|
|||
Double amounts = (materialById.getAmounts() / 100); |
|||
|
|||
Integer newInventory = minRecord.getNewInventory(); |
|||
Double avgPrice = 0.0; |
|||
if (Integer.compare(newInventory, 0) != 0) { |
|||
// 如果新的库存不是0
|
|||
|
|||
// 新的均价
|
|||
avgPrice = (amounts / newInventory) * 100; |
|||
} |
|||
|
|||
|
|||
materialById.setPrice(avgPrice); |
|||
|
|||
// 获取当前库位上物料数量
|
|||
Integer oldQuantity = materialById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity(); |
|||
|
|||
materialById.setQuantity(oldQuantity + newInventory); |
|||
|
|||
|
|||
|
|||
// 用于计算新的库位数量
|
|||
Integer newNumberForPlace = 0; |
|||
// 用于计算新的库位与物料对应关系的数量
|
|||
Integer newNumberForMatrialAndPlace = 0; |
|||
if ("Inventory_up".equals(takingResult)) { |
|||
// 如果盘盈
|
|||
|
|||
// 更新当前库位数量
|
|||
newNumberForPlace = placeById.getQuantity() + inventory; |
|||
|
|||
if (newNumberForPlace < placeById.getMax()) { |
|||
|
|||
// 如果更新后的库位数量没有上溢
|
|||
|
|||
// 更新当前库位的数量
|
|||
placeById.setQuantity(newNumberForPlace); |
|||
} else { |
|||
// 添加错误信息
|
|||
errIds.add(minRecord.getId()); |
|||
err.add("当前库位数量溢出,需要转移"); |
|||
|
|||
continue; |
|||
} |
|||
|
|||
newNumberForMatrialAndPlace = placeAndMaterialByMidAndPid.getQuantity() + inventory; |
|||
// 更新物料与库位对应关系的数量
|
|||
placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace); |
|||
|
|||
} else { |
|||
|
|||
// 如果盘亏
|
|||
newNumberForPlace = placeById.getQuantity() - inventory; |
|||
|
|||
if (newNumberForPlace > placeById.getMin()) { |
|||
//如果更新后的库位数量没有下溢
|
|||
|
|||
// 更新当前库位数量
|
|||
placeById.setQuantity(newNumberForPlace); |
|||
|
|||
// 更新物料与库位对应关系的数量
|
|||
newNumberForMatrialAndPlace = placeAndMaterialByMidAndPid.getQuantity() - inventory; |
|||
|
|||
} else { |
|||
placeById.setQuantity(0); |
|||
newNumberForMatrialAndPlace = 0; |
|||
} |
|||
|
|||
|
|||
placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace); |
|||
|
|||
} |
|||
|
|||
|
|||
// 更新库位
|
|||
placeMapper.UpdatePlace(placeById); |
|||
|
|||
|
|||
// 更新库位与物料的对应关系
|
|||
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|||
|
|||
|
|||
// 更新当前物料信息
|
|||
materialMapper.updateMaterial(materialById); |
|||
|
|||
} |
|||
|
|||
if (errIds.size() > 0) { |
|||
// 如果有出错的情况
|
|||
|
|||
errMsg.put("errIds", errIds); |
|||
errMsg.put("errMsg", err); |
|||
|
|||
result.put("errMsg", errMsg); |
|||
} |
|||
|
|||
} |
|||
// 更新结果
|
|||
|
|||
map.put("id", mainId); |
|||
map.put("state",state); |
|||
String simpleTime = DateUtil.getSimpleTime(new Date()); |
|||
map.put("completeTime", DateUtil.DateTimeToTimeStamp(simpleTime)); |
|||
map.put("departmentManager",userByPort.getId()); |
|||
stockTakingMapper.updateStockTaking(map); |
|||
return 1; |
|||
} |
|||
|
|||
|
|||
public String createTakingCode(String depositoryName) { |
|||
String key = "wms_stockTakingNumber"; |
|||
RLock lock = redissonClient.getLock(key); |
|||
String first = "GK"; |
|||
// 获取仓库的首字母
|
|||
depositoryName = WordUtil.getPinYinHeadChar(depositoryName); |
|||
String nowTime = DateUtil.getNowTime(); |
|||
lock.lock(5, TimeUnit.SECONDS); |
|||
String orderNumber = redisTemplate.opsForValue().get(key); |
|||
if (orderNumber == null) { |
|||
redisTemplate.opsForValue().set(key, "1", DateUtil.getSecondsNextEarlyMorning(), TimeUnit.SECONDS); |
|||
orderNumber = "1"; |
|||
} |
|||
int newNumber = ObjectFormatUtil.toInteger(orderNumber) + 1; |
|||
redisTemplate.boundValueOps(key).set(String.valueOf(newNumber), DateUtil.getSecondsNextEarlyMorning(), TimeUnit.SECONDS); |
|||
lock.unlock(); |
|||
orderNumber = String.format("%09d", ObjectFormatUtil.toInteger(orderNumber)); |
|||
String code = first + depositoryName + nowTime + orderNumber; |
|||
return code; |
|||
} |
|||
} |
|||
@ -0,0 +1,350 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<title>仓库盘点</title> |
|||
<meta name="renderer" content="webkit"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=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/css/public.css" media="all"> |
|||
<link rel="stylesheet" href="/static/js/lay-module/step-lay/step.css" media="all"> |
|||
<style> |
|||
.inputdiv { |
|||
display: flex; |
|||
background-color: #fff; |
|||
height: 38px; |
|||
line-height: 38px; |
|||
border: 1px solid rgb(238, 238, 238); |
|||
} |
|||
|
|||
.layui-form-label { |
|||
padding: 9px 0px; |
|||
text-align: left; |
|||
} |
|||
|
|||
.layui-input-block { |
|||
margin-left: 80px; |
|||
} |
|||
|
|||
.layui-form-select { |
|||
width: 100%; |
|||
border-style: none; |
|||
} |
|||
|
|||
</style> |
|||
</head> |
|||
<body> |
|||
<div class="layuimini-container"> |
|||
<div class="layuimini-main"> |
|||
<div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto; "> |
|||
<div carousel-item style="overflow: inherit"> |
|||
<div> |
|||
<fieldset class="table-search-fieldset"> |
|||
<legend>库存盘点</legend> |
|||
<div class="layui-fluid"> |
|||
<div class="layui-card"> |
|||
<form class="layui-form" |
|||
style="margin: 0 auto;max-width: 700px;padding-top: 100px; padding-bottom: 200px" |
|||
lay-filter="form1" id="form1"> |
|||
<div class="layui-card-body" id="takingHeader" style="padding-right: 0px"> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">盘点位置:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" name="mainId" id="mainId" th:value="${mainRecord.getId()}" style="display:none;"> |
|||
<input type="text" class="layui-input" |
|||
th:value="${mainRecord.getDepositoryName()}" |
|||
style="border-style: none" |
|||
id="openSonByDepository" readonly |
|||
lay-verify="required"/> |
|||
<input type="text" name="depositoryId" class="layui-input" |
|||
id="depositoryId" th:value="${mainRecord.getDepositoryId()}" |
|||
style="display: none" lay-verify="required"/> |
|||
<input type="text" name="placeId" class="layui-input" id="placeId" |
|||
th:value="${mainRecord.getPlaceId()}" |
|||
style="display: none" lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">负责人:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请选择负责人" class="layui-input" |
|||
id="departmentManager" readonly |
|||
th:value="${mainRecord.getDepartmentManagerName()}" |
|||
lay-verify="required"/> |
|||
<input type="text" id="departmentManagerId" name="departmentManagerId" |
|||
th:value="${mainRecord.getDepartmentManager()}" |
|||
class="layui-input" style="display: none" lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">发起人:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请选择负责人" class="layui-input" |
|||
id="originatorName" readonly |
|||
th:value="${mainRecord.getOriginatorName()}" |
|||
lay-verify="required"/> |
|||
<input type="text" id="originator" name="departmentManagerId" |
|||
th:value="${mainRecord.getOriginator()}" |
|||
class="layui-input" style="display: none" lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<fieldset class="table-search-fieldset"> |
|||
<legend>盘点明细</legend> |
|||
<div class="layui-card-body" id="InventoryDetails" style="padding-right: 0px"> |
|||
<hr> |
|||
|
|||
<div class="layui-collapse" lay-accordion> |
|||
<div class="layui-colla-item" |
|||
th:each="recordMin,iterStar:${recordChild}"> |
|||
<h2 class="layui-colla-title" |
|||
th:text="${recordMin.getMname()}"></h2> |
|||
<div class="layui-colla-content"> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">物料编码:</label> |
|||
<div class="layui-input-block" style="margin: 0px;"> |
|||
<div class="inputdiv"> |
|||
<input th:attr="name='code' +${recordMin.getId()},id='code'+${recordMin.getId()}" |
|||
type="text" placeholder="请填写入物料编码" |
|||
th:value="${recordMin.getMcode()}" |
|||
class="layui-input" lay-verify="required" |
|||
style="border-style: none"> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">条形编码:</label> |
|||
<div class="layui-input-block" style="margin: 0px;"> |
|||
<div class="inputdiv"> |
|||
<select |
|||
th:attr="id='barCode'+${recordMin.getId()},name='barCode'+${recordMin.getId()}" |
|||
style="border-style: none"> |
|||
|
|||
</select> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">物料类型:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请选择物料类型" |
|||
class="layui-input" |
|||
th:value="${recordMin.getTname()}" |
|||
th:attr="id='openSonByMateralType'+${recordMin.getId()}" |
|||
readonly |
|||
lay-verify="required"/> |
|||
<input type="text" |
|||
th:value="${recordMin.getMtId()}" |
|||
th:attr="id='materialTypeId'+${recordMin.getId()},name='typeId'+${recordMin.getId()}" |
|||
placeholder="请选择物料类型" class="layui-input" |
|||
style="display: none" lay-verify="required"/> |
|||
|
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">材质:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请填写材质名称" |
|||
class="layui-input" |
|||
th:value="${recordMin.getMtexture()}" |
|||
th:attr="id='texture'+${recordMin.getId()},name='texture'+${recordMin.getId()}" |
|||
/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">规格型号:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请填写规格型号" |
|||
class="layui-input" |
|||
th:value="${recordMin.getMversion()}" |
|||
th:attr="id='version'+${recordMin.getId()},name='version'+${recordMin.getId()}" |
|||
/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">计量单位:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请填写计量单位" |
|||
class="layui-input" |
|||
th:value="${recordMin.getMunit()}" |
|||
th:attr="id='unit'+${recordMin.getId()},name='unit'+${recordMin.getId()}" |
|||
/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">库存数量:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="number" class="layui-input" readonly |
|||
th:value="${recordMin.getOldInventory()}" |
|||
th:attr="id='oldInventory'+${recordMin.getId()},name='oldInventory'+${recordMin.getId()}" |
|||
lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">盘点数量:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="number" class="layui-input" |
|||
th:value="${recordMin.getNewInventory()}" |
|||
th:attr="id='newInventory'+${recordMin.getId()},name='newInventory'+${recordMin.getId()}" |
|||
lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">盘点结果:</label> |
|||
<div class="layui-input-block"> |
|||
|
|||
<input type="text" class="layui-input" id="takingResult" |
|||
th:value="${recordMin.getTakingResultShow()}" |
|||
th:attr="id='takingResult'+${recordMin.getId()},name='takingResult'+${recordMin.getId()}" |
|||
lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">盈亏数量:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="number" class="layui-input" readonly |
|||
|
|||
th:value="${recordMin.getInventory()}" |
|||
th:attr="id='inventory'+${recordMin.getId()},name='inventory'+${recordMin.getId()}" |
|||
lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</fieldset> |
|||
|
|||
<div id="review"> |
|||
<div class="layui-form" style="margin: 0 auto;max-width: 900px;padding-top: 40px;"> |
|||
|
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">审核备注:</label> |
|||
<div class="layui-input-block"> |
|||
<textarea id="auditOpinion" name="auditOpinion" placeholder="请填写相关原因及申请原因" value="" class="layui-textarea"></textarea> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<div class="layui-input-block"> |
|||
<button type="button" class="layui-btn" onclick="review(1)"> |
|||
 审核通过  |
|||
</button> |
|||
<button type="button" class="layui-btn layui-btn-danger" onclick="review(2)"> |
|||
 审核不通过  |
|||
</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
</div> |
|||
</fieldset> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
|||
<script src="/static/js/lay-config.js?v=1.0.4" charset="utf-8"></script> |
|||
<script> |
|||
|
|||
function review(data){} |
|||
layui.use(['form','step','element'], function () { |
|||
var $ = layui.$, |
|||
step = layui.step, |
|||
element = layui.element, |
|||
form = layui.form; |
|||
|
|||
var position=0,states={},number = 2; |
|||
states = [ {title: "待审核"}]; |
|||
// 用于分步表单加载 |
|||
step.render({ |
|||
elem: '#stepForm', |
|||
filter: 'stepForm', |
|||
width: '100%', //设置容器宽度 |
|||
stepWidth: '750px', |
|||
height: '1495px', |
|||
position: position, |
|||
number:number, |
|||
stepItems: states |
|||
}); |
|||
|
|||
|
|||
|
|||
// 用于获取审核结果与审核的单号 |
|||
review=function (pass) { |
|||
let data = {}; |
|||
data.mainId = $("#mainId").val(); |
|||
data.auditOpinion = $("#auditOpinion").val(); |
|||
data.state = pass; |
|||
|
|||
$.ajax({ |
|||
url:"/stockTaking/review", |
|||
type:'post', |
|||
dataType:'json', |
|||
contentType: "application/json;charset=utf-8", |
|||
data:JSON.stringify(data), |
|||
beforeSend:function () { |
|||
this.layerIndex = layer.load(0, { shade: [0.5, '#393D49'] }); |
|||
}, |
|||
success:function(d){ |
|||
layer.close(this.layerIndex); |
|||
if(d.status >= 300){ |
|||
var errMsg = d.data.errMsg; |
|||
// 获取出错的子订单 |
|||
layer.confirm("当前盘点数量中有溢出情况,需要进行转移", { |
|||
btn:["确定"] |
|||
},function () { // 继续 |
|||
layer.open({ |
|||
type: 2, |
|||
title: '转移物料', |
|||
skin: 'layui-layer-rim', |
|||
maxmin: true, |
|||
shadeClose: true, //点击遮罩关闭层 |
|||
area: ['70%', '70%'], |
|||
move: '.layui-layer-title', |
|||
fixed: false, |
|||
content: '/stockTakingTransfer?minIds='+errMsg.errIds, |
|||
end: function (res) { |
|||
if(res.status >= 300){ |
|||
layer.msg("提交失败,联系开发人员解决", { |
|||
icon: 5,//成功的表情 |
|||
time: 500 //1秒关闭(如果不配置,默认是3秒) |
|||
}, function(){ |
|||
window.location = '/StockTakingView?id='+data.mainId; |
|||
}); |
|||
}else{ |
|||
layer.msg("提交成功", { |
|||
icon: 6,//成功的表情 |
|||
time: 500 //1秒关闭(如果不配置,默认是3秒) |
|||
}, function(){ |
|||
window.location = '/StockTakingView?id='+data.mainId; |
|||
}); |
|||
} |
|||
} |
|||
}); |
|||
}); |
|||
|
|||
|
|||
} |
|||
else{ |
|||
layer.msg("提交成功", { |
|||
icon: 6,//成功的表情 |
|||
time: 500 //1秒关闭(如果不配置,默认是3秒) |
|||
}, function(){ |
|||
window.location = '/StockTakingView?id='+data.mainId; |
|||
}); |
|||
} |
|||
}, |
|||
}) |
|||
|
|||
}; |
|||
|
|||
}); |
|||
|
|||
</script> |
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,291 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<title>仓库盘点</title> |
|||
<meta name="renderer" content="webkit"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=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/css/public.css" media="all"> |
|||
<link rel="stylesheet" href="/static/js/lay-module/step-lay/step.css" media="all"> |
|||
<style> |
|||
.inputdiv { |
|||
display: flex; |
|||
background-color: #fff; |
|||
height: 38px; |
|||
line-height: 38px; |
|||
border: 1px solid rgb(238, 238, 238); |
|||
} |
|||
|
|||
.layui-form-label { |
|||
padding: 9px 0px; |
|||
text-align: left; |
|||
} |
|||
|
|||
.layui-input-block { |
|||
margin-left: 80px; |
|||
} |
|||
|
|||
.layui-form-select { |
|||
width: 100%; |
|||
border-style: none; |
|||
} |
|||
|
|||
</style> |
|||
</head> |
|||
<body> |
|||
<div class="layuimini-container"> |
|||
<div class="layuimini-main"> |
|||
<div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto; "> |
|||
<div carousel-item style="overflow: inherit"> |
|||
<div> |
|||
<fieldset class="table-search-fieldset"> |
|||
<legend>库存盘点</legend> |
|||
<div class="layui-fluid"> |
|||
<div class="layui-card"> |
|||
<form class="layui-form" |
|||
style="margin: 0 auto;max-width: 700px;padding-top: 100px; padding-bottom: 200px" |
|||
lay-filter="form1" id="form1"> |
|||
<div class="layui-card-body" id="takingHeader" style="padding-right: 0px"> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">盘点位置:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" name="mainId" th:value="${mainRecord.getId()}" style="display:none;"> |
|||
<input type="text" class="layui-input" |
|||
th:value="${mainRecord.getDepositoryName()}" |
|||
style="border-style: none" |
|||
id="openSonByDepository" readonly |
|||
lay-verify="required"/> |
|||
<input type="text" name="depositoryId" class="layui-input" |
|||
id="depositoryId" th:value="${mainRecord.getDepositoryId()}" |
|||
style="display: none" lay-verify="required"/> |
|||
<input type="text" name="placeId" class="layui-input" id="placeId" |
|||
th:value="${mainRecord.getPlaceId()}" |
|||
style="display: none" lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">负责人:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请选择负责人" class="layui-input" |
|||
id="departmentManager" readonly |
|||
th:value="${mainRecord.getDepartmentManagerName()}" |
|||
lay-verify="required"/> |
|||
<input type="text" id="departmentManagerId" name="departmentManagerId" |
|||
th:value="${mainRecord.getDepartmentManager()}" |
|||
class="layui-input" style="display: none" lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">发起人:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请选择负责人" class="layui-input" |
|||
id="originatorName" readonly |
|||
th:value="${mainRecord.getOriginatorName()}" |
|||
lay-verify="required"/> |
|||
<input type="text" id="originator" name="departmentManagerId" |
|||
th:value="${mainRecord.getOriginator()}" |
|||
class="layui-input" style="display: none" lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<fieldset class="table-search-fieldset"> |
|||
<legend>盘点明细</legend> |
|||
<div class="layui-card-body" id="InventoryDetails" style="padding-right: 0px"> |
|||
<hr> |
|||
|
|||
<div class="layui-collapse" lay-accordion> |
|||
<div class="layui-colla-item" |
|||
th:each="recordMin,iterStar:${recordChild}"> |
|||
<h2 class="layui-colla-title" |
|||
th:text="${recordMin.getMname()}"></h2> |
|||
<div class="layui-colla-content"> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">物料编码:</label> |
|||
<div class="layui-input-block" style="margin: 0px;"> |
|||
<div class="inputdiv"> |
|||
<input th:attr="name='code' +${recordMin.getId()},id='code'+${recordMin.getId()}" |
|||
type="text" placeholder="请填写入物料编码" |
|||
th:value="${recordMin.getMcode()}" |
|||
class="layui-input" lay-verify="required" |
|||
style="border-style: none"> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">条形编码:</label> |
|||
<div class="layui-input-block" style="margin: 0px;"> |
|||
<div class="inputdiv"> |
|||
<select |
|||
th:attr="id='barCode'+${recordMin.getId()},name='barCode'+${recordMin.getId()}" |
|||
style="border-style: none"> |
|||
|
|||
</select> |
|||
|
|||
</select> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">物料类型:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请选择物料类型" |
|||
class="layui-input" |
|||
th:value="${recordMin.getTname()}" |
|||
th:attr="id='openSonByMateralType'+${recordMin.getId()}" |
|||
readonly |
|||
lay-verify="required"/> |
|||
<input type="text" |
|||
th:value="${recordMin.getMtId()}" |
|||
th:attr="id='materialTypeId'+${recordMin.getId()},name='typeId'+${recordMin.getId()}" |
|||
placeholder="请选择物料类型" class="layui-input" |
|||
style="display: none" lay-verify="required"/> |
|||
|
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">材质:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请填写材质名称" |
|||
class="layui-input" |
|||
th:value="${recordMin.getMtexture()}" |
|||
th:attr="id='texture'+${recordMin.getId()},name='texture'+${recordMin.getId()}" |
|||
/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">规格型号:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请填写规格型号" |
|||
class="layui-input" |
|||
th:value="${recordMin.getMversion()}" |
|||
th:attr="id='version'+${recordMin.getId()},name='version'+${recordMin.getId()}" |
|||
/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">计量单位:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请填写计量单位" |
|||
class="layui-input" |
|||
th:value="${recordMin.getMunit()}" |
|||
th:attr="id='unit'+${recordMin.getId()},name='unit'+${recordMin.getId()}" |
|||
/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">库存数量:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="number" class="layui-input" readonly |
|||
th:value="${recordMin.getOldInventory()}" |
|||
th:attr="id='oldInventory'+${recordMin.getId()},name='oldInventory'+${recordMin.getId()}" |
|||
lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">盘点数量:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="number" class="layui-input" |
|||
th:value="${recordMin.getNewInventory()}" |
|||
th:attr="id='newInventory'+${recordMin.getId()},name='newInventory'+${recordMin.getId()}" |
|||
lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">盘点结果:</label> |
|||
<div class="layui-input-block"> |
|||
|
|||
<input type="text" class="layui-input" id="takingResult" |
|||
th:value="${recordMin.getTakingResultShow()}" |
|||
th:attr="id='takingResult'+${recordMin.getId()},name='takingResult'+${recordMin.getId()}" |
|||
lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">盈亏数量:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="number" class="layui-input" readonly |
|||
|
|||
th:value="${recordMin.getInventory()}" |
|||
th:attr="id='inventory'+${recordMin.getId()},name='inventory'+${recordMin.getId()}" |
|||
lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</fieldset> |
|||
|
|||
<div class="layui-card-body" id="takingFooter" style="padding-right: 0px;display: none"> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">处理时间:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" id="completeTime" class="layui-input" th:value="${mainRecord.getCompleteTime()}" readonly> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">审核意见:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="" class="layui-input" |
|||
readonly |
|||
th:value="${mainRecord.getAuditOpinion()}" |
|||
lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
</div> |
|||
</fieldset> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
|||
<script src="/static/js/lay-config.js?v=1.0.4" charset="utf-8"></script> |
|||
<script> |
|||
|
|||
|
|||
layui.use(['form', 'flow','step','element'], function () { |
|||
var $ = layui.$, |
|||
step = layui.step, |
|||
element = layui.element, |
|||
form = layui.form; |
|||
|
|||
var position=0,states={},number = 2; |
|||
|
|||
var ifShow = ($("#completeTime").val() === ""); |
|||
|
|||
|
|||
console.log($("#completeTime").val()) |
|||
console.log(ifShow) |
|||
if(ifShow){ |
|||
// 如果还未处理 |
|||
states = [ {title: "待审核"}]; |
|||
}else{ |
|||
$("#takingFooter").show(); |
|||
states = [{title: "已处理"}] |
|||
} |
|||
|
|||
|
|||
// 用于分步表单加载 |
|||
step.render({ |
|||
elem: '#stepForm', |
|||
filter: 'stepForm', |
|||
width: '100%', //设置容器宽度 |
|||
stepWidth: '750px', |
|||
height: '1300px', |
|||
position: position, |
|||
number:number, |
|||
stepItems: states |
|||
}); |
|||
|
|||
}); |
|||
|
|||
</script> |
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,395 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<title>仓库盘点</title> |
|||
<meta name="renderer" content="webkit"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=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/css/public.css" media="all"> |
|||
<link rel="stylesheet" href="/static/js/lay-module/step-lay/step.css" media="all"> |
|||
<style> |
|||
.inputdiv { |
|||
display: flex; |
|||
background-color: #fff; |
|||
height: 38px; |
|||
line-height: 38px; |
|||
border: 1px solid rgb(238, 238, 238); |
|||
} |
|||
|
|||
.layui-form-label { |
|||
padding: 9px 0px; |
|||
text-align: left; |
|||
} |
|||
|
|||
.layui-input-block { |
|||
margin-left: 80px; |
|||
} |
|||
|
|||
.layui-form-select { |
|||
width: 100%; |
|||
border-style: none; |
|||
} |
|||
|
|||
</style> |
|||
</head> |
|||
<body> |
|||
<div class="layuimini-container"> |
|||
<div class="layuimini-main"> |
|||
<div> |
|||
<fieldset class="table-search-fieldset"> |
|||
<legend>转移盘点</legend> |
|||
<div class="layui-fluid"> |
|||
<div class="layui-card"> |
|||
<form class="layui-form" |
|||
style="margin: 0 auto;max-width: 700px;padding-top: 100px; padding-bottom: 200px" |
|||
lay-filter="form1" id="form1"> |
|||
<div class="layui-card-body" id="takingHeader" style="padding-right: 0px"> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">转移位置:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" id="minIds" name="minIds" th:value="${minIds}" style="display:none;"> |
|||
<input type="text" name="mainId" id="mainId" th:value="${mainRecord.getId()}" |
|||
style="display:none;"> |
|||
<input type="text" class="layui-input" |
|||
id="openSonByDepository" readonly |
|||
lay-verify="required"/> |
|||
<input type="text" name="depositoryId" class="layui-input" |
|||
id="depositoryId" |
|||
style="display: none" lay-verify="required"/> |
|||
<input type="text" name="placeId" class="layui-input" id="placeId" |
|||
style="display: none" lay-verify="required"/> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<fieldset class="table-search-fieldset"> |
|||
<legend>转移明细</legend> |
|||
<div class="layui-card-body" id="InventoryDetails" style="padding-right: 0px"> |
|||
<hr> |
|||
|
|||
<div class="layui-collapse" lay-accordion> |
|||
<div class="layui-colla-item" |
|||
th:each="recordMin,iterStar:${recordChild}"> |
|||
<h2 class="layui-colla-title" |
|||
th:text="${recordMin.getMname()}"></h2> |
|||
<div class="layui-colla-content"> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">物料编码:</label> |
|||
<div class="layui-input-block" style="margin: 0px;"> |
|||
<div class="inputdiv"> |
|||
<input th:attr="name='code' +${recordMin.getId()},id='code'+${recordMin.getId()}" |
|||
type="text" placeholder="请填写入物料编码" |
|||
th:value="${recordMin.getMcode()}" |
|||
class="layui-input" lay-verify="required" |
|||
style="border-style: none"> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">条形编码:</label> |
|||
<div class="layui-input-block" style="margin: 0px;"> |
|||
<div class="inputdiv"> |
|||
<select |
|||
th:attr="id='barCode'+${recordMin.getId()},name='barCode'+${recordMin.getId()}" |
|||
style="border-style: none"> |
|||
|
|||
</select> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">物料类型:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请选择物料类型" |
|||
class="layui-input" |
|||
th:value="${recordMin.getTname()}" |
|||
th:attr="id='openSonByMateralType'+${recordMin.getId()}" |
|||
readonly |
|||
lay-verify="required"/> |
|||
<input type="text" |
|||
th:value="${recordMin.getMtId()}" |
|||
th:attr="id='materialTypeId'+${recordMin.getId()},name='typeId'+${recordMin.getId()}" |
|||
placeholder="请选择物料类型" class="layui-input" |
|||
style="display: none" lay-verify="required"/> |
|||
|
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">材质:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请填写材质名称" |
|||
class="layui-input" |
|||
th:value="${recordMin.getMtexture()}" |
|||
th:attr="id='texture'+${recordMin.getId()},name='texture'+${recordMin.getId()}" |
|||
/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">规格型号:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请填写规格型号" |
|||
class="layui-input" |
|||
th:value="${recordMin.getMversion()}" |
|||
th:attr="id='version'+${recordMin.getId()},name='version'+${recordMin.getId()}" |
|||
/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">计量单位:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" placeholder="请填写计量单位" |
|||
class="layui-input" |
|||
th:value="${recordMin.getMunit()}" |
|||
th:attr="id='unit'+${recordMin.getId()},name='unit'+${recordMin.getId()}" |
|||
/> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">盘点数量:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="number" class="layui-input" |
|||
th:value="${recordMin.getNewInventory()}" |
|||
th:attr="id='newInventory'+${recordMin.getId()},name='newInventory'+${recordMin.getId()}" |
|||
readonly |
|||
lay-verify="required"/> |
|||
|
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">转移数量:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="number" class="layui-input" |
|||
th:value="${recordMin.getInventory()}" |
|||
th:attr="id='invnetory'+${recordMin.getId()},name='invnetory'+${recordMin.getId()}" |
|||
onblur="checkNumber(this)" |
|||
lay-verify="required"/> |
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</fieldset> |
|||
|
|||
<div class="layui-card-body" id="takingFooter" style="padding-right: 0px"> |
|||
<div class="layui-form-item"> |
|||
<div class="layui-input-block"> |
|||
<button class="layui-btn" lay-submit lay-filter="formStep"> |
|||
 提交  |
|||
</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
</div> |
|||
</fieldset> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
|||
<script src="/static/js/lay-config.js?v=1.0.4" charset="utf-8"></script> |
|||
<script> |
|||
|
|||
|
|||
// 用于扫描条形码或二维码 |
|||
function scanCode(obj) { |
|||
} |
|||
|
|||
// 用于盘点当前转移数量是否合适 |
|||
function checkNumber(obj) { |
|||
|
|||
} |
|||
|
|||
|
|||
// 用于暂存卡片个数 |
|||
let params = []; |
|||
|
|||
// 用于存储当前选择的盘点位置 |
|||
let depositoryId; |
|||
let placeId; |
|||
|
|||
|
|||
//用于存储当前最小转移量 |
|||
let minTransferNum = {}; |
|||
|
|||
let minIds = []; |
|||
layui.use(['form', 'flow'], function () { |
|||
var $ = layui.$, |
|||
form = layui.form; |
|||
|
|||
var minRecordIds = $("#minIds").val(); |
|||
let split = minRecordIds.split(","); |
|||
for (let i = 0; i < split.length; i++) { |
|||
var s = split[i]; |
|||
if ("" === s) { |
|||
continue; |
|||
} |
|||
minIds.push(Number(s)); |
|||
minTransferNum["invnetory" + s] = ($("#invnetory" + s).val()); |
|||
} |
|||
// 用于打开仓库树形菜单 |
|||
$('#openSonByDepository').on('click', function () { |
|||
layer.open({ |
|||
type: 2, |
|||
title: '弹窗内容', |
|||
skin: 'layui-layer-rim', |
|||
maxmin: true, |
|||
shadeClose: true, //点击遮罩关闭层 |
|||
area: ['70%', '70%'], |
|||
move: '.layui-layer-title', |
|||
fixed: false, |
|||
content: '/selectDepository?type=2', |
|||
end: function () { |
|||
var nowDepositoryId = $("#depositoryId").val(); |
|||
var nowPlaceId = $("#placeId").val(); |
|||
if (nowDepositoryId !== depositoryId || nowPlaceId !== placeId) { |
|||
// 如果重新选择盘点位置 |
|||
var nowDepositoryName = $("#openSonByDepository").val(); |
|||
$("#form1")[0].reset(); |
|||
$("#depositoryId").val(nowDepositoryId); |
|||
$("#placeId").val(nowPlaceId); |
|||
$("#openSonByDepository").val(nowDepositoryName); |
|||
form.render(); |
|||
} |
|||
depositoryId = nowDepositoryId; |
|||
placeId = nowPlaceId; |
|||
|
|||
} |
|||
}); |
|||
}); |
|||
|
|||
|
|||
// 用于提交盘点转移情况 |
|||
form.on('submit(formStep)', function (data) { |
|||
if (depositoryId !== null && depositoryId !== undefined && depositoryId !== "") { |
|||
data = data.field; |
|||
$.ajax({ |
|||
url: "/stockTaking/stockTransfer", |
|||
type: 'post', |
|||
dataType: 'json', |
|||
contentType: "application/json;charset=utf-8", |
|||
data: JSON.stringify(data), |
|||
beforeSend: function () { |
|||
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); |
|||
}, |
|||
success: function (data) { |
|||
layer.msg("申请提交成功", { |
|||
icon: 6,//成功的表情 |
|||
time: 500 //1秒关闭(如果不配置,默认是3秒) |
|||
}, function () { |
|||
step.next('#stepForm'); |
|||
}); |
|||
}, |
|||
complete: function () { |
|||
layer.close(this.layerIndex); |
|||
} |
|||
}); |
|||
} else { |
|||
layer.msg("请先选择盘点位置", { |
|||
icon: 0, |
|||
time: 500 |
|||
}) |
|||
} |
|||
}); |
|||
|
|||
//删除数组中指定元素 |
|||
function remove(arr, item) { |
|||
var result = []; |
|||
for (let i = 0; i < arr.length; i++) { |
|||
if (arr[i] === item) { |
|||
continue; |
|||
} |
|||
result.push(arr[i]); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
|
|||
// 扫码盘点位置 |
|||
scanCode = function () { |
|||
layer.open({ |
|||
type: 2, |
|||
title: '弹窗内容', |
|||
skin: 'layui-layer-rim', |
|||
maxmin: true, |
|||
shadeClose: true, //点击遮罩关闭层 |
|||
area: ['100%', '100%'], |
|||
move: '.layui-layer-title', |
|||
fixed: false, |
|||
content: '/scanCodeByTaking', |
|||
end: function () { |
|||
var nowDepositoryId = $("#depositoryId").val(); |
|||
var nowPlaceId = $("#placeId").val(); |
|||
if (nowDepositoryId !== depositoryId || nowPlaceId !== placeId) { |
|||
// 如果重新选择盘点位置 |
|||
var nowDepositoryName = $("#openSonByDepository").val(); |
|||
$("#form1")[0].reset(); |
|||
$("#depositoryId").val(nowDepositoryId); |
|||
$("#placeId").val(nowPlaceId); |
|||
$("#openSonByDepository").val(nowDepositoryName); |
|||
form.render(); |
|||
} |
|||
depositoryId = nowDepositoryId; |
|||
placeId = nowPlaceId; |
|||
|
|||
} |
|||
}); |
|||
}; |
|||
|
|||
|
|||
// 用于判断当前数量是否合适 |
|||
checkNumber = function (obj) { |
|||
var id = obj.id; |
|||
var oldNumber = Number(minTransferNum[id]); |
|||
if (depositoryId !== null && depositoryId !== undefined && depositoryId !== "") { |
|||
var req = {}; |
|||
req.depositoryId = depositoryId; |
|||
req.placeId = placeId; |
|||
$.ajax({ |
|||
url: "/stockTaking/findInventoryByLocation", |
|||
type: 'post', |
|||
dataType: 'json', |
|||
contentType: "application/json;charset=utf-8", |
|||
data: JSON.stringify(req), |
|||
success: function (d) { |
|||
var data = d.data; |
|||
var placeInventory = data.inventory; |
|||
id = id.split("invnetory")[1]; |
|||
var number = Number(obj.value); |
|||
var inventory = Number($("#newInventory" + id).val()); |
|||
if (number < oldNumber) { |
|||
layer.msg("转移数量不能小于" + oldNumber); |
|||
obj.value = oldNumber; |
|||
} |
|||
if (number > inventory) { |
|||
layer.msg("转移数量不能大于当前盘点数量:" + inventory); |
|||
obj.value = oldNumber; |
|||
} |
|||
if(number > placeInventory){ |
|||
layer.msg("当前转移库位只能存放:" + placeInventory+"的物料"); |
|||
obj.value = oldNumber; |
|||
} |
|||
} |
|||
|
|||
}) |
|||
} else { |
|||
layer.msg("请先选择盘点位置", { |
|||
icon: 0, |
|||
time: 500 |
|||
}, function () { |
|||
obj.value = oldNumber; |
|||
}) |
|||
} |
|||
} |
|||
|
|||
|
|||
}); |
|||
|
|||
</script> |
|||
</body> |
|||
</html> |
|||
Loading…
Reference in new issue