Browse Source

入库审批第一次尝试

lwx_dev
erdanergou 3 years ago
parent
commit
5b154d0ed9
  1. 9
      src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml
  2. 12
      src/main/java/com/dreamchaser/depository_manage/pojo/ApplicationInRecordP.java
  3. 56
      src/main/java/com/dreamchaser/depository_manage/service/SplitUnitService.java
  4. 205
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  5. 13
      src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java
  6. 9
      target/classes/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml

9
src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml

@ -50,6 +50,7 @@
<result column="mname" property="mname" jdbcType="VARCHAR"/> <result column="mname" property="mname" jdbcType="VARCHAR"/>
<result column="quantity" property="quantity" jdbcType="INTEGER"/> <result column="quantity" property="quantity" jdbcType="INTEGER"/>
<result column="mid" property="mid" jdbcType="INTEGER"/> <result column="mid" property="mid" jdbcType="INTEGER"/>
<result column="did" property="depositoryId" jdbcType="INTEGER"/>
<result column="flagForGroup" property="flagForGroup" jdbcType="INTEGER"/> <result column="flagForGroup" property="flagForGroup" jdbcType="INTEGER"/>
<result column="price" property="price" jdbcType="VARCHAR"/> <result column="price" property="price" jdbcType="VARCHAR"/>
<result column="tname" property="materialTypeName" jdbcType="VARCHAR"/> <result column="tname" property="materialTypeName" jdbcType="VARCHAR"/>
@ -69,6 +70,7 @@
<result column="mdepositoryCode" property="mdepositoryCode" jdbcType="VARCHAR"/> <result column="mdepositoryCode" property="mdepositoryCode" jdbcType="VARCHAR"/>
<result column="airapproverPass" property="airapproverPass" jdbcType="INTEGER"/> <result column="airapproverPass" property="airapproverPass" jdbcType="INTEGER"/>
<result column="airapproverTime" property="airapproverTime" jdbcType="INTEGER"/> <result column="airapproverTime" property="airapproverTime" jdbcType="INTEGER"/>
<result column="airmproducedDate" property="mproducedDate" jdbcType="INTEGER"/>
<result column="airapproverId" property="airapproverId" jdbcType="VARCHAR"/> <result column="airapproverId" property="airapproverId" jdbcType="VARCHAR"/>
<result column="airstate" property="airstate" jdbcType="VARCHAR"/> <result column="airstate" property="airstate" jdbcType="VARCHAR"/>
<result column="airapproverMessage" property="airapproverMessage" jdbcType="VARCHAR"/> <result column="airapproverMessage" property="airapproverMessage" jdbcType="VARCHAR"/>
@ -146,7 +148,7 @@
</sql> </sql>
<sql id="ApplicationInRecordInfo"> <sql id="ApplicationInRecordInfo">
airid,mname,quantity,price,tname,applicant_time,aircode,dname,applicant_id,applyRemark,mcode,mversion,munit,mtexture,mkingdeecode,mdepositoryCode,airUnit,flagForGroup,mid,airPlaceId,airapproverPass,airapproverTime,airapproverId,airstate,airapproverMessage airid,did,airmproducedDate,mname,quantity,price,tname,applicant_time,aircode,dname,applicant_id,applyRemark,mcode,mversion,munit,mtexture,mkingdeecode,mdepositoryCode,airUnit,flagForGroup,mid,airPlaceId,airapproverPass,airapproverTime,airapproverId,airstate,airapproverMessage
</sql> </sql>
<sql id="ApplicationOutRecordInfo"> <sql id="ApplicationOutRecordInfo">
@ -883,7 +885,7 @@
<!-- 插入一条入库记录--> <!-- 插入一条入库记录-->
<insert id="insertApplicationInRecord" parameterType="map" useGeneratedKeys="true" keyProperty="id"> <insert id="insertApplicationInRecord" parameterType="map" useGeneratedKeys="true" keyProperty="id">
insert into application_in_record (id,mid,quantity,price,applicant_id,applicant_time,depository_id,code,applyRemark,unit,flagForGroup,placeId,approverPass,approverTime,approverId,state,approverMessage) insert into application_in_record (id,mid,quantity,price,applicant_id,applicant_time,depository_id,code,applyRemark,unit,flagForGroup,placeId,approverPass,approverTime,approverId,state,approverMessage,mproducedDate)
values( values(
#{id}, #{id},
#{mid}, #{mid},
@ -901,7 +903,8 @@
#{approverTime}, #{approverTime},
#{approverId}, #{approverId},
#{state}, #{state},
#{approverMessage} #{approverMessage},
#{producedDate}
) )
</insert> </insert>

12
src/main/java/com/dreamchaser/depository_manage/pojo/ApplicationInRecordP.java

@ -50,6 +50,12 @@ public class ApplicationInRecordP {
private String depositoryName; private String depositoryName;
/**
* 仓库id
*/
private Integer depositoryId;
/** /**
* 提交备注 * 提交备注
*/ */
@ -132,4 +138,10 @@ public class ApplicationInRecordP {
*/ */
private String airapproverMessage; private String airapproverMessage;
/**
* 入库时填写的生产日期
*/
private Long mproducedDate;
} }

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

@ -16,17 +16,19 @@ public interface SplitUnitService {
/** /**
* 用于添加一条拆单记录 * 用于添加一条拆单记录
*
* @param map 待添加数据 * @param map 待添加数据
* @return * @return
*/ */
Integer addSplitInfo(Map<String,Object> map); Integer addSplitInfo(Map<String, Object> map);
/** /**
* 用于添加一条拆单库存处理记录 * 用于添加一条拆单库存处理记录
*
* @param map 待添加数据 * @param map 待添加数据
* @return * @return
*/ */
Integer addSplitInventory(Map<String,Object> map); Integer addSplitInventory(Map<String, Object> map);
// Integer reviewForInventory() // Integer reviewForInventory()
@ -34,20 +36,23 @@ public interface SplitUnitService {
/** /**
* 根据条件查询对应拆单详细信息 * 根据条件查询对应拆单详细信息
*
* @param map 查询条件 * @param map 查询条件
* @return * @return
*/ */
List<SplitInfoP> findSplitInfoPByCondition(Map<String,Object> map); List<SplitInfoP> findSplitInfoPByCondition(Map<String, Object> map);
/** /**
* 根据条件查询对应拆单数量 * 根据条件查询对应拆单数量
*
* @param map 查询条件 * @param map 查询条件
* @return * @return
*/ */
Integer findSplitInfoPCountByCondition(Map<String,Object> map); Integer findSplitInfoPCountByCondition(Map<String, Object> map);
/** /**
* 根据主键删除拆单信息软删除 * 根据主键删除拆单信息软删除
*
* @param id 待删除id * @param id 待删除id
* @return * @return
*/ */
@ -55,6 +60,7 @@ public interface SplitUnitService {
/** /**
* 根据主键删除拆单信息硬删除 * 根据主键删除拆单信息硬删除
*
* @param id 待删除id * @param id 待删除id
* @return * @return
*/ */
@ -62,14 +68,16 @@ public interface SplitUnitService {
/** /**
* 根据条件修改拆单信息 * 根据条件修改拆单信息
*
* @param map 待修改数据 * @param map 待修改数据
* @return * @return
*/ */
Integer updateSplitInfo(Map<String,Object> map); Integer updateSplitInfo(Map<String, Object> map);
/** /**
* 根据主键id获取拆单信息 * 根据主键id获取拆单信息
*
* @param id 待查询主键 * @param id 待查询主键
* @return * @return
*/ */
@ -77,6 +85,7 @@ public interface SplitUnitService {
/** /**
* 根据主键id获取拆单详细信息 * 根据主键id获取拆单详细信息
*
* @param id 待查询主键 * @param id 待查询主键
* @return * @return
*/ */
@ -84,6 +93,7 @@ public interface SplitUnitService {
/** /**
* 根据物料id查询对应的拆单记录 * 根据物料id查询对应的拆单记录
*
* @param mid 待查询物料id * @param mid 待查询物料id
* @return * @return
*/ */
@ -92,14 +102,16 @@ public interface SplitUnitService {
/** /**
* 通过物料id与拆单前的计量单位获取对应拆单记录 * 通过物料id与拆单前的计量单位获取对应拆单记录
*
* @param map 查询条件 * @param map 查询条件
* @return * @return
*/ */
SplitInfo findSplitInfoByMidAndUnit(Map<String,Object> map); SplitInfo findSplitInfoByMidAndUnit(Map<String, Object> map);
/** /**
* 根据库存id获取对应拆单库存处理记录 * 根据库存id获取对应拆单库存处理记录
*
* @param Iid 待查询库存id * @param Iid 待查询库存id
* @return * @return
*/ */
@ -107,7 +119,8 @@ public interface SplitUnitService {
/** /**
* 用于计算当前拆单单位与目标拆单单位之间的进率 * 用于计算当前拆单单位与目标拆单单位之间的进率
* @param splitInfo 待查询拆单记录 *
* @param splitInfo 待查询拆单记录
* @param parentSplitInfoId 目标拆单单位 * @param parentSplitInfoId 目标拆单单位
* @return * @return
*/ */
@ -117,22 +130,23 @@ public interface SplitUnitService {
/** /**
* 获取当前拆单与基础拆单之间的库存总额(当前拆单记录为-1是全部库存是使用) * 获取当前拆单与基础拆单之间的库存总额(当前拆单记录为-1是全部库存是使用)
* *
* @param splitInfoId 当前拆单记录Id * @param splitInfoId 当前拆单记录Id
* @param materialAndPlace 库存记录 * @param materialAndPlace 库存记录
* @param baseSplitInfoId 基础拆单记录Id * @param baseSplitInfoId 基础拆单记录Id
* @param saveQuantity 最终返回值 * @param saveQuantity 最终返回值
* @param allQuantityFlag 用于标志是否获取全部库存 * @param allQuantityFlag 用于标志是否获取全部库存
* @return * @return
*/ */
int findAllInventoryForSplitInfo(Integer splitInfoId, MaterialAndPlace materialAndPlace, Integer baseSplitInfoId, int saveQuantity, boolean allQuantityFlag); int findAllInventoryForSplitInfo(Integer splitInfoId, MaterialAndPlace materialAndPlace, Integer baseSplitInfoId, int saveQuantity, boolean allQuantityFlag);
/** /**
* 根据库存id与拆单记录id获取对应拆单库存处理记录 * 根据库存id与拆单记录id获取对应拆单库存处理记录
*
* @param Iid 待查询库存id * @param Iid 待查询库存id
* @param sid 待查询拆单id * @param sid 待查询拆单id
* @return * @return
*/ */
SplitInventory findSplitInventoryByIidAndSid(Integer Iid,Integer sid); SplitInventory findSplitInventoryByIidAndSid(Integer Iid, Integer sid);
/** /**
@ -143,10 +157,11 @@ public interface SplitUnitService {
* @param map 入库条件 * @param map 入库条件
* @param inQuantity 最终入库数量 * @param inQuantity 最终入库数量
*/ */
void updateSplitInfoSaveQuantity(SplitInfo splitInfo, int quantity, int iid, Map<String, Object> map, int inQuantity, SplitInfo baseSplitInfo); void updateSplitInfoSaveQuantity(SplitInfo splitInfo, int quantity, int iid, Map<String, Object> map, int inQuantity, SplitInfo baseSplitInfo);
/** /**
* 根据父级查询拆单记录 * 根据父级查询拆单记录
*
* @param parentId 待查询父级 * @param parentId 待查询父级
* @return * @return
*/ */
@ -155,8 +170,21 @@ public interface SplitUnitService {
/** /**
* 用于查找当前拆单是否正在使用 * 用于查找当前拆单是否正在使用
*
* @param sid 待查询id * @param sid 待查询id
* @return * @return
*/ */
boolean findAllSplitInfoForbidden(Integer sid); boolean findAllSplitInfoForbidden(Integer sid);
/**
* 用于审批通过或无需审批时修改库存
*
* @param quantity 库存数量
* @param splitInventory 拆单库存记录
* @param map 调剂
* @param splitInfoForUnit 拆单记录
* @param placeAndMaterialByMidAndPid 物料库位对应关系
* @return
*/
Integer realInInventoryToDepository(Double quantity, SplitInventory splitInventory, Map<String, Object> map, SplitInfo splitInfoForUnit, MaterialAndPlace placeAndMaterialByMidAndPid);
} }

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

@ -134,6 +134,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} else { } else {
producedDate = DateUtil.DateTimeByDayToTimeStamp(s.toString()); producedDate = DateUtil.DateTimeByDayToTimeStamp(s.toString());
} }
map.put("producedDate", producedDate);
} }
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
param.put("depositoryId", depositoryId); param.put("depositoryId", depositoryId);
@ -149,21 +150,21 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 获取当前入库物料id // 获取当前入库物料id
Integer newMid = 0; Integer newMid = 0;
if(!flagForApproval){ if (!flagForApproval) {
// 如果不需要审批 // 如果不需要审批
newMid = updateOrInsertInventory(map,materialByCondition,quantity,mid,depositoryId,producedDate); newMid = updateOrInsertInventory(map, materialByCondition, quantity, mid, depositoryId, producedDate);
map.put("approverPass",4); map.put("approverPass", 4);
map.put("state","已入库"); map.put("state", "已入库");
}else{ } else {
// 如果需要审批 // 如果需要审批
List<RoleAndDepository> depositoryListForIn = roleService.findRoleAndDepositoryByDepositoryIdForIn(depositoryId); List<RoleAndDepository> depositoryListForIn = roleService.findRoleAndDepositoryByDepositoryIdForIn(depositoryId);
map.put("approverPass",3); map.put("approverPass", 3);
StringBuilder approverId = new StringBuilder(); StringBuilder approverId = new StringBuilder();
for (RoleAndDepository roleAndDepository : depositoryListForIn) { for (RoleAndDepository roleAndDepository : depositoryListForIn) {
approverId.append(roleAndDepository.getUserId()).append(","); approverId.append(roleAndDepository.getUserId()).append(",");
} }
map.put("approverId",approverId.toString()); map.put("approverId", approverId.toString());
map.put("state","待审核"); map.put("state", "待审核");
} }
// 将新入库的物料id记录下来 // 将新入库的物料id记录下来
@ -184,15 +185,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
/** /**
* 用于入库申请时更新物料库存计量 * 用于入库申请时更新物料库存计量
* @param map 入库数据 *
* @param map 入库数据
* @param materialByCondition 当前仓库是否存在该物料 * @param materialByCondition 当前仓库是否存在该物料
* @param quantity 入库数量 * @param quantity 入库数量
* @param mid 入库物料id * @param mid 入库物料id
* @param depositoryId 入库位置 * @param depositoryId 入库位置
* @param producedDate 生产日期 * @param producedDate 生产日期
* @return * @return
*/ */
Integer updateOrInsertInventory(Map<String,Object> map,List<Inventory> materialByCondition,Double quantity,Integer mid,Integer depositoryId,long producedDate){ 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) { // 如果当前存在
@ -202,8 +204,7 @@ 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);
@ -661,10 +662,10 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 获取当前仓库是否需要审批 // 获取当前仓库是否需要审批
List<RoleAndDepository> depositoryListForIn = roleService.findRoleAndDepositoryByDepositoryIdForIn(ObjectFormatUtil.toInteger(map.get("depositoryId"))); List<RoleAndDepository> depositoryListForIn = roleService.findRoleAndDepositoryByDepositoryIdForIn(ObjectFormatUtil.toInteger(map.get("depositoryId")));
boolean flagForApproval = false; // 默认不需要审批 boolean flagForApproval = false; // 默认不需要审批
if(depositoryListForIn.size() > 0){ if (depositoryListForIn.size() > 0) {
flagForApproval = true; flagForApproval = true;
} }
map.put("flagForApproval",flagForApproval); map.put("flagForApproval", flagForApproval);
if (placeById.getMax() - placeById.getQuantity() > quantity) { if (placeById.getMax() - placeById.getQuantity() > quantity) {
// 如果当前库位还能存放 // 如果当前库位还能存放
@ -674,13 +675,13 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
return -1; return -1;
} }
if(!flagForApproval){ if (!flagForApproval) {
// 如果不需要审批 // 如果不需要审批
Integer result = updateInventoryInfoForApproval(map, quantity, materialById, placeById); Integer result = updateInventoryInfoForApproval(map, quantity, materialById, placeById);
map.remove("applicationInId"); map.remove("applicationInId");
return result; return result;
}else{ } else {
map.put("applicationInId",map.get("id")); map.put("applicationInId", map.get("id"));
map.remove("id"); map.remove("id");
} }
return integer; return integer;
@ -692,18 +693,19 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
/** /**
* 用于入库后修改相关数据信息 * 用于入库后修改相关数据信息
* @param map 入库数据 *
* @param quantity 数量 * @param map 入库数据
* @param quantity 数量
* @param materialById 入库物料 * @param materialById 入库物料
* @param placeById 入库库位 * @param placeById 入库库位
* @return * @return
*/ */
Integer updateInventoryInfoForApproval(Map<String,Object> map,Integer quantity,Material materialById,Place placeById){ 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
Integer InId = ObjectFormatUtil.toInteger(map.get("id")); Integer InId = ObjectFormatUtil.toInteger(map.get("id"));
map.put("applicationInId",map.get("id")); map.put("applicationInId", map.get("id"));
Map<String, Object> insertProducedDate = new HashMap<>(); Map<String, Object> insertProducedDate = new HashMap<>();
insertProducedDate.put("inid", InId); insertProducedDate.put("inid", InId);
insertProducedDate.put("mid", newInMid); insertProducedDate.put("mid", newInMid);
@ -726,8 +728,7 @@ 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);
@ -741,10 +742,9 @@ 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 (Integer.compare(placeById.getId(),0) == 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);
@ -761,8 +761,7 @@ 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);
@ -2045,11 +2044,12 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
/** /**
* 用于企业微信的物料入库审批处理 * 用于企业微信的物料入库审批处理
* @param mainId 需要进行审批的单号 *
* @param mainId 需要进行审批的单号
* @param approvalInfo_details 审批详情 * @param approvalInfo_details 审批详情
* @param userAgent 加密后的user-agent * @param userAgent 加密后的user-agent
* @param spStatus 审批状态 * @param spStatus 审批状态
* @param spNo 审批订单号 * @param spNo 审批订单号
*/ */
@Override @Override
public void reviewByQyWxApprovalIn(String mainId, ApprovalInfo_Details approvalInfo_details, String userAgent, String spStatus, String spNo) { public void reviewByQyWxApprovalIn(String mainId, ApprovalInfo_Details approvalInfo_details, String userAgent, String spStatus, String spNo) {
@ -2062,33 +2062,105 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 获取审批人 // 获取审批人
Map<String, Object> portInfo = PortConfig.findUserByQyWxUserId(userId); Map<String, Object> portInfo = PortConfig.findUserByQyWxUserId(userId);
UserByPort userByPort = (UserByPort) portInfo.get("user"); UserByPort userByPort = (UserByPort) portInfo.get("user");
Map<String,Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("approverId",userByPort.getId()); map.put("approverId", userByPort.getId());
map.put("approverTime",System.currentTimeMillis()); map.put("approverTime", System.currentTimeMillis());
if ("2".equals(spStatus)) {
// 如果同意 // 如果同意
map.put("approverPass",1); for (String sid : split
for (String sid:split ) {
) { if ("2".equals(spStatus)) {
if(!"".equals(sid)) { map.put("approverPass", 1);
Integer id = ObjectFormatUtil.toInteger(sid); } else {
// 获取具体入库订单 // 如果驳回
ApplicationInRecordP recordP = depositoryRecordMapper.findApplicationInRecordPById(id); map.put("approverPass", 2);
// 获取当前入库对应的物料 }
Material materialById = materialMapper.findMaterialById(recordP.getMid()); if (!"".equals(sid)) {
if(materialById.getUnit().equals(recordP.getAirUnit())){ Integer id = ObjectFormatUtil.toInteger(sid);
// 如果是基础单位 // 获取具体入库订单
Map<String,Object> paramForUpdateInventory = new HashMap<>(); ApplicationInRecordP recordP = depositoryRecordMapper.findApplicationInRecordPById(id);
// paramForUpdateInventory.put("") // 获取当前入库对应的物料
// updateOrInsertInventory() Material materialById = materialMapper.findMaterialById(recordP.getMid());
}else{ if (materialById.getUnit().equals(recordP.getAirUnit())) {
// 如果是拆单单位 // 如果是基础单位
Map<String, Object> param = new HashMap<>();
param.put("depositoryId", recordP.getDepositoryId());
param.put("mcode", materialById.getCode());
// 判断该仓库中有无该物物料
List<Inventory> materialByCondition = materialMapper.findInventory(param);
// 用于调用入库方法而创建的
Map<String, Object> paramForUpdateInventory = new HashMap<>();
paramForUpdateInventory.put("mid", recordP.getMid());
paramForUpdateInventory.put("quantity", recordP.getQuantity());
// 修改仓库库存
Long mproducedDate = recordP.getMproducedDate();
if (mproducedDate == null) {
mproducedDate = 0L;
}
Integer newMid = updateOrInsertInventory(paramForUpdateInventory, materialByCondition, (double) recordP.getQuantity(), materialById.getId(), recordP.getDepositoryId(), mproducedDate);
// 修改库位库存
paramForUpdateInventory.put("newInMid", newMid);
paramForUpdateInventory.put("id", recordP.getId());
paramForUpdateInventory.put("producedDate", recordP.getMproducedDate());
paramForUpdateInventory.put("depositoryId", recordP.getDepositoryId());
Place placeById = placeMapper.findPlaceById(recordP.getPlaceId());
updateInventoryInfoForApproval(paramForUpdateInventory, recordP.getQuantity(), materialById, placeById);
} else {
// 如果是拆单单位
// 查询拆单记录
Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("newUnit", recordP.getAirUnit());
paramForSplitInfo.put("mid", recordP.getMid());
// 查询当前拆单是否存在
SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
if (splitInfoForUnit != null) {
// 如果该拆单记录存在
// 定义库存拆单记录
SplitInventory splitInventory = null;
// 定义对应的库存记录
Inventory inventory = null;
// 定义对应库存所在库位
MaterialAndPlace placeAndMaterialByMidAndPid = null;
// 用于存储拆单库存处理操作的数据
Map<String, Object> paramForInsertSplitInventory = new HashMap<>();
Map<String, Object> paramForInventory = new HashMap<>();
paramForInventory.put("depositoryId", recordP.getDepositoryId());
paramForInventory.put("mid", recordP.getMid());
// 判断该仓库中有无该物物料
List<Inventory> inventoryList = materialMapper.findInventory(paramForInventory);
if (inventoryList.size() > 0) {
inventory = inventoryList.get(0);
// 用于查找该库存对应库位
Map<String, Object> paramForInventoryToPlace = new HashMap<>();
paramForInventoryToPlace.put("pid", recordP.getPlaceId());
paramForInventoryToPlace.put("mid", inventory.getId());
placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForInventoryToPlace);
if (placeAndMaterialByMidAndPid != null) {
paramForInsertSplitInventory.put("iid", placeAndMaterialByMidAndPid.getId());
// 查询当前库存是否有该拆单的处理记录
splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForInsertSplitInventory);
}
}
splitUnitService.realInInventoryToDepository((double) recordP.getQuantity(), splitInventory, map, splitInfoForUnit, placeAndMaterialByMidAndPid);
} }
} }
} }
}else{ map.put("id", sid);
// 如果驳回 depositoryRecordMapper.updateApplicationInRecord(map);
map.put("approverPass",2);
} }
} }
@ -2407,8 +2479,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
// 开启流程通知其他人忽略审批流程 // 开启流程通知其他人忽略审批流程
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
@ -2835,7 +2905,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, placeAndMaterial.getId(), map, quantity, splitInfo); splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, placeAndMaterial.getId(), map, quantity, splitInfo);
} else { } else {
applicationInPlace(map); applicationInPlace(map);
map.put("applicationInId",map.get("id")); map.put("applicationInId", map.get("id"));
map.remove("id"); map.remove("id");
} }
@ -2913,7 +2983,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, placeAndMaterial.getId(), map, quantity, splitInfo); splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, placeAndMaterial.getId(), map, quantity, splitInfo);
} else { } else {
applicationInPlace(map); applicationInPlace(map);
map.put("applicationInId",map.get("id")); map.put("applicationInId", map.get("id"));
map.remove("id"); map.remove("id");
} }
@ -3072,7 +3142,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, ObjectFormatUtil.toInteger(insertForMaterialAndPlace.get("id")), map, quantity, splitInfo); splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, ObjectFormatUtil.toInteger(insertForMaterialAndPlace.get("id")), map, quantity, splitInfo);
} else { } else {
applicationInPlace(map); applicationInPlace(map);
map.put("applicationInId",map.get("id")); map.put("applicationInId", map.get("id"));
map.remove("id"); map.remove("id");
} }
@ -3609,8 +3679,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Material materialById = materialMapper.findMaterialById(mid); Material materialById = materialMapper.findMaterialById(mid);
if (materialById.getPrice() != null) { if (materialById.getPrice() != null) {
sum += (materialById.getPrice() / 100) * recordMin.getQuantity(); sum += (materialById.getPrice() / 100) * recordMin.getQuantity();
} } else {
else{
sum += 0; sum += 0;
} }
} }

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

