Browse Source

修改库存盘点处理功能

lwx_dev
erdanergou 3 years ago
parent
commit
eb96f1a7bf
  1. 34
      src/main/java/com/dreamchaser/depository_manage/controller/PageController.java
  2. 2
      src/main/java/com/dreamchaser/depository_manage/controller/StockTakingController.java
  3. 5
      src/main/java/com/dreamchaser/depository_manage/entity/StockTaking.java
  4. 33
      src/main/java/com/dreamchaser/depository_manage/mapper/StockTakingMapper.xml
  5. 6
      src/main/java/com/dreamchaser/depository_manage/pojo/StockTakingChildP.java
  6. 1
      src/main/java/com/dreamchaser/depository_manage/pojo/StockTakingP.java
  7. 47
      src/main/java/com/dreamchaser/depository_manage/service/impl/QyWxOperationService.java
  8. 124
      src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java
  9. 51
      src/main/resources/templates/pages/stockTaking/stockTaking.html
  10. 9
      src/main/resources/templates/pages/stockTaking/stockTakingComplete.html
  11. 33
      target/classes/com/dreamchaser/depository_manage/mapper/StockTakingMapper.xml
  12. 51
      target/classes/templates/pages/stockTaking/stockTaking.html
  13. 9
      target/classes/templates/pages/stockTaking/stockTakingComplete.html

34
src/main/java/com/dreamchaser/depository_manage/controller/PageController.java

@ -330,7 +330,7 @@ public class PageController {
Map<String, Object> paramForTask = new HashMap<>();
paramForTask.put("isDone", 0);
paramForTask.put("userId", userToken.getId());
paramForTask.put("departmentHead", userToken.getNumber());
// 定义任务列表
List<SimpleTaskP> list = new ArrayList<>();
@ -1268,6 +1268,7 @@ public class PageController {
/**
* 用于跳转到仓库管理员
*
* @param id
* @return
*/
@ -1281,6 +1282,7 @@ public class PageController {
/**
* 用于跳转到入库申请审核时的赋权
*
* @param id
* @return
*/
@ -1597,8 +1599,6 @@ public class PageController {
}
@GetMapping("/form_step_lookByminRecordOut")
public ModelAndView form_step_lookByminRecordOut(Integer id, HttpServletRequest request) {
UserByPort userToken = (UserByPort) request.getAttribute("userToken");
@ -1866,28 +1866,20 @@ public class PageController {
// 负责人姓名
StringBuilder managerName = new StringBuilder();
String[] split = stp.getDepartmentManager().split(",");
for (int i = 0; i < split.length; i++) {
String s = split[i];
for (String s : split) {
if ("".equals(s)) {
continue;
}
UserByPort manager = PortConfig.findUserByPortByNumber(s);
managerName.append(manager.getName() + ",");
managerName.append(manager.getName()).append(",");
}
stp.setDepartmentManagerName(managerName.toString());
// 获取盘点位置
Integer placeId = stockTaking.getPlaceId();
StringBuilder location = new StringBuilder();
Depository depository = depositoryService.findDepositoryById(stockTaking.getDepositoryId());
location.append(depository.getDname());
if (!(Integer.compare(placeId, 0) == 0)) {
// 如果不是默认库位
Place placeById = placeService.findPlaceById(placeId);
location.append("-" + placeById.getCode());
}
String location = depository.getDname();
// 设置盘点位置
stp.setDepositoryName(location.toString());
stp.setDepositoryName(location);
mv.addObject("mainRecord", stp);
mv.addObject("recordChild", stockTakingChildPByMainId);
Integer departmentManagerState = stp.getDepartmentManagerState();
@ -1956,15 +1948,8 @@ public class PageController {
stp.setDepartmentManagerName(managerName.toString());
// 获取盘点位置
Integer placeId = stockTaking.getPlaceId();
StringBuilder location = new StringBuilder();
Depository depository = depositoryService.findDepositoryById(stockTaking.getDepositoryId());
location.append(depository.getDname());
if (!(Integer.compare(placeId, 0) == 0)) {
// 如果不是默认库位
Place placeById = placeService.findPlaceById(placeId);
location.append("-").append(placeById.getCode());
}
String location = depository.getDname();
// 设置盘点位置
stp.setDepositoryName(location.toString());
mv.addObject("mainRecord", stp);
@ -1996,7 +1981,6 @@ public class PageController {
}
public List<AdministrationP> findAllCompany(UserByPort userByPort) {
String url = PortConfig.external_url + "/org/govlist";
Map<String, Object> map = new HashMap<>();
@ -2508,7 +2492,7 @@ public class PageController {
// 获取主订单
stockTaking = stockTakingService.findStockTakingById(stcp.getMainId());
Integer placeId = stockTaking.getPlaceId();
Integer placeId = stcp.getMid();
// 获取库位详情
Place placeById = placeService.findPlaceById(placeId);

2
src/main/java/com/dreamchaser/depository_manage/controller/StockTakingController.java

@ -345,7 +345,7 @@ public class StockTakingController {
}
param.put("newInventory", newInventory);
param.put("depositoryId",map.get("depositoryId"));
param.put("placeId",map.get("placeId"));
param.put("placeId",placeAndMaterial.getPid().toString());
param.put("departmentManager",map.get("departmentManager"));
param.put("state",3);
param.put("departmentManagerState",3);

5
src/main/java/com/dreamchaser/depository_manage/entity/StockTaking.java

@ -26,11 +26,6 @@ public class StockTaking {
/**
* 盘点仓库
*/
private Integer placeId;
/**
* 盘点库位
*/
private Integer depositoryId;
/**

33
src/main/java/com/dreamchaser/depository_manage/mapper/StockTakingMapper.xml

@ -9,10 +9,9 @@
<id column="id" property="id" jdbcType="INTEGER" />
<result column="code" property="code" jdbcType="VARCHAR" />
<result column="depositoryId" property="depositoryId" jdbcType="INTEGER" />
<result column="placeId" property="placeId" jdbcType="INTEGER" />
<result column="state" property="state" jdbcType="INTEGER" />
<result column="departmentManagerState" property="departmentManagerState" jdbcType="INTEGER" />
<result column="crateTime" property="crateTime" jdbcType="INTEGER" />
<result column="createTime" property="createTime" jdbcType="INTEGER" />
<result column="completeTime" property="completeTime" jdbcType="INTEGER" />
<result column="reviewTime" property="reviewTime" jdbcType="INTEGER" />
<result column="originator" property="originator" jdbcType="INTEGER" />
@ -36,6 +35,7 @@
<result column="mcode" property="mcode" jdbcType="VARCHAR" />
<result column="mname" property="mname" jdbcType="VARCHAR" />
<result column="mtId" property="mtId" jdbcType="INTEGER" />
<result column="pid" property="pid" jdbcType="INTEGER" />
<result column="producedDate" property="producedDate" jdbcType="INTEGER" />
</resultMap>
@ -44,21 +44,20 @@
<!-- 表查询字段 -->
<sql id="StockTakingAllColumns">
st.id,st.code,st.depositoryId,st.placeId,st.departmentManager,st.state,st.createTime,st.originator,st.completeTime,st.reviewTime,st.auditOpinion,st.departmentManagerState
st.id,st.code,st.depositoryId,st.departmentManager,st.state,st.createTime,st.originator,st.completeTime,st.reviewTime,st.auditOpinion,st.departmentManagerState
</sql>
<sql id="StockTakingChildPAllColumns">
id,mid,oldInventory,newInventory,inventory,mainId,takingResult,mname,mtId,tname,mcode,mversion,munit,mtexture,producedDate,stcUnit
id,mid,oldInventory,newInventory,inventory,mainId,takingResult,mname,mtId,tname,mcode,mversion,munit,mtexture,producedDate,stcUnit,pid
</sql>
<!-- 插入主表-->
<insert id="insertStockTaking" useGeneratedKeys="true" keyProperty="id">
INSERT INTO stocktaking (id,code,depositoryId,placeId,departmentManager,state,createTime,originator,departmentManagerState)
INSERT INTO stocktaking (id,code,depositoryId,departmentManager,state,createTime,originator,departmentManagerState)
values (
#{id},
#{code},
#{depositoryId},
#{placeId},
#{departmentManager},
#{state},
#{createTime},
@ -69,9 +68,9 @@
<!-- 插入子表-->
<insert id="insertStockTakingChild" useGeneratedKeys="true" keyProperty="id">
INSERT INTO stocktakingchild (id,mid,oldInventory,newInventory,takingResult,inventory,mainId,producedDate,unit)
INSERT INTO stocktakingchild (id,mid,oldInventory,newInventory,takingResult,inventory,mainId,producedDate,unit,pid)
values (
#{id},#{mid},#{oldInventory},#{newInventory},#{takingResult},#{inventory},#{mainId},#{producedDate},#{unit}
#{id},#{mid},#{oldInventory},#{newInventory},#{takingResult},#{inventory},#{mainId},#{producedDate},#{unit},#{placeId}
)
</insert>
@ -109,9 +108,6 @@
<if test="depositoryId != null">
depositoryId = #{depositoryId},
</if>
<if test="placeId != null">
placeId = #{placeId},
</if>
<if test="departmentManager != null and departmentManager != ''">
departmentManager = #{departmentManager},
</if>
@ -166,9 +162,13 @@
<if test="producedDate != null and producedDate != ''">
producedDate = #{producedDate},
</if>
<if test="placeId != null">
pid = #{placeId},
</if>
<if test="unit != null and unit != ''">
unit = #{unit}
</if>
</set>
where id = #{id}
</update>
@ -202,9 +202,7 @@
<if test="depositoryId != null and depositoryId != ''">
and st.depositoryId = #{depositoryId}
</if>
<if test="placeId != null">
and st.placeId = #{placeId}
</if>
<if test="departmentManagerState != null and departmentManagerState != ''">
and st.departmentManagerState = #{departmentManagerState}
</if>
@ -232,6 +230,9 @@
<if test="newInventory != null">
and newInventory = #{newInventory}
</if>
<if test="placeId != null">
and pid = #{placeId}
</if>
<if test="takingResult != null and takingResult != ''">
and takingResult = #{takingResult}
</if>
@ -287,10 +288,10 @@
from stocktaking st
where 1 = 1
<if test='isDone == 0'>
and (state = 3 and departmentManagerState = 3 and FIND_IN_SET(#{departmentHead},st.departmentManager) != 0 )
and (state = 3 and FIND_IN_SET(#{departmentHead},st.departmentManager) != 0 )
</if>
<if test='isDone == 1'>
and (state != 3 and departmentManagerState != 3 and FIND_IN_SET(#{departmentHead},st.departmentManager) != 0 )
and (state != 3 and FIND_IN_SET(#{departmentHead},st.departmentManager) != 0 )
</if>
ORDER BY st.createTime desc
<if test="begin != null and size != null">

6
src/main/java/com/dreamchaser/depository_manage/pojo/StockTakingChildP.java

@ -19,6 +19,12 @@ public class StockTakingChildP {
* 物料id
*/
private Integer mid;
/**
* 盘点库位id
*/
private Integer pid;
/**
* 库存容量
*/

1
src/main/java/com/dreamchaser/depository_manage/pojo/StockTakingP.java

@ -95,7 +95,6 @@ public class StockTakingP {
this.code = st.getCode();
this.departmentManager = st.getDepartmentManager();
this.depositoryId = st.getDepositoryId();
this.placeId = st.getPlaceId();
this.state = st.getState();
this.departmentManagerState = st.getDepartmentManagerState();
this.createTime = DateUtil.TimeStampToDateTime(st.getCreateTime());

47
src/main/java/com/dreamchaser/depository_manage/service/impl/QyWxOperationService.java

@ -280,23 +280,12 @@ public class QyWxOperationService {
StringBuilder stockTakingResult = new StringBuilder();
// 物料盘盈数量
StringBuilder stockTakingInventory = new StringBuilder();
// 获取盘点的库位
Integer placeId = mainRecord.getPlaceId();
Place place = placeMapper.findPlaceById(placeId);
// 获取盘点的仓库
Integer depositoryId = mainRecord.getDepositoryId();
Depository depository = depositoryMapper.findDepositoryById(depositoryId);
Location.append(depository.getDname());
if (Integer.compare(0, placeId) == 0) {
// 如果盘点库位为默认库位
Location.append(" - 默认库位");
} else {
Location.append(" - ").append(place.getCode());
}
for (StockTakingChildP childP : minRecordList) {
// 获取子订单信息
@ -528,23 +517,12 @@ public class QyWxOperationService {
StringBuilder stockTakingResult = new StringBuilder();
// 物料盘盈数量
StringBuilder stockTakingInventory = new StringBuilder();
// 获取盘点的库位
Integer placeId = mainRecord.getPlaceId();
Place place = placeMapper.findPlaceById(placeId);
// 获取盘点的仓库
Integer depositoryId = mainRecord.getDepositoryId();
Depository depository = depositoryMapper.findDepositoryById(depositoryId);
Location.append(depository.getDname());
if (Integer.compare(0, placeId) == 0) {
// 如果盘点库位为默认库位
Location.append(" - 默认库位");
} else {
Location.append(" - ").append(place.getCode());
}
for (StockTakingChildP childP : minRecordList) {
// 获取子订单信息
@ -866,9 +844,8 @@ public class QyWxOperationService {
content.append("%n---%n");
for (int i = 0; i < minIds.size(); i++) {
for (Long minId : minIds) {
Long minId = minIds.get(i);
// 获取对应子订单
StockTakingChildP minRecord = stockTakingMapper.selectStockTakingChildPById(minId);
@ -886,7 +863,7 @@ public class QyWxOperationService {
}
// 获取转移前的库位
Integer oldPlaceId = ObjectFormatUtil.toInteger(mainRecord.getPlaceId());
Integer oldPlaceId = ObjectFormatUtil.toInteger(minRecord.getPid());
Place oldPlace = placeMapper.findPlaceById(oldPlaceId);
@ -976,9 +953,8 @@ public class QyWxOperationService {
content.append("%n---%n");
for (int i = 0; i < errIds.size(); i++) {
for (Long minId : errIds) {
Long minId = errIds.get(i);
// 获取错误的子订单
StockTakingChildP minRecord = stockTakingMapper.selectStockTakingChildPById(minId);
@ -987,7 +963,7 @@ public class QyWxOperationService {
// 获取转移前的库位
Integer oldPlaceId = ObjectFormatUtil.toInteger(mainRecord.getPlaceId());
Integer oldPlaceId = ObjectFormatUtil.toInteger(minRecord.getPid());
Place oldPlace = placeMapper.findPlaceById(oldPlaceId);
@ -1075,8 +1051,7 @@ public class QyWxOperationService {
content.append("%n---%n");
for (int i = 0; i < minIds.size(); i++) {
Long minId = minIds.get(i);
for (Long minId : minIds) {
// 获取对应子订单
StockTakingChildP minRecord = stockTakingMapper.selectStockTakingChildPById(minId);
@ -1087,7 +1062,7 @@ public class QyWxOperationService {
// 获取转移数量
Integer inventory = ObjectFormatUtil.toInteger(map.get("invnetory" + minId));
// 获取转移前的库位
Integer oldPlaceId = ObjectFormatUtil.toInteger(mainRecord.getPlaceId());
Integer oldPlaceId = ObjectFormatUtil.toInteger(minRecord.getPid());
Place oldPlace = placeMapper.findPlaceById(oldPlaceId);
@ -2140,14 +2115,10 @@ public class QyWxOperationService {
// 获取当前盘点位置
Depository depository = depositoryMapper.findDepositoryById(mainRecord.getDepositoryId());
Place place = placeMapper.findPlaceById(mainRecord.getPlaceId());
// 声明盘点位置
String location = "";
if (Integer.compare(place.getId(), 0) == 0) {
location = depository.getDname();
} else {
location = depository.getDname() + "-" + place.getCode();
}
String location = depository.getDname();
// 声明盘点审批模板
ApprovalTemplate approvalTemplate = new ApprovalTemplate();

124
src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java

@ -162,10 +162,10 @@ public class StockTakingServiceImpl implements StockTakingService {
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);
for (StockTaking stockTaking : myTask) {
SimpleStockTakingP ssp = new SimpleStockTakingP(stockTaking);
Depository depositoryRecordById = depositoryMapper.findDepositoryById(stockTaking.getDepositoryId());
ssp.setDepositoryName(depositoryRecordById.getDname());
@ -358,9 +358,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 定义出错信息
List<String> err = new ArrayList<>();
Integer placeId = mainRecord.getPlaceId();
// 获取库位详情
Place placeById = placeMapper.findPlaceById(placeId);
Integer depositoryId = mainRecord.getDepositoryId();
// 获取所有子单
@ -369,6 +367,10 @@ public class StockTakingServiceImpl implements StockTakingService {
// 获取子单详情
// 获取盘点的物料详情
Integer placeId = minRecord.getPid();
// 获取库位详情
Place placeById = placeMapper.findPlaceById(placeId);
// 获取当前盘点结果
String takingResult = minRecord.getTakingResult();
if ("Inventory_normal".equals(takingResult)) {
@ -388,6 +390,8 @@ public class StockTakingServiceImpl implements StockTakingService {
// 获取物料与库位的对应关系
MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace);
// 根据盘点结果重新计算物料的单价
@ -403,7 +407,8 @@ public class StockTakingServiceImpl implements StockTakingService {
int newNumberForPlace = 0;
// 用于计算新的库位与物料对应关系的数量
int newNumberForMatrialAndPlace = 0;
if ("Inventory_up".equals(takingResult)) {
if ("Inventory_up".equals(takingResult))
{
// 如果盘盈
// 更新当前库位数量
@ -427,7 +432,8 @@ public class StockTakingServiceImpl implements StockTakingService {
// 更新物料与库位对应关系的数量
placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace);
} else {
}
else {
// 如果盘亏
newNumberForPlace = placeById.getQuantity() - inventory;
@ -450,7 +456,6 @@ public class StockTakingServiceImpl implements StockTakingService {
placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace);
}
normalMinId.add(minRecord.getId());
}
@ -500,7 +505,7 @@ public class StockTakingServiceImpl implements StockTakingService {
map.put("departmentManager", userToken.getNumber());
stockTakingMapper.updateStockTaking(map);
// 更新其他卡片
/*// 更新其他卡片
String finalStockTakingResult = stockTakingResult;
new Thread(new Runnable() {
@Override
@ -513,7 +518,7 @@ public class StockTakingServiceImpl implements StockTakingService {
String responseCode = (String) redisTemplate.opsForHash().get(key, "responseCode");
qyWxOperationService.updateTemplateCard(responseCode, userToken.getName(), finalStockTakingResult, userAgent);
}
}).start();
}).start();*/
// 开启流程通知其他人忽略审批流程
new Thread(new Runnable() {
@ -522,8 +527,7 @@ public class StockTakingServiceImpl implements StockTakingService {
String departmentManager1 = mainRecord.getDepartmentManager();
String[] split = departmentManager1.split(",");
StringBuilder QyWxUid = new StringBuilder();
for (int i = 0; i < split.length; i++) {
String s = split[i];
for (String s : split) {
if ("".equals(s.trim())) {
continue;
}
@ -586,16 +590,15 @@ public class StockTakingServiceImpl implements StockTakingService {
// 定义出错信息
List<String> err = new ArrayList<>();
Integer placeId = mainRecord.getPlaceId();
// 获取库位详情
Place placeById = placeMapper.findPlaceById(placeId);
Integer depositoryId = mainRecord.getDepositoryId();
// 获取所有子单
List<StockTakingChildP> minRecordList = stockTakingMapper.selectStockTakingChildByMainId(mainId);
// 遍历当前拆单的子单详情
for (StockTakingChildP minRecord : minRecordList) {
// 获取子单详情
Integer placeId = minRecord.getPid();
// 获取库位详情
Place placeById = placeMapper.findPlaceById(placeId);
// 获取当前盘点结果
String takingResult = minRecord.getTakingResult();
@ -613,7 +616,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 获取盘点物料信息
Inventory inventoryById = materialMapper.findInventoryById(minRecord.getMid());
// 定义用于获取物料与库位的对应关系的参数
Map<String, Object> paramForMaterialAndPlace = new HashMap<>();
paramForMaterialAndPlace.put("mid", inventoryById.getId());
paramForMaterialAndPlace.put("pid", placeById.getId());
@ -637,8 +640,8 @@ public class StockTakingServiceImpl implements StockTakingService {
mapForProducedDate.put("producedDate", producedDate);
// 获取当前生产日期下的物料与生产日期的对应关系
MaterialAndProducedDate materialAndProducedDate = materialMapper.findMaterialAndProducedDateByMidAndProducedDate(mapForProducedDate);
Integer oldInventroy = materialAndProducedDate.getInventory();
if (newInventory > oldInventroy) {
Integer oldInventory = materialAndProducedDate.getInventory();
if (newInventory > oldInventory) {
// 如果当前盘点数量大于库存数量
// 修改当前库存
@ -647,7 +650,7 @@ public class StockTakingServiceImpl implements StockTakingService {
materialAndProducedDate.setExpendnum(materialAndProducedDate.getQuantity() - newInventory);
// 修改物料对应数量
inventoryById.setQuantity(inventoryById.getQuantity() + newInventory - oldInventroy);
inventoryById.setQuantity(inventoryById.getQuantity() + newInventory - oldInventory);
} else {
@ -659,14 +662,12 @@ public class StockTakingServiceImpl implements StockTakingService {
materialAndProducedDate.setExpendnum(materialAndProducedDate.getQuantity() - newInventory);
// 修改物料对应数量
inventoryById.setQuantity(inventoryById.getQuantity() - oldInventroy + newInventory);
inventoryById.setQuantity(inventoryById.getQuantity() - oldInventory + newInventory);
}
// 获取当前物料数目
Integer quantity = inventoryById.getQuantity();
materialMapper.updateMaterialAndProducedDate(materialAndProducedDate);
} else {
}
else {
// 如果没有生产日期
// 获取当前库位以外的物料数量
@ -680,21 +681,20 @@ public class StockTakingServiceImpl implements StockTakingService {
}
// 用于计算新的库位数量
Integer newNumberForPlace = 0;
int newNumberForPlace = 0;
// 用于计算新的库位与物料对应关系的数量
Integer newNumberForMatrialAndPlace = 0;
int newNumberForMatrialAndPlace = 0;
if ("Inventory_up".equals(takingResult)) {
// 如果盘盈
// 如果是基础单位
if ("-1".equals(unit)) {
if ("-1".equals(unit) || inventoryById.getUnit().equals(minRecord.getUnit())) {
// 更新当前库位数量
newNumberForPlace = placeById.getQuantity() + inventory;
if (newNumberForPlace <= placeById.getMax()) {
// 如果更新后的库位数量没有上溢
// 更新当前库位的数量
@ -714,16 +714,8 @@ public class StockTakingServiceImpl implements StockTakingService {
}
else {
// 如果是拆单单位
// 更新当前库位数量
newNumberForPlace = placeById.getQuantity() + inventory;
if (newNumberForPlace > placeById.getMax()) {
// 添加错误信息
errIds.add(minRecord.getId());
err.add("当前库位数量溢出,需要转移");
continue;
}
// 用于查找对应的拆单记录
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("newUnit", unit);
@ -733,8 +725,9 @@ public class StockTakingServiceImpl implements StockTakingService {
// 查找当前拆单记录对应的库存记录
SplitInventory splitInventory = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), splitInfo.getId());
// 如果存在拆单库存记录
if(splitInventory != null){
// 获取当前盘点后的库存数
int realQuantity = Math.round(inventory) + splitInventory.getSaveQuantity();
// 定义当前进制
int scale = splitInfo.getQuantity();
@ -775,8 +768,21 @@ public class StockTakingServiceImpl implements StockTakingService {
// 修改拆单库存
splitUnitMapper.updateSplitInventory(splitInventory);
}
}else{
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
}
else{
// 如果不存在拆单库存记录
Map<String, Object> paramForUpdateSplitInventory = new HashMap<>();
paramForUpdateSplitInventory.put("placeId",minRecord.getPid());
paramForUpdateSplitInventory.put("depositoryId",mainRecord.getDepositoryId());
paramForUpdateSplitInventory.put("quantity",inventory);
paramForUpdateSplitInventory.put("mid",inventoryById.getMid());
paramForUpdateSplitInventory.put("unit",minRecord.getUnit());
splitUnitService.realInInventoryToDepository(Double.valueOf(inventory), null,paramForUpdateSplitInventory,splitInfo,placeAndMaterialByMidAndPid,false);
if (paramForUpdateSplitInventory.containsKey("applicationInId")) {
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(paramForUpdateSplitInventory.get("applicationInId")));
}
}
@ -785,7 +791,7 @@ public class StockTakingServiceImpl implements StockTakingService {
else {
// 如果盘亏
if ("-1".equals(unit)) {
if ("-1".equals(unit) || inventoryById.getUnit().equals(minRecord.getUnit())) {
// 如果盘点的是基础单位
newNumberForPlace = placeById.getQuantity() - inventory;
@ -875,13 +881,12 @@ public class StockTakingServiceImpl implements StockTakingService {
map.put("minIds", minIds);
// 开启一个线程用于发送抄送信息给负责人
StockTaking finalMainRecord = mainRecord;
new Thread(new Runnable() {
@Override
public void run() {
String s = QyWxUid.toString();
s = "PangFuZhen,";
JSONObject jsonObject = qyWxOperationService.sendCcStockTakingMessageToHead(s, map, userToken, finalMainRecord, userAgent);
JSONObject jsonObject = qyWxOperationService.sendCcStockTakingMessageToHead(s, map, userToken, mainRecord, userAgent);
}
}).start();
@ -945,10 +950,7 @@ public class StockTakingServiceImpl implements StockTakingService {
List<Long> errIds = new ArrayList<>();
// 定义出错信息
List<String> err = new ArrayList<>();
// 获取盘点的库位id
Integer placeId = mainRecord.getPlaceId();
// 获取库位详情
Place placeById = placeMapper.findPlaceById(placeId);
// 获取盘点的仓库id
Integer depositoryId = mainRecord.getDepositoryId();
// 获取仓库详情
@ -961,6 +963,10 @@ public class StockTakingServiceImpl implements StockTakingService {
// 获取当前盘点的计量单位
String unit = minRecord.getUnit();
// 获取盘点的库位id
Integer placeId = minRecord.getPid();
// 获取库位详情
Place placeById = placeMapper.findPlaceById(placeId);
// 获取当前盘点结果
String takingResult = minRecord.getTakingResult();
@ -1444,15 +1450,17 @@ public class StockTakingServiceImpl implements StockTakingService {
// 定义出错信息
List<String> err = new ArrayList<>();
Integer placeId = mainRecord.getPlaceId();
// 获取库位详情
Place placeById = placeMapper.findPlaceById(placeId);
Integer depositoryId = mainRecord.getDepositoryId();
// 获取所有子单
List<StockTakingChildP> minRecordList = stockTakingMapper.selectStockTakingChildByMainId(ObjectFormatUtil.toInteger(mainId));
for (StockTakingChildP minRecord : minRecordList) {
// 获取子单详情
Integer placeId = minRecord.getPid();
// 获取库位详情
Place placeById = placeMapper.findPlaceById(placeId);
// 获取盘点的物料详情
@ -1646,7 +1654,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 如果转移前的库位为空
if (oldPlace == null) {
// 查询当前主订单对应的盘点库位
oldPlace = placeMapper.findPlaceById(mainRecord.getPlaceId());
oldPlace = placeMapper.findPlaceById(minRecord.getPid());
// 设置当前转移前库位的总数
sumTransferAfter = oldPlace.getQuantity();
}
@ -2519,12 +2527,7 @@ public class StockTakingServiceImpl implements StockTakingService {
// 定义出错信息
List<String> err = new ArrayList<>();
Integer placeId = mainRecord.getPlaceId();
// 获取库位详情
Place placeById = placeMapper.findPlaceById(placeId);
Integer depositoryId = mainRecord.getDepositoryId();
// 获取仓库详情
Depository depositoryById = depositoryMapper.findDepositoryById(depositoryId);
// 获取所有子单
@ -2532,7 +2535,10 @@ public class StockTakingServiceImpl implements StockTakingService {
for (int i = 0; i < minRecordList.size(); i++) {
// 获取子单详情
StockTakingChildP minRecord = minRecordList.get(i);
// 获取盘点的物料详情
Integer placeId = minRecord.getPid();
// 获取库位详情
Place placeById = placeMapper.findPlaceById(placeId);
// 获取当前盘点结果
String takingResult = minRecord.getTakingResult();

51
src/main/resources/templates/pages/stockTaking/stockTaking.html

@ -317,6 +317,7 @@
{field: 'mname', width: 150, title: '物料名称'},
{field: 'typeName', width: 100, title: '物料种类'},
{field: 'version', width: 150, title: '规格型号',},
{field: 'pcode', width: 150, title: '所处库位',},
{title: '计量单位', width: 200, templet: '#changeUnit', align: "center"},
{field: 'inventory', width: 100, title: '库存数'},
{field: 'stockTakingQuantity', width: 100, title: '盘点数', edit: 'quantity'},
@ -333,8 +334,8 @@
let takingUnit = j["takingUnit"];
if (takingUnit !== null) {
let parentItem = $("[lay-id='currentTableId'] tr:eq(" + (i + 1) + ")");
let unitHandleItem = parentItem.children()[4];
let quantityHandleItem = parentItem.children()[5];
let unitHandleItem = parentItem.children()[5];
let quantityHandleItem = parentItem.children()[6];
unitHandleItem.childNodes[0].childNodes[1].childNodes[0].data = takingUnit;
quantityHandleItem.childNodes[0].innerText = j["splitInventory"][takingUnit];
}
@ -499,7 +500,7 @@
, data: dropDownDataList
, click: function (unit) {
this.elem[0].childNodes[0].data = unit.title;
obj.tr[0].childNodes[5].childNodes[0].innerText = obj.data.splitInventory[unit.title];
obj.tr[0].childNodes[6].childNodes[0].innerText = obj.data.splitInventory[unit.title];
}
, align: 'right' //右对齐弹出(v2.6.8 新增)
, style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' //设置额外样式
@ -512,7 +513,7 @@
// 用于计算盘点结果
calculate = function (obj) {
let oldInventory = Number(obj.tr[0].childNodes[5].childNodes[0].innerText);
let oldInventory = Number(obj.tr[0].childNodes[6].childNodes[0].innerText);
let nowInventory = Number(obj.value);
let number = 0;
let takingResult = '';
@ -530,15 +531,15 @@
takingResult = "Inventory_normal";
takingResultString = "正常";
}
obj.tr[0].childNodes[7].childNodes[0].innerText = takingResultString;
obj.tr[0].childNodes[8].childNodes[0].innerText = number;
obj.tr[0].childNodes[8].childNodes[0].innerText = takingResultString;
obj.tr[0].childNodes[9].childNodes[0].innerText = number;
obj.update({takingResult: takingResult});
obj.update({takingInventory: number});
req.number = number + "";
req.takingResult = takingResult;
req.takingResultString = takingResultString;
req.id = obj.data.id + "";
req.unit = obj.tr[0].childNodes[4].childNodes[0].innerText;
req.unit = obj.tr[0].childNodes[5].childNodes[0].innerText;
req.oldInventory = oldInventory+"";
$.ajax({
url: "/stockTaking/temporaryStorageForTakingResult",
@ -548,42 +549,6 @@
contentType: "application/json;charset=utf-8"
});
};
form.on('select()', function (data) {
var id = data.elem.id; //得到select原始DOM对象id
var req = {};
if (id.includes("producedDate")) {
var idNumber = id.split('producedDate')[1]; // 得到当前id对应数字
req.mid = $("#" + "mid" + idNumber).val();
req.producedDate = data.value;
$.ajax({
url: "/material/findQuantityByProducedDate",
type: "post",
dataType: 'json',
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success: function (d) {
$("#" + "oldInventory" + idNumber).val(d.data)
}
});
} else if (id.includes("unit")) {
let idNumber = id.split("unit")[1]; // 得到当前id对应数字
req.mid = $("#" + "mid" + idNumber).val();
req.unit = data.value;
req.placeId = $("#placeId").val();
$.ajax({
url: "/material/findQuantityByUnit",
type: "post",
dataType: 'json',
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success: function (d) {
$("#" + "oldInventory" + idNumber).val(d.data)
}
});
}
});
});
</script>

9
src/main/resources/templates/pages/stockTaking/stockTakingComplete.html

@ -45,7 +45,7 @@
<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"
style="margin: 0 auto;max-width: 700px;"
lay-filter="form1" id="form1">
<div class="layui-card-body" id="takingHeader" style="padding-right: 0px">
<div class="layui-form-item">
@ -219,6 +219,10 @@
</div>
</fieldset>
</form>
</div>
</div>
<div id="review">
<div class="layui-form"
style="margin: 0 auto;max-width: 900px;padding-top: 40px;">
@ -231,9 +235,6 @@
</div>
</div>
</div>
</form>
</div>
</div>
</fieldset>
</div>
</div>

33
target/classes/com/dreamchaser/depository_manage/mapper/StockTakingMapper.xml

@ -9,10 +9,9 @@
<id column="id" property="id" jdbcType="INTEGER" />
<result column="code" property="code" jdbcType="VARCHAR" />
<result column="depositoryId" property="depositoryId" jdbcType="INTEGER" />
<result column="placeId" property="placeId" jdbcType="INTEGER" />
<result column="state" property="state" jdbcType="INTEGER" />
<result column="departmentManagerState" property="departmentManagerState" jdbcType="INTEGER" />
<result column="crateTime" property="crateTime" jdbcType="INTEGER" />
<result column="createTime" property="createTime" jdbcType="INTEGER" />
<result column="completeTime" property="completeTime" jdbcType="INTEGER" />
<result column="reviewTime" property="reviewTime" jdbcType="INTEGER" />
<result column="originator" property="originator" jdbcType="INTEGER" />
@ -36,6 +35,7 @@
<result column="mcode" property="mcode" jdbcType="VARCHAR" />
<result column="mname" property="mname" jdbcType="VARCHAR" />
<result column="mtId" property="mtId" jdbcType="INTEGER" />
<result column="pid" property="pid" jdbcType="INTEGER" />
<result column="producedDate" property="producedDate" jdbcType="INTEGER" />
</resultMap>
@ -44,21 +44,20 @@
<!-- 表查询字段 -->
<sql id="StockTakingAllColumns">
st.id,st.code,st.depositoryId,st.placeId,st.departmentManager,st.state,st.createTime,st.originator,st.completeTime,st.reviewTime,st.auditOpinion,st.departmentManagerState
st.id,st.code,st.depositoryId,st.departmentManager,st.state,st.createTime,st.originator,st.completeTime,st.reviewTime,st.auditOpinion,st.departmentManagerState
</sql>
<sql id="StockTakingChildPAllColumns">
id,mid,oldInventory,newInventory,inventory,mainId,takingResult,mname,mtId,tname,mcode,mversion,munit,mtexture,producedDate,stcUnit
id,mid,oldInventory,newInventory,inventory,mainId,takingResult,mname,mtId,tname,mcode,mversion,munit,mtexture,producedDate,stcUnit,pid
</sql>
<!-- 插入主表-->
<insert id="insertStockTaking" useGeneratedKeys="true" keyProperty="id">
INSERT INTO stocktaking (id,code,depositoryId,placeId,departmentManager,state,createTime,originator,departmentManagerState)
INSERT INTO stocktaking (id,code,depositoryId,departmentManager,state,createTime,originator,departmentManagerState)
values (
#{id},
#{code},
#{depositoryId},
#{placeId},
#{departmentManager},
#{state},
#{createTime},
@ -69,9 +68,9 @@
<!-- 插入子表-->
<insert id="insertStockTakingChild" useGeneratedKeys="true" keyProperty="id">
INSERT INTO stocktakingchild (id,mid,oldInventory,newInventory,takingResult,inventory,mainId,producedDate,unit)
INSERT INTO stocktakingchild (id,mid,oldInventory,newInventory,takingResult,inventory,mainId,producedDate,unit,pid)
values (
#{id},#{mid},#{oldInventory},#{newInventory},#{takingResult},#{inventory},#{mainId},#{producedDate},#{unit}
#{id},#{mid},#{oldInventory},#{newInventory},#{takingResult},#{inventory},#{mainId},#{producedDate},#{unit},#{placeId}
)
</insert>
@ -109,9 +108,6 @@
<if test="depositoryId != null">
depositoryId = #{depositoryId},
</if>
<if test="placeId != null">
placeId = #{placeId},
</if>
<if test="departmentManager != null and departmentManager != ''">
departmentManager = #{departmentManager},
</if>
@ -166,9 +162,13 @@
<if test="producedDate != null and producedDate != ''">
producedDate = #{producedDate},
</if>
<if test="placeId != null">
pid = #{placeId},
</if>
<if test="unit != null and unit != ''">
unit = #{unit}
</if>
</set>
where id = #{id}
</update>
@ -202,9 +202,7 @@
<if test="depositoryId != null and depositoryId != ''">
and st.depositoryId = #{depositoryId}
</if>
<if test="placeId != null">
and st.placeId = #{placeId}
</if>
<if test="departmentManagerState != null and departmentManagerState != ''">
and st.departmentManagerState = #{departmentManagerState}
</if>
@ -232,6 +230,9 @@
<if test="newInventory != null">
and newInventory = #{newInventory}
</if>
<if test="placeId != null">
and pid = #{placeId}
</if>
<if test="takingResult != null and takingResult != ''">
and takingResult = #{takingResult}
</if>
@ -287,10 +288,10 @@
from stocktaking st
where 1 = 1
<if test='isDone == 0'>
and (state = 3 and departmentManagerState = 3 and FIND_IN_SET(#{departmentHead},st.departmentManager) != 0 )
and (state = 3 and FIND_IN_SET(#{departmentHead},st.departmentManager) != 0 )
</if>
<if test='isDone == 1'>
and (state != 3 and departmentManagerState != 3 and FIND_IN_SET(#{departmentHead},st.departmentManager) != 0 )
and (state != 3 and FIND_IN_SET(#{departmentHead},st.departmentManager) != 0 )
</if>
ORDER BY st.createTime desc
<if test="begin != null and size != null">

51
target/classes/templates/pages/stockTaking/stockTaking.html

@ -317,6 +317,7 @@
{field: 'mname', width: 150, title: '物料名称'},
{field: 'typeName', width: 100, title: '物料种类'},
{field: 'version', width: 150, title: '规格型号',},
{field: 'pcode', width: 150, title: '所处库位',},
{title: '计量单位', width: 200, templet: '#changeUnit', align: "center"},
{field: 'inventory', width: 100, title: '库存数'},
{field: 'stockTakingQuantity', width: 100, title: '盘点数', edit: 'quantity'},
@ -333,8 +334,8 @@
let takingUnit = j["takingUnit"];
if (takingUnit !== null) {
let parentItem = $("[lay-id='currentTableId'] tr:eq(" + (i + 1) + ")");
let unitHandleItem = parentItem.children()[4];
let quantityHandleItem = parentItem.children()[5];
let unitHandleItem = parentItem.children()[5];
let quantityHandleItem = parentItem.children()[6];
unitHandleItem.childNodes[0].childNodes[1].childNodes[0].data = takingUnit;
quantityHandleItem.childNodes[0].innerText = j["splitInventory"][takingUnit];
}
@ -499,7 +500,7 @@
, data: dropDownDataList
, click: function (unit) {
this.elem[0].childNodes[0].data = unit.title;
obj.tr[0].childNodes[5].childNodes[0].innerText = obj.data.splitInventory[unit.title];
obj.tr[0].childNodes[6].childNodes[0].innerText = obj.data.splitInventory[unit.title];
}
, align: 'right' //右对齐弹出(v2.6.8 新增)
, style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' //设置额外样式
@ -512,7 +513,7 @@
// 用于计算盘点结果
calculate = function (obj) {
let oldInventory = Number(obj.tr[0].childNodes[5].childNodes[0].innerText);
let oldInventory = Number(obj.tr[0].childNodes[6].childNodes[0].innerText);
let nowInventory = Number(obj.value);
let number = 0;
let takingResult = '';
@ -530,15 +531,15 @@
takingResult = "Inventory_normal";
takingResultString = "正常";
}
obj.tr[0].childNodes[7].childNodes[0].innerText = takingResultString;
obj.tr[0].childNodes[8].childNodes[0].innerText = number;
obj.tr[0].childNodes[8].childNodes[0].innerText = takingResultString;
obj.tr[0].childNodes[9].childNodes[0].innerText = number;
obj.update({takingResult: takingResult});
obj.update({takingInventory: number});
req.number = number + "";
req.takingResult = takingResult;
req.takingResultString = takingResultString;
req.id = obj.data.id + "";
req.unit = obj.tr[0].childNodes[4].childNodes[0].innerText;
req.unit = obj.tr[0].childNodes[5].childNodes[0].innerText;
req.oldInventory = oldInventory+"";
$.ajax({
url: "/stockTaking/temporaryStorageForTakingResult",
@ -548,42 +549,6 @@
contentType: "application/json;charset=utf-8"
});
};
form.on('select()', function (data) {
var id = data.elem.id; //得到select原始DOM对象id
var req = {};
if (id.includes("producedDate")) {
var idNumber = id.split('producedDate')[1]; // 得到当前id对应数字
req.mid = $("#" + "mid" + idNumber).val();
req.producedDate = data.value;
$.ajax({
url: "/material/findQuantityByProducedDate",
type: "post",
dataType: 'json',
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success: function (d) {
$("#" + "oldInventory" + idNumber).val(d.data)
}
});
} else if (id.includes("unit")) {
let idNumber = id.split("unit")[1]; // 得到当前id对应数字
req.mid = $("#" + "mid" + idNumber).val();
req.unit = data.value;
req.placeId = $("#placeId").val();
$.ajax({
url: "/material/findQuantityByUnit",
type: "post",
dataType: 'json',
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success: function (d) {
$("#" + "oldInventory" + idNumber).val(d.data)
}
});
}
});
});
</script>

9
target/classes/templates/pages/stockTaking/stockTakingComplete.html

@ -45,7 +45,7 @@
<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"
style="margin: 0 auto;max-width: 700px;"
lay-filter="form1" id="form1">
<div class="layui-card-body" id="takingHeader" style="padding-right: 0px">
<div class="layui-form-item">
@ -219,6 +219,10 @@
</div>
</fieldset>
</form>
</div>
</div>
<div id="review">
<div class="layui-form"
style="margin: 0 auto;max-width: 900px;padding-top: 40px;">
@ -231,9 +235,6 @@
</div>
</div>
</div>
</form>
</div>
</div>
</fieldset>
</div>
</div>

Loading…
Cancel
Save