Browse Source

修改盘点后的物料转移

lwx_dev
erdanergou 3 years ago
parent
commit
e768c42664
  1. 4
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java
  2. 104
      src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java
  3. 30
      src/main/java/com/dreamchaser/depository_manage/controller/StockTakingController.java
  4. 23
      src/main/java/com/dreamchaser/depository_manage/mapper/StockTakingMapper.xml
  5. 6
      src/main/java/com/dreamchaser/depository_manage/pojo/StockTakingChildP.java
  6. 10
      src/main/java/com/dreamchaser/depository_manage/service/MaterialService.java
  7. 1
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  8. 675
      src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java
  9. 8
      src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java
  10. 1351
      src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java
  11. 88
      src/main/resources/templates/pages/depository/table-stock.html
  12. 4
      src/main/resources/templates/pages/material/selectPlaceByDepository.html
  13. 194
      src/main/resources/templates/pages/stockTaking/stockTaking.html
  14. 2
      src/main/resources/templates/pages/stockTaking/stockTakingComplete.html
  15. 2
      src/main/resources/templates/pages/stockTaking/stockTakingReview.html
  16. 2
      src/main/resources/templates/pages/stockTaking/stockTakingView.html
  17. 4
      src/test/java/com/dreamchaser/depository_manage/TestForOther.java
  18. 0
      target/classes/.restartTriggerFile
  19. BIN
      target/classes/META-INF/depository_manage (2).kotlin_module
  20. 17
      target/classes/META-INF/spring-configuration-metadata.json
  21. 23
      target/classes/com/dreamchaser/depository_manage/mapper/StockTakingMapper.xml
  22. 86
      target/classes/templates/pages/depository/table-stock.html
  23. 194
      target/classes/templates/pages/stockTaking/stockTaking.html
  24. 2
      target/classes/templates/pages/stockTaking/stockTakingComplete.html
  25. 2
      target/classes/templates/pages/stockTaking/stockTakingReview.html
  26. 2
      target/classes/templates/pages/stockTaking/stockTakingView.html

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

@ -429,7 +429,7 @@ public class DepositoryRecordController {
}
}).start();*/
// 开启一个线程开启审批
/* // 开启一个线程开启审批
new Thread(new Runnable() {
@Override
public void run() {
@ -442,7 +442,7 @@ public class DepositoryRecordController {
// 设置过期为7天
redisTemplateForHash.expire(sp_no, 7, TimeUnit.DAYS);
}
}).start();
}).start();*/
}

104
src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java

@ -173,7 +173,7 @@ public class MaterialController {
list.addAll(inventory);
total += materialService.findInventoryCount(map);
}
for (InventoryP inventoryP :list
for (InventoryP inventoryP : list
) {
inventoryP.setSplitInfoList(splitUnitService.findSplitInfoByMid(inventoryP.getMid()));
}
@ -253,7 +253,8 @@ public class MaterialController {
list = materialService.InitTreeMenus(mname, depositoryId, placeId);
}*/
if (!"".equals(mname)) {
list = materialService.InitTreeForSelectName(mname.split(",")[0], type);
// 如果是出入库
list = materialService.InitTreeForSelectName(mname.split(",")[0], type,map);
} else {
list = materialService.InitTreeMenus_Test();
}
@ -261,13 +262,6 @@ public class MaterialController {
}
@PostMapping("/treeMenus_Test")
public RestResponse TreeMenus_Test(@RequestBody Map<String, Object> map, HttpServletRequest request) {
List<Object> list = new ArrayList<>();
list = materialService.InitMaterialTree_New();
return new RestResponse(list);
}
/**
* 根据id获取物料
@ -326,8 +320,8 @@ public class MaterialController {
* @param mid
* @return
*/
@GetMapping("/findMatrialByIdAndPid")
public RestResponse findMatrialByIdAndPid(@RequestParam(value = "mid", required = false) String mid,
@GetMapping("/findInventoryByIdAndPid")
public RestResponse findInventoryByIdAndPid(@RequestParam(value = "mid", required = false) String mid,
@RequestParam(value = "pid", required = false) String pid,
HttpServletRequest request) {
UserByPort userToken = (UserByPort) request.getAttribute("userToken");
@ -335,23 +329,23 @@ public class MaterialController {
return new RestResponse("", 0, 200);
}
Map<String, Object> map = new HashMap<>();
Material materialById = materialService.findMaterialById(ObjectFormatUtil.toInteger(mid));
Inventory inventory = materialService.findInventoryById(ObjectFormatUtil.toInteger(mid));
List<PlaceP> placePList = new ArrayList<>();
List<Depository> depositoryByAdminorg = depositoryService.findDepositoryByAdminorg(userToken.getMaindeparment().toString());
for (int i = 0; i < depositoryByAdminorg.size(); i++) {
List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(ObjectFormatUtil.toInteger(mid), depositoryByAdminorg.get(i).getId());
for (Depository depository : depositoryByAdminorg) {
List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(ObjectFormatUtil.toInteger(mid), depository.getId());
placePList.addAll(placeByMidAndDid);
}
Map<String, Object> param = new HashMap<>();
param.put("code", materialById.getCode());
param.put("code", inventory.getCode());
Map<String, Object> paramByBarcode = new HashMap<>();
paramByBarcode.put("mcode", materialById.getCode());
paramByBarcode.put("mcode", inventory.getCode());
List<MaterialAndBarCode> materialByBarCodeByCondition = materialService.findMaterialByBarCodeByCondition(paramByBarcode);
materialById.setMaterialAndBarCodeList(materialByBarCodeByCondition);
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(ObjectFormatUtil.toInteger(pid), materialById.getId());
materialById.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
inventory.setMaterialAndBarCodeList(materialByBarCodeByCondition);
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(ObjectFormatUtil.toInteger(pid), inventory.getId());
inventory.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
List<MaterialAndProducedDate> materialAndProducedDateByMid = materialService.findMaterialAndProducedDateByMid(materialById.getId());
List<MaterialAndProducedDate> materialAndProducedDateByMid = materialService.findMaterialAndProducedDateByMid(inventory.getId());
List<String> producedDateList = new ArrayList<>();
// 用于标志是否要更改数量
boolean flagForQuantity = true;
@ -359,13 +353,16 @@ public class MaterialController {
// 获取当前生产日期
producedDateList.add(DateUtil.TimeStampToDateTimeForDay(materialAndProducedDate.getProducedDate()));
if (flagForQuantity) {
materialById.setQuantity(materialAndProducedDate.getInventory());
inventory.setQuantity(materialAndProducedDate.getInventory());
flagForQuantity = false;
}
}
map.put("materialById", materialById);
List<SplitInfo> splitInfoList = splitUnitService.findSplitInfoByMid(inventory.getMid());
inventory.setSplitInfoList(splitInfoList);
map.put("materialById", inventory);
map.put("producedDateList", producedDateList);
map.put("placeList", placePList);
return new RestResponse(map, 1, 200);
}
@ -997,7 +994,7 @@ public class MaterialController {
// 如果当前物料不在该库位
flag = false;
} else {
mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
materialP.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
}
} else {
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(0, materialP.getId());
@ -1005,7 +1002,7 @@ public class MaterialController {
// 如果当前物料不在该库位
flag = false;
} else {
mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
materialP.setQuantity(placeAndMaterialByMidAndPid.getQuantity());
}
}
mp = materialP;
@ -1023,6 +1020,8 @@ public class MaterialController {
producedDateList.add(DateUtil.TimeStampToDateTimeForDay(materialAndProducedDate.getProducedDate()));
}
mp.setProducedDateList(producedDateList);
List<SplitInfo> splitInfoList = splitUnitService.findSplitInfoByMid(mp.getMid());
mp.setSplitInfoList(splitInfoList);
return new RestResponse(mp);
}
return new RestResponse(null);
@ -1423,6 +1422,8 @@ public class MaterialController {
producedDateList.add(DateUtil.TimeStampToDateTimeForDay(materialAndProducedDate.getProducedDate()));
material.setQuantity(materialAndProducedDate.getInventory());
}
List<SplitInfo> splitInfoByMid = splitUnitService.findSplitInfoByMid(material.getMid());
material.setSplitInfoList(splitInfoByMid);
material.setProducedDateList(producedDateList);
}
result.put("material", material);
@ -1504,13 +1505,16 @@ public class MaterialController {
} else {
// 获取当前物料
InventoryP materialP = inventory.get(0);
MaterialAndPlace pm = placeService.findPlaceAndMaterialByMidAndPid(ObjectFormatUtil.toInteger(placeById), materialP.getId());
MaterialAndPlace pm = placeService.findPlaceAndMaterialByMidAndPid(ObjectFormatUtil.toInteger(placeById.getId()), materialP.getId());
if (pm != null) {
// 如果成功获取
Map<String, Object> paramForCode = new HashMap<>();
paramForCode.put("mcode", materialP.getCode());
List<MaterialAndBarCode> materialByBarCodeByCondition = materialService.findMaterialByBarCodeByCondition(paramForCode);
List<SplitInfo> splitInfoByMid = splitUnitService.findSplitInfoByMid(materialP.getMid());
materialP.setSplitInfoList(splitInfoByMid);
materialP.setMaterialAndBarCodeList(materialByBarCodeByCondition);
materialP.setQuantity(pm.getQuantity());
return new RestResponse(materialP, 1, 200);
} else {
return new RestResponse("", 0, 200);
@ -1593,6 +1597,8 @@ public class MaterialController {
}
}
mp.setProducedDateList(producedDateList);
List<SplitInfo> splitInfoByMid = splitUnitService.findSplitInfoByMid(mp.getMid());
mp.setSplitInfoList(splitInfoByMid);
}
return new RestResponse(mp, 1, 200);
@ -1739,7 +1745,6 @@ public class MaterialController {
* @param request
* @return
*/
@PostMapping("/editPlaceMaterial")
public RestResponse editPlaceMaterial(@RequestBody Map<String, Object> map, HttpServletRequest request) {
Integer integer = materialService.editPlaceMaterial(map);
@ -1749,4 +1754,51 @@ public class MaterialController {
return CrudUtil.putHandle(1, integer);
}
}
/**
* 用于根据当前单位查询对应数量的库存
*
* @param map
* @return
*/
@PostMapping("/findQuantityByUnit")
public RestResponse findQuantityByUnit(@RequestBody Map<String, Object> map) {
if (map.containsKey("placeId")) {
// 定义最终数量
Integer quantity = 0;
// 获取当前的计量单位
String unit = (String) map.get("unit");
// 获取当前库存id
Integer id = ObjectFormatUtil.toInteger(map.get("mid"));
// 获取当前判断库位
Integer placeId = ObjectFormatUtil.toInteger(map.get("placeId"));
// 获取当前库存所在库位的对应信息
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(placeId, id);
if ("-1".equals(unit)) {
// 如果盘点的是默认单位
quantity = placeAndMaterialByMidAndPid.getQuantity();
} else {
// 如果不是
// 获取当前库存信息
Inventory inventory = materialService.findInventoryById(id);
// 用于获取对应拆单记录
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("newUnit", unit);
paramForSplitInfo.put("mid", inventory.getMid());
// 获取拆单记录
SplitInfo splitInfo = splitUnitService.findSplitInfoByMidAndUnit(paramForSplitInfo);
// 获取当前拆单记录对应的库存数量
SplitInventory splitInventoryByIidAndSid = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), splitInfo.getId());
quantity = splitInventoryByIidAndSid.getSaveQuantity();
}
return new RestResponse(quantity);
} else {
throw new MyException("缺少必要参数");
}
}
}

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

@ -94,17 +94,18 @@ public class StockTakingController {
param.put("state",3);
param.put("departmentManagerState",3);
param.put("originator",userToken.getId());
for (int i = 0; i < params.size(); i++) {
Integer temp = ObjectFormatUtil.toInteger(params.get(i));
for (Object o : params) {
Integer temp = ObjectFormatUtil.toInteger(o);
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));
param.put("producedDate",map.get("producedDate"+temp));
param.put("temp",temp);
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));
param.put("producedDate", map.get("producedDate" + temp));
param.put("unit",map.get("unit"+temp));
param.put("temp", temp);
success += stockTakingService.insertStockTaking(param);
param.remove("id");
}
@ -116,6 +117,7 @@ public class StockTakingController {
param.put("takingResult",map.get("takingResult"));
param.put("inventory",map.get("inventory"));
param.put("producedDate",map.get("producedDate"));
param.put("unit",map.get("unit"));
success += stockTakingService.insertStockTaking(param);
Object mainId = param.get("mainId");
@ -139,7 +141,7 @@ public class StockTakingController {
}).start();*/
// 用于发送审批
new Thread(new Runnable() {
/*new Thread(new Runnable() {
@Override
public void run() {
JSONObject jsonObject = qyWxOperationService.sendApprovalTemplateStockTaking(crypt, userToken, ObjectFormatUtil.toInteger(mainId), QyWxDepartmentManager.toString());
@ -152,7 +154,7 @@ public class StockTakingController {
redisTemplateForHash.expire(sp_no,7,TimeUnit.DAYS);
}
}).start();
*/
}
else{
@ -177,7 +179,7 @@ public class StockTakingController {
}).start();*/
// 用于发送审批
new Thread(new Runnable() {
/*new Thread(new Runnable() {
@Override
public void run() {
JSONObject jsonObject = qyWxOperationService.sendApprovalTemplateStockTaking(crypt, userToken, ObjectFormatUtil.toInteger(mainId), QyWxDepartmentManager.toString());
@ -189,7 +191,7 @@ public class StockTakingController {
// 设置过期时间为7天
redisTemplateForHash.expire(sp_no,7,TimeUnit.DAYS);
}
}).start();
}).start();*/
}

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

@ -31,6 +31,7 @@
<result column="mtexture" property="mtexture" jdbcType="VARCHAR" />
<result column="mversion" property="mversion" jdbcType="VARCHAR" />
<result column="munit" property="munit" jdbcType="VARCHAR" />
<result column="stcUnit" property="unit" jdbcType="VARCHAR" />
<result column="tname" property="tname" jdbcType="VARCHAR" />
<result column="mcode" property="mcode" jdbcType="VARCHAR" />
<result column="mname" property="mname" jdbcType="VARCHAR" />
@ -47,7 +48,7 @@
</sql>
<sql id="StockTakingChildPAllColumns">
id,mid,oldInventory,newInventory,inventory,mainId,takingResult,mname,mtId,tname,mcode,mversion,munit,mtexture,producedDate
id,mid,oldInventory,newInventory,inventory,mainId,takingResult,mname,mtId,tname,mcode,mversion,munit,mtexture,producedDate,stcUnit
</sql>
<!-- 插入主表-->
@ -68,9 +69,9 @@
<!-- 插入子表-->
<insert id="insertStockTakingChild" useGeneratedKeys="true" keyProperty="id">
INSERT INTO stocktakingchild (id,mid,oldInventory,newInventory,takingResult,inventory,mainId,producedDate)
INSERT INTO stocktakingchild (id,mid,oldInventory,newInventory,takingResult,inventory,mainId,producedDate,unit)
values (
#{id},#{mid},#{oldInventory},#{newInventory},#{takingResult},#{inventory},#{mainId},#{producedDate}
#{id},#{mid},#{oldInventory},#{newInventory},#{takingResult},#{inventory},#{mainId},#{producedDate},#{unit}
)
</insert>
@ -163,7 +164,10 @@
mainId = #{mainId},
</if>
<if test="producedDate != null and producedDate != ''">
producedDate = #{producedDate}
producedDate = #{producedDate},
</if>
<if test="unit != null and unit != ''">
unit = #{unit}
</if>
</set>
where id = #{id}
@ -257,6 +261,9 @@
<if test="producedDate != null">
and producedDate = #{producedDate}
</if>
<if test="unit != null and unit !=''">
and unit = #{unit}
</if>
</select>
<select id="selectStockTakingById" resultMap="StockTakingMap">
@ -278,11 +285,11 @@
<include refid="StockTakingAllColumns"/>
from stocktaking st
where 1 = 1
<if test='isDone == "0"'>
<if test='isDone == 0'>
and (state = 3 and departmentManagerState = 3 and FIND_IN_SET(#{userId},st.departmentManager) != 0 )
or (state = 3 and departmentManagerState != 3 and #{userId} = st.originator)
</if>
<if test='isDone == "1"'>
<if test='isDone == 1'>
and (state != 3 and departmentManagerState != 3 and FIND_IN_SET(#{userId},st.departmentManager) != 0 )
or (state != 3 and departmentManagerState != 3 and #{userId} = st.originator)
</if>
@ -296,11 +303,11 @@
count(*)
from stocktaking st
where 1 = 1
<if test='isDone == "0"'>
<if test='isDone == 0'>
and (state = 3 and departmentManagerState = 3 and FIND_IN_SET(#{userId},st.departmentManager) != 0 )
or (state = 3 and departmentManagerState != 3 and #{userId} = st.originator)
</if>
<if test='isDone == "1"'>
<if test='isDone == 1'>
and (state != 3 and departmentManagerState != 3 and FIND_IN_SET(#{userId},st.departmentManager) != 0 )
or (state != 3 and departmentManagerState != 3 and #{userId} = st.originator)
</if>

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

@ -96,6 +96,12 @@ public class StockTakingChildP {
*/
private Long producedDate;
/**
* 当前盘点的计量单位
*/
private String unit;
}

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

@ -338,11 +338,7 @@ public interface MaterialService {
*/
void closeTreeChildren(Long mtId);
/**
* 用于构造物料数新算法
* @return
*/
List<Object> InitMaterialTree_New();
/**
* 用于修改库位中的物料
@ -354,7 +350,9 @@ public interface MaterialService {
/**
* 通过物料名称构造树
* @param mname 物料名称
* @param map 相关数据
* @param type 类型出入库盘点
* @return
*/
List<Object> InitTreeForSelectName(String mname,String type);
List<Object> InitTreeForSelectName(String mname,String type,Map<String,Object> map);
}

1
src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java

@ -2412,6 +2412,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
map.put("mid", material.getMid());
map.put("depositoryId", transferRecord.getToId());
map.put("placeId", transferRecord.getToPlaceId());
map.put("unit",unit);
if ("-1".equals(unit)) {
// 如果是基础单位

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

@ -49,6 +49,18 @@ public class MaterialServiceImpl implements MaterialService {
@Autowired
SplitUnitMapper splitUnitMapper;
/**
* 用于深度拷贝列表
*
* @param oldList
* @param <T>
* @return
*/
public static <T> List<T> deepCopy(List<T> oldList) {
List<T> newList = (List<T>) Arrays.asList(new Object[oldList.size()]);
Collections.copy(newList, oldList);
return newList;
}
/**
* 增加一条库存记录
@ -107,7 +119,6 @@ public class MaterialServiceImpl implements MaterialService {
return materialMapper.insertMaterial(map);
}
/**
* 增加一条库存记录
*
@ -164,7 +175,6 @@ public class MaterialServiceImpl implements MaterialService {
return materialMapper.updateMaterial(map);
}
/**
* 根据id删除一条库存记录
*
@ -416,7 +426,6 @@ public class MaterialServiceImpl implements MaterialService {
return inventoryByMid;
}
/**
* 根据物料id获取其在对应仓库中的库存数
*
@ -570,7 +579,6 @@ public class MaterialServiceImpl implements MaterialService {
return materialMapper.updateStateByParam(map);
}
/**
* 对查出来的库存记录进行包装包装成前端需要的数据
*
@ -636,7 +644,7 @@ public class MaterialServiceImpl implements MaterialService {
List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(m.getId(), m.getDepositoryId());
Map<String,Integer> splitInventoryForUnit = new HashMap<>();
Map<String, Integer> splitInventoryForUnit = new HashMap<>();
// 获取拆单信息对应库存
StringBuilder showQuantity = new StringBuilder();
@ -646,8 +654,8 @@ public class MaterialServiceImpl implements MaterialService {
if (Integer.compare(m.getQuantity(), 0) != 0) {
showQuantity.append(m.getUnit()).append(":").append(m.getQuantity()).append(" ");
}
for (PlaceP place:
placeByMidAndDid) {
for (PlaceP place :
placeByMidAndDid) {
// 获取当前具体数据
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(place.getId(), m.getId());
// 获取当前是否存在拆单处理记录
@ -657,14 +665,14 @@ public class MaterialServiceImpl implements MaterialService {
for (SplitInventory splitInventory : splitInventoryList) {
SplitInfo splitInfo = splitUnitMapper.findSplitInfoById(splitInventory.getSid());
if (Integer.compare(splitInventory.getSaveQuantity(), 0) != 0) {
if(splitInventoryForUnit.containsKey(splitInfo.getNewUnit())){
if (splitInventoryForUnit.containsKey(splitInfo.getNewUnit())) {
// 如果当前存在该拆单类型的记录
// 更新当前类型数据
splitInventoryForUnit.put(splitInfo.getNewUnit(),splitInventoryForUnit.get(splitInfo.getNewUnit())+splitInventory.getSaveQuantity());
}else{
splitInventoryForUnit.put(splitInfo.getNewUnit(), splitInventoryForUnit.get(splitInfo.getNewUnit()) + splitInventory.getSaveQuantity());
} else {
// 如果不存在,则新增
splitInventoryForUnit.put(splitInfo.getNewUnit(),splitInventory.getSaveQuantity());
splitInventoryForUnit.put(splitInfo.getNewUnit(), splitInventory.getSaveQuantity());
}
// 计算拆单后的单价
BigDecimal bigDecimal = BigDecimal.valueOf(inventory.getPrice() / splitInfo.getQuantity());
@ -678,14 +686,13 @@ public class MaterialServiceImpl implements MaterialService {
// 设置新总额
m.setAmounts(m.getAmounts() + amounts);
// 获取当前各拆单信息对应的库存
splitInventoryForUnit.put(inventory.getUnit(),inventory.getQuantity());
splitInventoryForUnit.put(inventory.getUnit(), inventory.getQuantity());
m.setShowQuantity(splitInventoryForUnit);
result.add(m);
}
return result;
}
/**
* 对查出来的物料记录进行包装包装成前端需要的数据
*
@ -1123,7 +1130,6 @@ public class MaterialServiceImpl implements MaterialService {
}
}
/**
* 设置当前树结构为打开状态
*
@ -1192,7 +1198,6 @@ public class MaterialServiceImpl implements MaterialService {
}
/**
* 用于判断当前类型是几级子类
*
@ -1262,12 +1267,6 @@ public class MaterialServiceImpl implements MaterialService {
}
}
@Override
public List<Object> InitMaterialTree_New() {
List<Object> objectList = buildTree_New(InitTree_Test_New(), Long.valueOf(0));
return objectList;
}
/**
* 用于修改库位中的物料
*
@ -1346,7 +1345,6 @@ public class MaterialServiceImpl implements MaterialService {
return 1;
}
/**
* 用于真实关闭打开的树
*
@ -1388,7 +1386,6 @@ public class MaterialServiceImpl implements MaterialService {
return ja;
}
/**
* 重构树结构
*
@ -1487,7 +1484,6 @@ public class MaterialServiceImpl implements MaterialService {
return children;
}
/**
* 构造树形选择框
*
@ -1604,61 +1600,6 @@ public class MaterialServiceImpl implements MaterialService {
return list;
}
// 用于执行线程任务(用于构造物料树形)
class Task implements Callable<Object> {
MaterialType mt;
String mname;
String adminorg;
public Task(MaterialType mt, String mname, String adminorg) {
this.mt = mt;
this.mname = mname;
this.adminorg = adminorg;
}
@Override
public Object call() throws Exception {
List<Object> childForMaterialTypeByParent = findChildForMaterialTypeByParent(mt.getOldId(), mname, adminorg);
Map<String, Object> stringObjectMap = new HashMap<>();
if (childForMaterialTypeByParent != null) {
stringObjectMap = InitTreeMenus(mt, childForMaterialTypeByParent);
} else {
List<Object> materialByType = AddMaterialByType(mt, mname, adminorg);
stringObjectMap = InitTreeMenus(mt, materialByType);
}
return stringObjectMap;
}
}
class TaskForTaking implements Callable<Object> {
MaterialType mt;
String mname;
String placeId;
String depositoryId;
public TaskForTaking(MaterialType mt, String mname, String depositoryId, String placeId) {
this.mt = mt;
this.mname = mname;
this.placeId = placeId;
this.depositoryId = depositoryId;
}
@Override
public Object call() throws Exception {
List<Object> childForMaterialTypeByParent = findChildForMaterialTypeByParent(mt.getOldId(), mname, depositoryId, placeId);
Map<String, Object> stringObjectMap = new HashMap<>();
if (childForMaterialTypeByParent != null) {
stringObjectMap = InitTreeMenus(mt, childForMaterialTypeByParent);
} else {
List<Object> materialByType = AddMaterialByType(mt, mname, depositoryId, placeId);
stringObjectMap = InitTreeMenus(mt, materialByType);
}
return stringObjectMap;
}
}
// 构造树形组件数据模板
public Map<String, Object> InitTreeMenus(MaterialType mt, List<Object> children) {
if (mt != null) {
@ -1672,7 +1613,6 @@ public class MaterialServiceImpl implements MaterialService {
}
}
// 构造树形组件数据模板
public Map<String, Object> InitTreeMenusTest(MaterialType mt, List<Object> children) {
if (mt != null) {
@ -1939,7 +1879,6 @@ public class MaterialServiceImpl implements MaterialService {
}
}
// 根据类别id获取子类(盘点专用)
public List<Object> findChildForMaterialTypeByParent(Long id, String mname, String depositoryId, String placeId) {
Map<String, Object> param = new HashMap<>();
@ -1969,7 +1908,6 @@ public class MaterialServiceImpl implements MaterialService {
}
}
// 用于测试构造属性框
public List<Object> InitTreeMenus_Test() {
List<Object> list = new ArrayList<>();
@ -2025,34 +1963,6 @@ public class MaterialServiceImpl implements MaterialService {
}
}
// 用于执行测试新算法
class TaskTest implements Callable<Object> {
MaterialType mt;
Integer level;
Integer staticLevel;
public TaskTest(MaterialType mt, Integer level, Integer staticLevel) {
this.mt = mt;
this.level = level;
this.staticLevel = staticLevel;
}
@Override
public Object call() throws Exception {
List<Object> childForMaterialTypeByParent = findChildForMaterialTypeByParent_Test(mt.getOldId(), 1, 1);
Map<String, Object> stringObjectMap = new HashMap<>();
if (childForMaterialTypeByParent != null) {
stringObjectMap = InitTreeMenus(mt, childForMaterialTypeByParent);
} else {
List<Object> materialByType = AddMaterialByType(mt, "", "");
stringObjectMap = InitTreeMenus(mt, materialByType);
}
return stringObjectMap;
}
}
// 根据id获取子类(只获取类别)
public List<Object> findChildForMaterialTypeByParent_OnlyType(Long Oldid) {
Map<String, Object> param = new HashMap<>();
@ -2073,7 +1983,6 @@ public class MaterialServiceImpl implements MaterialService {
}
}
// 根据id获取子类
public List<Object> findChildForMaterialTypeByParent_Test(Long Oldid, int level, int staticlevel) {
Map<String, Object> param = new HashMap<>();
@ -2103,20 +2012,6 @@ public class MaterialServiceImpl implements MaterialService {
}
/**
* 用于深度拷贝列表
*
* @param oldList
* @param <T>
* @return
*/
public static <T> List<T> deepCopy(List<T> oldList) {
List<T> newList = (List<T>) Arrays.asList(new Object[oldList.size()]);
Collections.copy(newList, oldList);
return newList;
}
/**
* 用于构造物料树结构
*
@ -2186,91 +2081,6 @@ public class MaterialServiceImpl implements MaterialService {
return list;
}
// 用于执行测试新算法
class TaskTest_New implements Callable<Object> {
// 待处理的物料类型id列表
List<Long> materialTypeIdList;
public TaskTest_New(List<Long> materialTypeByCondition) {
this.materialTypeIdList = materialTypeByCondition;
}
@Override
public Object call() throws Exception {
// 定义树结构结果集
List<Object> list = new ArrayList<>();
// 查询当前物料类型id列表中的物料类型
List<Material> materialByTypeIds = materialMapper.findMaterialByTypeIds(materialTypeIdList);
// 查询当前物料类型所包含的物料
List<MaterialType> materialTypeByOldIds = materialTypeMapper.findMaterialTypeByOldIds(materialTypeIdList);
// 定义线程集
ExecutorService exs = Executors.newFixedThreadPool(materialTypeByOldIds.size());
// 定义线程结果集
List<Future<Object>> futureList = new ArrayList<Future<Object>>();
// 1.定义CompletionService
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs);
for (int i = 0; i < materialTypeByOldIds.size(); i++) {
// 获取当前物料类型
MaterialType mt = materialTypeByOldIds.get(i);
// 开启对应线程
Future<Object> future = completionService.submit(new MtTaskTest_New(mt, materialByTypeIds));
// 添加到线程结果列表
futureList.add(future);
}
// 3.获取结果
for (int i = 0; i < materialTypeIdList.size(); i++) {
Object result = null;
try {
result = completionService.take().get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
list.add(result);
}
return list;
}
}
// 用于执行测试新算法
class MtTaskTest_New implements Callable<Object> {
MaterialType mt; // 物料类型
List<Material> materiaList; // 物料列表
public MtTaskTest_New(MaterialType mt, List<Material> materiaList) {
this.mt = mt;
this.materiaList = materiaList;
}
@Override
public Object call() throws Exception {
// 开启对应数量的线程
List<Material> materialList = new ArrayList<>();
for (int i = 0; i < materiaList.size(); i++) {
Material material = materiaList.get(i);
// 如果当前物料是当前物料类型下的物料
if (Long.compare(material.getMaterialTypeId(), mt.getOldId()) == 0) {
materialList.add(material);
}
}
// 将物料打包成树结构对应结果
List<Object> objectList = AddMaterialByType_New(materialList);
// 封装成对应的结构
Map<String, Object> objectMap = InitTreeMenus_New(mt, objectList);
return objectMap;
}
}
// 构造树形组件数据模板
public Map<String, Object> InitTreeMenus_New(MaterialType mt, List<Object> children) {
if (mt != null) {
@ -2329,23 +2139,22 @@ public class MaterialServiceImpl implements MaterialService {
return result;
}
/**
* 用于构造物料树结构(通过物料名称搜索)
*
* @return
*/
public List<Object> InitTreeForSelectName(String mname, String type) {
public List<Object> InitTreeForSelectName(String mname, String type,Map<String,Object> map) {
// 获取所有物料类型
List<MaterialType> materialTypeAll = materialTypeMapper.findMaterialTypeAll();
// 物料总数
Integer totalVal = materialTypeAll.size();
int totalVal = materialTypeAll.size();
// 定义分页数量
double size = 100.0;
// 定义线程数
Integer threadSize = (int) Math.ceil(totalVal / size);
int threadSize = (int) Math.ceil(totalVal / size);
// 开启对应数量的线程
ExecutorService exs = Executors.newFixedThreadPool(threadSize);
@ -2358,12 +2167,22 @@ public class MaterialServiceImpl implements MaterialService {
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs);
// 物料类型id列表
List<Long> materialTypeList = new ArrayList<>();
// 用于标志是否为库存盘点
boolean flagForStock = false;
if("3".equals(type)){
// 如果是库存盘点
flagForStock = true;
}
for (int i = 0; i < materialTypeAll.size(); i++) {
// 获取当前类型
MaterialType materialType = materialTypeAll.get(i);
if (((i + 1) % 100) == 0) { // 如果有100个开启线程进行处理
materialTypeList.add(materialType.getOldId());
Future<Object> future = completionService.submit(new TaskTestForSelectMname(materialTypeList, mname, type));
TaskTestForSelectMname taskTestForSelectMname = new TaskTestForSelectMname(materialTypeList, mname, type);
if(flagForStock){
taskTestForSelectMname.setMap(map);
}
Future<Object> future = completionService.submit(taskTestForSelectMname);
futureList.add(future); // 添加到结果集
materialTypeList = new ArrayList<>(); // 情况列表
} else {
@ -2374,7 +2193,11 @@ public class MaterialServiceImpl implements MaterialService {
if (materialTypeList.size() > 0) {
// 如果有剩余,开启线程进行处理
Future<Object> future = completionService.submit(new TaskTestForSelectMname(materialTypeList, mname, type));
TaskTestForSelectMname taskTestForSelectMname = new TaskTestForSelectMname(materialTypeList, mname, type);
if(flagForStock){
taskTestForSelectMname.setMap(map);
}
Future<Object> future = completionService.submit(taskTestForSelectMname);
futureList.add(future);
}
@ -2394,38 +2217,308 @@ public class MaterialServiceImpl implements MaterialService {
return buildTreeForSelectName(list);
}
// 用于执行测试新算法(通过物料名称搜索)
class TaskTestForSelectMname implements Callable<Object> {
// 待处理的物料类型id列表
List<Long> materialTypeIdList;
String mname;
// 1入库2出库3盘点
String type;
public TaskTestForSelectMname(List<Long> materialTypeByCondition, String mname, String type) {
this.materialTypeIdList = materialTypeByCondition;
this.mname = mname;
this.type = type;
// 构造树形组件数据模板(通过物料名称搜索)
public Map<String, Object> InitTreeMenusForSelectName(MaterialType mt, List<Object> children) {
if (mt != null) {
Map<String, Object> map = new HashMap<>();
map.put("title", mt.getTname());
map.put("id", mt.getOldId());
map.put("parentId", mt.getParentId());
map.put("children", children);
return map;
} else {
return null;
}
}
@Override
public Object call() throws Exception {
// 定义树结构结果集
List<Object> list = new ArrayList<>();
// 查询当前物料类型id列表中的物料类型
Map<String, Object> paramForMnameAndMtid = new HashMap<>();
paramForMnameAndMtid.put("list", materialTypeIdList);
paramForMnameAndMtid.put("mname", mname);
List<Material> materialByTypeIds = new ArrayList<>();
List<Inventory> inventoryByTypeIdsAndMname = new ArrayList<>();
if ("1".equals(type)) {
materialByTypeIds = materialMapper.findMaterialByTypeIdsAndMname(paramForMnameAndMtid);
// 在类别后添加物料名称(通过物料名称搜索)
public List<Object> AddMaterialByTypeForSelectMname(List<Material> materialList, List<Inventory> inventoryList) {
List<Object> result = new ArrayList<>();
if (materialList != null) {
for (Material material : materialList) {
Map<String, Object> map = new HashMap<>();
String version = material.getVersion();
if (version == null) {
version = "";
}
String title = "";
title = material.getMname() + ",规格型号: " + version;
map.put("title", title);
map.put("id", material.getId());
result.add(map);
}
} else if (inventoryList != null) {
for (Inventory inventory : inventoryList) {
Map<String, Object> map = new HashMap<>();
String version = inventory.getVersion();
if (version == null) {
version = "";
}
StringBuilder title = new StringBuilder();
title = new StringBuilder(inventory.getMname() + ",规格型号: " + version + ",库存数量:" + inventory.getUnit() + ":" + inventory.getQuantity());
// 获取对应拆单库存处理记录
List<SplitInventory> splitInventoryList = splitUnitMapper.findSplitInventoryByIid(inventory.getId());
if (splitInventoryList.size() > 0) {
// 如果不为空
// 获取对应拆单信息
for (SplitInventory splitInventory :
splitInventoryList) {
SplitInfo splitInfoById = splitUnitMapper.findSplitInfoById(splitInventory.getSid());
title.append(",").append(splitInfoById.getNewUnit()).append(":").append(splitInventory.getSaveQuantity());
}
}
map.put("title", title.toString());
map.put("id", inventory.getId());
result.add(map);
}
}
return result;
}
/**
* 用于构造树结构通过物料名称搜索)
*
* @param list 树列表
* @return
*/
public List<Object> buildTreeForSelectName(List<Object> list) {
// 定义树结构
List<Object> result = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
// 构造为jsonObject类
JSONObject jsonObject = new JSONObject((Map<String, Object>) list.get(i));
JSONArray children = jsonObject.getJSONArray("children");
if (children.size() > 0) {
result.add(jsonObject);
}
}
return result;
}
// 用于执行线程任务(用于构造物料树形)
class Task implements Callable<Object> {
MaterialType mt;
String mname;
String adminorg;
public Task(MaterialType mt, String mname, String adminorg) {
this.mt = mt;
this.mname = mname;
this.adminorg = adminorg;
}
@Override
public Object call() throws Exception {
List<Object> childForMaterialTypeByParent = findChildForMaterialTypeByParent(mt.getOldId(), mname, adminorg);
Map<String, Object> stringObjectMap = new HashMap<>();
if (childForMaterialTypeByParent != null) {
stringObjectMap = InitTreeMenus(mt, childForMaterialTypeByParent);
} else {
List<Object> materialByType = AddMaterialByType(mt, mname, adminorg);
stringObjectMap = InitTreeMenus(mt, materialByType);
}
return stringObjectMap;
}
}
class TaskForTaking implements Callable<Object> {
MaterialType mt;
String mname;
String placeId;
String depositoryId;
public TaskForTaking(MaterialType mt, String mname, String depositoryId, String placeId) {
this.mt = mt;
this.mname = mname;
this.placeId = placeId;
this.depositoryId = depositoryId;
}
@Override
public Object call() throws Exception {
List<Object> childForMaterialTypeByParent = findChildForMaterialTypeByParent(mt.getOldId(), mname, depositoryId, placeId);
Map<String, Object> stringObjectMap = new HashMap<>();
if (childForMaterialTypeByParent != null) {
stringObjectMap = InitTreeMenus(mt, childForMaterialTypeByParent);
} else {
List<Object> materialByType = AddMaterialByType(mt, mname, depositoryId, placeId);
stringObjectMap = InitTreeMenus(mt, materialByType);
}
return stringObjectMap;
}
}
// 用于执行测试新算法
class TaskTest implements Callable<Object> {
MaterialType mt;
Integer level;
Integer staticLevel;
public TaskTest(MaterialType mt, Integer level, Integer staticLevel) {
this.mt = mt;
this.level = level;
this.staticLevel = staticLevel;
}
@Override
public Object call() throws Exception {
List<Object> childForMaterialTypeByParent = findChildForMaterialTypeByParent_Test(mt.getOldId(), 1, 1);
Map<String, Object> stringObjectMap = new HashMap<>();
if (childForMaterialTypeByParent != null) {
stringObjectMap = InitTreeMenus(mt, childForMaterialTypeByParent);
} else {
List<Object> materialByType = AddMaterialByType(mt, "", "");
stringObjectMap = InitTreeMenus(mt, materialByType);
}
return stringObjectMap;
}
}
// 用于执行测试新算法(通过物料名称搜索)
// 用于执行测试新算法
class TaskTest_New implements Callable<Object> {
// 待处理的物料类型id列表
List<Long> materialTypeIdList;
public TaskTest_New(List<Long> materialTypeByCondition) {
this.materialTypeIdList = materialTypeByCondition;
}
@Override
public Object call() throws Exception {
// 定义树结构结果集
List<Object> list = new ArrayList<>();
// 查询当前物料类型id列表中的物料类型
List<Material> materialByTypeIds = materialMapper.findMaterialByTypeIds(materialTypeIdList);
// 查询当前物料类型所包含的物料
List<MaterialType> materialTypeByOldIds = materialTypeMapper.findMaterialTypeByOldIds(materialTypeIdList);
// 定义线程集
ExecutorService exs = Executors.newFixedThreadPool(materialTypeByOldIds.size());
// 定义线程结果集
List<Future<Object>> futureList = new ArrayList<Future<Object>>();
// 1.定义CompletionService
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs);
for (int i = 0; i < materialTypeByOldIds.size(); i++) {
// 获取当前物料类型
MaterialType mt = materialTypeByOldIds.get(i);
// 开启对应线程
Future<Object> future = completionService.submit(new MtTaskTest_New(mt, materialByTypeIds));
// 添加到线程结果列表
futureList.add(future);
}
// 3.获取结果
for (int i = 0; i < materialTypeIdList.size(); i++) {
Object result = null;
try {
result = completionService.take().get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
list.add(result);
}
return list;
}
}
// 用于执行测试新算法
class MtTaskTest_New implements Callable<Object> {
MaterialType mt; // 物料类型
List<Material> materiaList; // 物料列表
public MtTaskTest_New(MaterialType mt, List<Material> materiaList) {
this.mt = mt;
this.materiaList = materiaList;
}
@Override
public Object call() throws Exception {
// 开启对应数量的线程
List<Material> materialList = new ArrayList<>();
for (int i = 0; i < materiaList.size(); i++) {
Material material = materiaList.get(i);
// 如果当前物料是当前物料类型下的物料
if (Long.compare(material.getMaterialTypeId(), mt.getOldId()) == 0) {
materialList.add(material);
}
}
// 将物料打包成树结构对应结果
List<Object> objectList = AddMaterialByType_New(materialList);
// 封装成对应的结构
Map<String, Object> objectMap = InitTreeMenus_New(mt, objectList);
return objectMap;
}
}
// 用于执行测试新算法(通过物料名称搜索)
class TaskTestForSelectMname implements Callable<Object> {
// 待处理的物料类型id列表
List<Long> materialTypeIdList;
String mname;
// 1入库2出库3盘点
String type;
// 相关使用的数据
Map<String,Object> map;
public void setMap(Map<String, Object> map) {
this.map = map;
}
public TaskTestForSelectMname(List<Long> materialTypeByCondition, String mname, String type) {
this.materialTypeIdList = materialTypeByCondition;
this.mname = mname;
this.type = type;
}
@Override
public Object call() throws Exception {
// 定义树结构结果集
List<Object> list = new ArrayList<>();
// 查询当前物料类型id列表中的物料类型
Map<String, Object> paramForMnameAndMtid = new HashMap<>();
paramForMnameAndMtid.put("list", materialTypeIdList);
paramForMnameAndMtid.put("mname", mname);
List<Material> materialByTypeIds = new ArrayList<>();
List<Inventory> inventoryByTypeIdsAndMname = new ArrayList<>();
if ("1".equals(type)) {
// 如果是入库
materialByTypeIds = materialMapper.findMaterialByTypeIdsAndMname(paramForMnameAndMtid);
} else if ("2".equals(type)) {
// 如果是出库
inventoryByTypeIdsAndMname = materialMapper.findInventoryByTypeIdsAndMname(paramForMnameAndMtid);
}else if("3".equals(type)){
// 如果是盘点
List<Inventory> inventoryList = materialMapper.findInventoryByTypeIdsAndMname(paramForMnameAndMtid);
Integer placeId = ObjectFormatUtil.toInteger(map.get("placeId"));
// 查询当前存在于当前库位的物料
for (Inventory inventory:
inventoryList) {
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(placeId, inventory.getId());
if(placeAndMaterialByMidAndPid != null){
inventoryByTypeIdsAndMname.add(inventory);
}
}
}
// 查询当前物料类型所包含的物料
List<MaterialType> materialTypeByOldIds = materialTypeMapper.findMaterialTypeByOldIds(materialTypeIdList);
@ -2446,7 +2539,7 @@ public class MaterialServiceImpl implements MaterialService {
// 添加到线程结果列表
futureList.add(future);
}
} else if ("2".equals(type)) {
} else if ("2".equals(type) || "3".equals(type)) {
for (MaterialType mt : materialTypeByOldIds) {
// 获取当前物料类型
// 开启对应线程
@ -2475,8 +2568,6 @@ public class MaterialServiceImpl implements MaterialService {
}
// 用于执行测试新算法(通过物料名称搜索)
class MtTaskTestForSelectMname implements Callable<Object> {
MaterialType mt; // 物料类型
@ -2505,17 +2596,15 @@ public class MaterialServiceImpl implements MaterialService {
// 将物料打包成树结构对应结果
List<Object> objectList = new ArrayList<>();
if ("1".equals(type)) {
for (int i = 0; i < materiaList.size(); i++) {
Material material = materiaList.get(i);
for (Material material : materiaList) {
// 如果当前物料是当前物料类型下的物料
if (Long.compare(material.getMaterialTypeId(), mt.getOldId()) == 0) {
materialList.add(material);
}
}
objectList = AddMaterialByTypeForSelectMname(materialList, null);
} else if ("2".equals(type)) {
for (int i = 0; i < inventorys.size(); i++) {
Inventory inventory = inventorys.get(i);
} else if ("2".equals(type) || "3".equals(type)) {
for (Inventory inventory : inventorys) {
// 如果当前物料是当前物料类型下的物料
if (Long.compare(inventory.getMaterialTypeId(), mt.getOldId()) == 0) {
inventoryList.add(inventory);
@ -2525,90 +2614,8 @@ public class MaterialServiceImpl implements MaterialService {
}
// 封装成对应的结构
Map<String, Object> objectMap = InitTreeMenusForSelectName(mt, objectList);
return objectMap;
}
}
// 构造树形组件数据模板(通过物料名称搜索)
public Map<String, Object> InitTreeMenusForSelectName(MaterialType mt, List<Object> children) {
if (mt != null) {
Map<String, Object> map = new HashMap<>();
map.put("title", mt.getTname());
map.put("id", mt.getOldId());
map.put("parentId", mt.getParentId());
map.put("children", children);
return map;
} else {
return null;
}
}
// 在类别后添加物料名称(通过物料名称搜索)
public List<Object> AddMaterialByTypeForSelectMname(List<Material> materialList, List<Inventory> inventoryList) {
List<Object> result = new ArrayList<>();
if (materialList != null) {
for (Material material : materialList) {
Map<String, Object> map = new HashMap<>();
String version = material.getVersion();
if (version == null) {
version = "";
}
String title = "";
title = material.getMname() + ",规格型号: " + version;
map.put("title", title);
map.put("id", material.getId());
result.add(map);
}
} else if (inventoryList != null) {
for (Inventory inventory : inventoryList) {
Map<String, Object> map = new HashMap<>();
String version = inventory.getVersion();
if (version == null) {
version = "";
}
StringBuilder title = new StringBuilder();
title = new StringBuilder(inventory.getMname() + ",规格型号: " + version + ",库存数量:" + inventory.getUnit() + ":" + inventory.getQuantity());
// 获取对应拆单库存处理记录
List<SplitInventory> splitInventoryList = splitUnitMapper.findSplitInventoryByIid(inventory.getId());
if (splitInventoryList.size() > 0) {
// 如果不为空
// 获取对应拆单信息
for (SplitInventory splitInventory :
splitInventoryList) {
SplitInfo splitInfoById = splitUnitMapper.findSplitInfoById(splitInventory.getSid());
title.append(",").append(splitInfoById.getNewUnit()).append(":").append(splitInventory.getSaveQuantity());
}
}
map.put("title", title.toString());
map.put("id", inventory.getId());
result.add(map);
}
}
return result;
}
/**
* 用于构造树结构通过物料名称搜索)
*
* @param list 树列表
* @return
*/
public List<Object> buildTreeForSelectName(List<Object> list) {
// 定义树结构
List<Object> result = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
// 构造为jsonObject类
JSONObject jsonObject = new JSONObject((Map<String, Object>) list.get(i));
JSONArray children = jsonObject.getJSONArray("children");
if (children.size() > 0) {
result.add(jsonObject);
}
return InitTreeMenusForSelectName(mt, objectList);
}
return result;
}
}

8
src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java

@ -546,6 +546,8 @@ public class SplitUnitServiceImpl implements SplitUnitService {
map.put("quantity", String.valueOf(disposeQuantity));
map.put("realQuantity", String.valueOf(inQuantity));
depositoryRecordService.applicationInPlace(map);
// 删除入库订单
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
map.remove("id");
}
}
@ -561,6 +563,8 @@ public class SplitUnitServiceImpl implements SplitUnitService {
map.put("quantity", "0");
map.put("realQuantity", String.valueOf(inQuantity));
depositoryRecordService.applicationInPlace(map);
// 删除入库订单
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
map.remove("id");
}
}
@ -597,6 +601,8 @@ public class SplitUnitServiceImpl implements SplitUnitService {
map.put("quantity", String.valueOf(quantity_scale));
map.put("realQuantity", String.valueOf(inQuantity));
depositoryRecordService.applicationInPlace(map);
// 删除入库订单
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
map.remove("id");
}
} else {
@ -607,6 +613,8 @@ public class SplitUnitServiceImpl implements SplitUnitService {
map.put("realQuantity", String.valueOf(inQuantity));
map.put("price", map.get("price").toString());
depositoryRecordService.applicationInPlace(map);
// 删除入库订单
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
map.remove("id");
}

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

File diff suppressed because it is too large

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

@ -28,6 +28,7 @@
readonly/>
<input type="text" name="depositoryId" class="layui-input" id="depositoryId"
style="display: none"/>
<input type="text" name="placeId" id="placeId" style="display: none">
</div>
</div>
<div class="layui-inline">
@ -69,17 +70,24 @@
<a class="layui-btn layui-btn-xs data-count-edit" lay-event="applicationOut">出库申请</a>
</script>
<!-- 用于计量单位的展示-->
<!-- 用于计量单位的展示-->
<script id="changeUnit" type="text/html">
<button class="layui-btn layui-btn-primary layui-btn-xs" lay-event="changeUnit" click_num="0" id="btn_{{d.id}}" value="{{d.unit}}">{{d.unit}}</button>
<button class="layui-btn layui-btn-primary layui-btn-xs" lay-event="changeUnit" click_num="0"
id="btn_{{d.id}}" value="{{d.unit}}">{{d.unit}}
</button>
</script>
</div>
</div>
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
var data;
function changePlaceCode(){}
function changeUnit(){}
function changePlaceCode() {
}
function changeUnit() {
}
layui.use(['form', 'table', 'upload'], function () {
var $ = layui.jquery,
form = layui.form,
@ -87,8 +95,6 @@
table = layui.table;
$('#openSonByDepository').on('click', function () {
layer.open({
type: 2,
@ -100,12 +106,12 @@
move: '.layui-layer-title',
fixed: false,
content: '/selectDepository?type=2',
success: function(layero, index){
success: function (layero, index) {
var children = layero.children();
var content = $(children[1]);
var iframeChildren = $(content.children());
content.css('height','100%');
iframeChildren.css('height','100%');
content.css('height', '100%');
iframeChildren.css('height', '100%');
}
});
});
@ -144,7 +150,7 @@
{field: 'quantity', width: 200, title: '数量'},
{field: 'depositoryName', width: 200, title: '仓库名称'},
{field: 'depositoryCode', width: 200, title: '仓库编码'},
{title: '所处库位', width: 200, templet: '#selectManager', align: "center"},
{title: '所处库位', width: 200, templet: '#changePlace', align: "center"},
{field: 'warningCount', width: 200, title: '待过期数量', sort: true},
{field: 'price', title: '单价', width: 200, sort: true},
{field: 'amounts', title: '总金额', width: 200, sort: true},
@ -152,7 +158,7 @@
{title: '操作', minWidth: 250, toolbar: '#currentTableBar', align: "center"}
]
],
limits: [10, 15, 20, 25, 50,100],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
skin: 'line',
@ -172,14 +178,14 @@
}
// 所处库位
var placeCodeItem = $("[lay-id='currentTableId'] tr:eq(" + (i+1) + ")").children()[9];
var placeCodeItem = $("[lay-id='currentTableId'] tr:eq(" + (i + 1) + ")").children()[9];
//计量单位
// 用于库位的添加
var aItem = placeCodeItem.childNodes[0];
// 用于计量单位的添加
for (let k = 0; k < placeCode.length; k++) {
if(placeCode[k] !== ""){
$(aItem).append('<button id='+mid+' class="layui-btn layui-btn-primary layui-btn-xs" onclick="changePlaceCode(this)" value='+depositoryId+'>'+placeCode[k]+'</button>')
if (placeCode[k] !== "") {
$(aItem).append('<button id=' + mid + ' class="layui-btn layui-btn-primary layui-btn-xs" onclick="changePlaceCode(this)" value=' + depositoryId + '>' + placeCode[k] + '</button>')
}
}
@ -188,6 +194,7 @@
}
});
// 用于给table行上色的方法
function Layui_SetDataTableRowColor(TabDivId, RowIndex, ColorString) {
try {
@ -212,7 +219,7 @@
// 用于进行渲染库位编码
form.on('switch(createPlaceCode)', function (obj) {
console.log(obj)
console.log(obj)
});
// 监听库位修改操作
@ -228,6 +235,9 @@
if (data.depositoryId !== '') {
req.depositoryId = data.depositoryId;
}
if (data.placeId !== '') {
req.placeId = data.placeId;
}
if (data.code !== '') {
req.mcode = data.code;
}
@ -299,8 +309,7 @@
layer.msg("未选中记录,请确认!");
return false;
}
}
else if (obj.event === 'dispose') {
} else if (obj.event === 'dispose') {
var index = layer.open({
title: '入库申请',
type: 2,
@ -334,8 +343,7 @@
layer.full(index);
});
return false;
}
else if (obj.event === 'applicationOut') {
} else if (obj.event === 'applicationOut') {
// 出库申请
var index = layer.open({
title: '出库申请',
@ -350,24 +358,23 @@
layer.full(index);
});
return false;
}
else if (obj.event === 'changeUnit') {
let splitInfoList = data.splitInfoList;
let btn = $("#btn_"+data.id);
} else if (obj.event === 'changeUnit') {
let splitInfoList = data.splitInfoList;
let btn = $("#btn_" + data.id);
let clickNum = Number(btn.attr("click_num"));
if(splitInfoList.length > 0){
if(clickNum < splitInfoList.length){
let newUnit = splitInfoList[clickNum].newUnit;
if (splitInfoList.length > 0) {
if (clickNum < splitInfoList.length) {
let newUnit = splitInfoList[clickNum].newUnit;
btn.text(newUnit);
clickNum += 1;
btn.attr("click_num",clickNum);
btn.attr("click_num", clickNum);
let showQuantity = data.showQuantity[newUnit];
obj.update({quantity:showQuantity});
}else{
obj.update({quantity: showQuantity});
} else {
btn.text(data.unit);
btn.attr("click_num",0);
btn.attr("click_num", 0);
let showQuantity = data.showQuantity[data.unit];
obj.update({quantity:showQuantity});
obj.update({quantity: showQuantity});
}
}
@ -375,7 +382,8 @@
}
});
changePlaceCode = function (obj) {
// 用于更改同一仓库下的库位
changePlaceCode = function (obj) {
var depositoryId = obj.value;
var placeCode = obj.innerText;
var mid = obj.id;
@ -386,15 +394,15 @@
maxmin: true,
shadeClose: true,
area: ['70%', '70%'],
content: '/selectPlaceByDepository?depositoryId=' + depositoryId+'&mid='+mid+'&placeCode='+placeCode,
success: function(layero, index){
content: '/selectPlaceByDepository?depositoryId=' + depositoryId + '&mid=' + mid + '&placeCode=' + placeCode,
success: function (layero, index) {
var children = layero.children();
var content = $(children[1]);
var iframeChildren = $(content.children());
content.css('height','100%');
iframeChildren.css('height','100%');
content.css('height', '100%');
iframeChildren.css('height', '100%');
},
end:function () {
end: function () {
//执行搜索重载
table.reload('currentTableId', {
url: '/material/findInventory',
@ -429,12 +437,12 @@
re += show
}
for (let i = 0; i < res.data.dataList.length; i++) {
var code = res.data.dataList[i]["code"] === null?'':res.data.dataList[i]["code"];
var code = res.data.dataList[i]["code"] === null ? '' : res.data.dataList[i]["code"];
var mname = res.data.dataList[i]["mname"];
var version = res.data.dataList[i]["version"] === null?'':res.data.dataList[i]["version"];
var version = res.data.dataList[i]["version"] === null ? '' : res.data.dataList[i]["version"];
var price = res.data.dataList[i]["price"];
var quantity = res.data.dataList[i]["quantity"];
var show = "<p style='color: #00FF00'>" + code+", "+mname + ", " + version + ", 单价为" + price + ", 数量为" + quantity + ":成功" + "</p>";
var show = "<p style='color: #00FF00'>" + code + ", " + mname + ", " + version + ", 单价为" + price + ", 数量为" + quantity + ":成功" + "</p>";
re += show
}

4
src/main/resources/templates/pages/material/selectPlaceByDepository.html

@ -20,8 +20,12 @@
layui.use(['form', 'layer','dropdown','tree'], function () {
var $ = layui.jquery,
tree = layui.tree;
// 获取当前仓库
var depositoryId = $("#depositoryId").val();
// 当前库存总数
var quantity = $("#quantity").val();
// 定义转移前的库位
var fromPlaceId = $("#placeId").val();
var mid = $("#mid").val();
test = tree.render({

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

@ -168,8 +168,7 @@
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<input type="text" placeholder="请填写计量单位" class="layui-input"
name="unit"/>
<select id="unit" name="unit"></select>
</div>
</div>
<div class="layui-form-item" style="display: none" id="producedDateItem">
@ -338,15 +337,7 @@
title: '提交成功'
}]
});
// 用于选择生产日期
/* selectDate = function(obj) {
var name = obj.id;
laydate.render({
elem: '#'+name
, format: 'yyyy-MM-dd'
, show: true
});
};*/
// 用于打开仓库树形菜单
$('#openSonByDepository').on('click', function () {
@ -532,7 +523,7 @@
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<input name=` + "unit" + NewIdNumber + ` type="text" placeholder="请填写计量单位" class="layui-input" />
<select name=` + "unit" + NewIdNumber + ` id=` + "unit" + NewIdNumber + `></select>
</div>
</div>
<div class="layui-form-item" style="display: none" id=` + "producedDateItem" + NewIdNumber + `>
@ -721,55 +712,66 @@
},
end: function () {
var mid = materialId.value;
$.ajax({
url: "/material/findMatrialByIdAndPid?mid=" + mid + "&pid=" + placeId,
type: "get",
dataType: 'json',
contentType: "application/json;charset=utf-8",
success: function (d) {
var material = d.data.materialById;
var code = material.code;
if (code === undefined) {
code = "";
}
codeValue.value = code;
materialTypeItem[1].value = material.typeName;
materialTypeItem[3].value = material.typeId;
textureChildren.childNodes[3].childNodes[1].value = material.texture === null || material.texture === undefined ? '' : material.texture;
versionChildren.childNodes[3].childNodes[1].value = material.version === null || material.version === undefined ? '' : material.version;
unitChildren.childNodes[3].childNodes[1].value = material.unit === null || material.unit === undefined ? '' : material.unit;
inventoryChildren.childNodes[3].childNodes[1].value = material.quantity;
var materialAndBarCodeList = material.materialAndBarCodeList;
if (materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
var id = barCodeInput.id;
// barCodeInput.style = "display:none";
if(mid !== ''){
$.ajax({
url: "/material/findInventoryByIdAndPid?mid=" + mid + "&pid=" + placeId,
type: "get",
dataType: 'json',
contentType: "application/json;charset=utf-8",
success: function (d) {
var material = d.data.materialById;
var code = material.code;
if (code === undefined) {
code = "";
}
codeValue.value = code;
materialTypeItem[1].value = material.typeName;
materialTypeItem[3].value = material.typeId;
textureChildren.childNodes[3].childNodes[1].value = material.texture === null || material.texture === undefined ? '' : material.texture;
versionChildren.childNodes[3].childNodes[1].value = material.version === null || material.version === undefined ? '' : material.version;
inventoryChildren.childNodes[3].childNodes[1].value = material.quantity;
var materialAndBarCodeList = material.materialAndBarCodeList;
var idNumber = materialId.name.split("mid")[1];
form.render();
$.each(materialAndBarCodeList, function (index, item) {
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}
var shelfLife = material.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
$("#" + "producedDateItem" + idNumber).show();
var producedDateList = d.data['producedDateList'];
if (producedDateList != null && producedDateList != undefined && producedDateList.length > 0) {
$.each(producedDateList, function (index, item) {
$("#" + "producedDate" + idNumber).append(new Option(item, item));
if (materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
var id = barCodeInput.id;
form.render();
$.each(materialAndBarCodeList, function (index, item) {
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}
let unitItem = $("#unit"+idNumber);
unitItem.empty()
unitItem.append(new Option(material.unit,"-1"));
let splitInfoList = material.splitInfoList;
if(splitInfoList.length > 0){
$.each(splitInfoList, function (index, item) {
unitItem.append(new Option(item.newUnit, item.newUnit));
})
}
form.render();
}else{
$("#" + "producedDateItem" + idNumber).hide();
form.render();
}
var shelfLife = material.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
$("#" + "producedDateItem" + idNumber).show();
var producedDateList = d.data['producedDateList'];
if (producedDateList !== null && producedDateList !== undefined && producedDateList.length > 0) {
$.each(producedDateList, function (index, item) {
$("#" + "producedDate" + idNumber).append(new Option(item, item));
})
}
form.render();
}else{
$("#" + "producedDateItem" + idNumber).hide();
form.render();
}
}
});
}
});
}
}
});
} else {
@ -845,22 +847,31 @@
versionChildren.childNodes[3].childNodes[1].value = "";
unitChildren.childNodes[3].childNodes[1].value = "";
inventoryChildren.childNodes[3].childNodes[1].value = "";
} else {
}
else {
materialName.value = d.mname;
materialId.value = d.id;
materialTypeItem[1].value = d.typeName;
materialTypeItem[3].value = d.typeId;
textureChildren.childNodes[3].childNodes[1].value = d.texture === null || d.texture === undefined ? '' : d.texture;
versionChildren.childNodes[3].childNodes[1].value = d.version === null || d.version === undefined ? '' : d.version;
unitChildren.childNodes[3].childNodes[1].value = d.unit === null || d.unit === undefined ? '' : d.unit;
inventoryChildren.childNodes[3].childNodes[1].value = d.quantity;
// 获取物料与条形码的对应关系
var materialAndBarCodeList = d["materialAndBarCodeList"];
var idNumber = materialId.name.split("mid")[1];
let unit = $("#unit"+idNumber);
var barCode = $("#barCode" + idNumber);
if (barCode.length > 0) {
barCode.empty();
}
unit.empty();
unit.append(new Option(d.unit,"-1"));
if(d.splitInfoList !==null && d.splitInfoList.length > 0){
$.each(d.splitInfoList, function (index, item) {
unit.append(new Option(item.newUnit, item.newUnit));//往下拉菜单里添加元素
});
form.render();
}
if (materialAndBarCodeList !== null && materialAndBarCodeList.length > 0) {
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
@ -979,7 +990,7 @@
inventoryChildren.childNodes[3].childNodes[1].value = "";
return false;
} else {
var material = d.data[0];
var material = d.data;
materialName.value = material.mname;
materialId.value = material.id;
codeValue.value = material.code;
@ -987,26 +998,34 @@
materialTypeItem[3].value = material.typeId;
textureChildren.childNodes[3].childNodes[1].value = material.texture === null || material.texture === undefined ? '' : material.texture;
versionChildren.childNodes[3].childNodes[1].value = material.version === null || material.version === undefined ? '' : material.version;
unitChildren.childNodes[3].childNodes[1].value = material.unit === null || material.unit === undefined ? '' : material.unit;
inventoryChildren.childNodes[3].childNodes[1].value = material.quantity;
var idNumber = materialId.name.split("mid")[1];
// 获取物料与条形码的对应关系
var materialAndBarCodeList = material["materialAndBarCodeList"];
if (materialAndBarCodeList !== null && materialAndBarCodeList.length > 0) {
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
var id = barCodeInput.id;
var idNumber = materialId.name.split("mid")[1];
form.render();
$.each(materialAndBarCodeList, function (index, item) {
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}
let unitItem = $("#unit"+idNumber);
unitItem.empty();
unitItem.append(new Option(material.unit,"-1"));
let splitInfoList = material.splitInfoList;
if(splitInfoList.length > 0){
$.each(splitInfoList, function (index, item) {
unitItem.append(new Option(item.newUnit, item.newUnit));
})
}
var shelfLife = d.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
$("#" + "producedDateItem" + idNumber).show();
var producedDateList = d['producedDateList'];
if (producedDateList != null && producedDateList != undefined && producedDateList.length > 0) {
if (producedDateList !== null && producedDateList !== undefined && producedDateList.length > 0) {
$.each(producedDateList, function (index, item) {
$("#" + "producedDate" + idNumber).append(new Option(item, item));
})
@ -1170,6 +1189,7 @@
scanMaterialCodeForTaking = function (obj) {
if (depositoryId !== undefined && departmentManagerId !== undefined && departmentManagerId !== "") {
parent.wx.scanQRCode({
desc: 'scanQRCode desc',
needResult: 1, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
@ -1238,22 +1258,32 @@
inventoryChildren.childNodes[3].childNodes[1].value = data.quantity;
// 获取物料与条形码的对应关系
var materialAndBarCodeList = data["materialAndBarCodeList"];
var idNumber = materialId.name.split("mid")[1];
if (materialAndBarCodeList !== null && materialAndBarCodeList.length > 0) {
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
var id = barCodeInput.id;
var idNumber = materialId.name.split("mid")[1];
form.render();
$.each(materialAndBarCodeList, function (index, item) {
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}
var unitItem = $("#unit"+idNumber);
unitItem.empty();
unitItem.append(new Option(data.unit,"-1"));
let splitInfoList = data.splitInfoList;
if(splitInfoList.length > 0){
$.each(splitInfoList,function (index,item) {
unitItem.append(new Option(item.newUnit,item.newUnit));
})
}
form.render();
var shelfLife = data.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
$("#" + "producedDateItem" + idNumber).show();
var producedDateList = data['producedDateList'];
if (producedDateList != null && producedDateList != undefined && producedDateList.length > 0) {
if (producedDateList !== null && producedDateList !== undefined && producedDateList.length > 0) {
$.each(producedDateList, function (index, item) {
$("#" + "producedDate" + idNumber).append(new Option(item, item));
})
@ -1336,8 +1366,6 @@
// 物料种类条目
var materialTypeItem = typeChildren.childNodes[3].childNodes;
// 条形码条目
var barCodeItem = barCodeChildren.childNodes[3];
materialName.value = material.mname;
materialId.value = material.id;
@ -1346,14 +1374,13 @@
materialTypeItem[3].value = material.typeId;
textureChildren.childNodes[3].childNodes[1].value = material.texture === null || material.texture === undefined ? '' : material.texture;
versionChildren.childNodes[3].childNodes[1].value = material.version === null || material.version === undefined ? '' : material.version;
unitChildren.childNodes[3].childNodes[1].value = material.unit === null || material.unit === undefined ? '' : material.unit;
inventoryChildren.childNodes[3].childNodes[1].value = material.quantity;
$("#barCode" + id).append(new Option(result, 0));//往下拉菜单里添加元素
var shelfLife = material.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
$("#" + "producedDateItem" + id).show();
var producedDateList = material['producedDateList'];
if (producedDateList != null && producedDateList != undefined && producedDateList.length > 0) {
if (producedDateList !== null && producedDateList !== undefined && producedDateList.length > 0) {
$.each(producedDateList, function (index, item) {
$("#" + "producedDate" + id).append(new Option(item, item));
})
@ -1361,10 +1388,21 @@
form.render();
}
else{
$("#" + "producedDateItem" + idNumber).hide();
$("#" + "producedDateItem" + id).hide();
form.render();
}
form.render();
var unitItem = $("#unit"+id);
unitItem.empty();
unitItem.append(new Option(material.unit,"-1"));
let splitInfoList = material.splitInfoList;
if(splitInfoList.length > 0){
$.each(splitInfoList,function (index,item) {
unitItem.append(new Option(item.newUnit,item.newUnit));
})
}
form.render();
}
if (barCodeListByNoMaterial.length > 0) {
// 如果扫描的条形码没有对应的物料
@ -1445,9 +1483,9 @@
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对应数字
var req = {};
req.mid = $("#" + "mid" + idNumber).val();
req.producedDate = data.value;
$.ajax({
@ -1461,6 +1499,22 @@
}
});
}
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)
}
});
}
});
});

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

@ -171,7 +171,7 @@
<div class="layui-input-block">
<input type="text" placeholder="请填写计量单位"
class="layui-input" readonly
th:value="${recordMin.getMunit()}"
th:value="${recordMin.getUnit()}"
th:attr="id='unit'+${recordMin.getId()},name='unit'+${recordMin.getId()}"
/>
</div>

2
src/main/resources/templates/pages/stockTaking/stockTakingReview.html

@ -169,7 +169,7 @@
<div class="layui-input-block">
<input type="text" placeholder="请填写计量单位"
class="layui-input"
th:value="${recordMin.getMunit()}"
th:value="${recordMin.getUnit()}"
th:attr="id='unit'+${recordMin.getId()},name='unit'+${recordMin.getId()}"
/>
</div>

2
src/main/resources/templates/pages/stockTaking/stockTakingView.html

@ -172,7 +172,7 @@
<div class="layui-input-block">
<input type="text" placeholder="请填写计量单位"
class="layui-input"
th:value="${recordMin.getMunit()}"
th:value="${recordMin.getUnit()}"
th:attr="id='unit'+${recordMin.getId()},name='unit'+${recordMin.getId()}"
/>
</div>

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

@ -36,9 +36,7 @@ public class TestForOther {
@Test
public void Test() throws IOException {
SplitInfo splitInfoById = splitUnitMapper.findSplitInfoById(4);
double splitInfoScaleQuantity = findSplitInfoScaleQuantity(splitInfoById, null);
System.out.println(splitInfoScaleQuantity);
}

0
target/classes/.restartTriggerFile

BIN
target/classes/META-INF/depository_manage (2).kotlin_module

Binary file not shown.

17
target/classes/META-INF/spring-configuration-metadata.json

@ -1,17 +0,0 @@
{
"groups": [
{
"name": "file",
"type": "com.dreamchaser.depository_manage.config.FileConfig",
"sourceType": "com.dreamchaser.depository_manage.config.FileConfig"
}
],
"properties": [
{
"name": "file.upload-path",
"type": "java.lang.String",
"sourceType": "com.dreamchaser.depository_manage.config.FileConfig"
}
],
"hints": []
}

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

@ -31,6 +31,7 @@
<result column="mtexture" property="mtexture" jdbcType="VARCHAR" />
<result column="mversion" property="mversion" jdbcType="VARCHAR" />
<result column="munit" property="munit" jdbcType="VARCHAR" />
<result column="stcUnit" property="unit" jdbcType="VARCHAR" />
<result column="tname" property="tname" jdbcType="VARCHAR" />
<result column="mcode" property="mcode" jdbcType="VARCHAR" />
<result column="mname" property="mname" jdbcType="VARCHAR" />
@ -47,7 +48,7 @@
</sql>
<sql id="StockTakingChildPAllColumns">
id,mid,oldInventory,newInventory,inventory,mainId,takingResult,mname,mtId,tname,mcode,mversion,munit,mtexture,producedDate
id,mid,oldInventory,newInventory,inventory,mainId,takingResult,mname,mtId,tname,mcode,mversion,munit,mtexture,producedDate,stcUnit
</sql>
<!-- 插入主表-->
@ -68,9 +69,9 @@
<!-- 插入子表-->
<insert id="insertStockTakingChild" useGeneratedKeys="true" keyProperty="id">
INSERT INTO stocktakingchild (id,mid,oldInventory,newInventory,takingResult,inventory,mainId,producedDate)
INSERT INTO stocktakingchild (id,mid,oldInventory,newInventory,takingResult,inventory,mainId,producedDate,unit)
values (
#{id},#{mid},#{oldInventory},#{newInventory},#{takingResult},#{inventory},#{mainId},#{producedDate}
#{id},#{mid},#{oldInventory},#{newInventory},#{takingResult},#{inventory},#{mainId},#{producedDate},#{unit}
)
</insert>
@ -163,7 +164,10 @@
mainId = #{mainId},
</if>
<if test="producedDate != null and producedDate != ''">
producedDate = #{producedDate}
producedDate = #{producedDate},
</if>
<if test="unit != null and unit != ''">
unit = #{unit}
</if>
</set>
where id = #{id}
@ -257,6 +261,9 @@
<if test="producedDate != null">
and producedDate = #{producedDate}
</if>
<if test="unit != null and unit !=''">
and unit = #{unit}
</if>
</select>
<select id="selectStockTakingById" resultMap="StockTakingMap">
@ -278,11 +285,11 @@
<include refid="StockTakingAllColumns"/>
from stocktaking st
where 1 = 1
<if test='isDone == "0"'>
<if test='isDone == 0'>
and (state = 3 and departmentManagerState = 3 and FIND_IN_SET(#{userId},st.departmentManager) != 0 )
or (state = 3 and departmentManagerState != 3 and #{userId} = st.originator)
</if>
<if test='isDone == "1"'>
<if test='isDone == 1'>
and (state != 3 and departmentManagerState != 3 and FIND_IN_SET(#{userId},st.departmentManager) != 0 )
or (state != 3 and departmentManagerState != 3 and #{userId} = st.originator)
</if>
@ -296,11 +303,11 @@
count(*)
from stocktaking st
where 1 = 1
<if test='isDone == "0"'>
<if test='isDone == 0'>
and (state = 3 and departmentManagerState = 3 and FIND_IN_SET(#{userId},st.departmentManager) != 0 )
or (state = 3 and departmentManagerState != 3 and #{userId} = st.originator)
</if>
<if test='isDone == "1"'>
<if test='isDone == 1'>
and (state != 3 and departmentManagerState != 3 and FIND_IN_SET(#{userId},st.departmentManager) != 0 )
or (state != 3 and departmentManagerState != 3 and #{userId} = st.originator)
</if>

86
target/classes/templates/pages/depository/table-stock.html

@ -28,6 +28,7 @@
readonly/>
<input type="text" name="depositoryId" class="layui-input" id="depositoryId"
style="display: none"/>
<input type="text" name="placeId" id="placeId" style="display: none">
</div>
</div>
<div class="layui-inline">
@ -69,17 +70,24 @@
<a class="layui-btn layui-btn-xs data-count-edit" lay-event="applicationOut">出库申请</a>
</script>
<!-- 用于计量单位的展示-->
<!-- 用于计量单位的展示-->
<script id="changeUnit" type="text/html">
<button class="layui-btn layui-btn-primary layui-btn-xs" lay-event="changeUnit" click_num="0" id="btn_{{d.id}}" value="{{d.unit}}">{{d.unit}}</button>
<button class="layui-btn layui-btn-primary layui-btn-xs" lay-event="changeUnit" click_num="0"
id="btn_{{d.id}}" value="{{d.unit}}">{{d.unit}}
</button>
</script>
</div>
</div>
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
var data;
function changePlaceCode(){}
function changeUnit(){}
function changePlaceCode() {
}
function changeUnit() {
}
layui.use(['form', 'table', 'upload'], function () {
var $ = layui.jquery,
form = layui.form,
@ -87,8 +95,6 @@
table = layui.table;
$('#openSonByDepository').on('click', function () {
layer.open({
type: 2,
@ -100,12 +106,12 @@
move: '.layui-layer-title',
fixed: false,
content: '/selectDepository?type=2',
success: function(layero, index){
success: function (layero, index) {
var children = layero.children();
var content = $(children[1]);
var iframeChildren = $(content.children());
content.css('height','100%');
iframeChildren.css('height','100%');
content.css('height', '100%');
iframeChildren.css('height', '100%');
}
});
});
@ -152,7 +158,7 @@
{title: '操作', minWidth: 250, toolbar: '#currentTableBar', align: "center"}
]
],
limits: [10, 15, 20, 25, 50,100],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
skin: 'line',
@ -172,14 +178,14 @@
}
// 所处库位
var placeCodeItem = $("[lay-id='currentTableId'] tr:eq(" + (i+1) + ")").children()[9];
var placeCodeItem = $("[lay-id='currentTableId'] tr:eq(" + (i + 1) + ")").children()[9];
//计量单位
// 用于库位的添加
var aItem = placeCodeItem.childNodes[0];
// 用于计量单位的添加
for (let k = 0; k < placeCode.length; k++) {
if(placeCode[k] !== ""){
$(aItem).append('<button id='+mid+' class="layui-btn layui-btn-primary layui-btn-xs" onclick="changePlaceCode(this)" value='+depositoryId+'>'+placeCode[k]+'</button>')
if (placeCode[k] !== "") {
$(aItem).append('<button id=' + mid + ' class="layui-btn layui-btn-primary layui-btn-xs" onclick="changePlaceCode(this)" value=' + depositoryId + '>' + placeCode[k] + '</button>')
}
}
@ -188,6 +194,7 @@
}
});
// 用于给table行上色的方法
function Layui_SetDataTableRowColor(TabDivId, RowIndex, ColorString) {
try {
@ -212,7 +219,7 @@
// 用于进行渲染库位编码
form.on('switch(createPlaceCode)', function (obj) {
console.log(obj)
console.log(obj)
});
// 监听库位修改操作
@ -228,6 +235,9 @@
if (data.depositoryId !== '') {
req.depositoryId = data.depositoryId;
}
if (data.placeId !== '') {
req.placeId = data.placeId;
}
if (data.code !== '') {
req.mcode = data.code;
}
@ -299,8 +309,7 @@
layer.msg("未选中记录,请确认!");
return false;
}
}
else if (obj.event === 'dispose') {
} else if (obj.event === 'dispose') {
var index = layer.open({
title: '入库申请',
type: 2,
@ -334,8 +343,7 @@
layer.full(index);
});
return false;
}
else if (obj.event === 'applicationOut') {
} else if (obj.event === 'applicationOut') {
// 出库申请
var index = layer.open({
title: '出库申请',
@ -350,24 +358,23 @@
layer.full(index);
});
return false;
}
else if (obj.event === 'changeUnit') {
let splitInfoList = data.splitInfoList;
let btn = $("#btn_"+data.id);
} else if (obj.event === 'changeUnit') {
let splitInfoList = data.splitInfoList;
let btn = $("#btn_" + data.id);
let clickNum = Number(btn.attr("click_num"));
if(splitInfoList.length > 0){
if(clickNum < splitInfoList.length){
let newUnit = splitInfoList[clickNum].newUnit;
if (splitInfoList.length > 0) {
if (clickNum < splitInfoList.length) {
let newUnit = splitInfoList[clickNum].newUnit;
btn.text(newUnit);
clickNum += 1;
btn.attr("click_num",clickNum);
btn.attr("click_num", clickNum);
let showQuantity = data.showQuantity[newUnit];
obj.update({quantity:showQuantity});
}else{
obj.update({quantity: showQuantity});
} else {
btn.text(data.unit);
btn.attr("click_num",0);
btn.attr("click_num", 0);
let showQuantity = data.showQuantity[data.unit];
obj.update({quantity:showQuantity});
obj.update({quantity: showQuantity});
}
}
@ -375,7 +382,8 @@
}
});
changePlaceCode = function (obj) {
// 用于更改同一仓库下的库位
changePlaceCode = function (obj) {
var depositoryId = obj.value;
var placeCode = obj.innerText;
var mid = obj.id;
@ -386,15 +394,15 @@
maxmin: true,
shadeClose: true,
area: ['70%', '70%'],
content: '/selectPlaceByDepository?depositoryId=' + depositoryId+'&mid='+mid+'&placeCode='+placeCode,
success: function(layero, index){
content: '/selectPlaceByDepository?depositoryId=' + depositoryId + '&mid=' + mid + '&placeCode=' + placeCode,
success: function (layero, index) {
var children = layero.children();
var content = $(children[1]);
var iframeChildren = $(content.children());
content.css('height','100%');
iframeChildren.css('height','100%');
content.css('height', '100%');
iframeChildren.css('height', '100%');
},
end:function () {
end: function () {
//执行搜索重载
table.reload('currentTableId', {
url: '/material/findInventory',
@ -429,12 +437,12 @@
re += show
}
for (let i = 0; i < res.data.dataList.length; i++) {
var code = res.data.dataList[i]["code"] === null?'':res.data.dataList[i]["code"];
var code = res.data.dataList[i]["code"] === null ? '' : res.data.dataList[i]["code"];
var mname = res.data.dataList[i]["mname"];
var version = res.data.dataList[i]["version"] === null?'':res.data.dataList[i]["version"];
var version = res.data.dataList[i]["version"] === null ? '' : res.data.dataList[i]["version"];
var price = res.data.dataList[i]["price"];
var quantity = res.data.dataList[i]["quantity"];
var show = "<p style='color: #00FF00'>" + code+", "+mname + ", " + version + ", 单价为" + price + ", 数量为" + quantity + ":成功" + "</p>";
var show = "<p style='color: #00FF00'>" + code + ", " + mname + ", " + version + ", 单价为" + price + ", 数量为" + quantity + ":成功" + "</p>";
re += show
}

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

@ -168,8 +168,7 @@
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<input type="text" placeholder="请填写计量单位" class="layui-input"
name="unit"/>
<select id="unit" name="unit"></select>
</div>
</div>
<div class="layui-form-item" style="display: none" id="producedDateItem">
@ -338,15 +337,7 @@
title: '提交成功'
}]
});
// 用于选择生产日期
/* selectDate = function(obj) {
var name = obj.id;
laydate.render({
elem: '#'+name
, format: 'yyyy-MM-dd'
, show: true
});
};*/
// 用于打开仓库树形菜单
$('#openSonByDepository').on('click', function () {
@ -532,7 +523,7 @@
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<input name=` + "unit" + NewIdNumber + ` type="text" placeholder="请填写计量单位" class="layui-input" />
<select name=` + "unit" + NewIdNumber + ` id=` + "unit" + NewIdNumber + `></select>
</div>
</div>
<div class="layui-form-item" style="display: none" id=` + "producedDateItem" + NewIdNumber + `>
@ -721,55 +712,66 @@
},
end: function () {
var mid = materialId.value;
$.ajax({
url: "/material/findMatrialByIdAndPid?mid=" + mid + "&pid=" + placeId,
type: "get",
dataType: 'json',
contentType: "application/json;charset=utf-8",
success: function (d) {
var material = d.data.materialById;
var code = material.code;
if (code === undefined) {
code = "";
}
codeValue.value = code;
materialTypeItem[1].value = material.typeName;
materialTypeItem[3].value = material.typeId;
textureChildren.childNodes[3].childNodes[1].value = material.texture === null || material.texture === undefined ? '' : material.texture;
versionChildren.childNodes[3].childNodes[1].value = material.version === null || material.version === undefined ? '' : material.version;
unitChildren.childNodes[3].childNodes[1].value = material.unit === null || material.unit === undefined ? '' : material.unit;
inventoryChildren.childNodes[3].childNodes[1].value = material.quantity;
var materialAndBarCodeList = material.materialAndBarCodeList;
if (materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
var id = barCodeInput.id;
// barCodeInput.style = "display:none";
if(mid !== ''){
$.ajax({
url: "/material/findInventoryByIdAndPid?mid=" + mid + "&pid=" + placeId,
type: "get",
dataType: 'json',
contentType: "application/json;charset=utf-8",
success: function (d) {
var material = d.data.materialById;
var code = material.code;
if (code === undefined) {
code = "";
}
codeValue.value = code;
materialTypeItem[1].value = material.typeName;
materialTypeItem[3].value = material.typeId;
textureChildren.childNodes[3].childNodes[1].value = material.texture === null || material.texture === undefined ? '' : material.texture;
versionChildren.childNodes[3].childNodes[1].value = material.version === null || material.version === undefined ? '' : material.version;
inventoryChildren.childNodes[3].childNodes[1].value = material.quantity;
var materialAndBarCodeList = material.materialAndBarCodeList;
var idNumber = materialId.name.split("mid")[1];
form.render();
$.each(materialAndBarCodeList, function (index, item) {
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}
var shelfLife = material.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
$("#" + "producedDateItem" + idNumber).show();
var producedDateList = d.data['producedDateList'];
if (producedDateList != null && producedDateList != undefined && producedDateList.length > 0) {
$.each(producedDateList, function (index, item) {
$("#" + "producedDate" + idNumber).append(new Option(item, item));
if (materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
var id = barCodeInput.id;
form.render();
$.each(materialAndBarCodeList, function (index, item) {
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}
let unitItem = $("#unit"+idNumber);
unitItem.empty()
unitItem.append(new Option(material.unit,"-1"));
let splitInfoList = material.splitInfoList;
if(splitInfoList.length > 0){
$.each(splitInfoList, function (index, item) {
unitItem.append(new Option(item.newUnit, item.newUnit));
})
}
form.render();
}else{
$("#" + "producedDateItem" + idNumber).hide();
form.render();
}
var shelfLife = material.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
$("#" + "producedDateItem" + idNumber).show();
var producedDateList = d.data['producedDateList'];
if (producedDateList !== null && producedDateList !== undefined && producedDateList.length > 0) {
$.each(producedDateList, function (index, item) {
$("#" + "producedDate" + idNumber).append(new Option(item, item));
})
}
form.render();
}else{
$("#" + "producedDateItem" + idNumber).hide();
form.render();
}
}
});
}
});
}
}
});
} else {
@ -845,22 +847,31 @@
versionChildren.childNodes[3].childNodes[1].value = "";
unitChildren.childNodes[3].childNodes[1].value = "";
inventoryChildren.childNodes[3].childNodes[1].value = "";
} else {
}
else {
materialName.value = d.mname;
materialId.value = d.id;
materialTypeItem[1].value = d.typeName;
materialTypeItem[3].value = d.typeId;
textureChildren.childNodes[3].childNodes[1].value = d.texture === null || d.texture === undefined ? '' : d.texture;
versionChildren.childNodes[3].childNodes[1].value = d.version === null || d.version === undefined ? '' : d.version;
unitChildren.childNodes[3].childNodes[1].value = d.unit === null || d.unit === undefined ? '' : d.unit;
inventoryChildren.childNodes[3].childNodes[1].value = d.quantity;
// 获取物料与条形码的对应关系
var materialAndBarCodeList = d["materialAndBarCodeList"];
var idNumber = materialId.name.split("mid")[1];
let unit = $("#unit"+idNumber);
var barCode = $("#barCode" + idNumber);
if (barCode.length > 0) {
barCode.empty();
}
unit.empty();
unit.append(new Option(d.unit,"-1"));
if(d.splitInfoList !==null && d.splitInfoList.length > 0){
$.each(d.splitInfoList, function (index, item) {
unit.append(new Option(item.newUnit, item.newUnit));//往下拉菜单里添加元素
});
form.render();
}
if (materialAndBarCodeList !== null && materialAndBarCodeList.length > 0) {
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
@ -979,7 +990,7 @@
inventoryChildren.childNodes[3].childNodes[1].value = "";
return false;
} else {
var material = d.data[0];
var material = d.data;
materialName.value = material.mname;
materialId.value = material.id;
codeValue.value = material.code;
@ -987,26 +998,34 @@
materialTypeItem[3].value = material.typeId;
textureChildren.childNodes[3].childNodes[1].value = material.texture === null || material.texture === undefined ? '' : material.texture;
versionChildren.childNodes[3].childNodes[1].value = material.version === null || material.version === undefined ? '' : material.version;
unitChildren.childNodes[3].childNodes[1].value = material.unit === null || material.unit === undefined ? '' : material.unit;
inventoryChildren.childNodes[3].childNodes[1].value = material.quantity;
var idNumber = materialId.name.split("mid")[1];
// 获取物料与条形码的对应关系
var materialAndBarCodeList = material["materialAndBarCodeList"];
if (materialAndBarCodeList !== null && materialAndBarCodeList.length > 0) {
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
var id = barCodeInput.id;
var idNumber = materialId.name.split("mid")[1];
form.render();
$.each(materialAndBarCodeList, function (index, item) {
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}
let unitItem = $("#unit"+idNumber);
unitItem.empty();
unitItem.append(new Option(material.unit,"-1"));
let splitInfoList = material.splitInfoList;
if(splitInfoList.length > 0){
$.each(splitInfoList, function (index, item) {
unitItem.append(new Option(item.newUnit, item.newUnit));
})
}
var shelfLife = d.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
$("#" + "producedDateItem" + idNumber).show();
var producedDateList = d['producedDateList'];
if (producedDateList != null && producedDateList != undefined && producedDateList.length > 0) {
if (producedDateList !== null && producedDateList !== undefined && producedDateList.length > 0) {
$.each(producedDateList, function (index, item) {
$("#" + "producedDate" + idNumber).append(new Option(item, item));
})
@ -1170,6 +1189,7 @@
scanMaterialCodeForTaking = function (obj) {
if (depositoryId !== undefined && departmentManagerId !== undefined && departmentManagerId !== "") {
parent.wx.scanQRCode({
desc: 'scanQRCode desc',
needResult: 1, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
@ -1238,22 +1258,32 @@
inventoryChildren.childNodes[3].childNodes[1].value = data.quantity;
// 获取物料与条形码的对应关系
var materialAndBarCodeList = data["materialAndBarCodeList"];
var idNumber = materialId.name.split("mid")[1];
if (materialAndBarCodeList !== null && materialAndBarCodeList.length > 0) {
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
var id = barCodeInput.id;
var idNumber = materialId.name.split("mid")[1];
form.render();
$.each(materialAndBarCodeList, function (index, item) {
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}
var unitItem = $("#unit"+idNumber);
unitItem.empty();
unitItem.append(new Option(data.unit,"-1"));
let splitInfoList = data.splitInfoList;
if(splitInfoList.length > 0){
$.each(splitInfoList,function (index,item) {
unitItem.append(new Option(item.newUnit,item.newUnit));
})
}
form.render();
var shelfLife = data.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
$("#" + "producedDateItem" + idNumber).show();
var producedDateList = data['producedDateList'];
if (producedDateList != null && producedDateList != undefined && producedDateList.length > 0) {
if (producedDateList !== null && producedDateList !== undefined && producedDateList.length > 0) {
$.each(producedDateList, function (index, item) {
$("#" + "producedDate" + idNumber).append(new Option(item, item));
})
@ -1336,8 +1366,6 @@
// 物料种类条目
var materialTypeItem = typeChildren.childNodes[3].childNodes;
// 条形码条目
var barCodeItem = barCodeChildren.childNodes[3];
materialName.value = material.mname;
materialId.value = material.id;
@ -1346,14 +1374,13 @@
materialTypeItem[3].value = material.typeId;
textureChildren.childNodes[3].childNodes[1].value = material.texture === null || material.texture === undefined ? '' : material.texture;
versionChildren.childNodes[3].childNodes[1].value = material.version === null || material.version === undefined ? '' : material.version;
unitChildren.childNodes[3].childNodes[1].value = material.unit === null || material.unit === undefined ? '' : material.unit;
inventoryChildren.childNodes[3].childNodes[1].value = material.quantity;
$("#barCode" + id).append(new Option(result, 0));//往下拉菜单里添加元素
var shelfLife = material.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
$("#" + "producedDateItem" + id).show();
var producedDateList = material['producedDateList'];
if (producedDateList != null && producedDateList != undefined && producedDateList.length > 0) {
if (producedDateList !== null && producedDateList !== undefined && producedDateList.length > 0) {
$.each(producedDateList, function (index, item) {
$("#" + "producedDate" + id).append(new Option(item, item));
})
@ -1361,10 +1388,21 @@
form.render();
}
else{
$("#" + "producedDateItem" + idNumber).hide();
$("#" + "producedDateItem" + id).hide();
form.render();
}
form.render();
var unitItem = $("#unit"+id);
unitItem.empty();
unitItem.append(new Option(material.unit,"-1"));
let splitInfoList = material.splitInfoList;
if(splitInfoList.length > 0){
$.each(splitInfoList,function (index,item) {
unitItem.append(new Option(item.newUnit,item.newUnit));
})
}
form.render();
}
if (barCodeListByNoMaterial.length > 0) {
// 如果扫描的条形码没有对应的物料
@ -1445,9 +1483,9 @@
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对应数字
var req = {};
req.mid = $("#" + "mid" + idNumber).val();
req.producedDate = data.value;
$.ajax({
@ -1461,6 +1499,22 @@
}
});
}
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)
}
});
}
});
});

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

@ -171,7 +171,7 @@
<div class="layui-input-block">
<input type="text" placeholder="请填写计量单位"
class="layui-input" readonly
th:value="${recordMin.getMunit()}"
th:value="${recordMin.getUnit()}"
th:attr="id='unit'+${recordMin.getId()},name='unit'+${recordMin.getId()}"
/>
</div>

2
target/classes/templates/pages/stockTaking/stockTakingReview.html

@ -169,7 +169,7 @@
<div class="layui-input-block">
<input type="text" placeholder="请填写计量单位"
class="layui-input"
th:value="${recordMin.getMunit()}"
th:value="${recordMin.getUnit()}"
th:attr="id='unit'+${recordMin.getId()},name='unit'+${recordMin.getId()}"
/>
</div>

2
target/classes/templates/pages/stockTaking/stockTakingView.html

@ -172,7 +172,7 @@
<div class="layui-input-block">
<input type="text" placeholder="请填写计量单位"
class="layui-input"
th:value="${recordMin.getMunit()}"
th:value="${recordMin.getUnit()}"
th:attr="id='unit'+${recordMin.getId()},name='unit'+${recordMin.getId()}"
/>
</div>

Loading…
Cancel
Save