@ -101,8 +101,6 @@ public class SplitUnitServiceImpl implements SplitUnitService {
Integer result = 0; Integer result = 0;
if (splitInfoForUnit != null) { if (splitInfoForUnit != null) {
// 获取当前进制
Integer scale = splitInfoForUnit.getQuantity();
// 获取当前处理的类型 // 获取当前处理的类型
String type = (String) map.get("type"); String type = (String) map.get("type");
@ -182,7 +180,16 @@ public class SplitUnitServiceImpl implements SplitUnitService {
} }
Integer realInInventoryToDepository(Double quantity, SplitInventory splitInventory, Map<String, Object> map, SplitInfo splitInfoForUnit, MaterialAndPlace placeAndMaterialByMidAndPid) { /**
* 用于审批通过或无需审批时修改库存
* @param quantity 库存数量
* @param splitInventory 拆单库存记录
* @param map 调剂
* @param splitInfoForUnit 拆单记录
* @param placeAndMaterialByMidAndPid 物料库位对应关系
* @return
*/
public Integer realInInventoryToDepository(Double quantity, SplitInventory splitInventory, Map<String, Object> map, SplitInfo splitInfoForUnit, MaterialAndPlace placeAndMaterialByMidAndPid) {
Integer result = 0; Integer result = 0;
// 获取当前进制 // 获取当前进制

9
target/classes/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml

@ -50,6 +50,7 @@
<result column="mname" property="mname" jdbcType="VARCHAR"/> <result column="mname" property="mname" jdbcType="VARCHAR"/>
<result column="quantity" property="quantity" jdbcType="INTEGER"/> <result column="quantity" property="quantity" jdbcType="INTEGER"/>
<result column="mid" property="mid" jdbcType="INTEGER"/> <result column="mid" property="mid" jdbcType="INTEGER"/>
<result column="did" property="depositoryId" jdbcType="INTEGER"/>
<result column="flagForGroup" property="flagForGroup" jdbcType="INTEGER"/> <result column="flagForGroup" property="flagForGroup" jdbcType="INTEGER"/>
<result column="price" property="price" jdbcType="VARCHAR"/> <result column="price" property="price" jdbcType="VARCHAR"/>
<result column="tname" property="materialTypeName" jdbcType="VARCHAR"/> <result column="tname" property="materialTypeName" jdbcType="VARCHAR"/>
@ -69,6 +70,7 @@
<result column="mdepositoryCode" property="mdepositoryCode" jdbcType="VARCHAR"/> <result column="mdepositoryCode" property="mdepositoryCode" jdbcType="VARCHAR"/>
<result column="airapproverPass" property="airapproverPass" jdbcType="INTEGER"/> <result column="airapproverPass" property="airapproverPass" jdbcType="INTEGER"/>
<result column="airapproverTime" property="airapproverTime" jdbcType="INTEGER"/> <result column="airapproverTime" property="airapproverTime" jdbcType="INTEGER"/>
<result column="airmproducedDate" property="mproducedDate" jdbcType="INTEGER"/>
<result column="airapproverId" property="airapproverId" jdbcType="VARCHAR"/> <result column="airapproverId" property="airapproverId" jdbcType="VARCHAR"/>
<result column="airstate" property="airstate" jdbcType="VARCHAR"/> <result column="airstate" property="airstate" jdbcType="VARCHAR"/>
<result column="airapproverMessage" property="airapproverMessage" jdbcType="VARCHAR"/> <result column="airapproverMessage" property="airapproverMessage" jdbcType="VARCHAR"/>
@ -146,7 +148,7 @@
</sql> </sql>
<sql id="ApplicationInRecordInfo"> <sql id="ApplicationInRecordInfo">
airid,mname,quantity,price,tname,applicant_time,aircode,dname,applicant_id,applyRemark,mcode,mversion,munit,mtexture,mkingdeecode,mdepositoryCode,airUnit,flagForGroup,mid,airPlaceId,airapproverPass,airapproverTime,airapproverId,airstate,airapproverMessage airid,did,airmproducedDate,mname,quantity,price,tname,applicant_time,aircode,dname,applicant_id,applyRemark,mcode,mversion,munit,mtexture,mkingdeecode,mdepositoryCode,airUnit,flagForGroup,mid,airPlaceId,airapproverPass,airapproverTime,airapproverId,airstate,airapproverMessage
</sql> </sql>
<sql id="ApplicationOutRecordInfo"> <sql id="ApplicationOutRecordInfo">
@ -883,7 +885,7 @@
<!-- 插入一条入库记录--> <!-- 插入一条入库记录-->
<insert id="insertApplicationInRecord" parameterType="map" useGeneratedKeys="true" keyProperty="id"> <insert id="insertApplicationInRecord" parameterType="map" useGeneratedKeys="true" keyProperty="id">
insert into application_in_record (id,mid,quantity,price,applicant_id,applicant_time,depository_id,code,applyRemark,unit,flagForGroup,placeId,approverPass,approverTime,approverId,state,approverMessage) insert into application_in_record (id,mid,quantity,price,applicant_id,applicant_time,depository_id,code,applyRemark,unit,flagForGroup,placeId,approverPass,approverTime,approverId,state,approverMessage,mproducedDate)
values( values(
#{id}, #{id},
#{mid}, #{mid},
@ -901,7 +903,8 @@
#{approverTime}, #{approverTime},
#{approverId}, #{approverId},
#{state}, #{state},
#{approverMessage} #{approverMessage},
#{producedDate}
) )
</insert> </insert>

Loading…
Cancel
Save