Commit 01699892 by ice

修改验收入库接口、验收通过审核人赋值

parent 966562de
......@@ -73,10 +73,7 @@ public class RcvReceiptController {
if(!"RECEIVED".equals(rcvReceiptHeaderPage.getHeaderStatus())){
return new Result(false,StatusCode.ERROR,"接收单号为"+rcvReceiptHeaderPage.getReceiptNumber()+"的状态不为新建");
}
for(RcvReceiptLine rcvReceiptLine:rcvReceiptHeaderPage.getRcvReceiptLineList()){
rcvReceiptLineService.updateLineStatusByLineId(rcvReceiptLine.getId(),updateBy,updateTime,"APPROVAL");
}
rcvReceiptHeaderService.updateRcvHeaderStatusByHeaderId(id,updateBy,updateTime,"APPROVAL");
rcvReceiptHeaderService.updateRcvHeaderStatusByHeaderId(id,null,updateBy,updateTime,"APPROVAL");
}
return new Result(true,StatusCode.OK,"审核成功!");
}
......@@ -196,22 +193,19 @@ public class RcvReceiptController {
for(RcvReceiptHeaderPage rcvRecPage:rcvReceiptHeaderPageList){
RcvReceiptHeader rcvReceiptHeader = rcvReceiptHeaderService.findRcvRecHeaderById(rcvRecPage.getId());
if(rcvReceiptHeader == null){
return new Result(false,20001,ErrorEnum.NotExistModel.getErrorMsg());//返回实体不存在
}
if(!rcvReceiptHeader.getHeaderStatus().equals(rcvRecPage.getHeaderStatus())){
return new Result(false,20001,ErrorEnum.DataTransmitError.getErrorMsg());//返回数据传输有误
return new Result(false,StatusCode.ERROR,"选中的数据不存在,请刷新!");//返回实体不存在
}
//判断验收通过时的接收单状态
if("accept".equals(status)){
//这时的接收单状态只能为已接收(RECEIVED)或部分已检验(PARTINSPECTED)
if(!"APPROVAL".equals(rcvRecPage.getHeaderStatus()) && !"PARTINSPECTED".equals(rcvRecPage.getHeaderStatus())){
//这时的接收单状态只能为已审核
if(!"APPROVAL".equals(rcvRecPage.getHeaderStatus())){
errorIds.add(rcvRecPage.getReceiptNumber());
}
}
//判断提交入库时的接收单状态
if("submit".equals(status)){
//这时的接收单状态只能是“部分已检验(PARTINSPECTED)”或“已检验(INSPECTED)”或“部分已入库(PARTACCEPTED)”
if(!"PARTINSPECTED".equals(rcvRecPage.getHeaderStatus()) && !"INSPECTED".equals(rcvRecPage.getHeaderStatus()) && !"PARTACCEPTED".equals(rcvRecPage.getHeaderStatus())){
//这时的接收单状态只能是“已检验(INSPECTED)”
if( !"INSPECTED".equals(rcvRecPage.getHeaderStatus())){
errorIds.add(rcvRecPage.getReceiptNumber());
}
//判断接收单行的库存以及子库存是否有填写
......@@ -238,9 +232,10 @@ public class RcvReceiptController {
//查询用户
SysUser sysUser = userServer.getSysUserById(sysAccessToken.getUserId());
if(sysUser == null){
return new Result(false,20001,ErrorEnum.UserNotExist.getErrorMsg());
return new Result(false,StatusCode.ERROR,ErrorEnum.UserNotExist.getErrorMsg());
}
String updateBy = sysUser.getRealname();
String inspector = sysUser.getId();
//获取当前时间
LocalDateTime updateTime = LocalDateTime.now();
//验收入库判断操作
......@@ -248,157 +243,28 @@ public class RcvReceiptController {
String lineStatus = null;
//调用验收通过
if ("accept".equals(status)) {
//判断该接收单每一行的状态
//接收单头状态为已接收或是部分已检验时是同样的判断,可合并
lineStatus = editStatus(rcvRecHeaderPage.getRcvReceiptLineList());
if ("APPROVAL".equals(lineStatus)) {
return new Result(false,20001,"验收不通过!");//返回操作失败
}
//差异数量不为0时生成差异处理单
int count = 0;
for(RcvReceiptLine rcvReceiptLine:rcvRecHeaderPage.getRcvReceiptLineList()){
if(rcvReceiptLine.getRejectQuantity() != 0){
if((rcvReceiptLine.getRejectQuantity() + rcvReceiptLine.getAcceptQuantity()) != rcvReceiptLine.getReceivedQuantity()){
return new Result(false,StatusCode.ERROR,"接收单号为:"+rcvRecHeaderPage.getReceiptNumber()+"的差异数量与接受数量之和不等于接收数量,请检查!");
}
rcvReceiptLineService.updateLineStatusByLineId(rcvReceiptLine.getId(),updateBy,updateTime,"INSPECTED");
insertWarDifferent(rcvRecHeaderPage,rcvReceiptLine,updateBy,updateTime);
count++;
}
}
if(count == rcvRecHeaderPage.getRcvReceiptLineList().size()){
lineStatus = "INSPECTED";
}
}
//调用提交入库
if("submit".equals(status)){
//判断每一行的状态
if("PARTINSPECTED".equals(rcvRecHeaderPage.getHeaderStatus()) || "INSPECTED".equals(rcvRecHeaderPage.getHeaderStatus())){
lineStatus = updateStatus(rcvRecHeaderPage,token,updateBy,updateTime);
}
if("PARTACCEPTED".equals(rcvRecHeaderPage.getHeaderStatus())){
lineStatus = editStatus(rcvRecHeaderPage,token,updateBy,updateTime);
for(RcvReceiptLine rcvReceiptLine:rcvRecHeaderPage.getRcvReceiptLineList()) {
JSONObject json = getJsonData(rcvRecHeaderPage.getId(), rcvReceiptLine.getAcceptQuantity(), rcvReceiptLine);
transactionController.invItemInOut(token, json);
}
lineStatus = "ACCEPTED";
}
//更新接收单头的状态
rcvReceiptHeaderService.updateRcvHeaderStatusByHeaderId(rcvRecHeaderPage.getId(),updateBy,updateTime,lineStatus);
rcvReceiptHeaderService.updateRcvHeaderStatusByHeaderId(rcvRecHeaderPage.getId(),inspector,updateBy,updateTime,lineStatus);
}
return new Result(true,20000,ErrorEnum.SUCCESS.getErrorMsg());
}
//验收通过接口时的状态判断方法
public String editStatus(List<RcvReceiptLine> rcvReceiptLineList){
String status = null;//返回的接收单行状态
int inspectedNum = 0;//接收单行状态为已检验的数量
int partinspectedNum = 0; //接收单行状态为部分已检验的数量
int receivedNum = 0; //接收单行状态为已接收的数量
for(RcvReceiptLine rcvRecLine : rcvReceiptLineList){
if("INSPECTED".equals(rcvRecLine.getLineStatus())){
inspectedNum++;
}
if("PARTINSPECTED".equals(rcvRecLine.getLineStatus())){
partinspectedNum++;
}
if("APPROVAL".equals(rcvRecLine.getLineStatus())){
receivedNum++;
}
}
//接收单行的每一行状态都为已检验,则将接收单头的状态改为已检验
if(inspectedNum == rcvReceiptLineList.size()){
status = "INSPECTED";
}
//接收单行存在行状态为部分已检验,则将接收单头的状态改为部分已检验
if(partinspectedNum > 0){
status = "PARTINSPECTED";
}
if(receivedNum == rcvReceiptLineList.size()){
status = "APPROVAL";
}
return status;
}
//提交入库时状态判断方法
public String updateStatus(RcvReceiptHeaderPage headerPage, String token, String updateBy, LocalDateTime updateTime){
String status = null;//返回的接收单头状态
int inspectedNum = 0;//接收单行状态为已检验的数量
int partinspectedNum = 0; //接收单行状态为部分已检验的数量
for(RcvReceiptLine rcvReceiptLine:headerPage.getRcvReceiptLineList()){
String lineStatus = null;//接收单行状态
//将已检验状态的修改为已入库
if("INSPECTED".equals(rcvReceiptLine.getLineStatus())){
inspectedNum++;
//修改状态
lineStatus = "ACCEPTED";
}
//将部分已检验的状态修改为部分已入库
if("PARTINSPECTED".equals(rcvReceiptLine.getLineStatus())){
partinspectedNum++;
//修改状态
lineStatus = "PARTACCEPTED";
}
//调用入库处理接口,此次入库数量 = 接受数量
JSONObject json = getJsonData(headerPage.getId(),rcvReceiptLine.getAcceptQuantity(),rcvReceiptLine);
transactionController.invItemInOut(token,json);
//修改状态
rcvReceiptLineService.updateLineStatusByLineId(rcvReceiptLine.getId(),updateBy,updateTime,lineStatus);
}
//接收单每行都为已入库时,将接收单头的状态修改为已入库
if(inspectedNum == headerPage.getRcvReceiptLineList().size()){
status = "ACCEPTED";
}
//接收单行存在部分已入库时,将接收单头的状态修改为部分已入库
if(partinspectedNum > 0){
status = "PARTACCEPTED";
}
return status;
}
//提交入库时的状态判断
public String editStatus(RcvReceiptHeaderPage headerPage, String token, String updateBy, LocalDateTime updateTime){
String status = null;//返回的接收单头状态
String sourceHeaderId = headerPage.getId();
int acceptedNum = 0; //已入库的接收单行数量判断
for(RcvReceiptLine rcvReceiptLine : headerPage.getRcvReceiptLineList()){
String lineStatus = null;
if("ACCEPTED".equals(rcvReceiptLine.getLineStatus())){
acceptedNum++;
}
if("PARTACCEPTED".equals(rcvReceiptLine.getLineStatus())) {
String sourceLineId = rcvReceiptLine.getId();
Integer count = transactionServer.findQuantity(sourceHeaderId, sourceLineId);//已经入库的数量
//判断如上次入库的数量大于这次接受入库的数量,则返回出错
if (count > rcvReceiptLine.getAcceptQuantity()) {
throw ErrorEnum.InputNumberError.createException(rcvReceiptLine.getLineNumber());
}
int quantity = 0;
//上次入库数量<这次入库数量(接受数量)=接收数量,行状态修改为已入库
if ((rcvReceiptLine.getAcceptQuantity() > count) && (rcvReceiptLine.getAcceptQuantity() == rcvReceiptLine.getReceivedQuantity())) {
acceptedNum++;
lineStatus = "ACCEPTED";
}
//上次入库数量<这次入库数量(接受数量)<接收数量,行状态仍为部分已入库,不作状态修改
//上次入库数量<这次入库数量(接受数量),行状态仍为部分已入库
if (rcvReceiptLine.getAcceptQuantity() == count) {
continue; //不执行插入数据库操作,进到下一次for循环
}
//此次入库数量=接收数量-上次入库数量
quantity = rcvReceiptLine.getAcceptQuantity() - count;
JSONObject json = getJsonData(headerPage.getId(), quantity, rcvReceiptLine);
transactionController.invItemInOut(token, json);
}
if("ACCEPTED".equals(lineStatus)) {
rcvReceiptLineService.updateLineStatusByLineId(rcvReceiptLine.getId(), updateBy, updateTime, lineStatus);
}
}
if(acceptedNum == headerPage.getRcvReceiptLineList().size()){
status = "ACCEPTED";
}else{
status = "PARTACCEPTED";
}
return status;
}
//调用入库事务处理接口需要的json格式数据封装
public JSONObject getJsonData(String id, int quantity, RcvReceiptLine rcvReceiptLine){
JSONObject jsonObject = new JSONObject();
......
......@@ -49,6 +49,7 @@ public class TransferController {
return new Result(false,StatusCode.ERROR,"token失效!");
}
String updateBy = sysUser.getRealname();
String excutorId = sysUser.getId();
//获取当前时间
LocalDateTime updateTime = LocalDateTime.now();
JSONObject data = jsonObject.getJSONObject("data");
......@@ -87,7 +88,7 @@ public class TransferController {
JSONObject json = getJson(warTransferPage,warTransferLine);
transactionController.invItemeTransfer(token,json);
}
int count = transferService.updateTransferStatus("approval",updateBy,updateTime,id);
int count = transferService.updateTransferStatus(excutorId,"approval",updateBy,updateTime,id);
if(count == 0){
return new Result(false,StatusCode.ERROR,"调拨单号为:"+warTransferPage.getOrderNumber()+"的状态修改失败!");
}
......@@ -190,7 +191,7 @@ public class TransferController {
}
}
}
int count = transferService.updateTransferStatus("completed",updateBy,updateTime,id);
int count = transferService.updateTransferStatus(null,"completed",updateBy,updateTime,id);
if(count == 0){
return new Result(false,StatusCode.ERROR,"调拨单号为:"+warTransferPage.getOrderNumber()+"的状态修改失败!");
}
......
......@@ -98,8 +98,11 @@ public List<RcvReceiptHeader> select();
@Update("UPDATE rcv_receipt_header SET inspector = #{inspector} WHERE id = #{headerId}")
void updateHeaderInspectorByHeaderId(@Param("headerId")String headerId,@Param("inspector")String inspector);
@Update("UPDATE rcv_receipt_header SET header_status = #{status},update_by=#{updateBy},update_time=#{updateTime} WHERE id = #{headerId}")
void updateRcvHeaderStatusByHeaderId(@Param("headerId")String headerId, @Param("updateBy")String updateBy, @Param("updateTime") LocalDateTime updateTime, @Param("status")String status);
@Update({"<script>UPDATE rcv_receipt_header SET " +
"<if test = 'inspector != null'>inspector = #{inspector},</if>" +
"header_status = #{status},update_by=#{updateBy},update_time=#{updateTime} " +
"WHERE id = #{headerId}</script>"})
void updateRcvHeaderStatusByHeaderId(@Param("headerId")String headerId, @Param("inspector")String inspector,@Param("updateBy")String updateBy, @Param("updateTime") LocalDateTime updateTime, @Param("status")String status);
@Insert("<script>" +
"INSERT INTO rcv_receipt_header(id,create_by,create_time,update_by,update_time,sys_org_code,attribute_category,attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,attribute7,attribute8,attribute9,attribute10,inv_id,receipt_type,receipt_number,receipt_date,shipment_number,shipment_date,party_id,party_site_id,shipper,receiver,inspector,header_remark,header_status,source_type,source_header_id,source_header_number,source_line_id,source_line_number) VALUES" +
......
......@@ -90,6 +90,8 @@ public interface RcvReceiptLineMapper{
@Update("UPDATE rcv_receipt_line SET line_status = #{status},update_by = #{updateBy},update_time = #{updateTime} WHERE id = #{id}")
void updateRcvRecLineStatusByLineId(@Param("id")String id, @Param("updateBy")String updateBy, @Param("updateTime")LocalDateTime updateTime, @Param("status")String status);
@Update("UPDATE rcv_receipt_line SET line_status = #{status},update_by = #{updateBy},update_time = #{updateTime} WHERE rcv_receipt_header_id = #{id}")
void updateRcvRecLineStatusByheaderId(@Param("id")String id, @Param("updateBy")String updateBy, @Param("updateTime")LocalDateTime updateTime, @Param("status")String status);
@Insert("<script>" +
"INSERT INTO rcv_receipt_line(id,create_by,create_time,update_by,update_time,sys_org_code,attribute_category,attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,attribute7,attribute8,attribute9,attribute10,rcv_receipt_header_id,line_number,subinv_id,locator_id,item_id,shipped_quantity,received_quantity,accept_quantity,reject_quantity,unit_code,line_remark,line_status,source_type,source_header_id,source_header_number,source_line_id,source_line_number,inv_id) VALUES" +
......
......@@ -72,6 +72,9 @@ Integer insert(WarTransfer WarTransfer);
@ResultMap("wartransfer")
WarTransfer selectTransferById(@Param("id") String id);
@Update("update war_transfer set order_status = #{status},update_by = #{updateBy},update_time=#{updateTime} where id = #{id}")
Integer updateTransferStatusById(@Param("status") String status, @Param("updateBy") String updateBy, @Param("updateTime") LocalDateTime updateTime, @Param("id") String id);
@Update({"<script>update war_transfer set " +
"<if test = 'excutorId != null '>excutor_id = #{excutorId},</if>" +
"order_status = #{status},update_by = #{updateBy}," +
"update_time=#{updateTime} where id = #{id}</script>"})
Integer updateTransferStatusById(@Param("excutorId")String excutorId,@Param("status") String status, @Param("updateBy") String updateBy, @Param("updateTime") LocalDateTime updateTime, @Param("id") String id);
}
\ No newline at end of file
......@@ -26,8 +26,12 @@ public class RcvReceiptHeaderService {
return rcvReceiptHeaderMapper.selectRcvRecHeaderById(id);
}
public void updateRcvHeaderStatusByHeaderId(String id, String updateBy, LocalDateTime updateTime,String status){
rcvReceiptHeaderMapper.updateRcvHeaderStatusByHeaderId(id, updateBy, updateTime, status);
public void updateRcvHeaderStatusByHeaderId(String id, String inspector,String updateBy, LocalDateTime updateTime,String status){
if(!"INSPECTED".equals(status)){
inspector = null;
}
rcvReceiptLineMapper.updateRcvRecLineStatusByheaderId(id, updateBy, updateTime, status);
rcvReceiptHeaderMapper.updateRcvHeaderStatusByHeaderId(id,inspector, updateBy, updateTime, status);
}
//生成接收单
......
......@@ -37,9 +37,9 @@ public class TransferService {
return warTransferPage;
}
public int updateTransferStatus(String status, String updateBy, LocalDateTime updateTime,String id){
public int updateTransferStatus(String excutorId,String status, String updateBy, LocalDateTime updateTime,String id){
warTransferLineMapper.updateTransferLineStatusById(status, updateBy, updateTime, id);
return warTransferMapper.updateTransferStatusById(status, updateBy, updateTime, id);
return warTransferMapper.updateTransferStatusById(excutorId,status, updateBy, updateTime, id);
}
public int updateInvTransaction(String headerId,String lineId){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment