| | |
| | | import com.example.erp.entity.sd.Delivery; |
| | | import com.example.erp.entity.sd.DeliveryDetail; |
| | | import com.example.erp.entity.sd.OrderDetail; |
| | | import com.example.erp.entity.userInfo.Log; |
| | | import com.example.erp.entity.userInfo.SysError; |
| | | import com.example.erp.mapper.mm.BasicWarehouseTypeMapper; |
| | | import com.example.erp.mapper.mm.MaterialInventoryMapper; |
| | | import com.example.erp.mapper.mm.MaterialStoreMapper; |
| | | import com.example.erp.service.userInfo.LogService; |
| | | import com.example.erp.service.userInfo.SysErrorService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | BasicWarehouseTypeMapper basicWarehouseTypeMapper; |
| | | @Autowired |
| | | SysErrorService sysErrorService; |
| | | @Autowired |
| | | LogService logService; |
| | | |
| | | public Boolean saveMaterialOutbound(Map<String,Object> object) { |
| | | boolean saveState = true; |
| | |
| | | if (object.get("materialOutboundId") != null) { |
| | | materialOutboundId = object.get("materialOutboundId").toString(); |
| | | } |
| | | Log log = new Log(); |
| | | log.setContent(object.toString()); |
| | | try { |
| | | MaterialOutbound materialOutbound = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), MaterialOutbound.class); |
| | | List<MaterialOutboundDetail> materialOutboundDetailList = JSONArray.parseArray(JSONObject.toJSONString(object.get("materialOutboundDetail")), MaterialOutboundDetail.class); |
| | |
| | | materialInventoryMapper.deleteMaterialOutboundDetail(materialOutboundId); |
| | | materialInventoryMapper.updateMaterialOutbound(materialOutbound, materialOutboundId); |
| | | oddNumber = materialOutboundId; |
| | | log.setFunction("saveMaterialOutbound修改:"+oddNumber); |
| | | } else { |
| | | //获取单号 |
| | | oddNumber = orderNumberSetting("出库"); |
| | | //新增材料出库表数据 |
| | | materialInventoryMapper.insertMaterialOutbound(materialOutbound, oddNumber); |
| | | log.setFunction("saveMaterialOutbound新增:"+oddNumber); |
| | | } |
| | | |
| | | //获取对象集合循环进行新增修改 |
| | |
| | | } |
| | | |
| | | } |
| | | logService.saveLog(log); |
| | | |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | |
| | | if (object.get("materialCode") != null) { |
| | | materialCode = Long.valueOf(object.get("materialCode").toString()); |
| | | } |
| | | Log log = new Log(); |
| | | log.setContent(object.toString()); |
| | | |
| | | MaterialInventory materialInventory = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), MaterialInventory.class); |
| | | |
| | |
| | | |
| | | if(MaterialInventoryCount>0){ |
| | | materialInventoryMapper.updateMaterialInventory(materialCode,singlePieceArea,totalArea,materialInventory); |
| | | log.setFunction("saveMaterialInventory修改"); |
| | | }else { |
| | | materialInventoryMapper.insertMaterialInventory(materialCode,singlePieceArea,totalArea,materialInventory); |
| | | log.setFunction("saveMaterialInventory新增"); |
| | | } |
| | | logService.saveLog(log); |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | |
| | | materialInventoryMapper.deleteMaterialOutboundDetail(materialOutboundId); |
| | | materialInventoryMapper.deleteMaterialOutbound(materialOutboundId); |
| | | } |
| | | |
| | | Log log = new Log(); |
| | | log.setContent(object.toString()); |
| | | log.setFunction("deleteMaterialOutbound删除:"+materialOutboundId); |
| | | logService.saveLog(log); |
| | | |
| | | |
| | | } catch (Exception e) { |
| | |
| | | if (object.get("reviewed") != null) { |
| | | reviewed = object.get("reviewed").toString(); |
| | | } |
| | | Log log = new Log(); |
| | | log.setOperator(reviewed); |
| | | log.setContent(object.toString()); |
| | | log.setFunction("updateMaterialOutboundToExamine:"+type); |
| | | logService.saveLog(log); |
| | | |
| | | if (type==1){ |
| | | List<MaterialOutboundDetail> materialOutboundDetailList = materialInventoryMapper.getIsNotMaterialOutboundDetail(materialOutboundId); |
| | |
| | | if (object.get("returningId") != null) { |
| | | returningId = object.get("returningId").toString(); |
| | | } |
| | | Log log = new Log(); |
| | | log.setContent(object.toString()); |
| | | |
| | | ReturningWarehouse returningWarehouse = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), ReturningWarehouse.class); |
| | | List<ReturningWarehouseDetail> returningWarehouseDetailList = JSONArray.parseArray(JSONObject.toJSONString(object.get("returningWarehouseDetail")), ReturningWarehouseDetail.class); |
| | | //查询出库单是否存在 |
| | |
| | | //删除材料出库明细的数据 |
| | | materialInventoryMapper.deleteReturningWarehouseDetail(returningId); |
| | | oddNumber = returningId; |
| | | log.setFunction("saveReturningWarehouse修改:"+oddNumber); |
| | | } else { |
| | | //获取单号 |
| | | oddNumber = orderNumberSetting("返库"); |
| | | //新增材料出库表数据 |
| | | materialInventoryMapper.insertReturningWarehouse(returningWarehouse, oddNumber); |
| | | log.setFunction("saveReturningWarehouse新增:"+oddNumber); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | } |
| | | logService.saveLog(log); |
| | | |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | |
| | | if (object.get("reviewed") != null) { |
| | | reviewed = object.get("reviewed").toString(); |
| | | } |
| | | Log log = new Log(); |
| | | log.setOperator(reviewed); |
| | | log.setContent(object.toString()); |
| | | log.setFunction("updateReturningWarehouseToExamine:"+type); |
| | | logService.saveLog(log); |
| | | |
| | | if (type==1){ |
| | | List<ReturningWarehouseDetail> returningWarehouseDetailList = materialInventoryMapper.getIsNotReturningWarehouseDetail(returningId); |
| | |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | |
| | | String creator = ""; |
| | | if (object.get("creator") != null) { |
| | | creator = object.get("creator").toString(); |
| | | } |
| | | String type = ""; |
| | | if (object.get("type") != null) { |
| | | type = object.get("type").toString(); |
| | | } |
| | | int state = 0; |
| | | if (object.get("state") != null) { |
| | | state = Integer.parseInt(object.get("state").toString()); |
| | | } |
| | | String creator = ""; |
| | | if (object.get("creator") != null) { |
| | | creator = object.get("creator").toString(); |
| | | } |
| | | String type = ""; |
| | | if (object.get("type") != null) { |
| | | type = object.get("type").toString(); |
| | | } |
| | | int state = 0; |
| | | if (object.get("state") != null) { |
| | | state = Integer.parseInt(object.get("state").toString()); |
| | | } |
| | | Log log = new Log(); |
| | | log.setOperator(creator); |
| | | log.setContent(object.toString()); |
| | | log.setFunction("addSelectSurplusMaterialsDate:"+state); |
| | | logService.saveLog(log); |
| | | |
| | | |
| | | if(state==1){ |
| | | SurplusMaterials surplusMaterials = JSONObject.parseObject(JSONObject.toJSONString(object.get("surplusMaterials")), SurplusMaterials.class); |
| | | if(surplusMaterials!=null){ |
| | | SurplusMaterials surplusMaterials1=materialInventoryMapper.selectSurplusMaterialsCount(surplusMaterials); |
| | | if(surplusMaterials1!=null){ |
| | | System.out.println(surplusMaterials1); |
| | | materialInventoryMapper.updateSurplusMaterialsIntQuantity(surplusMaterials1); |
| | | materialInventoryMapper.insertSurplusMaterialsLog(surplusMaterials1,creator,type); |
| | | }else{ |
| | | materialInventoryMapper.insertSurplusMaterials(surplusMaterials); |
| | | materialInventoryMapper.insertSurplusMaterialsLog(surplusMaterials,creator,type); |
| | | } |
| | | } |
| | | } else if (state==2) { |
| | | List<SurplusMaterials> surplusMaterialsList = JSONArray.parseArray(JSONObject.toJSONString(object.get("surplusMaterials")), SurplusMaterials.class); |
| | | if(!surplusMaterialsList.isEmpty()){ |
| | | for(SurplusMaterials surplusMaterials:surplusMaterialsList){ |
| | | materialInventoryMapper.updateSurplusMaterialsOutQuantity(surplusMaterials); |
| | | materialInventoryMapper.insertSurplusMaterialsLog(surplusMaterials,creator,type); |
| | | } |
| | | |
| | | if(state==1){ |
| | | SurplusMaterials surplusMaterials = JSONObject.parseObject(JSONObject.toJSONString(object.get("surplusMaterials")), SurplusMaterials.class); |
| | | if(surplusMaterials!=null){ |
| | | SurplusMaterials surplusMaterials1=materialInventoryMapper.selectSurplusMaterialsCount(surplusMaterials); |
| | | if(surplusMaterials1!=null){ |
| | | System.out.println(surplusMaterials1); |
| | | materialInventoryMapper.updateSurplusMaterialsIntQuantity(surplusMaterials1); |
| | | materialInventoryMapper.insertSurplusMaterialsLog(surplusMaterials1,creator,type); |
| | | }else{ |
| | | materialInventoryMapper.insertSurplusMaterials(surplusMaterials); |
| | | materialInventoryMapper.insertSurplusMaterialsLog(surplusMaterials,creator,type); |
| | | } |
| | | } |
| | | } else if (state==2) { |
| | | List<SurplusMaterials> surplusMaterialsList = JSONArray.parseArray(JSONObject.toJSONString(object.get("surplusMaterials")), SurplusMaterials.class); |
| | | if(!surplusMaterialsList.isEmpty()){ |
| | | for(SurplusMaterials surplusMaterials:surplusMaterialsList){ |
| | | materialInventoryMapper.updateSurplusMaterialsOutQuantity(surplusMaterials); |
| | | materialInventoryMapper.insertSurplusMaterialsLog(surplusMaterials,creator,type); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |