Browse Source

将入库相关处理抽离

lwx_dev
erdanergou 3 years ago
parent
commit
3232626867
  1. 5
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java
  2. 7
      src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.java
  3. 12
      src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.xml
  4. 7
      src/main/java/com/dreamchaser/depository_manage/service/RoleService.java
  5. 3
      src/main/java/com/dreamchaser/depository_manage/service/SplitUnitService.java
  6. 100
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  7. 8
      src/main/java/com/dreamchaser/depository_manage/service/impl/RoleServiceImpl.java
  8. 87
      src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java
  9. 2
      src/main/java/com/dreamchaser/depository_manage/utils/ObjectFormatUtil.java
  10. 2
      src/main/resources/templates/pages/user/userRole.html
  11. 2
      src/main/resources/templates/pages/user/userRoleForIn.html
  12. 120
      src/test/java/com/dreamchaser/depository_manage/TestOther.java

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

@ -192,6 +192,9 @@ public class DepositoryRecordController {
List<Integer> recordIds = new ArrayList<>(); List<Integer> recordIds = new ArrayList<>();
if (params.size() < 1 && map.size() > 3) { if (params.size() < 1 && map.size() > 3) {
String unit = (String) (map.get("unit")); String unit = (String) (map.get("unit"));
if (!"-1".equals(unit)) { if (!"-1".equals(unit)) {
map.put("type", "in"); map.put("type", "in");
@ -310,7 +313,7 @@ public class DepositoryRecordController {
result.put("err", errMsg); result.put("err", errMsg);
result.put("success", successMsg); result.put("success", successMsg);
} }
System.out.println("列表list"+recordIds);
if (integer != 0 && params.size() < 1 && integer != -1) { if (integer != 0 && params.size() < 1 && integer != -1) {
return CrudUtil.postHandle(integer, 1); return CrudUtil.postHandle(integer, 1);
} else if (integer != 0 && params.size() > 0) { } else if (integer != 0 && params.size() > 0) {

7
src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.java

@ -59,6 +59,13 @@ public interface RoleMapper {
List<RoleAndDepository> findRoleAndDepositoryByCondition(Map<String,Object> map); List<RoleAndDepository> findRoleAndDepositoryByCondition(Map<String,Object> map);
/**
* 判断当前仓库是否需要入库审批
* @return
*/
List<RoleAndDepository> findRoleAndDepositoryByDepositoryIdForIn(Integer depositoryId);
/** /**
* 根据id获取权限 * 根据id获取权限

12
src/main/java/com/dreamchaser/depository_manage/mapper/RoleMapper.xml

@ -113,6 +113,18 @@
</select> </select>
<select id="findRoleAndDepositoryByDepositoryIdForIn" parameterType="int" resultMap="depositoryAndrole">
select
<include refid="roleNameAnddepositoryName"/>
from userroleanddepository
where 1 = 1
<if test="depositoryId != null and depositoryId != ''">
and did = #{depositoryId}
</if>
and classes in (3,4)
</select>
<select id="findRoleAndDepositoryById" parameterType="int" resultMap="depositoryAndrole"> <select id="findRoleAndDepositoryById" parameterType="int" resultMap="depositoryAndrole">
select select
<include refid="roleNameAnddepositoryName"/> <include refid="roleNameAnddepositoryName"/>

7
src/main/java/com/dreamchaser/depository_manage/service/RoleService.java

@ -81,4 +81,11 @@ public interface RoleService {
*/ */
List<RoleAndDepository> findRoleAndDepositoryByDid(Integer did); List<RoleAndDepository> findRoleAndDepositoryByDid(Integer did);
/**
* 判断当前仓库是否需要入库审批
* @return
*/
List<RoleAndDepository> findRoleAndDepositoryByDepositoryIdForIn(Integer depositoryId);
} }

3
src/main/java/com/dreamchaser/depository_manage/service/SplitUnitService.java

@ -29,6 +29,9 @@ public interface SplitUnitService {
Integer addSplitInventory(Map<String,Object> map); Integer addSplitInventory(Map<String,Object> map);
// Integer reviewForInventory()
/** /**
* 根据条件查询对应拆单详细信息 * 根据条件查询对应拆单详细信息
* @param map 查询条件 * @param map 查询条件

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

@ -106,6 +106,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Integer applicationIn(Map<String, Object> map) { public Integer applicationIn(Map<String, Object> map) {
Boolean flagForApproval = ObjectFormatUtil.toBoolean(map.get("flagForApproval"));
Integer depositoryId = ObjectFormatUtil.toInteger(map.get("depositoryId")); Integer depositoryId = ObjectFormatUtil.toInteger(map.get("depositoryId"));
Depository depositoryRecordById = depositoryMapper.findDepositoryById(depositoryId); Depository depositoryRecordById = depositoryMapper.findDepositoryById(depositoryId);
Map<String, Object> temp = new HashMap<>(); Map<String, Object> temp = new HashMap<>();
@ -115,7 +117,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Integer Inventory = depositoryMapper.getToDayInventoryByDName(temp); Integer Inventory = depositoryMapper.getToDayInventoryByDName(temp);
//构造单号 //构造单号
String code = createCode(depositoryRecordById.getDname(), "InOrderNumber", "in", ""); String code = createCode(depositoryRecordById.getDname(), "InOrderNumber", "in", "");
Double quantity = Double.parseDouble((String) map.get("quantity")); double quantity = Double.parseDouble((String) map.get("quantity"));
Integer mid = ObjectFormatUtil.toInteger(map.get("mid")); Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
// 根据物料id查询物料 // 根据物料id查询物料
Material material = materialMapper.findMaterialById(mid); Material material = materialMapper.findMaterialById(mid);
@ -145,6 +147,39 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
map.put("code", code); map.put("code", code);
// 获取当前物料 // 获取当前物料
// 获取当前入库物料id
Integer newMid = 0;
if(!flagForApproval){
newMid = updateOrInsertInventory(map,materialByCondition,quantity,mid,depositoryId,producedDate);
}
// 将新入库的物料id记录下来
map.put("newInMid", newMid);
// 如果包含realQuantity则代表是入库的拆单单位
if (map.containsKey("realQuantity")) {
// 将入库数量修改为realQuantity
map.put("quantity", map.get("realQuantity"));
}
if (!map.containsKey("flagForGroup")) {
// 如果不包含标志位.
map.put("flagForGroup", 1);
}
return depositoryRecordMapper.insertApplicationInRecord(map);
}
/**
* 用于入库申请时更新物料库存计量
* @param map 入库数据
* @param materialByCondition 当前仓库是否存在该物料
* @param quantity 入库数量
* @param mid 入库物料id
* @param depositoryId 入库位置
* @param producedDate 生产日期
* @return
*/
Integer updateOrInsertInventory(Map<String,Object> map,List<Inventory> materialByCondition,Double quantity,Integer mid,Integer depositoryId,long producedDate){
// 获取当前入库物料id // 获取当前入库物料id
Integer newMid = 0; Integer newMid = 0;
if (materialByCondition.size() > 0) { // 如果当前存在 if (materialByCondition.size() > 0) { // 如果当前存在
@ -154,7 +189,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
mt.setProducedDate(producedDate); mt.setProducedDate(producedDate);
materialMapper.updateInventory(mt); materialMapper.updateInventory(mt);
newMid = mt.getId(); newMid = mt.getId();
} else { }
else {
Map<String, Object> insert = new HashMap<>(); Map<String, Object> insert = new HashMap<>();
Material materialById = materialMapper.findMaterialById(mid); Material materialById = materialMapper.findMaterialById(mid);
insert.put("depositoryId", depositoryId); insert.put("depositoryId", depositoryId);
@ -165,19 +201,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
materialMapper.insertInventory(insert); materialMapper.insertInventory(insert);
newMid = ObjectFormatUtil.toInteger(insert.get("id")); newMid = ObjectFormatUtil.toInteger(insert.get("id"));
} }
// 将新入库的物料id记录下来 return newMid;
map.put("newInMid", newMid);
// 如果包含realQuantity则代表是入库的拆单单位
if (map.containsKey("realQuantity")) {
// 将入库数量修改为realQuantity
map.put("quantity", map.get("realQuantity"));
}
if (!map.containsKey("flagForGroup")) {
// 如果不包含标志位.
map.put("flagForGroup", 1);
}
return depositoryRecordMapper.insertApplicationInRecord(map);
} }
@ -620,6 +644,15 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if ("-1".equals(unit)) { if ("-1".equals(unit)) {
map.put("unit", materialById.getUnit()); map.put("unit", materialById.getUnit());
} }
// 获取当前仓库是否需要审批
List<RoleAndDepository> depositoryListForIn = roleService.findRoleAndDepositoryByDepositoryIdForIn(ObjectFormatUtil.toInteger(map.get("depositoryId")));
boolean flagForApproval = false; // 默认不需要审批
if(depositoryListForIn.size() > 0){
flagForApproval = true;
}
map.put("flagForApproval",flagForApproval);
if (placeById.getMax() - placeById.getQuantity() > quantity) { if (placeById.getMax() - placeById.getQuantity() > quantity) {
// 如果当前库位还能存放 // 如果当前库位还能存放
// 入库 // 入库
@ -627,6 +660,29 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if (integer != 1) { if (integer != 1) {
return -1; return -1;
} }
if(!flagForApproval){
// 如果不需要审批
Integer result = updateInventoryInfoForApproval(map, quantity, materialById, placeById);
map.remove("applicationInId");
return result;
}
return integer;
} else {
return -1;
}
}
/**
* 用于入库后修改相关数据信息
* @param map 入库数据
* @param quantity 数量
* @param materialById 入库物料
* @param placeById 入库库位
* @return
*/
Integer updateInventoryInfoForApproval(Map<String,Object> map,Integer quantity,Material materialById,Place placeById){
// 获取当前入库的物料id // 获取当前入库的物料id
Integer newInMid = ObjectFormatUtil.toInteger(map.get("newInMid")); Integer newInMid = ObjectFormatUtil.toInteger(map.get("newInMid"));
// 获取当前入库记录id // 获取当前入库记录id
@ -654,7 +710,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
materialAndProducedDateByMidAndProducedDate.setInventory(materialAndProducedDateByMidAndProducedDate.getInventory() + quantity); materialAndProducedDateByMidAndProducedDate.setInventory(materialAndProducedDateByMidAndProducedDate.getInventory() + quantity);
// 修改 // 修改
materialMapper.updateMaterialAndProducedDate(materialAndProducedDateByMidAndProducedDate); materialMapper.updateMaterialAndProducedDate(materialAndProducedDateByMidAndProducedDate);
} else { }
else {
insertProducedDate.put("quantity", quantity); insertProducedDate.put("quantity", quantity);
insertProducedDate.put("inventory", quantity); insertProducedDate.put("inventory", quantity);
insertProducedDate.put("expendnum", 0); insertProducedDate.put("expendnum", 0);
@ -668,9 +725,10 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
param.put("mcode", materialById.getCode()); param.put("mcode", materialById.getCode());
param.put("mname", materialById.getMname()); param.put("mname", materialById.getMname());
if (placeId == 0) { if (Integer.compare(placeById.getId(),0) == 0) {
param.put("depositoryId", map.get("depositoryId")); param.put("depositoryId", map.get("depositoryId"));
} else { }
else {
param.put("depositoryId", placeById.getDid()); param.put("depositoryId", placeById.getDid());
} }
List<Inventory> inventory = materialMapper.findInventory(param); List<Inventory> inventory = materialMapper.findInventory(param);
@ -687,7 +745,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
insert.put("quantity", quantity); insert.put("quantity", quantity);
// 插入记录 // 插入记录
placeMapper.addMaterialOnPlace(insert); placeMapper.addMaterialOnPlace(insert);
} else { }
else {
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + quantity); placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + quantity);
// 修改数量 // 修改数量
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid);
@ -695,9 +754,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 修改当前库位数量 // 修改当前库位数量
placeById.setQuantity(placeById.getQuantity() + quantity); placeById.setQuantity(placeById.getQuantity() + quantity);
return placeMapper.UpdatePlace(placeById); return placeMapper.UpdatePlace(placeById);
} else {
return -1;
}
} }
/** /**

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

@ -111,4 +111,12 @@ public class RoleServiceImpl implements RoleService {
map.put("depositoryId",did); map.put("depositoryId",did);
return roleMapper.findRoleAndDepositoryByCondition(map); return roleMapper.findRoleAndDepositoryByCondition(map);
} }
/**
* 判断当前仓库是否需要入库审批
* @return
*/
@Override
public List<RoleAndDepository> findRoleAndDepositoryByDepositoryIdForIn(Integer depositoryId) {
return roleMapper.findRoleAndDepositoryByDepositoryIdForIn(depositoryId);
}
} }

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

@ -2,6 +2,7 @@ package com.dreamchaser.depository_manage.service.impl;
import com.dreamchaser.depository_manage.entity.*; import com.dreamchaser.depository_manage.entity.*;
import com.dreamchaser.depository_manage.mapper.*; import com.dreamchaser.depository_manage.mapper.*;
import com.dreamchaser.depository_manage.pojo.RoleAndDepository;
import com.dreamchaser.depository_manage.pojo.SplitInfoP; import com.dreamchaser.depository_manage.pojo.SplitInfoP;
import com.dreamchaser.depository_manage.service.DepositoryRecordService; import com.dreamchaser.depository_manage.service.DepositoryRecordService;
import com.dreamchaser.depository_manage.service.SplitUnitService; import com.dreamchaser.depository_manage.service.SplitUnitService;
@ -39,6 +40,10 @@ public class SplitUnitServiceImpl implements SplitUnitService {
DepositoryRecordMapper depositoryRecordMapper; DepositoryRecordMapper depositoryRecordMapper;
@Autowired
RoleMapper roleMapper;
/** /**
* 用于添加一条拆单记录 * 用于添加一条拆单记录
* *
@ -83,6 +88,15 @@ public class SplitUnitServiceImpl implements SplitUnitService {
SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
// 获取当前仓库是否有用户进行管理入库审批
List<RoleAndDepository> roleAndDepositoryByCondition = roleMapper.findRoleAndDepositoryByDepositoryIdForIn(ObjectFormatUtil.toInteger(map.get("depositoryId")));
// 用于标志该仓库是否需要进行审批
boolean flagForApproval = false; // 默认不需要
if (roleAndDepositoryByCondition.size() > 0) {
flagForApproval = true;
}
// 用于存储最终计算结果 // 用于存储最终计算结果
Integer result = 0; Integer result = 0;
@ -148,7 +162,35 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 获取要操作的数量 // 获取要操作的数量
Double quantity = ObjectFormatUtil.toDouble(map.get("quantity")); Double quantity = ObjectFormatUtil.toDouble(map.get("quantity"));
if ("in".equals(type)) { if ("in".equals(type) && !flagForApproval) {
// 如果是入库并且不需要审批
result = realInInventoryToDepository(quantity, splitInventory, map, splitInfoForUnit, placeAndMaterialByMidAndPid);
map.remove("applicationInId");
}else if("in".equals(type)){
// 如果是入库且需要审批
result = depositoryRecordService.applicationIn(map);
map.put("applicationInId",map.get("id"));
map.remove("id");
}
}
return result;
}
Integer realInInventoryToDepository(Double quantity, SplitInventory splitInventory, Map<String, Object> map, SplitInfo splitInfoForUnit, MaterialAndPlace placeAndMaterialByMidAndPid) {
Integer result = 0;
// 获取当前进制
Integer scale = splitInfoForUnit.getQuantity();
// 用于存储拆单库存处理操作的数据
Map<String, Object> paramForInsertSplitInventory = new HashMap<>();
paramForInsertSplitInventory.put("sid", splitInfoForUnit.getId());
// 如果是入库操作 // 如果是入库操作
// 计算处理数量(下取整) // 计算处理数量(下取整)
@ -199,13 +241,12 @@ public class SplitUnitServiceImpl implements SplitUnitService {
} else { } else {
map.put("price", Double.toString(0)); map.put("price", Double.toString(0));
depositoryRecordService.applicationInPlace(map); depositoryRecordService.applicationInPlace(map);
map.put("applicationInId",map.get("id")); map.put("applicationInId", map.get("id"));
map.remove("id"); map.remove("id");
} }
} } else {
else {
// 如果没有记录 // 如果没有记录
// 获取当前拆单记录的父级 // 获取当前拆单记录的父级
@ -234,7 +275,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
} else { } else {
map.put("price", Double.toString(0)); map.put("price", Double.toString(0));
result += depositoryRecordService.applicationInPlace(map); result += depositoryRecordService.applicationInPlace(map);
map.put("applicationInId",map.get("id")); map.put("applicationInId", map.get("id"));
map.remove("id"); map.remove("id");
Map<String, Object> paramForInventoryToPlace = new HashMap<>(); Map<String, Object> paramForInventoryToPlace = new HashMap<>();
paramForInventoryToPlace.put("mid", map.get("newInMid")); paramForInventoryToPlace.put("mid", map.get("newInMid"));
@ -245,11 +286,10 @@ public class SplitUnitServiceImpl implements SplitUnitService {
} else { } else {
map.put("price", Double.toString(0)); map.put("price", Double.toString(0));
result += depositoryRecordService.applicationInPlace(map); result += depositoryRecordService.applicationInPlace(map);
map.put("applicationInId",map.get("id")); map.put("applicationInId", map.get("id"));
map.remove("id"); map.remove("id");
} }
} } else {
else {
// 如果不大于设置的进制数量 // 如果不大于设置的进制数量
paramForInsertSplitInventory.put("inQuantity", quantity); paramForInsertSplitInventory.put("inQuantity", quantity);
@ -272,14 +312,14 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 先插入一条库存记录用于后续操作 // 先插入一条库存记录用于后续操作
map.put("quantity", "0"); map.put("quantity", "0");
depositoryRecordService.applicationInPlace(map); depositoryRecordService.applicationInPlace(map);
map.put("applicationInId",map.get("id")); map.put("applicationInId", map.get("id"));
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
map.remove("id"); map.remove("id");
} else { } else {
// 如果没有父级 // 如果没有父级
depositoryRecordService.applicationInPlace(map); depositoryRecordService.applicationInPlace(map);
map.put("applicationInId",map.get("id")); map.put("applicationInId", map.get("id"));
map.remove("id"); map.remove("id");
} }
Map<String, Object> paramForInventoryToPlace = new HashMap<>(); Map<String, Object> paramForInventoryToPlace = new HashMap<>();
@ -299,16 +339,10 @@ public class SplitUnitServiceImpl implements SplitUnitService {
} }
}
}
return result; return result;
} }
/** /**
* 用于计算当前拆单单位与目标拆单单位之间的进率 * 用于计算当前拆单单位与目标拆单单位之间的进率
* *
@ -417,8 +451,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
} }
} } else {
else {
// 如果不是获取所有库存 // 如果不是获取所有库存
// 获取当前基础单位 // 获取当前基础单位
SplitInfo baseSplitInfo = splitUnitMapper.findSplitInfoById(baseSplitInfoId); SplitInfo baseSplitInfo = splitUnitMapper.findSplitInfoById(baseSplitInfoId);
@ -487,6 +520,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
/** /**
* 用于查找当前拆单是否正在使用 * 用于查找当前拆单是否正在使用
*
* @param sid 待查询id * @param sid 待查询id
* @return * @return
*/ */
@ -570,11 +604,10 @@ public class SplitUnitServiceImpl implements SplitUnitService {
depositoryRecordService.applicationInPlace(map); depositoryRecordService.applicationInPlace(map);
// 删除入库订单 // 删除入库订单
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); // depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
map.put("applicationInId",map.get("id")); map.put("applicationInId", map.get("id"));
map.remove("id"); map.remove("id");
} }
} } else {
else {
// 当前库存拆单记录与新入库的数目不大于预设的进制 // 当前库存拆单记录与新入库的数目不大于预设的进制
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() + (int) saveQuantity); splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() + (int) saveQuantity);
splitInventory.setInQuantity(splitInventory.getInQuantity() + (int) saveQuantity); splitInventory.setInQuantity(splitInventory.getInQuantity() + (int) saveQuantity);
@ -587,11 +620,10 @@ public class SplitUnitServiceImpl implements SplitUnitService {
depositoryRecordService.applicationInPlace(map); depositoryRecordService.applicationInPlace(map);
// 删除入库订单 // 删除入库订单
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); // depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
map.put("applicationInId",map.get("id")); map.put("applicationInId", map.get("id"));
map.remove("id"); map.remove("id");
} }
} } else {
else {
// 如果为空 // 如果为空
Map<String, Object> paramForInsertSplitInventory = new HashMap<>(); Map<String, Object> paramForInsertSplitInventory = new HashMap<>();
@ -617,15 +649,14 @@ public class SplitUnitServiceImpl implements SplitUnitService {
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(parentId); SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(parentId);
updateSplitInfoSaveQuantity(parentSplitInfo, quantity_scale, iid, map, inQuantity, baseSplitInfo); updateSplitInfoSaveQuantity(parentSplitInfo, quantity_scale, iid, map, inQuantity, baseSplitInfo);
} } else {
else {
map.put("price", Double.toString(0)); map.put("price", Double.toString(0));
map.put("quantity", String.valueOf(quantity_scale)); map.put("quantity", String.valueOf(quantity_scale));
map.put("realQuantity", String.valueOf(inQuantity)); map.put("realQuantity", String.valueOf(inQuantity));
depositoryRecordService.applicationInPlace(map); depositoryRecordService.applicationInPlace(map);
// 删除入库订单 // 删除入库订单
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); // depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
map.put("applicationInId",map.get("id")); map.put("applicationInId", map.get("id"));
map.remove("id"); map.remove("id");
} }
} else { } else {
@ -638,7 +669,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
depositoryRecordService.applicationInPlace(map); depositoryRecordService.applicationInPlace(map);
// 删除入库订单 // 删除入库订单
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); // depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
map.put("applicationInId",map.get("id")); map.put("applicationInId", map.get("id"));
map.remove("id"); map.remove("id");
} }

2
src/main/java/com/dreamchaser/depository_manage/utils/ObjectFormatUtil.java

@ -22,7 +22,7 @@ public class ObjectFormatUtil {
} }
public static Boolean toBoolean(Object o){ public static Boolean toBoolean(Object o){
return (o==null)?null:Boolean.getBoolean(o.toString()); return (o==null)?null:Boolean.parseBoolean(o.toString());
} }
public static Double toDouble(Object o){return (o == null)?null:Double.parseDouble(o.toString());} public static Double toDouble(Object o){return (o == null)?null:Double.parseDouble(o.toString());}

2
src/main/resources/templates/pages/user/userRole.html

@ -183,7 +183,7 @@
}); });
//执行搜索重载 //执行搜索重载
table.reload('demo', { table.reload('demo', {
url: '/findUserRole?userId=' + userId, url: '/findUserRole?userId=' + userId+'&classes=1',
page: { page: {
curr: 1 curr: 1
} }

2
src/main/resources/templates/pages/user/userRoleForIn.html

@ -183,7 +183,7 @@
}); });
//执行搜索重载 //执行搜索重载
table.reload('demo', { table.reload('demo', {
url: '/findUserRole?userId=' + userId, url: 'findUserRole?userId=' + userId+'&classes=3',
page: { page: {
curr: 1 curr: 1
} }

120
src/test/java/com/dreamchaser/depository_manage/TestOther.java

@ -1,6 +1,7 @@
package com.dreamchaser.depository_manage; package com.dreamchaser.depository_manage;
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType; import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException; import com.google.zxing.WriterException;
@ -26,130 +27,13 @@ import java.util.Map;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
public class TestOther { public class TestOther {
/**
* 条形码宽度
*/
public static final int WIDTH = 300;
/**
* 条形码高度
*/
public static final int HEIGHT = 52;
/**
* 加文字 条形码
*/
public static final int WORD_HEIGHT = 120;
/**
* 设置 条形码参数
*/
public Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>() {
public static final long serialVersionUID = 1L;
{
// 设置编码方式
put(EncodeHintType.CHARACTER_SET, "utf-8");
// 容错级别 这里选择最高H级别
put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
put(EncodeHintType.MARGIN, 1);
}
};
@Test @Test
public void Test() throws IOException { public void Test() throws IOException {
BufferedImage image = insertWords(getBarCode("123456"), "123456"); System.out.println(ObjectFormatUtil.toBoolean("true"));
ImageIO.write(image, "jpg", new File("D:/superMan.png"));
}
/**
* 生成 图片缓冲
*
* @param vaNumber VA
* @return 返回BufferedImage
* @author fxbin
*/
public BufferedImage getBarCode(String vaNumber) {
try {
Code128Writer writer = new Code128Writer();
// 编码内容, 编码类型, 宽度, 高度, 设置参数
BitMatrix bitMatrix = writer.encode(vaNumber, BarcodeFormat.CODE_128, WIDTH, HEIGHT, hints);
return MatrixToImageWriter.toBufferedImage(bitMatrix);
} catch (WriterException e) {
e.printStackTrace();
}
return null;
}
/**
* 把带logo的二维码下面加上文字
*
* @param image 条形码图片
* @param words 文字
* @return 返回BufferedImage
* @author fxbin
*/
public BufferedImage insertWords(BufferedImage image, String words) {
// 新的图片,把带logo的二维码下面加上文字
if (StringUtils.isNotEmpty(words)) {
BufferedImage outImage = new BufferedImage(WIDTH, WORD_HEIGHT, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = outImage.createGraphics();
// 抗锯齿
setGraphics2D(g2d);
// 设置白色
setColorWhite(g2d);
// 画条形码到新的面板
g2d.drawImage(image, 0, WORD_HEIGHT / 2 -image.getHeight() / 2, image.getWidth(), image.getHeight(), null);
// 画文字到新的面板
Color color = new Color(0, 0, 0);
g2d.setColor(color);
// 字体、字型、字号
g2d.setFont(new Font("微软雅黑", Font.PLAIN, 16));
//文字长度
int strWidth = g2d.getFontMetrics().stringWidth(words);
//总长度减去文字长度的一半 (居中显示)
int wordStartX = (WIDTH - strWidth) / 2;
//height + (outImage.getHeight() - height) / 2 + 12
int wordStartY = WORD_HEIGHT / 2 + image.getHeight() /2 + 16;
// 画文字
g2d.drawString(words, wordStartX, wordStartY);
g2d.drawString(words, wordStartX, 16);
g2d.dispose();
outImage.flush();
return outImage;
}
return null;
} }
/**
* 设置 Graphics2D 属性 抗锯齿
*
* @param g2d Graphics2D提供对几何形状坐标转换颜色管理和文本布局更为复杂的控制
*/
public void setGraphics2D(Graphics2D g2d) {
// 消除画图锯齿
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// 消除文字锯齿
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
Stroke s = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER);
g2d.setStroke(s);
}
/**
* 设置背景为白色
*
* @param g2d Graphics2D提供对几何形状坐标转换颜色管理和文本布局更为复杂的控制
*/
public void setColorWhite(Graphics2D g2d) {
g2d.setColor(Color.WHITE);
//填充整个屏幕
g2d.fillRect(0, 0, 302, 113);
//设置笔刷
g2d.setColor(Color.BLACK);
}
} }

Loading…
Cancel
Save